Delete.php 3.03 KB
Newer Older
totten's avatar
totten committed
1 2 3
<?php
/*
 +--------------------------------------------------------------------+
yashodha's avatar
yashodha committed
4
 | CiviCRM version 4.6                                                |
totten's avatar
totten committed
5
 +--------------------------------------------------------------------+
kurund's avatar
kurund committed
6
 | Copyright CiviCRM LLC (c) 2004-2014                                |
totten's avatar
totten committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 +--------------------------------------------------------------------+
 | This file is a part of CiviCRM.                                    |
 |                                                                    |
 | CiviCRM is free software; you can copy, modify, and distribute it  |
 | under the terms of the GNU Affero General Public License           |
 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
 |                                                                    |
 | CiviCRM is distributed in the hope that it will be useful, but     |
 | WITHOUT ANY WARRANTY; without even the implied warranty of         |
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
 | See the GNU Affero General Public License for more details.        |
 |                                                                    |
 | You should have received a copy of the GNU Affero General Public   |
 | License and the CiviCRM Licensing Exception along                  |
 | with this program; if not, contact CiviCRM LLC                     |
 | at info[AT]civicrm[DOT]org. If you have questions about the        |
 | GNU Affero General Public License or the licensing of CiviCRM,     |
 | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
 +--------------------------------------------------------------------+
26
 */
totten's avatar
totten committed
27 28 29 30

/**
 *
 * @package CRM
kurund's avatar
kurund committed
31
 * @copyright CiviCRM LLC (c) 2004-2014
totten's avatar
totten committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
 * $Id$
 *
 */

/**
 * This class provides the functionality to delete a group of
 * Activites. This class provides functionality for the actual
 * deletion.
 */
class CRM_Activity_Form_Task_Delete extends CRM_Activity_Form_Task {

  /**
   * Are we operating in "single mode", i.e. deleting one
   * specific Activity?
   *
   * @var boolean
   */
  protected $_single = FALSE;

  /**
colemanw's avatar
colemanw committed
52
   * Build all the data structures needed to build the form
totten's avatar
totten committed
53 54 55
   *
   * @return void
   */
56
  public function preProcess() {
totten's avatar
totten committed
57 58 59 60
    parent::preProcess();
  }

  /**
61
   * Build the form object
totten's avatar
totten committed
62 63 64 65
   *
   *
   * @return void
   */
66
  public function buildQuickForm() {
67
    $this->addDefaultButtons(ts('Delete Activities'), 'done');
totten's avatar
totten committed
68 69 70
  }

  /**
colemanw's avatar
colemanw committed
71
   * Process the form after the input has been submitted and validated
totten's avatar
totten committed
72 73
   *
   *
colemanw's avatar
colemanw committed
74
   * @return void
totten's avatar
totten committed
75 76 77 78 79 80 81 82 83 84 85 86 87
   */
  public function postProcess() {
    $deletedActivities = 0;
    foreach ($this->_activityHolderIds as $activityId['id']) {
      $moveToTrash = CRM_Case_BAO_Case::isCaseActivity($activityId['id']);
      if (CRM_Activity_BAO_Activity::deleteActivity($activityId, $moveToTrash)) {
        $deletedActivities++;
      }
    }

    CRM_Core_Session::setStatus($deletedActivities, ts('Deleted Activities'), "success");
    CRM_Core_Session::setStatus("", ts('Total Selected Activities: %1', array(1 => count($this->_activityHolderIds))), "info");
  }
88

totten's avatar
totten committed
89
}