/** * @return bool true (success) / false (failure) */ function isActive() { $module_dir = $this->meta['module_dir']; $module_name = $this->meta['name']; if ($module_dir == '' || $module_name == '') { // Sanity check return false; } // Make sure that module is active $hModule =& xoops_gethandler('module'); $mod =& $hModule->getByDirname($module_dir); if (is_object($mod)) { if ($mod->getVar('isactive')) { // Module active? $activeAdapter = xhelpGetMeta('faq_adapter'); if ($activeAdapter = $module_name) { return true; } else { return false; } } else { return false; } } else { return false; } }
/** * Store the parsed message in database * @access public * @param object $msg {@link xhelpParsedMsg} object Message to add * @param object $user {@link xoopsUser} object User that submitted message * @param object $mbox {@link xhelpDepartmentMailBox} object. Originating Mailbox for message * @return mixed Returns {@link xhelpTicket} object if new ticket, {@link xhelpResponses} object if a response, and false if unable to save. */ function &storeMsg(&$msg, &$user, &$mbox, &$errors) { //Remove any previous error messages $this->clearErrors(); $type = $msg->getMsgType(); switch ($type) { case _XHELP_MSGTYPE_TICKET: $obj =& $this->_hTicket->create(); $obj->setVar('uid', $user->getVar('uid')); $obj->setVar('subject', $msg->getSubject()); $obj->setVar('description', $msg->getMsg()); $obj->setVar('department', $mbox->getVar('departmentid')); $obj->setVar('priority', $mbox->getVar('priority')); $obj->setVar('posted', time()); $obj->setVar('serverid', $mbox->getVar('id')); $obj->setVar('userIP', 'via Email'); $obj->setVar('email', $user->getVar('email')); if (!($status = xhelpGetMeta("default_status"))) { xhelpSetMeta("default_status", "1"); $status = 1; } $obj->setVar('status', $status); $obj->createEmailHash($msg->getEmail()); if ($this->_hTicket->insert($obj)) { $obj->addSubmitter($user->getVar('email'), $user->getVar('uid')); $this->_saveAttachments($msg, $obj->getVar('id')); $errors = $this->_getErrors(); return array($obj); } break; case _XHELP_MSGTYPE_RESPONSE: if (!($ticket = $this->_hTicket->getTicketByHash($msg->getHash()))) { $this->_setError(_XHELP_RESPONSE_NO_TICKET); return false; } if ($msg->getEmail() != $ticket->getVar('email')) { $this->_setError(sprintf(_XHELP_MISMATCH_EMAIL, $msg->getEmail(), $ticket->getVar('email'))); return false; } $obj = $this->_hResponse->create(); $obj->setVar('ticketid', $ticket->getVar('id')); $obj->setVar('uid', $user->getVar('uid')); $obj->setVar('message', $msg->getMsg()); $obj->setVar('updateTime', time()); $obj->setVar('userIP', 'via Email'); if ($this->_hResponse->insert($obj)) { $this->_saveAttachments($msg, $ticket->getVar('id'), $obj->getVar('id')); $ticket->setVar('lastUpdated', time()); $this->_hTicket->insert($ticket); $errors = $this->_getErrors(); return array($ticket, $obj); } break; default: //Sanity Check, should never get here } return false; }
function updateActive() { if (!isset($_POST['modname'])) { redirect_header(XHELP_ADMIN_URL . "/faqAdapter.php", 3, _AM_XHELP_MESSAGE_NO_NAME); } else { $modname = $_POST['modname']; } $currentAdapter = xhelpGetMeta('faq_adapter'); if ($currentAdapter == $modname) { // Deactivate current adapter? $ret = xhelpDeleteMeta('faq_adapter'); } else { $ret = xhelpFaqAdapterFactory::setFaqAdapter($modname); } if ($ret) { header("Location: " . XHELP_ADMIN_URL . "/faqAdapter.php"); } else { redirect_header(XHELP_ADMIN_URL . "/faqAdapter.php", 3, _AM_XHELP_MSG_INSTALL_MODULE); } }
/** * Retrieve an FaqAdapter class */ function &getFaqAdapter($name = '') { // Step 1 - Retrieve configured faq application $ret = false; if ($name == '') { $name = xhelpGetMeta('faq_adapter'); if ($name == '') { return $ret; } } // Check adapterValid function $isValid = xhelpFaqAdapterFactory::_adapterValid($name); if ($isValid) { // Step 2 - include script with faq adapter class require_once XHELP_FAQ_ADAPTER_PATH . '/' . $name . '.php'; // Step 3 - create instance of adapter class $classname = 'xhelp' . $name . 'Adapter'; // Step 4 - return adapter class $ret = new $classname(); return $ret; } else { return $ret; } }
function manageDepartments() { global $xoopsModule, $oAdminButton, $aSortBy, $aOrderBy, $aLimitBy, $order, $limit, $start, $sort, $dept_search; $module_id = $xoopsModule->getVar('mid'); $hGroups =& xoops_gethandler('group'); $hGroupPerm =& xoops_gethandler('groupperm'); if (isset($_POST['addDept'])) { $hasErrors = false; $errors = array(); $groups = isset($_POST['groups']) ? $_POST['groups'] : array(); $hDepartments =& xhelpGetHandler('department'); //Department Name supplied? if (trim($_POST['newDept']) == '') { $hasErrors = true; $errors['newDept'][] = _AM_XHELP_MESSAGE_NO_DEPT; } else { //Department Name unique? $crit = new Criteria('department', $_POST['newDept']); if ($existingDepts = $hDepartments->getCount($crit)) { $hasErrors = true; $errors['newDept'][] = _XHELP_MESSAGE_DEPT_EXISTS; } } if ($hasErrors) { $session =& Session::singleton(); //Store existing dept info in session, reload addition page $aDept = array(); $aDept['newDept'] = $_POST['newDept']; $aDept['groups'] = $groups; $session->set('xhelp_addDepartment', $aDept); $session->set('xhelp_addDepartmentErrors', $errors); header('Location: ' . xhelpMakeURI(XHELP_ADMIN_URL . '/department.php', array('op' => 'manageDepartments'), false)); exit; } $department =& $hDepartments->create(); $department->setVar('department', $_POST['newDept']); if ($hDepartments->insert($department)) { $deptID = $department->getVar('id'); foreach ($groups as $group) { // Add new group permissions $hGroupPerm->addRight(_XHELP_GROUP_PERM_DEPT, $deptID, $group, $module_id); } // Set as default department? if (isset($_POST['defaultDept']) && $_POST['defaultDept'] == 1) { xhelpSetMeta("default_department", $deptID); } $hStaff =& xhelpGetHandler('staff'); $allDeptStaff =& $hStaff->getByAllDepts(); if (count($allDeptStaff) > 0) { $hMembership =& xhelpGetHandler('membership'); if ($hMembership->addStaffToDept($allDeptStaff, $department->getVar('id'))) { $message = _XHELP_MESSAGE_ADD_DEPT; } else { $message = _AM_XHELP_MESSAGE_STAFF_UPDATE_ERROR; } } else { $message = _XHELP_MESSAGE_ADD_DEPT; } // Add configoption for new department $hConfig =& xoops_gethandler('config'); $hConfigOption =& xoops_gethandler('configoption'); $crit = new Criteria('conf_name', 'xhelp_defaultDept'); $config =& $hConfig->getConfigs($crit); if (count($config) > 0) { $newOption =& $hConfigOption->create(); $newOption->setVar('confop_name', $department->getVar('department')); $newOption->setVar('confop_value', $department->getVar('id')); $newOption->setVar('conf_id', $config[0]->getVar('conf_id')); if (!$hConfigOption->insert($newOption)) { redirect_header(XHELP_ADMIN_URL . "/department.php?op=manageDepartments", 3, _AM_XHELP_MSG_ADD_CONFIG_ERR); } } _clearAddSessionVars(); header("Location: " . XHELP_ADMIN_URL . "/department.php?op=manageDepartments"); } else { $message = _XHELP_MESSAGE_ADD_DEPT_ERROR . $department->getHtmlErrors(); } $deptID = $department->getVar('id'); /* Not sure if this is needed. Already exists in if block above (ej) foreach($groups as $group){ $hGroupPerm->addRight(_XHELP_GROUP_PERM_DEPT, $deptID, $group, $module_id); } */ redirect_header(XHELP_ADMIN_URL . '/department.php?op=manageDepartments', 3, $message); } else { $hDepartments =& xhelpGetHandler('department'); if ($dept_search == false) { $crit = new Criteria('', ''); } else { $crit = new Criteria('department', "%{$dept_search}%", 'LIKE'); } $crit->setOrder($order); $crit->setSort($sort); $crit->setLimit($limit); $crit->setStart($start); $total = $hDepartments->getCount($crit); $departmentInfo =& $hDepartments->getObjects($crit); $nav = new XoopsPageNav($total, $limit, $start, 'start', "op=manageDepartments&limit={$limit}"); // Get list of all groups $crit = new Criteria('', ''); $crit->setSort('name'); $crit->setOrder('ASC'); $groups =& $hGroups->getObjects($crit, true); $aGroups = array(); foreach ($groups as $group_id => $group) { $aGroups[$group_id] = $group->getVar('name'); } asort($aGroups); // Set groups in alphabetical order xoops_cp_header(); echo $oAdminButton->renderButtons('manDept'); $session =& Session::singleton(); $sess_dept = $session->get('xhelp_addDepartment'); $sess_errors = $session->get('xhelp_addDepartmentErrors'); //Display any form errors if (!$sess_errors === false) { xhelpRenderErrors($sess_errors, xhelpMakeURI(XHELP_ADMIN_URL . '/department.php', array('op' => 'clearAddSession'), false)); } if (!$sess_dept === false) { $fld_newDept = $sess_dept['newDept']; $fld_groups = $sess_dept['groups']; } else { $fld_newDept = ''; $fld_groups = array(); } echo "<form method='post' action='" . XHELP_ADMIN_URL . "/department.php?op=manageDepartments'>"; echo "<table width='100%' cellspacing='1' class='outer'>\r\n <tr><th colspan='2'><label for='newDept'>" . _AM_XHELP_LINK_ADD_DEPT . " </label></th></tr>"; echo "<tr><td class='head' width='20%' valign='top'>" . _AM_XHELP_TEXT_NAME . "</td><td class='even'>"; echo "<input type='text' id='newDept' name='newDept' class='formButton' value='{$fld_newDept}' /></td></tr>"; echo "<tr><td class='head' width='20%' valign='top'>" . _AM_XHELP_TEXT_EDIT_DEPT_PERMS . "</td><td class='even'>"; echo "<select name='groups[]' multiple='multiple'>"; foreach ($aGroups as $group_id => $group) { if (in_array($group_id, $fld_groups, true)) { echo "<option value='{$group_id}' selected='selected'>{$group}</option>"; } else { echo "<option value='{$group_id}'>{$group}</option>"; } } echo "</select></td></tr>"; echo "<tr><td class='head' width='20%' valign='top'>" . _AM_XHELP_TEXT_DEFAULT_DEPT . "?</td>\r\n <td class='even'><input type='checkbox' name='defaultDept' id='defaultDept' value='1' /></td></tr>"; echo "<tr><td class='foot' colspan='2'><input type='submit' name='addDept' value='" . _AM_XHELP_BUTTON_SUBMIT . "' class='formButton' /></td></tr>"; echo "</table><br />"; echo "</form>"; if ($total > 0) { // Make sure there are departments echo "<form action='" . XHELP_ADMIN_URL . "/department.php?op=manageDepartments' style='margin:0; padding:0;' method='post'>"; echo "<table width='100%' cellspacing='1' class='outer'>"; echo "<tr><td align='right'>" . _AM_XHELP_BUTTON_SEARCH . "\r\n <input type='text' name='dept_search' value='{$dept_search}'/>\r\n \r\n " . _AM_XHELP_TEXT_SORT_BY . "\r\n <select name='sort'>"; foreach ($aSortBy as $value => $text) { $sort == $value ? $selected = "selected='selected'" : ($selected = ''); echo "<option value='{$value}' {$selected}>{$text}</option>"; } echo "</select>\r\n \r\n " . _AM_XHELP_TEXT_ORDER_BY . "\r\n <select name='order'>"; foreach ($aOrderBy as $value => $text) { $order == $value ? $selected = "selected='selected'" : ($selected = ''); echo "<option value='{$value}' {$selected}>{$text}</option>"; } echo "</select>\r\n \r\n " . _AM_XHELP_TEXT_NUMBER_PER_PAGE . "\r\n <select name='limit'>"; foreach ($aLimitBy as $value => $text) { $limit == $value ? $selected = "selected='selected'" : ($selected = ''); echo "<option value='{$value}' {$selected}>{$text}</option>"; } echo "</select>\r\n <input type='submit' name='dept_sort' id='dept_sort' value='" . _AM_XHELP_BUTTON_SUBMIT . "' />\r\n </td>\r\n </tr>"; echo "</table></form>"; echo "<table width='100%' cellspacing='1' class='outer'>\r\n <tr><th colspan='4'>" . _AM_XHELP_EXISTING_DEPARTMENTS . "</th></tr>\r\n <tr><td class='head'>" . _AM_XHELP_TEXT_ID . "</td><td class='head'>" . _AM_XHELP_TEXT_DEPARTMENT . "</td><td class='head'>" . _AM_XHELP_TEXT_DEFAULT . "</td><td class='head'>" . _AM_XHELP_TEXT_ACTIONS . "</td></tr>"; if (isset($departmentInfo)) { $defaultDept = xhelpGetMeta("default_department"); foreach ($departmentInfo as $dept) { echo "<tr><td class='even'>" . $dept->getVar('id') . "</td><td class='even'>" . $dept->getVar('department') . "</td>"; if ($dept->getVar('id') != $defaultDept) { echo "<td class='even' width='10%'><a href='" . XHELP_ADMIN_URL . "/department.php?op=updateDefault&id=" . $dept->getVar('id') . "'><img src='" . XHELP_IMAGE_URL . "/off.png' alt='" . _AM_XHELP_TEXT_MAKE_DEFAULT_DEPT . "' title='" . _AM_XHELP_TEXT_MAKE_DEFAULT_DEPT . "' /></a></td>"; } else { echo "<td class='even' width='10%'><img src='" . XHELP_IMAGE_URL . "/on.png'</td>"; } //echo "<td class='even' width='10%'><img src='".XHELP_IMAGE_URL."/". (($dept->getVar('id') == $defaultDept) ? "on.png" : "off.png")."'</td>"; echo "<td class='even' width='70'><a href='" . XHELP_ADMIN_URL . "/department.php?op=editDepartment&deptid=" . $dept->getVar('id') . "'><img src='" . XOOPS_URL . "/modules/xhelp/images/button_edit.png' title='" . _AM_XHELP_TEXT_EDIT . "' name='editDepartment' /></a> "; echo "<a href='" . XHELP_ADMIN_URL . "/delete.php?deleteDept=1&deptid=" . $dept->getVar('id') . "'><img src='" . XOOPS_URL . "/modules/xhelp/images/button_delete.png' title='" . _AM_XHELP_TEXT_DELETE . "' name='deleteDepartment' /></a></td></tr>"; } } } echo "</td></tr></table>"; echo "<div id='dept_nav'>" . $nav->renderNav() . "</div>"; xhelpAdminFooter(); xoops_cp_footer(); } }
function manageStatus() { global $oAdminButton, $aSortBy, $aOrderBy, $aLimitBy, $order, $limit, $start, $sort; $hStatus =& xhelpGetHandler('status'); if (isset($_POST['changeDefaultStatus'])) { xhelpSetMeta("default_status", $_POST['default']); } if (isset($_POST['newStatus'])) { if ($_POST['desc'] == '') { // If no description supplied $message = _AM_XHELP_MESSAGE_NO_DESC; redirect_header(XHELP_ADMIN_URL . "/status.php?op=manageStatus", 3, $message); } $newStatus =& $hStatus->create(); $newStatus->setVar('state', intval($_POST['state'])); $newStatus->setVar('description', $_POST['desc']); if ($hStatus->insert($newStatus)) { header("Location: " . XHELP_ADMIN_URL . "/status.php?op=manageStatus"); } else { $message = _AM_MESSAGE_ADD_STATUS_ERR; redirect_header(XHELP_ADMIN_URL . "/status.php?op=manageStatus", 3, $message); } } xoops_cp_header(); echo $oAdminButton->renderButtons('manStatus'); echo "<form method='post' action='" . XHELP_ADMIN_URL . "/status.php?op=manageStatus'>"; echo "<table width='100%' cellspacing='1' class='outer'>\r\n <tr><th colspan='2'><label>" . _AM_XHELP_TEXT_ADD_STATUS . "</label></th></tr>"; echo "<tr><td class='head' width='20%'>" . _AM_XHELP_TEXT_DESCRIPTION . "</td>\r\n <td class='even'>\r\n <input type='text' name='desc' value='' class='formButton' />\r\n </td>\r\n </tr>"; echo "<tr><td class='head' width='20%'>" . _AM_XHELP_TEXT_STATE . "</td><td class='even'>\r\n <select name='state'>\r\n <option value='1'>" . xhelpGetState(1) . "</option>\r\n <option value='2'>" . xhelpGetState(2) . "</option>\r\n </select></td></tr>"; echo "<tr><td class='foot' colspan='2'><input type='submit' name='newStatus' value='" . _AM_XHELP_TEXT_ADD_STATUS . "' class='formButton' /></td></tr>"; echo "</table></form>"; // Get list of existing statuses $crit = new Criteria('', ''); $crit->setOrder($order); $crit->setSort($sort); $crit->setLimit($limit); $crit->setStart($start); $statuses =& $hStatus->getObjects($crit); $total = $hStatus->getCount($crit); $aStatuses = array(); foreach ($statuses as $status) { $aStatuses[$status->getVar('id')] = $status->getVar('description'); } if (!($default_status = xhelpGetMeta("default_status"))) { xhelpSetMeta("default_status", "1"); $default_status = 1; } $form = new xhelpForm(_AM_XHELP_TEXT_DEFAULT_STATUS, 'default_status', xhelpMakeURI(XHELP_ADMIN_URL . '/status.php', array('op' => 'manageStatus'))); $status_select = new XoopsFormSelect(_AM_XHELP_TEXT_STATUS, 'default', $default_status); $status_select->addOptionArray($aStatuses); $btn_tray = new XoopsFormElementTray(''); $btn_tray->addElement(new XoopsFormButton('', 'changeDefaultStatus', _AM_XHELP_BUTTON_SUBMIT, 'submit')); $form->addElement($status_select); $form->addElement($btn_tray); $form->setLabelWidth('20%'); echo $form->render(); $nav = new XoopsPageNav($total, $limit, $start, 'start', "op=manageStatus&limit={$limit}"); echo "<form action='" . XHELP_ADMIN_URL . "/status.php?op=manageStatus' style='margin:0; padding:0;' method='post'>"; echo "<table width='100%' cellspacing='1' class='outer'>"; echo "<tr><td align='right'>" . _AM_XHELP_TEXT_SORT_BY . "\r\n <select name='sort'>"; foreach ($aSortBy as $value => $text) { $sort == $value ? $selected = "selected='selected'" : ($selected = ''); echo "<option value='{$value}' {$selected}>{$text}</option>"; } echo "</select>\r\n \r\n " . _AM_XHELP_TEXT_ORDER_BY . "\r\n <select name='order'>"; foreach ($aOrderBy as $value => $text) { $order == $value ? $selected = "selected='selected'" : ($selected = ''); echo "<option value='{$value}' {$selected}>{$text}</option>"; } echo "</select>\r\n \r\n " . _AM_XHELP_TEXT_NUMBER_PER_PAGE . "\r\n <select name='limit'>"; foreach ($aLimitBy as $value => $text) { $limit == $value ? $selected = "selected='selected'" : ($selected = ''); echo "<option value='{$value}' {$selected}>{$text}</option>"; } echo "</select>\r\n <input type='submit' name='status_sort' id='status_sort' value='" . _AM_XHELP_BUTTON_SUBMIT . "' />\r\n </td>\r\n </tr>"; echo "</table></form>"; echo "<table width='100%' cellspacing='1' class='outer'>\r\n <tr><th colspan='4'><label>" . _AM_XHELP_TEXT_MANAGE_STATUSES . "</label></th></tr>"; echo "<tr class='head'>\r\n <td>" . _AM_XHELP_TEXT_ID . "</td>\r\n <td>" . _AM_XHELP_TEXT_DESCRIPTION . "</td>\r\n <td>" . _AM_XHELP_TEXT_STATE . "</td>\r\n <td>" . _AM_XHELP_TEXT_ACTIONS . "</td>\r\n </tr>"; foreach ($statuses as $status) { echo "<tr class='even'><td>" . $status->getVar('id') . "</td><td>" . $status->getVar('description') . "</td>\r\n <td>" . xhelpGetState($status->getVar('state')) . "</td>\r\n <td>\r\n <a href='status.php?op=editStatus&statusid=" . $status->getVar('id') . "'><img src='" . XHELP_IMAGE_URL . "/button_edit.png' title='" . _AM_XHELP_TEXT_EDIT . "' name='editStatus' /></a> \r\n <a href='status.php?op=deleteStatus&statusid=" . $status->getVar('id') . "'><img src='" . XHELP_IMAGE_URL . "/button_delete.png' title='" . _AM_XHELP_TEXT_DELETE . "' name='deleteStatus' /></a></td></tr>\r\n </td></tr>"; } echo "</table>"; echo "<div id='status_nav'>" . $nav->renderNav() . "</div>"; xhelpAdminFooter(); xoops_cp_footer(); }
function upgradeDB() { global $xoopsModule, $oAdminButton; $xoopsDB =& Database::getInstance(); //1. Determine previous release // *** Update this in sql/mysql.sql for each release ** if (!xhelpTableExists('xhelp_meta')) { $ver = '0.5'; } else { if (!($ver = xhelpGetMeta('version'))) { exit(_AM_XHELP_VERSION_ERR); } } $hStaff =& xhelpGetHandler('staff'); $hMember =& xhelpGetHandler('membership'); $hTicket =& xhelpGetHandler('ticket'); $hXoopsMember =& xoops_gethandler('member'); $hRole =& xhelpGetHandler('role'); $mid = $xoopsModule->getVar('mid'); xoops_cp_header(); echo $oAdminButton->renderButtons(''); echo "<h2>" . _AM_XHELP_UPDATE_DB . "</h2>"; $ret = true; //2. Do All Upgrades necessary to make current // Break statements are omitted on purpose switch ($ver) { case '0.5': set_time_limit(60); printf("<h3>" . _AM_XHELP_UPDATE_TO . "</h3>", '0.6'); echo "<ul>"; //Create meta table $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (metakey varchar(50) NOT NULL default '', metavalue varchar(255) NOT NULL default '', PRIMARY KEY (metakey)) ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_meta')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_meta'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_meta')); //Insert Current Version into table $qry = $xoopsDB->query(sprintf("INSERT INTO %s values('version', %s)", $xoopsDB->prefix('xhelp_meta'), $xoopsDB->quoteString($ver))); //Update xhelp_responses table $ret = $ret && _runQuery(sprintf("ALTER TABLE %s ADD private INT(11) NOT NULL DEFAULT '0'", $xoopsDB->prefix('xhelp_responses')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_responses'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_responses')); //Retrieve uid's of all staff members $qry = $xoopsDB->query('SELECT uid FROM ' . $xoopsDB->prefix('xhelp_staff') . ' ORDER BY uid'); //Get email addresses in user profile $staff = array(); while ($arr = $xoopsDB->fetchArray($qry)) { $staff[$arr['uid']] = ''; } $xoopsDB->freeRecordSet($qry); $query = 'SELECT uid, email FROM ' . $xoopsDB->prefix('users') . ' WHERE uid IN (' . implode(array_keys($staff), ',') . ')'; $qry = $xoopsDB->query($query); while ($arr = $xoopsDB->fetchArray($qry)) { $staff[$arr['uid']] = $arr['email']; } $xoopsDB->freeRecordSet($qry); //Update xhelp_staff table $ret = $ret && _runQuery(sprintf("ALTER TABLE %s ADD email varchar(255) NOT NULL default '' AFTER uid, ADD notify int(11) NOT NULL default '0'", $xoopsDB->prefix('xhelp_staff')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_staff'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_staff')); //Update existing staff records $staff_tbl = $xoopsDB->prefix('xhelp_staff'); $notif_tbl = $xoopsDB->prefix('xoopsnotifications'); $email_tpl = $xoopsModule->getInfo('_email_tpl'); foreach ($staff as $uid => $email) { //get notifications for current user $usernotif = 0; $qry = $xoopsDB->query(sprintf("SELECT DISTINCT not_category, not_event FROM %s WHERE not_uid = %u AND not_category='dept' AND not_modid=%u", $notif_tbl, $uid, $mid)); while ($arr = $xoopsDB->fetchArray($qry)) { //Look for current event information in $email_tpl foreach ($email_tpl as $tpl) { if ($tpl['name'] == $arr['not_event'] && $tpl['category'] == $arr['not_category']) { $usernotif = $usernotif | pow(2, $tpl['bit_value']); break; } } } //Update xhelp_staff with user notifications & email address $ret = $ret && _runQuery(sprintf("UPDATE %s SET email = %s, notify = %u WHERE uid = %u", $staff_tbl, $xoopsDB->quoteString($email), $usernotif, $uid), sprintf(_AM_XHELP_MSG_UPDATESTAFF, $uid), sprintf(_AM_XHELP_MSG_UPDATESTAFF_ERR, $uid)); } echo "</ul>"; case '0.6': set_time_limit(60); //Do DB updates to make 0.7 printf("<h3>" . _AM_XHELP_UPDATE_TO . "</h3>", '0.7'); echo "<ul>"; // change table names to lowercase $ret = $ret && _renameTable('xhelp_logMessages', 'xhelp_logmessages'); $ret = $ret && _renameTable('xhelp_responseTemplates', 'xhelp_responsetemplates'); $ret = $ret && _renameTable('xhelp_jStaffDept', 'xhelp_jstaffdept'); $ret = $ret && _renameTable('xhelp_staffReview', 'xhelp_staffreview'); $ret = $ret && _renameTable('xhelp_emailTpl', 'xhelp_emailtpl'); // Remove unused table - xhelp_emailtpl $ret = $ret && _runQuery(sprintf("DROP TABLE %s", $xoopsDB->prefix('xhelp_emailtpl')), sprintf(_AM_XHELP_MSG_REMOVE_TABLE, 'xhelp_emailtpl'), sprintf(_AM_XHELP_MSG_NOT_REMOVE_TABLE, 'xhelp_emailtpl')); // xhelp_staff table - permTimestamp $ret = $ret && _runQuery(sprintf("ALTER TABLE %s ADD permTimestamp INT(11) NOT NULL DEFAULT '0'", $xoopsDB->prefix('xhelp_staff')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_staff'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_staff')); //Update xhelp_tickets table $ret = $ret && _runQuery(sprintf("ALTER TABLE %s MODIFY subject VARCHAR(100) NOT NULL default ''", $xoopsDB->prefix('xhelp_tickets')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_tickets'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_tickets')); $ret = $ret && _runQuery(sprintf("ALTER TABLE %s ADD (serverid INT(11) DEFAULT NULL,\r\n emailHash VARCHAR(100) DEFAULT NULL,\r\n email VARCHAR(100) DEFAULT NULL,\r\n overdueTime INT(11) NOT NULL DEFAULT '0',\r\n KEY emailHash (emailHash))", $xoopsDB->prefix('xhelp_tickets')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_tickets'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_tickets')); // Create xhelp_department_mailbox table $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (id int(11) NOT NULL auto_increment,\r\n departmentid int(11) default NULL,\r\n emailaddress varchar(255) default NULL,\r\n server varchar(50) default NULL,\r\n serverport int(11) default NULL,\r\n username varchar(50) default NULL,\r\n password varchar(50) default NULL,\r\n priority tinyint(4) default NULL,\r\n mboxtype int(11) NOT NULL default 1,\r\n PRIMARY KEY (id),\r\n UNIQUE KEY id (id),\r\n KEY departmentid (departmentid),\r\n KEY emailaddress (emailaddress),\r\n KEY mboxtype (mboxtype)\r\n )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_department_mailbox')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_department_mailbox'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_department_mailbox')); // Create xhelp_mailevent table $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (id int(11) NOT NULL auto_increment,\r\n mbox_id int(11) NOT NULL default '0',\r\n event_desc text,\r\n event_class int(11) NOT NULL default '0',\r\n posted int(11) NOT NULL default '0',\r\n PRIMARY KEY(id)\r\n )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_mailevent')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_mailevent'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_mailevent')); // Create xhelp_roles table $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (id int(11) NOT NULL auto_increment,\r\n name varchar(35) NOT NULL default '',\r\n description mediumtext,\r\n tasks int(11) NOT NULL default '0',\r\n PRIMARY KEY(id)\r\n )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_roles')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_roles'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_roles')); // Create xhelp_staffroles table $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (uid int(11) NOT NULL default '0',\r\n roleid int(11) NOT NULL default '0',\r\n deptid int(11) NOT NULL default '0',\r\n PRIMARY KEY(uid, roleid, deptid)\r\n )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_staffroles')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_staffroles'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_staffroles')); // Add default roles to db if (!($hasRoles = xhelpCreateRoles())) { echo "<li>" . _AM_XHELP_MESSAGE_DEF_ROLES_ERROR . "</li>"; } else { echo "<li>" . _AM_XHELP_MESSAGE_DEF_ROLES . "</li>"; } // Set all staff members to have admin permission role if ($staff =& $hStaff->getObjects()) { foreach ($staff as $stf) { $uid = $stf->getVar('uid'); $depts = $hMember->membershipByStaff($uid, true); if ($hStaff->addStaffRole($uid, 1, 0)) { echo "<li>" . sprintf(_AM_XHELP_MSG_GLOBAL_PERMS, $uid) . "</li>"; } foreach ($depts as $dept) { $deptid = $dept->getVar('id'); if ($hStaff->addStaffRole($uid, 1, $deptid)) { // Departmental permissions echo "<li>" . sprintf(_AM_XHELP_MSG_UPD_PERMS, $uid, $dept->getVar('department')) . "</li>"; } } $stf->setVar('permTimestamp', time()); // Set initial value for permTimestamp field if (!$hStaff->insert($stf)) { echo "<li>" . sprintf(_AM_XHELP_MSG_UPDATESTAFF_ERR, $uid) . "</li>"; } else { echo "<li>" . sprintf(_AM_XHELP_MSG_UPDATESTAFF, $uid) . "</li>"; } } } echo "</ul>"; case '0.7': set_time_limit(60); //Do DB updates to make 0.71 printf("<h3>" . _AM_XHELP_UPDATE_TO . "</h3>", '0.71'); echo "<ul>"; echo "</ul>"; case '0.71': set_time_limit(60); //Do DB updates to make 0.75 printf("<h3>" . _AM_XHELP_UPDATE_TO . "</h3>", '0.75'); echo "<ul>"; //Changes for php5 compabibility $ret = $ret && _runQuery(sprintf("ALTER TABLE %s MODIFY lastUpdated int(11) NOT NULL default '0'", $xoopsDB->prefix('xhelp_logmessages')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_logmessages'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_logmessages')); $ret = $ret && _runQuery(sprintf("ALTER TABLE %s MODIFY department int(11) NOT NULL default '0'", $xoopsDB->prefix('xhelp_jstaffdept')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_jstaffdept'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_jstaffdept')); // Create table for email template information $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (notif_id int(11) NOT NULL default '0',\r\n staff_setting int(11) NOT NULL default '0',\r\n user_setting int(11) NOT NULL default '0',\r\n staff_options mediumtext NOT NULL,\r\n PRIMARY KEY (notif_id)\r\n )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_notifications')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_notifications'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_notifications')); // Add xhelp_status table $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (id int(11) NOT NULL auto_increment,\r\n state int(11) NOT NULL default '0',\r\n description varchar(50) NOT NULL default '',\r\n PRIMARY KEY(id),\r\n KEY state (state)\r\n )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_status')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_status'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_status')); // Give default statuses for upgrade $hStatus =& xhelpGetHandler('status'); $startStatuses = array(_XHELP_STATUS0 => 1, _XHELP_STATUS1 => 1, _XHELP_STATUS2 => 2); $count = 1; set_time_limit(60); foreach ($startStatuses as $desc => $state) { $newStatus =& $hStatus->create(); $newStatus->setVar('id', $count); $newStatus->setVar('description', $desc); $newStatus->setVar('state', $state); if (!$hStatus->insert($newStatus)) { echo "<li>" . sprintf(_AM_XHELP_MSG_ADD_STATUS_ERR, $desc) . "</li>"; } else { echo "<li>" . sprintf(_AM_XHELP_MSG_ADD_STATUS, $desc) . "</li>"; } $count++; } // Change old status values to new status values $oldStatuses = array(2 => 3, 1 => 2, 0 => 1); foreach ($oldStatuses as $cStatus => $newStatus) { $crit = new Criteria('status', $cStatus); $success = $hTicket->updateAll('status', $newStatus, $crit); } if ($success) { echo "<li>" . _AM_XHELP_MSG_CHANGED_STATUS . "</li>"; } else { echo "<li>" . _AM_XHELP_MSG_CHANGED_STATUS_ERR . "</li>"; } // Add xhelp_ticket_submit_emails table $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (ticketid int(11) NOT NULL default '0',\r\n uid int(11) NOT NULL default '0',\r\n email varchar(100) NOT NULL default '',\r\n suppress int(11) NOT NULL default '0',\r\n PRIMARY KEY(ticketid, email)\r\n )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_ticket_submit_emails')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_ticket_submit_emails'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_ticket_submit_emails')); // Add records to xhelp_ticket_submit_emails for existing tickets $count = $hTicket->getCount(); $batchsize = 100; $crit = new Criteria('', ''); $crit->setLimit($batchsize); $i = 0; while ($i <= $count) { set_time_limit(60); $crit->setStart($i); $tickets =& $hTicket->getObjects($crit); $all_users = array(); foreach ($tickets as $ticket) { $all_users[$ticket->getVar('uid')] = $ticket->getVar('uid'); } $crit = new Criteria('uid', "(" . implode(array_keys($all_users), ',') . ")", 'IN'); $users =& $hXoopsMember->getUsers($crit, true); foreach ($users as $user) { $all_users[$user->getVar('uid')] = $user->getVar('email'); } unset($users); foreach ($tickets as $ticket) { set_time_limit(60); $ticket_uid = $ticket->getVar('uid'); if (array_key_exists($ticket_uid, $all_users)) { $ticket_email = $all_users[$ticket_uid]; $success = $ticket->addSubmitter($ticket_email, $ticket_uid); } } unset($tickets); //increment $i += $batchsize; } set_time_limit(60); // Update xhelp_roles Admin record with new value (2047) $crit = new Criteria('tasks', 511); $admin_roles =& $hRole->getObjects($crit); foreach ($admin_roles as $role) { $role->setVar('tasks', 2047); if ($hRole->insert($role)) { echo "<li>" . sprintf(_AM_XHELP_MSG_UPDATE_ROLE, $role->getVar('name')) . "</li>"; } else { echo "<li>" . sprintf(_AM_XHELP_MSG_UPDATE_ROLE_ERR, $role->getVar('name')) . "</li>"; } } set_time_limit(60); $ret = $ret && _runQuery(sprintf("ALTER TABLE %s ADD (active INT(11) NOT NULL DEFAULT 1,\r\n KEY active (active))", $xoopsDB->prefix('xhelp_department_mailbox')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_department_mailbox'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_department_mailbox')); // Add xhelp_saved_searches table $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (id int(11) NOT NULL auto_increment,\r\n uid int(11) NOT NULL default '0',\r\n name varchar(50) NOT NULL default '',\r\n search mediumtext NOT NULL,\r\n pagenav_vars mediumtext NOT NULL,\r\n PRIMARY KEY(id)\r\n )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_saved_searches')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_saved_searches'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_saved_searches')); set_time_limit(60); $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (fieldid int(11) NOT NULL default '0',\r\n deptid int(11) NOT NULL default '0',\r\n PRIMARY KEY (fieldid, deptid)\r\n )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_ticket_field_departments')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_ticket_field_departments'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_ticket_field_departments')); $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (ticketid int(11) NOT NULL default '0',\r\n PRIMARY KEY (ticketid)\r\n )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_ticket_values')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_ticket_values'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_ticket_values')); set_time_limit(60); $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (id int(11) NOT NULL auto_increment,\r\n name varchar(64) NOT NULL default '',\r\n description tinytext NOT NULL,\r\n fieldname varchar(64) NOT NULL default '',\r\n controltype int(11) NOT NULL default '0',\r\n datatype varchar(64) NOT NULL default '',\r\n required tinyint(1) NOT NULL default '0',\r\n fieldlength int(11) NOT NULL default '0',\r\n weight int(11) NOT NULL default '0',\r\n fieldvalues mediumtext NOT NULL,\r\n defaultvalue varchar(100) NOT NULL default '',\r\n validation mediumtext NOT NULL,\r\n PRIMARY KEY (id),\r\n KEY weight (weight)\r\n )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_ticket_fields')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_ticket_fields'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_ticket_fields')); set_time_limit(60); // Add notifications to new table set_time_limit(60); $hasNotifications = xhelpCreateNotifications(); // Make all departments visible to all groups $hasDeptVisibility = xhelpCreateDepartmentVisibility(); // Update staff permTimestamp $hStaff->updateAll('permTimestamp', time()); set_time_limit(60); //Update xhelp_tickets table set_time_limit(60); $ret = $ret && _runQuery(sprintf("ALTER TABLE %s MODIFY subject VARCHAR(255) NOT NULL default ''", $xoopsDB->prefix('xhelp_tickets')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_tickets'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_tickets')); case '0.75': set_time_limit(60); // Set default department $xoopsModuleConfig =& xhelpGetModuleConfig(); if (isset($xoopsModuleConfig['xhelp_defaultDept']) && $xoopsModuleConfig['xhelp_defaultDept'] != 0) { $ret = xhelpSetMeta('default_department', $xoopsModuleConfig['xhelp_defaultDept']); } else { $hDepartments =& xhelpGetHandler('department'); $depts =& $hDepartments->getObjects(); $aDepts = array(); foreach ($depts as $dpt) { $aDepts[] = $dpt->getVar('id'); } $ret = xhelpSetMeta("default_department", $aDepts[0]); } $qry = $xoopsDB->query(sprintf("ALTER TABLE %s DROP PRIMARY KEY", $xoopsDB->prefix('xhelp_ticket_submit_emails'))); $ret = $ret && _runQuery(sprintf("ALTER TABLE %s ADD PRIMARY KEY(ticketid, uid, email)", $xoopsDB->prefix('xhelp_ticket_submit_emails')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_ticket_submit_emails'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_ticket_submit_emails')); $ret = $ret && _runQuery(sprintf("ALTER TABLE %s MODIFY department int(11) NOT NULL default '0'", $xoopsDB->prefix('xhelp_jstaffdept')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_jstaffdept'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_jstaffdept')); echo "<li>" . _AM_XHELP_MSG_CHANGED_DEFAULT_DEPT . "</li>"; // Add field to xhelp_saved_searches to determine if custom fields table is needed $ret = $ret && _runQuery(sprintf("ALTER TABLE %s ADD (hasCustFields int(11) NOT NULL default '0')", $xoopsDB->prefix('xhelp_saved_searches')), sprintf(_AM_XHELP_MSG_MODIFYTABLE, 'xhelp_saved_searches'), sprintf(_AM_XHELP_MSG_MODIFYTABLE_ERR, 'xhelp_saved_searches')); // Take existing saved searches and add 'query' field $hSavedSearch =& xhelpGetHandler('savedSearch'); $savedSearches =& $hSavedSearch->getObjects(); foreach ($savedSearches as $savedSearch) { set_time_limit(60); $crit =& unserialize($savedSearch->getVar('search')); if (is_object($crit)) { $savedSearch->setVar('query', $crit->render()); if ($hSavedSearch->insert($savedSearch)) { echo "<li>" . sprintf(_AM_XHELP_MSG_UPDATE_SEARCH, $savedSearch->getVar('id')) . "</li>"; } else { echo "<li>" . sprintf(_AM_XHELP_MSG_UPDATE_SEARCH_ERR, $savedSearch->getVar('id')) . "</li>"; } } } unset($savedSearches); // Add ticket list table set_time_limit(60); $ret = $ret && _runQuery(sprintf("CREATE TABLE %s (id int(11) NOT NULL auto_increment,\r\n uid int(11) NOT NULL default '0',\r\n searchid int(11) NOT NULL default '0',\r\n weight int(11) NOT NULL default '0',\r\n PRIMARY KEY (id),\r\n KEY ticketList (uid, searchid)\r\n )ENGINE=MyISAM;", $xoopsDB->prefix('xhelp_ticket_lists')), sprintf(_AM_XHELP_MSG_ADDTABLE, 'xhelp_ticket_lists'), sprintf(_AM_XHELP_MSG_ADDTABLE_ERR, 'xhelp_ticket_lists')); // Add global ticket lists for staff members xhelpCreateDefaultTicketLists(); set_time_limit(60); // Update xhelp_roles Admin record with new value (4095) $crit = new Criteria('tasks', 2047); $admin_roles =& $hRole->getObjects($crit); foreach ($admin_roles as $role) { $role->setVar('tasks', 4095); if ($hRole->insert($role)) { echo "<li>" . sprintf(_AM_XHELP_MSG_UPDATE_ROLE, $role->getVar('name')) . "</li>"; } else { echo "<li>" . sprintf(_AM_XHELP_MSG_UPDATE_ROLE_ERR, $role->getVar('name')) . "</li>"; } } case '0.77': // No schema changes for 0.78 // No schema changes for 0.78 case '0.78': echo "</ul>"; } $newversion = round($xoopsModule->getVar('version') / 100, 2); //if successful, update xhelp_meta table with new ver if ($ret) { printf(_AM_XHELP_UPDATE_OK, $newversion); $ret = xhelpSetMeta('version', $newversion); } else { printf(_AM_XHELP_UPDATE_ERR, $newversion); } xhelpAdminFooter(); xoops_cp_footer(); }
$xoopsTpl->assign('xhelp_custFields', $aFields); if (!empty($aFields)) { $xoopsTpl->assign('xhelp_hasCustFields', true); } else { $xoopsTpl->assign('xhelp_hasCustFields', false); } $javascript = "<script type=\"text/javascript\" src=\"" . XHELP_BASE_URL . "/include/functions.js\"></script>\r\n<script type=\"text/javascript\" src='" . XHELP_SCRIPT_URL . "/addTicketDeptChange.php?client'></script>\r\n<script type=\"text/javascript\">\r\n<!--\r\nfunction departments_onchange() \r\n{\r\n dept = xoopsGetElementById('departments');\r\n var wl = new xhelpweblib(fieldHandler);\r\n wl.customfieldsbydept(dept.value);\r\n}\r\n\r\nvar fieldHandler = {\r\n customfieldsbydept: function(result){\r\n var tbl = gE('tblAddTicket');\r\n var beforeele = gE('addButtons');\r\n tbody = tbl.tBodies[0];\r\n xhelpFillCustomFlds(tbody, result, beforeele);\r\n }\r\n}\r\n\r\nfunction window_onload()\r\n{\r\n xhelpDOMAddEvent(xoopsGetElementById('departments'), 'change', departments_onchange, true);\r\n}\r\n\r\nwindow.setTimeout('window_onload()', 1500);\r\n//-->\r\n</script>"; $xoopsTpl->assign('xoops_module_header', $javascript . $xhelp_module_header); $xoopsTpl->assign('xhelp_allowUpload', $xoopsModuleConfig['xhelp_allowUpload']); $xoopsTpl->assign('xhelp_imagePath', XOOPS_URL . '/modules/xhelp/images/'); $xoopsTpl->assign('xhelp_departments', $aDept); $xoopsTpl->assign('xhelp_current_file', basename(__FILE__)); $xoopsTpl->assign('xhelp_priorities', array(5, 4, 3, 2, 1)); $xoopsTpl->assign('xhelp_priorities_desc', array('5' => _XHELP_PRIORITY5, '4' => _XHELP_PRIORITY4, '3' => _XHELP_PRIORITY3, '2' => _XHELP_PRIORITY2, '1' => _XHELP_PRIORITY1)); $xoopsTpl->assign('xhelp_default_priority', XHELP_DEFAULT_PRIORITY); $xoopsTpl->assign('xhelp_default_dept', xhelpGetMeta("default_department")); $xoopsTpl->assign('xhelp_includeURL', XHELP_INCLUDE_URL); $xoopsTpl->assign('xhelp_numTicketUploads', $xoopsModuleConfig['xhelp_numTicketUploads']); $errors = array(); $aElements = array(); if ($validateErrors =& $_xhelpSession->get('xhelp_validateError')) { foreach ($validateErrors as $fieldname => $error) { if (!empty($error['errors'])) { $aElements[] = $fieldname; foreach ($error['errors'] as $err) { $errors[$fieldname] = $err; } } } $xoopsTpl->assign('xhelp_errors', $errors); } else {
function edit() { global $oAdminButton, $xoopsModule, $_xhelpSession, $aNotifications, $has_notifications, $aStaffSettings, $aUserSettings, $hNotification; if (isset($_REQUEST['id'])) { $id = intval($_REQUEST['id']); } else { // No id specified, return to manage page redirect_header(XHELP_ADMIN_URL . "/notifications.php?op=manage", 3, _AM_XHELP_MESSAGE_NO_ID); } $settings =& $hNotification->get($id); xoops_cp_header(); echo $oAdminButton->renderButtons('manNotify'); $_xhelpSession->set("xhelp_return_page", substr(strstr($_SERVER['REQUEST_URI'], 'admin/'), 6)); if (isset($_POST['save_notification'])) { $settings->setVar('staff_setting', intval($_POST['staff_setting'])); $settings->setVar('user_setting', intval($_POST['user_setting'])); if ($_POST['staff_setting'] == XHELP_NOTIF_STAFF_DEPT) { $settings->setVar('staff_options', $_POST['roles']); } else { $settings->setVar('staff_options', array()); } $hNotification->insert($settings, true); header("Location: " . XHELP_ADMIN_URL . "/notifications.php?op=edit&id={$id}"); } // Retrieve list of email templates if (!($templates =& $_xhelpSession->get("xhelp_notifications"))) { $templates =& $xoopsModule->getInfo('_email_tpl'); $_xhelpSession->set("xhelp_notifications", $templates); } $notification = $aNotifications[$id]; $staff_settings = xhelpGetMeta("notify_staff{$id}"); $user_settings = xhelpGetMeta("notify_user{$id}"); $hRoles =& xhelpGetHandler('role'); if ($settings->getVar('staff_setting') == XHELP_NOTIF_STAFF_DEPT) { $selectedRoles = $settings->getVar('staff_options'); } else { $selectedRoles = array(); } $roles =& $hRoles->getObjects(); echo "<form method='post' action='" . XHELP_ADMIN_URL . "/notifications.php?op=edit&id=" . $id . "'>"; echo "<table width='100%' cellspacing='1' class='outer'>"; echo "<tr><th colspan='2'>" . $notification['name'] . "</th></tr>"; echo "<tr><td class='head' width='20%'>" . _AM_XHELP_TEXT_NOTIF_STAFF . "</td>\r\n <td class='even' valign='top'>"; echo "<table border='0'>"; echo "<tr>"; foreach ($aStaffSettings as $value => $setting) { echo "<td valign='top'>"; if ($settings->getVar('staff_setting') == $value) { $checked = "checked='checked'"; } else { $checked = ''; } echo "<input type='radio' name='staff_setting' id='staff" . $value . "' value='" . $value . "' {$checked} />\r\n <label for='staff" . $value . "'>" . $setting . "</label> "; if ($value == XHELP_NOTIF_STAFF_DEPT) { echo "<br /><br /> \r\n <select name='roles[]' multiple='multiple'>"; foreach ($roles as $role) { $role_id = $role->getVar('id'); if (in_array($role_id, $selectedRoles)) { echo "<option value='" . $role_id . "' selected='selected'>" . $role->getVar('name') . "</option>"; } else { echo "<option value='" . $role_id . "'>" . $role->getVar('name') . "</option>"; } } echo "</select>"; } echo "</td>"; } echo "</tr></table>"; echo "</td>\r\n </tr>"; echo "<tr><td class='head' width='20%'>" . _AM_XHELP_TEXT_NOTIF_USER . "</td>\r\n <td class='even'>"; foreach ($aUserSettings as $value => $setting) { if ($settings->getVar('user_setting') == $value) { $checked = "checked='checked'"; } else { $checked = ''; } echo "<input type='radio' name='user_setting' id='user" . $value . "' value='" . $value . "' {$checked} />\r\n <label for='user" . $value . "'>" . $setting . "</label> "; } echo "</td>\r\n </tr>"; echo "<tr>\r\n <td class='head'></td>\r\n <td class='even'><input type='submit' name='save_notification' value='" . _AM_XHELP_BUTTON_SUBMIT . "' /></td>\r\n </tr>"; echo "</table></form><br />"; echo "<table width='100%' cellspacing='1' class='outer'>"; echo "<tr><th colspan='3'>" . _AM_XHELP_TEXT_ASSOC_TPL . "</th></tr>"; echo "<tr class='head'><td>" . _AM_XHELP_TEXT_TEMPLATE_NAME . "</td>\r\n <td>" . _AM_XHELP_TEXT_DESCRIPTION . "</td>\r\n <td>" . _AM_XHELP_TEXT_ACTIONS . "</td></tr>"; foreach ($notification['email_tpl'] as $template) { echo "<tr class='even'>\r\n <td>" . $template['title'] . "</a></td><td>" . $template['description'] . "</td>\r\n <td><a href='" . XHELP_ADMIN_URL . "/notifications.php?op=modifyEmlTpl&file=" . $template['mail_template'] . ".tpl'>\r\n <img src='" . XOOPS_URL . "/modules/xhelp/images/button_edit.png' title='" . _AM_XHELP_TEXT_EDIT . "' name='editNotification' /></a>\r\n </td>\r\n </tr>"; } echo "</table>"; xoops_cp_footer(); }
/** * Sets a value for a key in the xhelp_meta table * * @param string $key * @param string $value * @return bool TRUE if success, FALSE if failure * * @access public */ function xhelpSetMeta($key, $value) { $xoopsDB =& Database::getInstance(); $ret = xhelpGetMeta($key); if ($ret != false) { $sql = sprintf("UPDATE %s SET metavalue = %s WHERE metakey = %s", $xoopsDB->prefix('xhelp_meta'), $xoopsDB->quoteString($value), $xoopsDB->quoteString($key)); } else { $sql = sprintf("INSERT INTO %s (metakey, metavalue) VALUES (%s, %s)", $xoopsDB->prefix('xhelp_meta'), $xoopsDB->quoteString($key), $xoopsDB->quoteString($value)); } $ret = $xoopsDB->queryF($sql); if (!$ret) { return false; } return true; }
function xhelpPluginHandler(&$db) { $this->_db = $db; $this->_active = unserialize(xhelpGetMeta('plugins')); }
$_eventsrv->advise('new_ticket', xhelp_logService::singleton()); $_eventsrv->advise('new_ticket', xhelp_cacheService::singleton()); $_eventsrv->advise('new_response', xhelp_logService::singleton()); $_eventsrv->advise('new_response', xhelp_notificationService::singleton()); $_eventsrv->advise('update_owner', xhelp_notificationService::singleton()); $_eventsrv->advise('update_owner', xhelp_logService::singleton()); */ $hTicket =& xhelpGetHandler('ticket'); $hStaff =& xhelpGetHandler('staff'); $hGroupPerm =& xoops_gethandler('groupperm'); $hMember =& xoops_gethandler('member'); $hMembership =& xhelpGetHandler('membership'); $hFieldDept =& xhelpGetHandler('ticketFieldDepartment'); $module_id = $xoopsModule->getVar('mid'); if ($xoopsUser) { if (!isset($dept_id)) { $dept_id = xhelpGetMeta("default_department"); } if (isset($_GET['saveTicket']) && $_GET['saveTicket'] == 1) { _saveTicket(); } if (!isset($_POST['addTicket'])) { // Initial load of page $xoopsOption['template_main'] = 'xhelp_addTicket.html'; // Always set main template before including the header include XOOPS_ROOT_PATH . '/header.php'; $hDepartments =& xhelpGetHandler('department'); // Department handler $crit = new Criteria('', ''); $crit->setSort('department'); $departments =& $hDepartments->getObjects($crit); if (count($departments) == 0) {