3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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-2014
37 * This class provides the functionality to email a group of contacts
39 class CRM_Activity_Form_Task_FileOnCase
extends CRM_Activity_Form_Task
{
42 * The title of the group
49 * Variable to store redirect path
51 protected $_userContext;
54 * Variable to store contact Ids
59 * Build all the data structures needed to build the form
63 public function preProcess() {
65 $session = CRM_Core_Session
::singleton();
66 $this->_userContext
= $session->readUserContext();
68 CRM_Utils_System
::setTitle(ts('File on Case'));
72 * Build the form object
77 public function buildQuickForm() {
78 $this->add('text', 'unclosed_case_id', ts('Select Case'), array('class' => 'huge'), TRUE);
79 $this->addDefaultButtons(ts('Save'));
83 * Add local and global form rules
88 public function addRules() {
92 * Process the form after the input has been submitted and validated
98 public function postProcess() {
99 $formparams = $this->exportValues();
100 $caseId = $formparams['unclosed_case_id'];
101 $filedActivities = 0;
102 foreach ($this->_activityHolderIds
as $key => $id) {
103 $targetContactValues = $defaults = array();
104 $params = array('id' => $id);
105 CRM_Activity_BAO_Activity
::retrieve($params, $defaults);
106 if (CRM_Case_BAO_Case
::checkPermission($id, 'File On Case', $defaults['activity_type_id'])) {
108 if (!CRM_Utils_Array
::crmIsEmptyArray($defaults['target_contact'])) {
109 $targetContactValues = array_combine(array_unique($defaults['target_contact']),
110 explode(';', trim($defaults['target_contact_value']))
112 $targetContactValues = implode(',', array_keys($targetContactValues));
118 'newSubject' => empty($defaults['subject']) ?
'' : $defaults['subject'],
119 'targetContactIds' => $targetContactValues,
123 $error_msg = CRM_Activity_Page_AJAX
::_convertToCaseActivity($params);
124 if (empty($error_msg['error_msg'])) {
128 CRM_Core_Session
::setStatus($error_msg['error_msg'], ts("Error"), "error");
132 CRM_Core_Session
::setStatus(ts('Not permitted to file activity %1 %2.', array(
133 1 => empty($defaults['subject']) ?
'' : $defaults['subject'],
134 2 => $defaults['activity_date_time'])),
135 ts("Error"), "error");
139 CRM_Core_Session
::setStatus($filedActivities, ts("Filed Activities"), "success");
140 CRM_Core_Session
::setStatus("", ts('Total Selected Activities: %1', array(1 => count($this->_activityHolderIds
))), "info");