<?php
/*=====================================================================*\
|| ###################################################################
|| # Bugdar
|| # Copyright ©2002-2007 Blue Static
|| #
|| # 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; version 2 of the License.
|| #
|| # 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, write to the Free Software Foundation, Inc.,
|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|| ###################################################################
\*=====================================================================*/
require_once('./global.php');
require_once('./includes/api_priority.php');
require_once('./includes/class_api_error.php');
APIError(array(new API_Error_Handler($admin), 'admin_error'));
NavLinks::fieldsPages();
$navigator->set_focus('tab', 'fields', null);
if (!can_perform('canadminfields'))
{
admin_login();
}
// ###################################################################
if (empty($_REQUEST['do']))
{
$_REQUEST['do'] = 'modify';
}
// ###################################################################
if ($_REQUEST['do'] == 'kill')
{
$priority = new PriorityAPI($bugsys);
$priority->set('priorityid', $bugsys->in['priorityid']);
$priority->set_condition();
$priority->delete();
$admin->redirect('priority.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'delete')
{
$admin->page_confirm(T('Are you sure you want to delete this priority? Doing so will revert all bugs to the default priority (which is set in the options panel)?'), 'priority.php', 'kill', array('priorityid' => $bugsys->input_clean('priorityid', TYPE_UINT)));
}
// ###################################################################
if ($_POST['do'] == 'insert')
{
$priority = new PriorityAPI($bugsys);
$priority->set('priority', $bugsys->in['priority']);
$priority->set('displayorder', $bugsys->in['displayorder']);
$priority->insert();
$admin->redirect('priority.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'add')
{
NavLinks::prioritiesAdd();
$navigator->set_focus('link', 'priorities-add', 'priorities');
$admin->page_start(T('Add New Priority'));
$admin->form_start('priority.php', 'insert');
$admin->table_start();
$admin->table_head(T('New Priority'));
$admin->row_input(T('Priority Title<div><dfn>The title of this priority flag (eg: `Slated for Development` or `Address Now`)</dfn></div>'), 'priority');
$admin->row_input(T('Display Order<div><dfn>The order in which the priorities are displayed. The higher the number, the lower down in the list it is.</dfn></div>'), 'displayorder');
$admin->row_submit();
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
// ###################################################################
if ($_POST['do'] == 'update')
{
$priority = new PriorityAPI($bugsys);
$priority->set('priorityid', $bugsys->in['priorityid']);
$priority->set_condition();
$priority->set('priority', $bugsys->in['priority']);
$priority->set('displayorder', $bugsys->in['displayorder']);
$priority->update();
$admin->redirect('priority.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'edit')
{
NavLinks::prioritiesEdit($bugsys->in['priorityid']);
$navigator->set_focus('link', 'fields-pages-priorities', 'fields-pages');
$priority = new PriorityAPI($bugsys);
$priority->set('priorityid', $bugsys->in['priorityid']);
$priority->set_condition();
$priority->fetch();
$admin->page_start(T('Edit Priority'));
$admin->form_start('priority.php', 'update');
$admin->form_hidden_field('priorityid', $priority->objdata['priorityid']);
$admin->table_start();
$admin->table_head(sprintf(T('Edit Priority `%1$s` (id: %2$s)'), $priority->objdata['priority'], $priority->objdata['priorityid']));
$admin->row_input(T('Priority Title<div><dfn>The title of this priority flag (eg: `Slated for Development` or `Address Now`)</dfn></div>'), 'priority', $priority->objdata['priority']);
$admin->row_input(T('Display Order<div><dfn>The order in which the priorities are displayed. The higher the number, the lower down in the list it is.</dfn></div>'), 'displayorder', $priority->objdata['displayorder']);
$admin->row_submit();
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
// ###################################################################
if ($_REQUEST['do'] == 'modify')
{
NavLinks::prioritiesAdd();
$navigator->set_focus('link', 'fields-pages-priorities', 'fields-pages');
$admin->page_start(T('Priority Manager'));
$priorities = $db->query("SELECT * FROM " . TABLE_PREFIX . "priority ORDER BY displayorder");
$admin->form_start('priority.php', 'null');
$admin->table_start();
$admin->table_head(T('Priority Manager'));
while ($priority = $db->fetch_array($priorities))
{
$admin->row_text("$priority[displayorder]: <a href=\"priority.php?do=edit&priorityid=$priority[priorityid]\">$priority[priority]</a>", "(priorityid: $priority[priorityid]) <a href=\"priority.php?do=edit&priorityid=$priority[priorityid]\">[" . T('Edit') . "]</a> <a href=\"priority.php?do=delete&priorityid=$priority[priorityid]\">[" . T('Delete') . "]</a>");
}
$db->free_result($priorities);
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/
?>