Ejemplo n.º 1
0
 /**
  * Function to delete contribution Types 
  * 
  * @param int $contributionTypeId
  * @static
  */
 static function del($contributionTypeId)
 {
     //checking if contribution type is present
     $check = false;
     //check dependencies
     $dependancy = array(array('Contribute', 'Contribution'), array('Contribute', 'ContributionPage'), array('Member', 'MembershipType'));
     foreach ($dependancy as $name) {
         require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_" . $name[0] . "_BAO_" . $name[1]) . ".php";
         eval('$bao = new CRM_' . $name[0] . '_BAO_' . $name[1] . '();');
         $bao->contribution_type_id = $contributionTypeId;
         if ($bao->find(true)) {
             $check = true;
         }
     }
     if ($check) {
         $session = CRM_Core_Session::singleton();
         CRM_Core_Session::setStatus(ts('This contribution type cannot be deleted because it is being referenced by one or more of the following types of records: Contributions, Contribution Pages, or Membership Types. Consider disabling this type instead if you no longer want it used.'));
         return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/contribute/contributionType', "reset=1&action=browse"));
     }
     //delete from contribution Type table
     require_once 'CRM/Contribute/DAO/Contribution.php';
     $contributionType = new CRM_Contribute_DAO_ContributionType();
     $contributionType->id = $contributionTypeId;
     $contributionType->delete();
 }
 /**
  * Function to delete contribution Types
  *
  * @param int $contributionTypeId
  * @static
  */
 static function del($contributionTypeId, $skipRedirect = FALSE)
 {
     //checking if contribution type is present
     $check = FALSE;
     //check dependencies
     $dependancy = array(array('Contribute', 'Contribution'), array('Contribute', 'ContributionPage'), array('Member', 'MembershipType'));
     foreach ($dependancy as $name) {
         require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_" . $name[0] . "_BAO_" . $name[1]) . ".php";
         eval('$bao = new CRM_' . $name[0] . '_BAO_' . $name[1] . '();');
         $bao->contribution_type_id = $contributionTypeId;
         if ($bao->find(TRUE)) {
             $check = TRUE;
         }
     }
     if ($check) {
         if (!$skipRedirect) {
             $session = CRM_Core_Session::singleton();
             CRM_Core_Session::setStatus(ts('This contribution type cannot be deleted because it is being referenced by one or more of the following types of records: Contributions, Contribution Pages, or Membership Types. Consider disabling this type instead if you no longer want it used.'));
             return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/contribute/contributionType', "reset=1&action=browse"));
         } else {
             $error = array();
             $error['is_error'] = 1;
             //don't translate as api error message are not translated
             $error['error_message'] = 'The Contribution Type cannot be deleted because it is being referenced by one or more of the following types of records: Contributions, Contribution Pages, or Membership Types.';
             return $error;
         }
     }
     //delete from contribution Type table
     $contributionType = new CRM_Contribute_DAO_ContributionType();
     $contributionType->id = $contributionTypeId;
     $contributionType->delete();
 }