Exemple #1
0
 /**
  * Delete the price set.
  *
  * @param int $id
  *   Price Set id.
  *
  * @return bool
  *   false if fields exist for this set, true if the
  *   set could be deleted
  *
  */
 public static function deleteSet($id)
 {
     // remove from all inactive forms
     $usedBy = self::getUsedBy($id);
     if (isset($usedBy['civicrm_event'])) {
         foreach ($usedBy['civicrm_event'] as $eventId => $unused) {
             $eventDAO = new CRM_Event_DAO_Event();
             $eventDAO->id = $eventId;
             $eventDAO->find();
             while ($eventDAO->fetch()) {
                 self::removeFrom('civicrm_event', $eventDAO->id);
             }
         }
     }
     // delete price fields
     $priceField = new CRM_Price_DAO_PriceField();
     $priceField->price_set_id = $id;
     $priceField->find();
     while ($priceField->fetch()) {
         // delete options first
         CRM_Price_BAO_PriceField::deleteField($priceField->id);
     }
     $set = new CRM_Price_DAO_PriceSet();
     $set->id = $id;
     return $set->delete();
 }