/** * Browse all saved searches. * * @return content of the parents run method * */ function browse() { $rows = array(); $savedSearch = new CRM_Contact_DAO_SavedSearch(); $savedSearch->is_active = 1; $savedSearch->selectAdd(); $savedSearch->selectAdd('id, form_values'); $savedSearch->find(); $properties = array('id', 'name', 'description'); while ($savedSearch->fetch()) { // get name and description from group object $group = new CRM_Contact_DAO_Group(); $group->saved_search_id = $savedSearch->id; if ($group->find(TRUE)) { $permissions = CRM_Group_Page_Group::checkPermission($group->id, $group->title); if (!CRM_Utils_System::isNull($permissions)) { $row = array(); $row['name'] = $group->title; $row['description'] = $group->description; $row['id'] = $savedSearch->id; $formValues = unserialize($savedSearch->form_values); $query = new CRM_Contact_BAO_Query($formValues); $row['query_detail'] = $query->qill(); $action = array_sum(array_keys(self::links())); $action = $action & CRM_Core_Action::mask($permissions); $row['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $row['id'])); $rows[] = $row; } } } $this->assign('rows', $rows); return parent::run(); }
/** * Query the db for all saved searches. * * @return array * contains the search name as value and and id as key */ public function getAll() { $savedSearch = new CRM_Contact_DAO_SavedSearch(); $savedSearch->selectAdd(); $savedSearch->selectAdd('id, name'); $savedSearch->find(); while ($savedSearch->fetch()) { $aSavedSearch[$savedSearch->id] = $savedSearch->name; } return $aSavedSearch; }