Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
86538308 EM |
2 | |
3 | /** | |
4 | * Class CRM_Contact_Form_Task_Unhold | |
5 | */ | |
6a488035 TO |
6 | class CRM_Contact_Form_Task_Unhold extends CRM_Contact_Form_Task { |
7 | ||
8 | /** | |
100fef9d | 9 | * Set variables up before form is built |
6a488035 TO |
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 = " | |
8ef12e64 | 27 | UPDATE civicrm_email SET on_hold = 0, hold_date = null |
6a488035 TO |
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 |