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