Merge pull request #19296 from eileenmcnaughton/fbool
[civicrm-core.git] / CRM / Contact / Page / CustomSearch.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * Main page for viewing all Saved searches.
20 */
21 class CRM_Contact_Page_CustomSearch extends CRM_Core_Page {
22
23 /**
24 * The action links that we need to display for the browse screen.
25 *
26 * @var array
27 */
28 public static $_links = NULL;
29
30 /**
31 * @return array
32 */
33 public static function &info() {
34 $sql = "
35 SELECT v.value, v.label, v.description
36 FROM civicrm_option_group g,
37 civicrm_option_value v
38 WHERE v.option_group_id = g.id
39 AND g.name = 'custom_search'
40 AND v.is_active = 1
41 ORDER By v.weight
42 ";
43 $dao = CRM_Core_DAO::executeQuery($sql);
44
45 $rows = [];
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 *
60 * @return mixed
61 * content of the parents run method
62 */
63 public function browse() {
64 $rows = self::info();
65 $this->assign('rows', $rows);
66 return parent::run();
67 }
68
69 /**
70 * Run this page (figure out the action needed and perform it).
71 */
72 public function run() {
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 }
81
82 }