public function preProcess()
 {
     $job_id = CRM_Utils_Request::retrieve('jid', 'Positive', $this, NULL);
     $queue_id = CRM_Utils_Request::retrieve('qid', 'Positive', $this, NULL);
     $hash = CRM_Utils_Request::retrieve('h', 'String', $this, NULL);
     $q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
     if ($q == NULL) {
         // ERROR.
         CRM_Core_Error::fatal(ts('Invalid form parameters.'));
         CRM_Core_Error::statusBounce(ts('Invalid form parameters.'));
     }
     $mailing =& $q->getMailing();
     if ($hash) {
         $emailId = CRM_Core_DAO::getfieldValue('CRM_Mailing_Event_DAO_Queue', $hash, 'email_id', 'hash');
         $this->_fromEmail = $fromEmail = CRM_Core_DAO::getfieldValue('CRM_Core_DAO_Email', $emailId, 'email');
         $this->assign('fromEmail', $fromEmail);
     }
     // Show the subject instead of the name here, since it's being
     // displayed to external contacts/users.
     CRM_Utils_System::setTitle(ts('Forward Mailing: %1', array(1 => $mailing->subject)));
     $this->set('queue_id', $queue_id);
     $this->set('job_id', $job_id);
     $this->set('hash', $hash);
 }
 /**
  * Function to delete the activity
  *
  * @param array  $params  associated array
  *
  * @return void
  * @access public
  *
  */
 public static function deleteActivity(&$params, $moveToTrash = FALSE)
 {
     // CRM-9137
     if (CRM_Utils_Array::value('id', $params) && !is_array($params['id'])) {
         CRM_Utils_Hook::pre('delete', 'Activity', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('delete', 'Activity', NULL, $params);
     }
     $transaction = new CRM_Core_Transaction();
     if (is_array(CRM_Utils_Array::value('source_record_id', $params))) {
         $sourceRecordIds = implode(',', $params['source_record_id']);
     } else {
         $sourceRecordIds = CRM_Utils_Array::value('source_record_id', $params);
     }
     $result = NULL;
     if (!$moveToTrash) {
         if (!isset($params['id'])) {
             if (is_array($params['activity_type_id'])) {
                 $activityTypes = implode(',', $params['activity_type_id']);
             } else {
                 $activityTypes = $params['activity_type_id'];
             }
             $query = "DELETE FROM civicrm_activity WHERE source_record_id IN ({$sourceRecordIds}) AND activity_type_id IN ( {$activityTypes} )";
             $dao = CRM_Core_DAO::executeQuery($query);
         } else {
             $activity = new CRM_Activity_DAO_Activity();
             $activity->copyValues($params);
             $result = $activity->delete();
             // CRM-8708
             $activity->case_id = CRM_Case_BAO_Case::getCaseIdByActivityId($activity->id);
         }
     } else {
         $activity = new CRM_Activity_DAO_Activity();
         $activity->copyValues($params);
         $activity->is_deleted = 1;
         $result = $activity->save();
         //log activty delete.CRM-4525.
         $logMsg = 'Case Activity deleted for';
         $msgs = array();
         $sourceContactId = CRM_Core_DAO::getfieldValue('CRM_Activity_DAO_Activity', $activity->id, 'source_contact_id');
         if ($sourceContactId) {
             $msgs[] = " source={$sourceContactId}";
         }
         //get target contacts.
         $targetContactIds = CRM_Activity_BAO_ActivityTarget::getTargetNames($activity->id);
         if (!empty($targetContactIds)) {
             $msgs[] = " target =" . implode(',', array_keys($targetContactIds));
         }
         //get assignee contacts.
         $assigneeContactIds = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activity->id);
         if (!empty($assigneeContactIds)) {
             $msgs[] = " assignee =" . implode(',', array_keys($assigneeContactIds));
         }
         $logMsg .= implode(', ', $msgs);
         self::logActivityAction($activity, $logMsg);
     }
     // delete the recently created Activity
     if ($result) {
         $activityRecent = array('id' => $activity->id, 'type' => 'Activity');
         CRM_Utils_Recent::del($activityRecent);
     }
     $transaction->commit();
     if (isset($activity)) {
         // CRM-8708
         $activity->case_id = CRM_Case_BAO_Case::getCaseIdByActivityId($activity->id);
         CRM_Utils_Hook::post('delete', 'Activity', $activity->id, $activity);
     }
     return $result;
 }
