/** * Method used to save the current search parameters in a cookie. * * TODO: Merge with Search::saveSearchParams() * * @return array The search parameters */ public static function saveSearchParams() { $sort_by = self::getParam('sort_by'); $sort_order = self::getParam('sort_order'); $rows = self::getParam('rows'); $cookie = array('rows' => $rows ? $rows : APP_DEFAULT_PAGER_SIZE, 'pagerRow' => self::getParam('pagerRow'), 'hide_associated' => self::getParam('hide_associated'), 'sort_by' => $sort_by ? $sort_by : 'sup_date', 'sort_order' => $sort_order ? $sort_order : 'DESC', 'keywords' => self::getParam('keywords'), 'sender' => self::getParam('sender'), 'to' => self::getParam('to'), 'ema_id' => self::getParam('ema_id'), 'filter' => self::getParam('filter')); // now do some magic to properly format the date fields $date_fields = array('arrival_date'); foreach ($date_fields as $field_name) { $field = self::getParam($field_name); if (empty($field) || $cookie['filter'][$field_name] != 'yes') { continue; } $end_field_name = $field_name . '_end'; $end_field = self::getParam($end_field_name); @($cookie[$field_name] = array('Year' => $field['Year'], 'Month' => $field['Month'], 'Day' => $field['Day'], 'start' => $field['Year'] . '-' . $field['Month'] . '-' . $field['Day'], 'filter_type' => $field['filter_type'], 'end' => $end_field['Year'] . '-' . $end_field['Month'] . '-' . $end_field['Day'])); @($cookie[$end_field_name] = array('Year' => $end_field['Year'], 'Month' => $end_field['Month'], 'Day' => $end_field['Day'])); } Search_Profile::save(Auth::getUserID(), Auth::getCurrentProject(), 'email', $cookie); return $cookie; }
/** * Method used to save the current search parameters in a cookie. * TODO: split to buildSearchParams() and actual saveSearchParams() * * @param bool|string $save_db Whether to save search parameters also to database * @return array The search parameters */ public static function saveSearchParams($save_db = true) { $request_only = !$save_db; // if we should only look at get / post not the DB or cookies $sort_by = self::getParam('sort_by', $request_only); $sort_order = self::getParam('sort_order', $request_only, array('asc', 'desc')); $rows = self::getParam('rows', $request_only); $hide_closed = self::getParam('hide_closed', $request_only); if ($hide_closed === '') { $hide_closed = 1; } $search_type = self::getParam('search_type', $request_only); if (empty($search_type)) { $search_type = 'all_text'; } $custom_field = self::getParam('custom_field', $request_only); if (is_string($custom_field)) { $custom_field = unserialize(urldecode($custom_field)); } $cookie = array('rows' => Misc::escapeString($rows ? $rows : APP_DEFAULT_PAGER_SIZE), 'pagerRow' => Misc::escapeInteger(self::getParam('pagerRow', $request_only)), 'hide_closed' => $hide_closed, 'sort_by' => Misc::stripHTML($sort_by ? $sort_by : 'pri_rank'), 'sort_order' => Misc::stripHTML($sort_order ? $sort_order : 'ASC'), 'customer_id' => Misc::escapeString(self::getParam('customer_id')), 'nosave' => self::getParam('nosave', $request_only), 'keywords' => self::getParam('keywords', $request_only), 'match_mode' => self::getParam('match_mode', $request_only), 'hide_excerpts' => self::getParam('hide_excerpts', $request_only), 'search_type' => Misc::stripHTML($search_type), 'users' => Misc::escapeString(self::getParam('users', $request_only)), 'status' => Misc::escapeInteger(self::getParam('status', $request_only)), 'priority' => Misc::escapeInteger(self::getParam('priority', $request_only)), 'severity' => Misc::escapeInteger(self::getParam('severity', $request_only)), 'category' => Misc::escapeInteger(self::getParam('category', $request_only)), 'customer_email' => Misc::stripHTML(self::getParam('customer_email', $request_only)), 'show_authorized_issues' => Misc::escapeString(self::getParam('show_authorized_issues', $request_only)), 'show_notification_list_issues' => Misc::escapeString(self::getParam('show_notification_list_issues', $request_only)), 'reporter' => Misc::escapeInteger(self::getParam('reporter', $request_only)), 'product' => Misc::escapeInteger(self::getParam('product', $request_only)), 'release' => Misc::escapeInteger(self::getParam('release', $request_only)), 'custom_field' => Misc::stripHTML($custom_field)); // now do some magic to properly format the date fields $date_fields = array('created_date', 'updated_date', 'last_response_date', 'first_response_date', 'closed_date'); foreach ($date_fields as $field_name) { $field = Misc::stripHTML(self::getParam($field_name, $request_only)); if (empty($field)) { continue; } if (@$field['filter_type'] == 'in_past') { @($cookie[$field_name] = array('filter_type' => 'in_past', 'time_period' => $field['time_period'])); } else { $end_field_name = $field_name . '_end'; $end_field = Misc::stripHTML(self::getParam($end_field_name, $request_only)); @($cookie[$field_name] = array('past_hour' => $field['past_hour'], 'Year' => $field['Year'], 'Month' => $field['Month'], 'Day' => $field['Day'], 'start' => $field['Year'] . '-' . $field['Month'] . '-' . $field['Day'], 'filter_type' => $field['filter_type'], 'end' => $end_field['Year'] . '-' . $end_field['Month'] . '-' . $end_field['Day'])); @($cookie[$end_field_name] = array('Year' => $end_field['Year'], 'Month' => $end_field['Month'], 'Day' => $end_field['Day'])); } } if ($save_db) { Search_Profile::save(Auth::getUserID(), Auth::getCurrentProject(), 'issue', $cookie); } return $cookie; }
if ($role_id == User::getRoleID('customer')) { $crm = CRM::getInstance($prj_id); // need the activity dashboard here $contact_id = User::getCustomerContactID($usr_id); $customer_id = Auth::getCurrentCustomerID(); $tpl->assign(array('contact' => $crm->getContact($contact_id), 'customer' => $crm->getCustomer($customer_id))); } else { if (Auth::getCurrentRole() <= User::getRoleID('Reporter') && Project::getSegregateReporters($prj_id)) { $tpl->assign('hide_stats', true); } else { $tpl->assign('hide_stats', false); $tpl->assign('status', Stats::getStatus()); $tpl->assign('releases', Stats::getRelease($hide_closed)); $tpl->assign('categories', Stats::getCategory($hide_closed)); $tpl->assign('priorities', Stats::getPriority($hide_closed)); $tpl->assign('users', Stats::getUser($hide_closed)); $tpl->assign('emails', Stats::getEmailStatus($hide_closed)); $tpl->assign('pie_chart', Stats::getPieChart($hide_closed)); } } if (@$_REQUEST['hide_closed'] == '') { $Stats_Search_Profile = Search_Profile::getProfile($usr_id, $prj_id, 'stats'); if (!empty($Stats_Search_Profile)) { $tpl->assign('hide_closed', $Stats_Search_Profile['hide_closed']); } } else { $tpl->assign('hide_closed', @$_REQUEST['hide_closed']); Search_Profile::save($usr_id, $prj_id, 'stats', array('hide_closed' => @$_REQUEST['hide_closed'])); } $tpl->assign('news', News::getListByProject($prj_id)); $tpl->displayTemplate();
$options_override = array('customer_id' => Misc::escapeString($_REQUEST['customer_id']), 'rows' => $rows); if (Search::getParam('hide_closed', true) === '') { $options_override['hide_closed'] = 0; } $_REQUEST['nosave'] = 1; $profile = Search_Profile::getProfile($usr_id, $prj_id, 'issue'); Search_Profile::remove($usr_id, $prj_id, 'issue'); Auth::redirect('list.php?customer_id=' . Misc::escapeString($_REQUEST['customer_id']) . "&hide_closed=1&rows={$rows}&sort_by=" . $profile['sort_by'] . '&sort_order=' . $profile['sort_order'] . '&nosave=1'); } elseif ($_REQUEST['view'] == 'reporter' && isset($_REQUEST['reporter_id'])) { $profile = Search_Profile::getProfile($usr_id, $prj_id, 'issue'); Auth::redirect('list.php?reporter=' . Misc::escapeInteger($_REQUEST['reporter_id']) . "&hide_closed=1&rows={$rows}&sort_by=" . $profile['sort_by'] . '&sort_order=' . $profile['sort_order'] . '&nosave=1'); } elseif ($_REQUEST['view'] == 'clear') { Search_Profile::remove($usr_id, $prj_id, 'issue'); Auth::redirect('list.php'); } elseif ($_REQUEST['view'] == 'clearandfilter') { Search_Profile::remove($usr_id, $prj_id, 'issue'); Auth::redirect('list.php?' . str_replace('view=clearandfilter&', '', $_SERVER['QUERY_STRING'])); } } if (!empty($_REQUEST['nosave'])) { $options = Search::saveSearchParams(false); } else { $options = Search::saveSearchParams(); } $options += $options_override; $options = array_merge($options, $options_override); $tpl->assign('options', $options); $tpl->assign('sorting', Search::getSortingInfo($options)); // generate options for assign list. If there are groups and user is above a customer, include groups $groups = Group::getAssocList($prj_id); $users = Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer'));
/** * Method used to save the current search parameters in a cookie. * * @access public * @return array The search parameters */ function saveSearchParams() { $sort_by = Issue::getParam('sort_by'); $sort_order = Issue::getParam('sort_order'); $rows = Issue::getParam('rows'); $hide_closed = Issue::getParam('hide_closed'); if ($hide_closed === '') { $hide_closed = 1; } $hide_answered = Issue::getParam('hide_answered'); if ($hide_answered === '') { $hide_answered = 1; } $search_type = Issue::getParam('search_type'); if (empty($search_type)) { $search_type = 'all_text'; } $custom_field = Issue::getParam('custom_field'); if (is_string($custom_field)) { $custom_field = unserialize(urldecode($custom_field)); } $cookie = array('rows' => $rows ? $rows : APP_DEFAULT_PAGER_SIZE, 'pagerRow' => Issue::getParam('pagerRow'), 'hide_closed' => $hide_closed, 'hide_answered' => $hide_answered, "sort_by" => $sort_by ? $sort_by : "pri_rank", "sort_order" => $sort_order ? $sort_order : "ASC", 'keywords' => Issue::getParam('keywords'), 'search_type' => $search_type, 'users' => Issue::getParam('users'), 'status' => Issue::getParam('status'), 'priority' => Issue::getParam('priority'), 'category' => Issue::getParam('category'), 'customer_email' => Issue::getParam('customer_email'), 'show_authorized_issues' => Issue::getParam('show_authorized_issues'), 'show_notification_list_issues' => Issue::getParam('show_notification_list_issues'), 'reporter' => Issue::getParam('reporter'), 'release' => Issue::getParam('release'), 'custom_field' => $custom_field); // now do some magic to properly format the date fields $date_fields = array('created_date', 'updated_date', 'last_response_date', 'first_response_date', 'closed_date'); foreach ($date_fields as $field_name) { $field = Issue::getParam($field_name); if (empty($field)) { continue; } if (@$field['filter_type'] == 'in_past' || @$field['filter_type'] == 'not_in_past') { @($cookie[$field_name] = array('filter_type' => @$field['filter_type'], 'time_period' => $field['time_period'])); } else { $end_field_name = $field_name . '_end'; $end_field = Issue::getParam($end_field_name); @($cookie[$field_name] = array('past_hour' => $field['past_hour'], 'Year' => $field['Year'], 'Month' => $field['Month'], 'Day' => $field['Day'], 'start' => $field['Year'] . '-' . $field['Month'] . '-' . $field['Day'], 'filter_type' => $field['filter_type'], 'end' => $end_field['Year'] . '-' . $end_field['Month'] . '-' . $end_field['Day'])); @($cookie[$end_field_name] = array('Year' => $end_field['Year'], 'Month' => $end_field['Month'], 'Day' => $end_field['Day'])); } } Search_Profile::save(Auth::getUserID(), Auth::getCurrentProject(), 'issue', $cookie); return $cookie; }
/** * Method used to save a search profile record for this user, for * the specified project, and profile type. * * @access public * @param integer $usr_id The user ID * @param integer $prj_id The project ID * @param string $type The type of the search profile ('issue' or 'email') * @param string $profile The search profile to be saved * @return boolean */ function save($usr_id, $prj_id, $type, $profile) { if (!Search_Profile::_exists($usr_id, $prj_id, $type)) { return Search_Profile::_insert($usr_id, $prj_id, $type, $profile); } else { return Search_Profile::_update($usr_id, $prj_id, $type, $profile); } }