dev/core#1405 Strip any spaces from Option Group name parameter and remove the name...
[civicrm-core.git] / CRM / Contact / Page / CustomSearch.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17
18/**
19 * Main page for viewing all Saved searches.
6a488035
TO
20 */
21class CRM_Contact_Page_CustomSearch extends CRM_Core_Page {
22
23 /**
fe482240 24 * The action links that we need to display for the browse screen.
6a488035
TO
25 *
26 * @var array
6a488035 27 */
69078420 28 public static $_links = NULL;
6a488035 29
4319322b
EM
30 /**
31 * @return array
32 */
6a488035
TO
33 public static function &info() {
34 $sql = "
35SELECT v.value, v.label, v.description
36FROM civicrm_option_group g,
37 civicrm_option_value v
38WHERE v.option_group_id = g.id
39AND g.name = 'custom_search'
40AND v.is_active = 1
41ORDER By v.weight
42";
e03e1641 43 $dao = CRM_Core_DAO::executeQuery($sql);
6a488035 44
be2fb01f 45 $rows = [];
6a488035
TO
46 while ($dao->fetch()) {
47 if (trim($dao->description)) {
48 $rows[$dao->value] = $dao->description;
49 }
50 else {
51 $rows[$dao->value] = $dao->label;
52 }
53 }
54 return $rows;
55 }
56
57 /**
58 * Browse all custom searches.
59 *
72b3a70c
CW
60 * @return mixed
61 * content of the parents run method
6a488035 62 */
00be9182 63 public function browse() {
6a488035
TO
64 $rows = self::info();
65 $this->assign('rows', $rows);
66 return parent::run();
67 }
68
69 /**
100fef9d 70 * Run this page (figure out the action needed and perform it).
6a488035 71 */
00be9182 72 public function run() {
6a488035
TO
73 $action = CRM_Utils_Request::retrieve('action',
74 'String',
75 $this, FALSE, 'browse'
76 );
77
78 $this->assign('action', $action);
79 return $this->browse();
80 }
96025800 81
6a488035 82}