<?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_userhelp.php');
require_once('./includes/functions_datastore.php');
require_once('./includes/class_api_error.php');
APIError(array(new API_Error_Handler($admin), 'admin_error'));
NavLinks::optionsPages();
NavLinks::userhelpAdd();
$navigator->set_focus('tab', 'options', null);
if (!can_perform('canadmintools'))
{
admin_login();
}
// ###################################################################
if (empty($_REQUEST['do']))
{
$_REQUEST['do'] = 'modify';
}
// ###################################################################
if ($_REQUEST['do'] == 'kill')
{
$help = new UserHelpAPI($bugsys);
$help->set('keystring', $bugsys->in['keystring']);
$help->delete();
build_user_help();
$admin->redirect('userhelp.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'delete')
{
$admin->page_confirm(T('Are you sure you want to delete help text?'), 'userhelp.php', 'kill', array('keystring' => $bugsys->in['keystring']));
}
// ###################################################################
if ($_POST['do'] == 'insert')
{
$help = new UserHelpAPI($bugsys);
$help->set('keystring', $bugsys->in['keystring']);
$help->set('title', $bugsys->in['title']);
$help->set('body', $bugsys->in['body']);
$help->insert();
$admin->redirect('userhelp.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'add')
{
$navigator->set_focus('link', 'options-userhelp-add', 'options-userhelp');
$admin->page_start(T('New Help Text'));
$admin->form_start('userhelp.php', 'insert');
$admin->table_start();
$admin->table_head(T('New Help Text'));
$admin->row_input(T('Topic Title'), 'title');
$admin->row_input(T('Unique Key<br />(lowercase letters, underscores, and numbers only)'), 'keystring');
$admin->row_textarea(T('Body Text'), 'body');
$admin->row_submit();
$admin->table_end();
$admin->form_end();
$admin->page_end();
}
// ###################################################################
if ($_POST['do'] == 'update')
{
foreach ($bugsys->in['help'] AS $keystring => $fields)
{
$help = new UserHelpAPI($bugsys);
$help->norunners = array('post_update');
$help->set('keystring', $keystring);
$help->set_condition();
$help->set('title', $fields['title']);
$help->set('body', $fields['body']);
$help->update();
}
build_user_help();
$admin->redirect('userhelp.php?do=modify');
}
// ###################################################################
if ($_REQUEST['do'] == 'modify')
{
$navigator->set_focus('link', 'options-pages-userhelp', 'options-pages');
$admin->page_start(T('Edit User Help'));
$admin->form_start('userhelp.php', 'update');
$admin->table_start();
$admin->table_head(T('Edit User Help'));
$topics = $db->query("SELECT * FROM " . TABLE_PREFIX . "fieldhelp ORDER BY keystring ASC");
while ($topic = $db->fetch_array($topics))
{
$inputfield = '<input type="text" class="input" name="help[' . $topic['keystring'] . '][title]" value="' . $topic['title'] . '" size="35" />';
$delete = (!in_array($topic['keystring'], UserHelpAPI::not_able_to_delete()) ? '<br /><br /><a href="userhelp.php?do=delete&keystring=' . $topic['keystring'] . '">[' . T('Delete') . ']</a>' : '');
$admin->row_textarea($inputfield . '<br /><em>' . $topic['keystring'] . '</em>' . $delete, 'help[' . $topic['keystring'] . '][body]', $topic['body']);
}
$admin->row_submit();
$admin->table_end();
$admin->page_end();
}
/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/
?>