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