codespell: CRM/*
[civicrm-core.git] / CRM / Campaign / Form / Task / Release.php
index d2a43b8b2a06ea6cde2d6bf0d76ceb8fe4bf6d6c..ec668bdb1649a70534fc4a08b9b9c0b0bf4d5b5e 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
@@ -63,16 +63,19 @@ class CRM_Campaign_Form_Task_Release extends CRM_Campaign_Form_Task {
   protected $_surveyActivities;
 
   /**
-   * Build all the data structures needed to build the form
+   * Build all the data structures needed to build the form.
    *
    * @return void
-   * @access public
-   */ function preProcess() {
+   */
+  public function preProcess() {
     $this->_interviewToRelease = $this->get('interviewToRelease');
     if ($this->_interviewToRelease) {
       //user came from interview form.
       foreach (array(
-        'surveyId', 'contactIds', 'interviewerId') as $fld) {
+                 'surveyId',
+                 'contactIds',
+                 'interviewerId',
+               ) as $fld) {
         $this->{"_$fld"} = $this->get($fld);
       }
 
@@ -104,7 +107,8 @@ class CRM_Campaign_Form_Task_Release extends CRM_Campaign_Form_Task {
     $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
     $statusIds = array();
     foreach (array(
-      'Scheduled') as $name) {
+               'Scheduled',
+             ) as $name) {
       if ($statusId = array_search($name, $activityStatus)) {
         $statusIds[] = $statusId;
       }
@@ -132,18 +136,17 @@ class CRM_Campaign_Form_Task_Release extends CRM_Campaign_Form_Task {
   }
 
   /**
-   * Build the form object
+   * Build the form object.
    *
-   * @access public
    *
    * @return void
    */
-  function buildQuickForm() {
+  public function buildQuickForm() {
 
     $this->addDefaultButtons(ts('Release Respondents'), 'done');
   }
 
-  function postProcess() {
+  public function postProcess() {
     $deleteActivityIds = array();
     foreach ($this->_contactIds as $cid) {
       if (array_key_exists($cid, $this->_surveyActivities)) {
@@ -151,19 +154,29 @@ class CRM_Campaign_Form_Task_Release extends CRM_Campaign_Form_Task {
       }
     }
 
-    //set survey activites as deleted = true.
+    //set survey activities as deleted = true.
     if (!empty($deleteActivityIds)) {
       $query = 'UPDATE civicrm_activity SET is_deleted = 1 WHERE id IN ( ' . implode(', ', $deleteActivityIds) . ' )';
       CRM_Core_DAO::executeQuery($query);
 
-      $status = array(ts("%1 respondent(s) have been released.", array(1 => count($deleteActivityIds))));
+      if ($deleteActivityIds) {
+        $status = ts("Respondent has been released.", array(
+          'count' => count($deleteActivityIds),
+          'plural' => '%count respondents have been released.',
+        ));
+        CRM_Core_Session::setStatus($status, ts('Released'), 'success');
+      }
+
       if (count($this->_contactIds) > count($deleteActivityIds)) {
-        $status[] = ts("%1 respondents did not release.",
-          array(1 => (count($this->_contactIds) - count($deleteActivityIds)))
+        $status = ts('1 respondent did not release.',
+          array(
+            'count' => (count($this->_contactIds) - count($deleteActivityIds)),
+            'plural' => '%count respondents did not release.',
+          )
         );
+        CRM_Core_Session::setStatus($status, ts('Notice'), 'alert');
       }
-      CRM_Core_Session::setStatus(implode(' ', $status), '', 'info');
     }
   }
-}
 
+}