Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
6b83d5bd | 6 | | Copyright CiviCRM LLC (c) 2004-2019 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
6b83d5bd | 31 | * @copyright CiviCRM LLC (c) 2004-2019 |
6a488035 TO |
32 | */ |
33 | class CRM_Group_Page_Group extends CRM_Core_Page_Basic { | |
d0f28894 KJ |
34 | protected $_sortByCharacter; |
35 | ||
e0ef6999 | 36 | /** |
8edd3d1a | 37 | * Get BAO name. |
38 | * | |
e0ef6999 EM |
39 | * @return string |
40 | */ | |
00be9182 | 41 | public function getBAOName() { |
6a488035 TO |
42 | return 'CRM_Contact_BAO_Group'; |
43 | } | |
44 | ||
45 | /** | |
fe482240 | 46 | * Define action links. |
6a488035 | 47 | * |
a6c01b45 | 48 | * self::$_links array of action links |
6a488035 | 49 | */ |
5c61c747 TO |
50 | public function &links() { |
51 | } | |
6a488035 TO |
52 | |
53 | /** | |
fe482240 | 54 | * Return class name of edit form. |
6a488035 TO |
55 | * |
56 | * @return string | |
6a488035 | 57 | */ |
00be9182 | 58 | public function editForm() { |
6a488035 TO |
59 | return 'CRM_Group_Form_Edit'; |
60 | } | |
61 | ||
62 | /** | |
fe482240 | 63 | * Return name of edit form. |
6a488035 TO |
64 | * |
65 | * @return string | |
6a488035 | 66 | */ |
00be9182 | 67 | public function editName() { |
6a488035 TO |
68 | return ts('Edit Group'); |
69 | } | |
70 | ||
6a488035 | 71 | /** |
fe482240 | 72 | * Return name of delete form. |
6a488035 TO |
73 | * |
74 | * @return string | |
6a488035 | 75 | */ |
00be9182 | 76 | public function deleteName() { |
6a488035 TO |
77 | return 'Delete Group'; |
78 | } | |
79 | ||
80 | /** | |
fe482240 | 81 | * Return user context uri to return to. |
6a488035 | 82 | * |
77b97be7 EM |
83 | * @param null $mode |
84 | * | |
6a488035 | 85 | * @return string |
6a488035 | 86 | */ |
00be9182 | 87 | public function userContext($mode = NULL) { |
6a488035 TO |
88 | return 'civicrm/group'; |
89 | } | |
90 | ||
91 | /** | |
fe482240 | 92 | * Return user context uri params. |
6a488035 | 93 | * |
77b97be7 EM |
94 | * @param null $mode |
95 | * | |
6a488035 | 96 | * @return string |
6a488035 | 97 | */ |
00be9182 | 98 | public function userContextParams($mode = NULL) { |
6a488035 TO |
99 | return 'reset=1&action=browse'; |
100 | } | |
101 | ||
6a488035 | 102 | /** |
8edd3d1a | 103 | * Re-implement browse. |
104 | * | |
6a488035 | 105 | * We need to do slightly different things for groups vs saved search groups, hence we |
8edd3d1a | 106 | * re-implement browse from Page_Basic. |
6a488035 TO |
107 | * |
108 | * @param int $action | |
6a488035 | 109 | */ |
00be9182 | 110 | public function browse($action = NULL) { |
6a488035 TO |
111 | $groupPermission = CRM_Core_Permission::check('edit groups') ? CRM_Core_Permission::EDIT : CRM_Core_Permission::VIEW; |
112 | $this->assign('groupPermission', $groupPermission); | |
113 | ||
114 | $showOrgInfo = FALSE; | |
115 | ||
116 | // CRM-9936 | |
117 | $reservedPermission = CRM_Core_Permission::check('administer reserved groups') ? CRM_Core_Permission::EDIT : CRM_Core_Permission::VIEW; | |
118 | $this->assign('reservedPermission', $reservedPermission); | |
119 | ||
120 | if (CRM_Core_Permission::check('administer Multiple Organizations') && | |
121 | CRM_Core_Permission::isMultisiteEnabled() | |
122 | ) { | |
123 | $showOrgInfo = TRUE; | |
124 | } | |
125 | $this->assign('showOrgInfo', $showOrgInfo); | |
126 | ||
b65e12f3 CW |
127 | // Refresh smart group cache |
128 | if (!empty($_GET['update_smart_groups'])) { | |
129 | CRM_Contact_BAO_GroupContactCache::loadAll(); | |
130 | } | |
21ca2cb6 | 131 | elseif (!CRM_Core_DAO::singleValueQuery("SELECT contact_id FROM civicrm_group_contact_cache LIMIT 1")) { |
d666ca08 | 132 | CRM_Core_Session::setStatus(ts('Count data for smart groups is not currently calculated. You may click Update Smart Groups to generate it. Be aware this can cause significant server load')); |
520bca8e | 133 | } |
b65e12f3 | 134 | |
6a488035 TO |
135 | $this->search(); |
136 | } | |
137 | ||
8edd3d1a | 138 | /** |
139 | * Search for groups. | |
140 | */ | |
00be9182 | 141 | public function search() { |
5c61c747 | 142 | if ($this->_action & (CRM_Core_Action::ADD | |
6a488035 TO |
143 | CRM_Core_Action::UPDATE | |
144 | CRM_Core_Action::DELETE | |
145 | ) | |
146 | ) { | |
147 | return; | |
148 | } | |
149 | ||
150 | $form = new CRM_Core_Controller_Simple('CRM_Group_Form_Search', ts('Search Groups'), CRM_Core_Action::ADD); | |
151 | $form->setEmbedded(TRUE); | |
152 | $form->setParent($this); | |
153 | $form->process(); | |
154 | $form->run(); | |
155 | } | |
96025800 | 156 | |
6a488035 | 157 | } |