3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2016
35 * This class generates task actions for CiviEvent.
37 class CRM_Case_Form_Task
extends CRM_Core_Form
{
40 * The task being performed
47 * The additional clause that we restrict the search with
51 protected $_componentClause = NULL;
54 * The array that holds all the component ids
58 protected $_componentIds;
61 * The array that holds all the case ids
68 * Build all the data structures needed to build the form.
70 public function preProcess() {
71 self
::preProcessCommon($this);
75 * @param CRM_Core_Form $form
76 * @param bool $useTable
78 public static function preProcessCommon(&$form, $useTable = FALSE) {
79 $form->_caseIds
= array();
81 $values = $form->controller
->exportValues($form->get('searchFormName'));
83 $form->_task
= $values['task'];
84 $caseTasks = CRM_Case_Task
::tasks();
85 $form->assign('taskName', $caseTasks[$form->_task
]);
88 if ($values['radio_ts'] == 'ts_sel') {
89 foreach ($values as $name => $value) {
90 if (substr($name, 0, CRM_Core_Form
::CB_PREFIX_LEN
) == CRM_Core_Form
::CB_PREFIX
) {
91 $ids[] = substr($name, CRM_Core_Form
::CB_PREFIX_LEN
);
96 $queryParams = $form->get('queryParams');
97 $query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE,
98 CRM_Contact_BAO_Query
::MODE_CASE
100 $query->_distinctComponentClause
= " ( civicrm_case.id )";
101 $query->_groupByComponentClause
= " GROUP BY civicrm_case.id ";
102 $result = $query->searchQuery(0, 0, NULL);
103 while ($result->fetch()) {
104 $ids[] = $result->case_id
;
109 $form->_componentClause
= ' civicrm_case.id IN ( ' . implode(',', $ids) . ' ) ';
110 $form->assign('totalSelectedCases', count($ids));
113 $form->_caseIds
= $form->_componentIds
= $ids;
115 //set the context for redirection for any task actions
116 $qfKey = CRM_Utils_Request
::retrieve('qfKey', 'String', $form);
117 $urlParams = 'force=1';
118 if (CRM_Utils_Rule
::qfKey($qfKey)) {
119 $urlParams .= "&qfKey=$qfKey";
122 $session = CRM_Core_Session
::singleton();
123 $searchFormName = strtolower($form->get('searchFormName'));
124 if ($searchFormName == 'search') {
125 $session->replaceUserContext(CRM_Utils_System
::url('civicrm/case/search', $urlParams));
128 $session->replaceUserContext(CRM_Utils_System
::url("civicrm/contact/search/$searchFormName",
135 * Given the signer id, compute the contact id
136 * since its used for things like send email
138 public function setContactIDs() {
139 $this->_contactIds
= &CRM_Core_DAO
::getContactIDsFromComponent($this->_caseIds
,
145 * Simple shell that derived classes can call to add buttons to
146 * the form with a customized title for the main Submit
148 * @param string $title
149 * Title of the main button.
150 * @param string $nextType
151 * Button type for the form after processing.
152 * @param string $backType
153 * @param bool $submitOnce
155 public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
156 $this->addButtons(array(
164 'name' => ts('Cancel'),