INFRA-132 - CRM/Group - phpcbf
[civicrm-core.git] / CRM / Group / Page / Group.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2014
32 * $Id$
33 *
34 */
35 class CRM_Group_Page_Group extends CRM_Core_Page_Basic {
36 protected $_sortByCharacter;
37
38 /**
39 * @return string
40 */
41 public function getBAOName() {
42 return 'CRM_Contact_BAO_Group';
43 }
44
45 /**
46 * Define action links
47 *
48 * @return array self::$_links array of action links
49 */
50 public function &links() {
51 }
52
53 /**
54 * Return class name of edit form
55 *
56 * @return string
57 */
58 public function editForm() {
59 return 'CRM_Group_Form_Edit';
60 }
61
62 /**
63 * Return name of edit form
64 *
65 * @return string
66 */
67 public function editName() {
68 return ts('Edit Group');
69 }
70
71 /**
72 * Return name of delete form
73 *
74 * @return string
75 */
76 public function deleteName() {
77 return 'Delete Group';
78 }
79
80 /**
81 * Return user context uri to return to
82 *
83 * @param null $mode
84 *
85 * @return string
86 */
87 public function userContext($mode = NULL) {
88 return 'civicrm/group';
89 }
90
91 /**
92 * Return user context uri params
93 *
94 * @param null $mode
95 *
96 * @return string
97 */
98 public function userContextParams($mode = NULL) {
99 return 'reset=1&action=browse';
100 }
101
102 /**
103 * Make sure that the user has permission to access this group
104 *
105 * @param int $id
106 * The id of the object.
107 * @param int $title
108 * Name or title of the object.
109 *
110 * @return string the permission that the user has (or null)
111 */
112 public function checkPermission($id, $title) {
113 return CRM_Contact_BAO_Group::checkPermission($id, $title);
114 }
115
116 /**
117 * We need to do slightly different things for groups vs saved search groups, hence we
118 * reimplement browse from Page_Basic
119 *
120 * @param int $action
121 *
122 * @return void
123 */
124 public function browse($action = NULL) {
125 $groupPermission = CRM_Core_Permission::check('edit groups') ? CRM_Core_Permission::EDIT : CRM_Core_Permission::VIEW;
126 $this->assign('groupPermission', $groupPermission);
127
128 $showOrgInfo = FALSE;
129
130 // CRM-9936
131 $reservedPermission = CRM_Core_Permission::check('administer reserved groups') ? CRM_Core_Permission::EDIT : CRM_Core_Permission::VIEW;
132 $this->assign('reservedPermission', $reservedPermission);
133
134 if (CRM_Core_Permission::check('administer Multiple Organizations') &&
135 CRM_Core_Permission::isMultisiteEnabled()
136 ) {
137 $showOrgInfo = TRUE;
138 }
139 $this->assign('showOrgInfo', $showOrgInfo);
140
141 // Refresh smart group cache
142 if (!empty($_GET['update_smart_groups'])) {
143 CRM_Contact_BAO_GroupContactCache::loadAll();
144 }
145 else {
146 CRM_Contact_BAO_GroupContactCache::fillIfEmpty();
147 }
148
149 $this->search();
150 }
151
152 public function search() {
153 if ($this->_action & (CRM_Core_Action::ADD |
154 CRM_Core_Action::UPDATE |
155 CRM_Core_Action::DELETE
156 )
157 ) {
158 return;
159 }
160
161 $form = new CRM_Core_Controller_Simple('CRM_Group_Form_Search', ts('Search Groups'), CRM_Core_Action::ADD);
162 $form->setEmbedded(TRUE);
163 $form->setParent($this);
164 $form->process();
165 $form->run();
166 }
167 }