Merge branch 'phpunit-ob-fix' of https://github.com/giant-rabbit/civicrm-core into...
[civicrm-core.git] / CRM / Contact / Form / Task / Unhold.php
1 <?php
2
3 /**
4 * Class CRM_Contact_Form_Task_Unhold
5 */
6 class CRM_Contact_Form_Task_Unhold extends CRM_Contact_Form_Task {
7
8 /**
9 * Set variables up before form is built
10 *
11 * @return void
12 * @access public
13 */
14 function preProcess() {
15 parent::preProcess();
16 }
17
18 function buildQuickForm() {
19 $this->addDefaultButtons(ts('Unhold Email'), 'done');
20 }
21
22 public function postProcess() {
23 // Query to unhold emails of selected contacts
24 $num = count($this->_contactIds);
25 if ($num >= 1) {
26 $queryString = "
27 UPDATE civicrm_email SET on_hold = 0, hold_date = null
28 WHERE on_hold = 1 AND hold_date is not null AND contact_id in (" . implode(",", $this->_contactIds) . ")";
29 CRM_Core_DAO::executeQuery($queryString);
30 $sql = "SELECT ROW_COUNT( )";
31 $result = CRM_Core_DAO::singleValueQuery($sql);
32 if ($result) {
33 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');
34 }
35 else {
36 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');
37 }
38 }
39 else {
40 CRM_Core_Session::setStatus(ts('Please select one or more contact for this action'), ts('No Contacts Selected'), 'error');
41 }
42 }
43 }
44