auth(); $inc->template(); $inc->canned(); $inc->department(); // Check to see if the person is not logged in $GLOBALS['auth']->check_logout(); // Define the three sets of links in the template if ($GLOBALS['auth']->admin()) { $GLOBALS['template']->links('admin', 'admin'); } else { $GLOBALS['template']->links('operator', 'operator'); } if (isset($_GET['add'])) { $GLOBALS['template']->assign('action', 'add'); } elseif (isset($_POST['add'])) { $GLOBALS['template']->assign('action', 'added'); $GLOBALS['canned']->insert(addslashes($_POST['operator']), addslashes($_POST['department']), addslashes($_POST['subject']), addslashes($_POST['message'])); } elseif (isset($_GET['edit'])) { $GLOBALS['template']->assign('action', 'edit'); $GLOBALS['template']->assign('canned_message', $GLOBALS['canned']->get('', '', addslashes($_GET['id']))); } elseif (isset($_POST['edit'])) { $GLOBALS['template']->assign('action', 'edited'); $GLOBALS['canned']->update(addslashes($_POST['id']), addslashes($_POST['operator']), addslashes($_POST['department']), addslashes($_POST['subject']), addslashes($_POST['message'])); } elseif (isset($_POST['delete'])) { $GLOBALS['template']->assign('action', 'delete'); // Loop though all the posted variables that have numbers as their name and conent // these need to be deleted (the number is the id of the db row) foreach ($_POST as $key => $val) { if ($key == $val && is_numeric($val)) { $GLOBALS['canned']->delete($val); } } } else { $GLOBALS['template']->assign('action', ''); } $GLOBALS['template']->assign('canned', $GLOBALS['canned']->get()); $GLOBALS['template']->assign('id', $GLOBALS['operator']->id()); $GLOBALS['template']->assign('departments', $GLOBALS['department']->listall($GLOBALS['operator']->id())); $GLOBALS['template']->assign('links_main', array( array('title' => $GLOBALS['lang']['view_all'], 'url' => $GLOBALS['conf']['url'].'/admin/canned.php'), array('title' => $GLOBALS['lang']['add'], 'url' => $GLOBALS['conf']['url'].'/admin/canned.php?add') )); // Assign the page's title and the content template that needs to be used $GLOBALS['template']->assign('title', $GLOBALS['lang']['canned_messages']); $GLOBALS['template']->assign('content', 'admin_canned.tpl'); // Include the javascript files $GLOBALS['template']->assign('javascript', 'misc&monitor'); // Display the output $GLOBALS['template']->display('admin.tpl'); // do events that need to be done at the end of the file $inc->finished(); ?>