Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.3 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
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-2013 | |
32 | * $Id$ | |
33 | * | |
34 | */ | |
35 | class CRM_Contact_Page_View_UserDashBoard_GroupContact extends CRM_Contact_Page_View_UserDashBoard { | |
36 | ||
37 | /** | |
38 | * This function is called when action is browse | |
39 | * | |
40 | * return null | |
41 | * @access public | |
42 | */ | |
43 | function browse() { | |
44 | $count = CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, | |
45 | NULL, | |
46 | NULL, TRUE, TRUE, | |
47 | $this->_onlyPublicGroups | |
48 | ); | |
49 | ||
50 | $in = &CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, | |
51 | 'Added', | |
52 | NULL, FALSE, TRUE, | |
53 | $this->_onlyPublicGroups | |
54 | ); | |
55 | $pending = &CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, | |
56 | 'Pending', | |
57 | NULL, FALSE, TRUE, | |
58 | $this->_onlyPublicGroups | |
59 | ); | |
60 | $out = &CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, | |
61 | 'Removed', | |
62 | NULL, FALSE, TRUE, | |
63 | $this->_onlyPublicGroups | |
64 | ); | |
65 | ||
66 | $this->assign('groupCount', $count); | |
67 | $this->assign_by_ref('groupIn', $in); | |
68 | $this->assign_by_ref('groupPending', $pending); | |
69 | $this->assign_by_ref('groupOut', $out); | |
70 | } | |
71 | ||
72 | /** | |
73 | * This function is called when action is update | |
74 | * | |
75 | * @param int $groupID group id | |
76 | * | |
77 | * return null | |
78 | * @access public | |
79 | */ | |
80 | function edit($groupId = NULL) { | |
81 | $this->assign('edit', $this->_edit); | |
82 | if (!$this->_edit) { | |
83 | return; | |
84 | } | |
85 | ||
86 | $action = CRM_Utils_Request::retrieve('action', 'String', | |
87 | CRM_Core_DAO::$_nullObject, | |
88 | FALSE, 'browse' | |
89 | ); | |
90 | ||
91 | if ($action == CRM_Core_Action::DELETE) { | |
92 | $groupContactId = CRM_Utils_Request::retrieve('gcid', 'Positive', | |
93 | CRM_Core_DAO::$_nullObject, TRUE | |
94 | ); | |
95 | $status = CRM_Utils_Request::retrieve('st', 'String', | |
96 | CRM_Core_DAO::$_nullObject, TRUE | |
97 | ); | |
98 | if (is_numeric($groupContactId) && $status) { | |
99 | CRM_Contact_Page_View_GroupContact::del($groupContactId, $status, $this->_contactId); | |
100 | } | |
101 | ||
102 | $url = CRM_Utils_System::url('civicrm/user', | |
103 | "reset=1&id={$this->_contactId}" | |
104 | ); | |
105 | CRM_Utils_System::redirect($url); | |
106 | } | |
107 | ||
108 | $controller = new CRM_Core_Controller_Simple('CRM_Contact_Form_GroupContact', | |
109 | ts("Contact's Groups"), | |
110 | CRM_Core_Action::ADD | |
111 | ); | |
112 | $controller->setEmbedded(TRUE); | |
113 | ||
114 | $session = CRM_Core_Session::singleton(); | |
115 | $session->pushUserContext(CRM_Utils_System::url('civicrm/user', | |
116 | "reset=1&id={$this->_contactId}" | |
117 | ), | |
118 | FALSE | |
119 | ); | |
120 | ||
121 | $controller->reset(); | |
122 | $controller->set('contactId', $this->_contactId); | |
123 | $controller->set('groupId', $groupId); | |
124 | $controller->set('context', 'user'); | |
125 | $controller->set('onlyPublicGroups', $this->_onlyPublicGroups); | |
126 | $controller->process(); | |
127 | $controller->run(); | |
128 | } | |
129 | ||
130 | /** | |
131 | * This function is the main function that is called when the page loads, | |
132 | * it decides the which action has to be taken for the page. | |
133 | * | |
134 | * return null | |
135 | * @access public | |
136 | */ | |
137 | function run() { | |
138 | $this->edit(); | |
139 | $this->browse(); | |
140 | } | |
141 | } | |
142 |