Пример #1
0
function b_xhelp_performance_show($options)
{
    global $xoopsUser, $xoopsDB;
    $dirname = 'xhelp';
    $block = array();
    if (!$xoopsUser) {
        return false;
    }
    //Determine if the GD library is installed
    $block['use_img'] = function_exists("imagecreatefrompng");
    $xoopsModule =& xhelpGetModule();
    if ($xoopsUser->isAdmin($xoopsModule->getVar('mid'))) {
        $sql = sprintf("SELECT COUNT(*) as TicketCount, d.department, d.id FROM %s t INNER JOIN %s d ON t.department = d.id  INNER JOIN %s s ON t.status = s.id WHERE s.state = 1 GROUP BY d.department, d.id ORDER BY d.department", $xoopsDB->prefix('xhelp_tickets'), $xoopsDB->prefix('xhelp_departments'), $xoopsDB->prefix('xhelp_status'));
    } else {
        $sql = sprintf("SELECT COUNT(*) as TicketCount, d.department, d.id FROM %s t INNER JOIN %s j on t.department = j.department INNER JOIN %s d ON t.department = d.id INNER JOIN %s s on t.status = s.id WHERE s.state = 1 AND j.uid = %u GROUP BY d.department, d.id", $xoopsDB->prefix('xhelp_tickets'), $xoopsDB->prefix('xhelp_jstaffdept'), $xoopsDB->prefix('xhelp_departments'), $xoopsDB->prefix('xhelp_status'), $xoopsUser->getVar('uid'));
    }
    $ret = $xoopsDB->query($sql);
    $depts = array();
    $max_open = 0;
    while ($myrow = $xoopsDB->fetchArray($ret)) {
        $max_open = max($max_open, $myrow['TicketCount']);
        $url = xhelpMakeURI(XHELP_BASE_URL . '/index.php', array('op' => 'staffViewAll', 'dept' => $myrow['id'], 'state' => 1));
        $depts[] = array('id' => $myrow['id'], 'tickets' => $myrow['TicketCount'], 'name' => $myrow['department'], 'url' => $url);
    }
    if (count($depts) == 0) {
        return false;
    }
    if ($block['use_img']) {
        //Retrieve the image path for each department
        for ($i = 0; $i < count($depts); $i++) {
            $depts[$i]['img'] = _xhelp_getDeptImg($depts[$i]['id'], $depts[$i]['tickets'], $max_open, $i);
        }
    }
    $block['departments'] = $depts;
    return $block;
}
Пример #2
0
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&amp;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                &nbsp;&nbsp;&nbsp;\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                  &nbsp;&nbsp;&nbsp;\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&amp;statusid=" . $status->getVar('id') . "'><img src='" . XHELP_IMAGE_URL . "/button_edit.png' title='" . _AM_XHELP_TEXT_EDIT . "' name='editStatus' /></a>&nbsp;\r\n                  <a href='status.php?op=deleteStatus&amp;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();
}
Пример #3
0
function updateDefault()
{
    $id = intval($_REQUEST['id']);
    xhelpSetMeta("default_department", $id);
    header('Location: ' . xhelpMakeURI(XHELP_ADMIN_URL . '/department.php', array('op' => 'manageDepartments'), false));
}
Пример #4
0
function _makeBatchTicketArray(&$oTickets, &$depts, &$all_users, &$j, $task)
{
    global $xhelp_staff;
    $sortedTickets['good'] = array();
    $sortedTickets['bad'] = array();
    foreach ($oTickets as $ticket) {
        $dept = @$depts[$ticket->getVar('department')];
        if (!($hasRights = $xhelp_staff->checkRoleRights($task, $ticket->getVar('department')))) {
            $sortedTickets['bad'][] = array('id' => $ticket->getVar('id'), 'uid' => $ticket->getVar('uid'), 'subject' => xoops_substr($ticket->getVar('subject'), 0, 35), 'full_subject' => $ticket->getVar('subject'), 'description' => $ticket->getVar('description'), 'department' => _safeDepartmentName($dept), 'departmentid' => $ticket->getVar('department'), 'departmenturl' => xhelpMakeURI('index.php', array('op' => 'staffViewAll', 'dept' => $ticket->getVar('department'))), 'priority' => $ticket->getVar('priority'), 'status' => xhelpGetStatus($ticket->getVar('status')), 'posted' => $ticket->posted(), 'ownership' => _XHELP_MESSAGE_NOOWNER, 'ownerid' => $ticket->getVar('ownership'), 'closedBy' => $ticket->getVar('closedBy'), 'totalTimeSpent' => $ticket->getVar('totalTimeSpent'), 'uname' => '', 'userinfo' => XHELP_SITE_URL . '/userinfo.php?uid=' . $ticket->getVar('uid'), 'ownerinfo' => '', 'url' => XHELP_BASE_URL . '/ticket.php?id=' . $ticket->getVar('id'), 'overdue' => $ticket->isOverdue());
        } else {
            $sortedTickets['good'][] = array('id' => $ticket->getVar('id'), 'uid' => $ticket->getVar('uid'), 'subject' => xoops_substr($ticket->getVar('subject'), 0, 35), 'full_subject' => $ticket->getVar('subject'), 'description' => $ticket->getVar('description'), 'department' => _safeDepartmentName($dept), 'departmentid' => $ticket->getVar('department'), 'departmenturl' => xhelpMakeURI('index.php', array('op' => 'staffViewAll', 'dept' => $ticket->getVar('department'))), 'priority' => $ticket->getVar('priority'), 'status' => xhelpGetStatus($ticket->getVar('status')), 'posted' => $ticket->posted(), 'ownership' => _XHELP_MESSAGE_NOOWNER, 'ownerid' => $ticket->getVar('ownership'), 'closedBy' => $ticket->getVar('closedBy'), 'totalTimeSpent' => $ticket->getVar('totalTimeSpent'), 'uname' => '', 'userinfo' => XHELP_SITE_URL . '/userinfo.php?uid=' . $ticket->getVar('uid'), 'ownerinfo' => '', 'url' => XHELP_BASE_URL . '/ticket.php?id=' . $ticket->getVar('id'), 'overdue' => $ticket->isOverdue());
        }
        $all_users[$ticket->getVar('uid')] = '';
        $all_users[$ticket->getVar('ownership')] = '';
        $all_users[$ticket->getVar('closedBy')] = '';
        $j++;
    }
    return $sortedTickets;
}
Пример #5
0
        }
        $aLastTickets[] = array('id' => $ticket->getVar('id'), 'subject' => $ticket->getVar('subject'), 'status' => xhelpGetStatus($ticket->getVar('status')), 'department' => $dept, 'dept_url' => $hasUrl ? XOOPS_URL . '/modules/xhelp/index.php?op=staffViewAll&amp;dept=' . $ticket->getVar('department') : '', 'url' => XOOPS_URL . '/modules/xhelp/ticket.php?id=' . $ticket->getVar('id'));
    }
    $has_lastTickets = count($lastTickets);
    unset($lastTickets);
}
switch ($op) {
    case "addEmail":
        if ($_POST['newEmail'] == '') {
            $message = _XHELP_MESSAGE_NO_EMAIL;
            redirect_header(XHELP_BASE_URL . "/ticket.php?id={$xhelp_id}", 3, $message);
        }
        //Check if email is valid
        $validator = new ValidateEmail($_POST['newEmail']);
        if (!$validator->isValid()) {
            redirect_header(xhelpMakeURI('ticket.php', array('id' => $xhelp_id), false), 3, _XHELP_MESSAGE_NO_EMAIL);
        }
        if (!($newUser = xhelpEmailIsXoopsUser($_POST['newEmail']))) {
            // If a user doesn't exist with this email
            $user_id = 0;
        } else {
            $user_id = $newUser->getVar('uid');
        }
        // Check that the email doesn't already exist for this ticket
        $hTicketEmails =& xhelpGetHandler('ticketEmails');
        $crit = new CriteriaCompo(new Criteria('ticketid', $xhelp_id));
        $crit->add(new Criteria('email', $_POST['newEmail']));
        $existingUsers =& $hTicketEmails->getObjects($crit);
        if (count($existingUsers) > 0) {
            $message = _XHELP_MESSAGE_EMAIL_USED;
            redirect_header(XHELP_BASE_URL . "/ticket.php?id={$xhelp_id}", 3, $message);
Пример #6
0
function clearEditSession()
{
    $mimeid = $_REQUEST['id'];
    _clearEditSessionVars($mimeid);
    header('Location: ' . xhelpMakeURI(XHELP_ADMIN_URL . '/mimetypes.php', array('op' => 'edit', 'id' => $mimeid), false));
}
Пример #7
0
 //$pageNav = new  XoopsPageNav($total, $limit, $start, "start", "limit=$limit&department=$search_department&description=$search_description&subject=$search_subject&priority=$search_priority&status=$search_status&submittedBy=$search_submittedBy&ownership=$search_ownership&closedBy=$search_closedBy");   // New PageNav object
 $pageNav = new XoopsPageNav($total, $limit, $start, "start", $pagenav_vars);
 $xoopsTpl->assign('xhelp_pagenav', $pageNav->renderNav());
 unset($pageNav);
 $member_handler =& xoops_gethandler('member');
 foreach ($tickets as $ticket) {
     $user =& $member_handler->getUser($ticket->getVar('uid'));
     $owner =& $member_handler->getUser($ticket->getVar('ownership'));
     //$closer =& $member_handler->getUser($ticket->getVar('closedBy'));
     $department =& $hDepartments->get($ticket->getVar('department'));
     //if($owner){
     $overdue = false;
     if ($ticket->isOverdue()) {
         $overdue = true;
     }
     $aTickets[$ticket->getVar('id')] = array('id' => $ticket->getVar('id'), 'uid' => $ticket->getVar('uid'), 'uname' => $user ? $user->getVar('uname') : $xoopsConfig['anonymous'], 'userinfo' => XOOPS_URL . '/userinfo.php?uid=' . $ticket->getVar('uid'), 'subject' => xoops_substr($ticket->getVar('subject'), 0, 35), 'full_subject' => $ticket->getVar('subject'), 'description' => $ticket->getVar('description'), 'department' => $department->getVar('department'), 'departmentid' => $department->getVar('id'), 'departmenturl' => xhelpMakeURI('index.php', array('op' => 'staffViewAll', 'dept' => $department->getVar('id'))), 'priority' => $ticket->getVar('priority'), 'status' => xhelpGetStatus($ticket->getVar('status')), 'posted' => $ticket->posted(), 'totalTimeSpent' => $ticket->getVar('totalTimeSpent'), 'ownership' => $owner && $owner->getVar('uname') != "" ? $owner->getVar('uname') : _XHELP_NO_OWNER, 'ownerid' => $owner && $owner->getVar('uid') != 0 ? $owner->getVar('uid') : 0, 'ownerinfo' => $owner && $owner->getVar('uid') != 0 ? XOOPS_URL . '/userinfo.php?uid=' . $owner->getVar('uid') : 0, 'closedBy' => $ticket->getVar('closedBy'), 'closedByUname' => $xoopsUser->getUnameFromId($ticket->getVar('closedBy')), 'url' => XOOPS_URL . '/modules/xhelp/ticket.php?id=' . $ticket->getVar('id'), 'elapsed' => $ticket->elapsed(), 'lastUpdate' => $ticket->lastUpdate(), 'overdue' => $overdue);
     unset($user);
     unset($owner);
     //$closer =& $member_handler->getUser($ticket->getVar('closedBy'));
     unset($department);
 }
 unset($tickets);
 $xoopsTpl->assign('xhelp_viewResults', $viewResults);
 if (isset($aTickets)) {
     $xoopsTpl->assign('xhelp_allTickets', $aTickets);
     $xoopsTpl->assign('xhelp_has_tickets', true);
 } else {
     $xoopsTpl->assign('xhelp_allTickets', 0);
     $xoopsTpl->assign('xhelp_has_tickets', false);
 }
 $tpl_cols = array();
Пример #8
0
function clearEditSession()
{
    $fieldid = $_REQUEST['id'];
    _clearEditSessionVars($fieldid);
    header('Location: ' . xhelpMakeURI(XHELP_ADMIN_URL . '/fields.php', array('op' => 'editfield', 'id' => $fieldid), false));
}