in['keystring'], $nokills)) { $admin->error($lang->string('You cannot delete this help text because it is part of the default set.')); } $db->query("DELETE FROM " . TABLE_PREFIX . "fieldhelp WHERE keystring = '" . $bugsys->in['keystring'] . "'"); build_user_help(); $admin->redirect('userhelp.php?do=modify'); } // ################################################################### if ($_REQUEST['do'] == 'delete') { if (in_array($bugsys->in['keystring'], $nokills)) { $admin->error($lang->string('You cannot delete this help text because it is part of the default set.')); } $admin->page_confirm($lang->string('Are you sure you want to delete help text?'), 'userhelp.php?do=kill&keystring=' . $bugsys->in['keystring']); } // ################################################################### if ($_POST['do'] == 'insert') { if (preg_match('#[^a-z0-9_]#', $bugsys->in['keystring'])) { $admin->error($lang->string('The unique key can only contain lowercase letters, underscores, and numbers.')); } if ($db->query_first("SELECT * FROM " . TABLE_PREFIX . "fieldhelp WHERE keystring = '" . $bugsys->in['keystring'] . "'")) { $admin->error($lang->string('The unique key must be unique.')); } if (empty($bugsys->in['keystring']) OR empty($bugsys->in['title']) OR empty($bugsys->in['body'])) { $admin->error($lang->string('All the fields are required. Please go back and fill each field in properly.')); } $db->query("INSERT INTO " . TABLE_PREFIX . "fieldhelp (keystring, title, body) VALUES ('" . $bugsys->in['keystring'] . "', '" . $bugsys->in['title'] . "', '" . $bugsys->in['body'] . "')"); build_user_help(); $admin->redirect('userhelp.php?do=modify'); } // ################################################################### if ($_REQUEST['do'] == 'add') { $admin->page_start($lang->string('New Help Text')); $admin->form_start('userhelp.php', 'insert'); $admin->table_start(); $admin->table_head($lang->string('New Help Text')); $admin->row_input($lang->string('Topic Title'), 'title'); $admin->row_input($lang->string('Unique Key
(lowercase letters, underscores, and numbers only)'), 'keystring'); $admin->row_textarea($lang->string('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) { if (empty($fields['title']) OR empty($fields['body'])) { $admin->error(sprintf($lang->string('No fields can be empty. Please correct this with the text for key %1$s.'), $keystring)); } else { $query[] = "UPDATE " . TABLE_PREFIX . "fieldhelp SET title = '$fields[title]', body = '$fields[body]' WHERE keystring = '$keystring'"; } } foreach ($query AS $sql) { $db->query($sql); } build_user_help(); $admin->redirect('userhelp.php?do=modify'); } // ################################################################### if ($_REQUEST['do'] == 'modify') { $admin->page_start($lang->string('Edit User Help')); $admin->form_start('userhelp.php', 'update'); $admin->table_start(); $admin->table_head($lang->string('Edit User Help')); $topics = $db->query("SELECT * FROM " . TABLE_PREFIX . "fieldhelp ORDER BY keystring ASC"); while ($topic = $db->fetch_array($topics)) { $inputfield = ''; $delete = (!in_array($topic['keystring'], $nokills) ? '

[' . $lang->string('Delete') . ']' : ''); $admin->row_textarea($inputfield . '
' . $topic['keystring'] . '' . $delete, 'help[' . $topic['keystring'] . '][body]', $topic['body']); } $admin->row_submit('[' . $lang->string('Add New Help Text') . ']'); $admin->table_end(); $admin->page_end(); } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>