Exemple #3
0
 /**
  * Function to delete the activity
  * @param array  $params  associated array 
  *
  * @return void
  * @access public
  *
  */
 public function deleteActivity(&$params, $moveToTrash = false)
 {
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     if (!$moveToTrash) {
         if (!isset($params['id'])) {
             if (is_array($params['activity_type_id'])) {
                 $activityTypes = implode(',', $params['activity_type_id']);
             } else {
                 $activityTypes = $params['activity_type_id'];
             }
             $query = "DELETE FROM civicrm_activity WHERE source_record_id = {$params['source_record_id']} AND activity_type_id IN ( {$activityTypes} )";
             $dao = CRM_Core_DAO::executeQuery($query);
         } else {
             $activity = new CRM_Activity_DAO_Activity();
             $activity->copyValues($params);
             $result = $activity->delete();
         }
     } else {
         $activity = new CRM_Activity_DAO_Activity();
         $activity->copyValues($params);
         $activity->is_deleted = 1;
         $result = $activity->save();
         //log activty delete.CRM-4525.
         $logMsg = "Case Activity deleted for";
         $msgs = array();
         $sourceContactId = CRM_Core_DAO::getfieldValue('CRM_Activity_DAO_Activity', $activity->id, 'source_contact_id');
         if ($sourceContactId) {
             $msgs[] = " source={$sourceContactId}";
         }
         //get target contacts.
         $targetContactIds = CRM_Activity_BAO_ActivityTarget::getTargetNames($activity->id);
         if (!empty($targetContactIds)) {
             $msgs[] = " target =" . implode(',', array_keys($targetContactIds));
         }
         //get assignee contacts.
         $assigneeContactIds = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activity->id);
         if (!empty($assigneeContactIds)) {
             $msgs[] = " assignee =" . implode(',', array_keys($assigneeContactIds));
         }
         $logMsg .= implode(', ', $msgs);
         self::logActivityAction($activity, $logMsg);
     }
     // delete the recently created Activity
     require_once 'CRM/Utils/Recent.php';
     if ($result) {
         $activityRecent = array('id' => $activity->id, 'type' => 'Activity');
         CRM_Utils_Recent::del($activityRecent);
     }
     $transaction->commit();
     return $result;
 }
Exemple #4
0
 /**
  * Function to delete the activity
  * @param array  $params  associated array 
  *
  * @return void
  * @access public
  *
  */
 public function deleteActivity(&$params, $moveToTrash = false)
 {
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     $activity =& new CRM_Activity_DAO_Activity();
     $activity->copyValues($params);
     if (!$moveToTrash) {
         $result = $activity->delete();
     } else {
         $activity->is_deleted = 1;
         $result = $activity->save();
         //log activty delete.CRM-4525.
         $logMsg = "Case Activity deleted for";
         $msgs = array();
         $sourceContactId = CRM_Core_DAO::getfieldValue('CRM_Activity_DAO_Activity', $activity->id, 'source_contact_id');
         if ($sourceContactId) {
             $msgs[] = " source={$sourceContactId}";
         }
         //get target contacts.
         $targetContactIds = CRM_Activity_BAO_ActivityTarget::getTargetNames($activity->id);
         if (!empty($targetContactIds)) {
             $msgs[] = " target =" . implode(',', array_keys($targetContactIds));
         }
         //get assignee contacts.
         $assigneeContactIds = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activity->id);
         if (!empty($assigneeContactIds)) {
             $msgs[] = " assigne =" . implode(',', array_keys($assigneeContactIds));
         }
         $logMsg .= implode(', ', $msgs);
         self::logActivityAction($activity, $logMsg);
     }
     // delete the recently created Activity
     require_once 'CRM/Utils/Recent.php';
     if ($result) {
         CRM_Utils_Recent::del($activity->id);
     }
     $transaction->commit();
     return $result;
 }