3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Class for member form task actions.
20 * FIXME: This needs refactoring to properly inherit from CRM_Core_Form_Task and share more functions.
22 class CRM_Member_Form_Task
extends CRM_Core_Form_Task
{
25 * The array that holds all the member ids.
29 protected $_memberIds;
32 * Build all the data structures needed to build the form.
37 * @throws \CRM_Core_Exception
39 public function preProcess() {
40 self
::preProcessCommon($this);
44 * @param \CRM_Core_Form_Task $form
46 * @throws \CRM_Core_Exception
48 public static function preProcessCommon(&$form) {
49 $form->_memberIds
= [];
51 $values = $form->getSearchFormValues();
53 $form->_task
= $values['task'];
54 $tasks = CRM_Member_Task
::permissionedTaskTitles(CRM_Core_Permission
::getPermission());
55 if (!array_key_exists($form->_task
, $tasks)) {
56 CRM_Core_Error
::statusBounce(ts('You do not have permission to access this page.'));
59 $ids = $form->getSelectedIDs($values);
62 $queryParams = $form->get('queryParams');
64 if ($form->get(CRM_Utils_Sort
::SORT_ORDER
)) {
65 $sortOrder = $form->get(CRM_Utils_Sort
::SORT_ORDER
);
67 $query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE,
68 CRM_Contact_BAO_Query
::MODE_MEMBER
70 $query->_distinctComponentClause
= ' civicrm_membership.id';
71 $query->_groupByComponentClause
= ' GROUP BY civicrm_membership.id ';
72 $result = $query->searchQuery(0, 0, $sortOrder);
74 while ($result->fetch()) {
75 $ids[] = $result->membership_id
;
80 $form->_componentClause
= ' civicrm_membership.id IN ( ' . implode(',', $ids) . ' ) ';
81 $form->assign('totalSelectedMembers', count($ids));
84 $form->_memberIds
= $form->_componentIds
= $ids;
85 $form->setNextUrl('member');
89 * Given the membership id, compute the contact id
90 * since its used for things like send email
92 public function setContactIDs() {
93 $this->_contactIds
= CRM_Core_DAO
::getContactIDsFromComponent($this->_memberIds
,