commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / 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 */
13 public function preProcess() {
14 parent::preProcess();
15 }
16
17 public function buildQuickForm() {
18 $this->addDefaultButtons(ts('Unhold Email'), 'done');
19 }
20
21 public function postProcess() {
22 // Query to unhold emails of selected contacts
23 $num = count($this->_contactIds);
24 if ($num >= 1) {
25 $queryString = "
26 UPDATE civicrm_email SET on_hold = 0, hold_date = null
27 WHERE on_hold = 1 AND hold_date is not null AND contact_id in (" . implode(",", $this->_contactIds) . ")";
28 CRM_Core_DAO::executeQuery($queryString);
29 $sql = "SELECT ROW_COUNT( )";
30 $result = CRM_Core_DAO::singleValueQuery($sql);
31 if ($result) {
32 CRM_Core_Session::setStatus(ts('%count email was found on hold and updated.', array(
33 'count' => $result,
34 'plural' => '%count emails were found on hold and updated.',
35 )), ts('Emails Restored'), 'success');
36 }
37 else {
38 CRM_Core_Session::setStatus(ts('The selected contact does not have an email on hold.', array(
39 'count' => $result,
40 'plural' => 'None of the selected contacts have an email on hold.',
41 )), ts('No Emails to Restore'), 'info');
42 }
43 }
44 else {
45 CRM_Core_Session::setStatus(ts('Please select one or more contact for this action'), ts('No Contacts Selected'), 'error');
46 }
47 }
48
49 }