$xhelp_isStaff = false; // Is the current user a staff member? if ($xoopsUser) { $hStaff =& xhelpGetHandler('staff'); if ($xhelp_staff =& $hStaff->getByUid($xoopsUser->getVar('uid'))) { $xhelp_isStaff = true; // Check if the staff member permissions have changed since the last page request if (!($myTime = $_xhelpSession->get("xhelp_permTime"))) { $roleReset = true; } else { $dbTime = $xhelp_staff->getVar('permTimestamp'); if ($dbTime > $myTime) { $roleReset = true; } } // Update staff member permissions (if necessary) if ($roleReset) { $updateRoles = $xhelp_staff->resetRoleRights(); $_xhelpSession->set("xhelp_permTime", time()); } //Retrieve the staff member's saved searches if (!($aSavedSearches = $_xhelpSession->get("xhelp_savedSearches"))) { $aSavedSearches =& xhelpGetSavedSearches($xoopsUser->getVar('uid')); $_xhelpSession->set('xhelp_savedSearches', $aSavedSearches); } } } $xhelp_module_css = XHELP_BASE_URL . '/styles/xhelp.css'; $xhelp_module_header = '<link rel="stylesheet" type="text/css" media="all" href="' . $xhelp_module_css . '" /><!--[if gte IE 5.5000]><script src="iepngfix.js" language="JavaScript" type="text/javascript"></script><![endif]-->'; // @todo - this line is for compatiblity, remove once all references to $isStaff have been modified //$isStaff = $xhelp_isStaff;
function staffmain_display() { global $xoopsOption, $xoopsTpl, $xoopsConfig, $xoopsUser, $xoopsLogger, $xoopsUserIsAdmin; global $limit, $start, $refresh, $displayName, $xhelp_isStaff, $_xhelpSession, $_eventsrv, $xhelp_module_header, $aSavedSearches; if (!$xhelp_isStaff) { redirect_header(XHELP_BASE_URL . "/" . basename(__FILE__), 3, _NOPERM); } $xhelpConfig = xhelpGetModuleConfig(); //Get Saved Searches for Current User + Searches for every user $allSavedSearches =& xhelpGetSavedSearches(array($xoopsUser->getVar('uid'), XHELP_GLOBAL_UID)); $hDepartments =& xhelpGetHandler('department'); $hTickets =& xhelpGetHandler('ticket'); $hTicketList =& xhelpGetHandler('ticketList'); //Set Number of items in each section if ($limit == 0) { $limit = $xhelpConfig['xhelp_staffTicketCount']; } elseif ($limit == -1) { $limit = 0; } $uid = $xoopsUser->getVar('uid'); $depts =& $hDepartments->getObjects(null, true); $priority =& $hTickets->getStaffTickets($uid, XHELP_QRY_STAFF_HIGHPRIORITY, $start, $limit); $ticketLists =& $hTicketList->getListsByUser($uid); $all_users = array(); $tickets = array(); $i = 0; foreach ($ticketLists as $ticketList) { $searchid = $ticketList->getVar('searchid'); $crit = $allSavedSearches[$searchid]['search']; $searchname = $allSavedSearches[$searchid]['name']; $searchOnCustFields = $allSavedSearches[$searchid]['hasCustFields']; $crit->setLimit($limit); $newTickets = $hTickets->getObjectsByStaff($crit, false, $searchOnCustFields); $tickets[$i] = array(); $tickets[$i]['tickets'] = array(); $tickets[$i]['searchid'] = $searchid; $tickets[$i]['searchname'] = $searchname; $tickets[$i]['tableid'] = _safeHTMLId($searchname); $tickets[$i]['hasTickets'] = count($newTickets) > 0; $j = 0; foreach ($newTickets as $ticket) { $dept = @$depts[$ticket->getVar('department')]; $tickets[$i]['tickets'][$j] = 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++; } $i++; unset($newTickets); } //Retrieve all member information for the current page if (count($all_users)) { $crit = new Criteria('uid', "(" . implode(array_keys($all_users), ',') . ")", 'IN'); $users =& xhelpGetUsers($crit, $displayName); } else { $users = array(); } //Update tickets with user information for ($i = 0; $i < count($ticketLists); $i++) { for ($j = 0; $j < count($tickets[$i]['tickets']); $j++) { if (isset($users[$tickets[$i]['tickets'][$j]['uid']])) { $tickets[$i]['tickets'][$j]['uname'] = $users[$tickets[$i]['tickets'][$j]['uid']]; } else { $tickets[$i]['tickets'][$j]['uname'] = $xoopsConfig['anonymous']; } if ($tickets[$i]['tickets'][$j]['ownerid']) { if (isset($users[$tickets[$i]['tickets'][$j]['ownerid']])) { $tickets[$i]['tickets'][$j]['ownership'] = $users[$tickets[$i]['tickets'][$j]['ownerid']]; $tickets[$i]['tickets'][$j]['ownerinfo'] = XOOPS_URL . '/userinfo.php?uid=' . $tickets[$i]['tickets'][$j]['ownerid']; } } } } $xoopsOption['template_main'] = 'xhelp_staff_index.html'; // Set template require XOOPS_ROOT_PATH . '/header.php'; // Include the page header if ($refresh > 0) { $xhelp_module_header .= "<meta http-equiv=\"Refresh\" content=\"{$refresh};url=" . XOOPS_URL . "/modules/xhelp/index.php?refresh={$refresh}\">"; } $xoopsTpl->assign('xhelp_baseURL', XHELP_BASE_URL); $xoopsTpl->assign('xhelp_ticketLists', $tickets); $xoopsTpl->assign('xhelp_hasTicketLists', count($tickets) > 0); $xoopsTpl->assign('xhelp_refresh', $refresh); $xoopsTpl->assign('xoops_module_header', $xhelp_module_header); $xoopsTpl->assign('xhelp_imagePath', XHELP_IMAGE_URL . '/'); $xoopsTpl->assign('xhelp_uid', $xoopsUser->getVar('uid')); $xoopsTpl->assign('xhelp_current_file', basename(__FILE__)); $xoopsTpl->assign('xhelp_savedSearches', $aSavedSearches); $xoopsTpl->assign('xhelp_allSavedSearches', $allSavedSearches); getAnnouncements($xhelpConfig['xhelp_announcements']); require XOOPS_ROOT_PATH . '/footer.php'; }
$crit = new Criteria('staffid', $xoopsUser->getVar('uid')); $crit->setSort('id'); $crit->setOrder('DESC'); $crit->setLimit(5); $reviews =& $hReview->getObjects($crit); $displayName =& $xoopsModuleConfig['xhelp_displayName']; // Determines if username or real name is displayed foreach ($reviews as $review) { $reviewer = $hMembers->getUser($review->getVar('submittedBy')); $xoopsTpl->append('xhelp_reviews', array('rating' => $review->getVar('rating'), 'ratingdsc' => xhelpGetRating($review->getVar('rating')), 'submittedBy' => $reviewer ? xhelpGetUsername($reviewer, $displayName) : $xoopsConfig['anonymous'], 'submittedByUID' => $review->getVar('submittedBy'), 'responseid' => $review->getVar('responseid'), 'comments' => $review->getVar('comments'), 'ticketid' => $review->getVar('ticketid'))); } $xoopsTpl->assign('xhelp_hasReviews', count($reviews) > 0); // Ticket Lists $ticketLists =& $hTicketList->getListsByUser($xoopsUser->getVar('uid')); $aMySavedSearches = array(); $mySavedSearches = xhelpGetSavedSearches(array($xoopsUser->getVar('uid'), XHELP_GLOBAL_UID)); $has_savedSearches = count($aMySavedSearches > 0); $ticketListCount = count($ticketLists); $aTicketLists = array(); $aUsedSearches = array(); $eleNum = 0; foreach ($ticketLists as $ticketList) { $weight = $ticketList->getVar('weight'); $searchid = $ticketList->getVar('searchid'); $aTicketLists[$ticketList->getVar('id')] = array('id' => $ticketList->getVar('id'), 'uid' => $ticketList->getVar('uid'), 'searchid' => $searchid, 'weight' => $weight, 'name' => $mySavedSearches[$ticketList->getVar('searchid')]['name'], 'hasWeightUp' => $eleNum != $ticketListCount - 1 ? true : false, 'hasWeightDown' => $eleNum != 0 ? true : false, 'hasEdit' => $mySavedSearches[$ticketList->getVar('searchid')]['uid'] != -999 ? true : false); $eleNum++; $aUsedSearches[$searchid] = $searchid; } unset($ticketLists); // Take used searches to get unused searches $aSearches = array();