// | Authors: João Prado Maia <*****@*****.**> | // +----------------------------------------------------------------------+ require_once dirname(__FILE__) . '/../init.php'; $tpl = new Template_Helper(); $tpl->setTemplate('emails.tpl.html'); Auth::checkAuthentication(APP_COOKIE); if (!Access::canAccessAssociateEmails(Auth::getUserID())) { $tpl->assign('no_access', 1); $tpl->displayTemplate(); exit; } $pagerRow = Support::getParam('pagerRow'); if (empty($pagerRow)) { $pagerRow = 0; } $rows = Support::getParam('rows'); if (empty($rows)) { $rows = APP_DEFAULT_PAGER_SIZE; } $options = Support::saveSearchParams(); $tpl->assign('options', $options); $tpl->assign('sorting', Support::getSortingInfo($options)); $list = Support::getEmailListing($options, $pagerRow, $rows); $tpl->assign('list', $list['list']); $tpl->assign('list_info', $list['info']); $tpl->assign('issues', Issue::getColList()); $tpl->assign('accounts', Email_Account::getAssocList(Auth::getCurrentProject())); $prefs = Prefs::get(Auth::getUserID()); $tpl->assign('refresh_rate', $prefs['email_refresh_rate'] * 60); $tpl->assign('refresh_page', 'emails.php'); $tpl->displayTemplate();
/** * Method used to get the next and previous messages in order to build * side links when viewing a particular email. * * @access public * @param integer $sup_id The email ID * @return array Information on the next and previous messages */ function getListingSides($sup_id) { $options = Support::saveSearchParams(); $stmt = "SELECT\n sup_id,\n sup_ema_id\n FROM\n (\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email,\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_account\n )\n LEFT JOIN\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue\n ON\n sup_iss_id = iss_id"; if (!empty($options['keywords'])) { $stmt .= "," . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "support_email_body"; } $stmt .= Support::buildWhereClause($options); $stmt .= "\n ORDER BY\n " . $options["sort_by"] . " " . $options["sort_order"]; $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt); if (PEAR::isError($res)) { Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); return ""; } else { // COMPAT: the next line requires PHP >= 4.0.5 $email_ids = array_keys($res); $index = array_search($sup_id, $email_ids); if (!empty($email_ids[$index + 1])) { $next = $email_ids[$index + 1]; } if (!empty($email_ids[$index - 1])) { $previous = $email_ids[$index - 1]; } return array("next" => array('sup_id' => @$next, 'ema_id' => @$res[$next]), "previous" => array('sup_id' => @$previous, 'ema_id' => @$res[$previous])); } }