Location: PHPKode > projects > ETraxis > src/projects/view.php
<?php

//------------------------------------------------------------------------------
//
//  eTraxis - Records tracking web-based system
//  Copyright (C) 2005-2010  Artem Rodygin
//
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
//
//------------------------------------------------------------------------------

/**
 * @package eTraxis
 * @ignore
 */

/**#@+
 * Dependency.
 */
require_once('../engine/engine.php');
require_once('../dbo/projects.php');
/**#@-*/

init_page(GUEST_IS_ALLOWED);

// check that requested project exists

$id      = ustr2int(try_request('id'));
$project = project_find($id);

if (!$project)
{
    debug_write_log(DEBUG_NOTICE, 'Project cannot be found.');
    header('Location: index.php');
    exit;
}

// page's title

$title = ustrprocess(get_html_resource(RES_PROJECT_X_ID), ustr2html($project['project_name']));

// generate breadcrumbs and tabs

$xml = gen_context_menu('tview.php?id=', 'sview.php?id=', 'fview.php?id=', $id)
     . '<breadcrumbs>'
     . '<breadcrumb url="index.php">' . get_html_resource(RES_PROJECTS_ID) . '</breadcrumb>'
     . '<breadcrumb url="view.php?id=' . $id . '">' . $title . '</breadcrumb>'
     . '</breadcrumbs>'
     . '<tabs>'
     . '<tab url="view.php?id=' . $id . '" active="true"><i>' . ustr2html($project['project_name']) . '</i></tab>';

if (get_user_level() == USER_LEVEL_ADMIN)
{
    $xml .= '<tab url="gindex.php?id=' . $id . '">' . get_html_resource(RES_GROUPS_ID)    . '</tab>'
          . '<tab url="tindex.php?id=' . $id . '">' . get_html_resource(RES_TEMPLATES_ID) . '</tab>';
}

$xml .= '<tab url="metrics.php?id=' . $id . '">' . get_html_resource(RES_METRICS_ID) . '</tab>'
      . '<content>';

// generate buttons

$xml .= '<button url="index.php">' . get_html_resource(RES_BACK_ID) . '</button>';

if (get_user_level() == USER_LEVEL_ADMIN)
{
    $xml .= HTML_SPLITTER
          . '<button url="pexport.php?id=' . $id . '">' . get_html_resource(RES_EXPORT_ID) . '</button>'
          . HTML_SPLITTER
          . '<button url="modify.php?id=' . $id . '">' . get_html_resource(RES_MODIFY_ID) . '</button>';

    $xml .= (is_project_removable($id)
                ? '<button url="delete.php?id=' . $id . '" prompt="' . get_html_resource(RES_CONFIRM_DELETE_PROJECT_ID) . '">'
                : '<button disabled="false">')
          . get_html_resource(RES_DELETE_ID)
          . '</button>';

    $xml .= '<button url="disable.php?id=' . $id . '">'
          . get_html_resource($project['is_suspended'] ? RES_ENABLE_ID : RES_DISABLE_ID)
          . '</button>';
}

// generate project information

$xml .= '<group title="' . get_html_resource(RES_PROJECT_INFO_ID) . '">'
      . '<text label="' . get_html_resource(RES_PROJECT_NAME_ID) . '">' . ustr2html($project['project_name']) . '</text>'
      . '<text label="' . get_html_resource(RES_START_TIME_ID)   . '">' . get_date($project['start_time'])    . '</text>'
      . '<text label="' . get_html_resource(RES_DESCRIPTION_ID)  . '">' . ustr2html($project['description'])  . '</text>'
      . '<text label="' . get_html_resource(RES_STATUS_ID)       . '">' . get_html_resource($project['is_suspended'] ? RES_SUSPENDED_ID : RES_ACTIVE_ID) . '</text>'
      . '</group>'
      . '</content>'
      . '</tabs>';

echo(xml2html($xml, $title));

?>
Return current item: ETraxis