Merge pull request #3201 from eileenmcnaughton/comments
[civicrm-core.git] / CRM / Contact / Form / Task / Unhold.php
1 <?php
2 class CRM_Contact_Form_Task_Unhold extends CRM_Contact_Form_Task {
3
4 /**
5 * Function to set variables up before form is built
6 *
7 * @return void
8 * @access public
9 */
10 function preProcess() {
11 parent::preProcess();
12 }
13
14 function buildQuickForm() {
15 $this->addDefaultButtons(ts('Unhold Email'), 'done');
16 }
17
18 public function postProcess() {
19 // Query to unhold emails of selected contacts
20 $num = count($this->_contactIds);
21 if ($num >= 1) {
22 $queryString = "
23 UPDATE civicrm_email SET on_hold = 0, hold_date = null
24 WHERE on_hold = 1 AND hold_date is not null AND contact_id in (" . implode(",", $this->_contactIds) . ")";
25 CRM_Core_DAO::executeQuery($queryString);
26 $sql = "SELECT ROW_COUNT( )";
27 $result = CRM_Core_DAO::singleValueQuery($sql);
28 if ($result) {
29 CRM_Core_Session::setStatus(ts('%count email was found on hold and updated.', array('count' => $result, 'plural' => '%count emails were found on hold and updated.')), ts('Emails Restored'), 'success');
30 }
31 else {
32 CRM_Core_Session::setStatus(ts('The selected contact does not have an email on hold.', array('count' => $result, 'plural' => 'None of the selected contacts have an email on hold.')), ts('No Emails to Restore'), 'info');
33 }
34 }
35 else {
36 CRM_Core_Session::setStatus(ts('Please select one or more contact for this action'), ts('No Contacts Selected'), 'error');
37 }
38 }
39 }
40