Example #1
0
 /**
  * Delete the group and all the object that connect to this group.
  *
  * Incredibly destructive.
  *
  * @param int $id Group id.
  */
 public static function discard($id)
 {
     CRM_Utils_Hook::pre('delete', 'Group', $id, CRM_Core_DAO::$_nullArray);
     $transaction = new CRM_Core_Transaction();
     // added for CRM-1631 and CRM-1794
     // delete all subscribed mails with the selected group id
     $subscribe = new CRM_Mailing_Event_DAO_Subscribe();
     $subscribe->group_id = $id;
     $subscribe->delete();
     // delete all Subscription  records with the selected group id
     $subHistory = new CRM_Contact_DAO_SubscriptionHistory();
     $subHistory->group_id = $id;
     $subHistory->delete();
     // delete all crm_group_contact records with the selected group id
     $groupContact = new CRM_Contact_DAO_GroupContact();
     $groupContact->group_id = $id;
     $groupContact->delete();
     // make all the 'add_to_group_id' field of 'civicrm_uf_group table', pointing to this group, as null
     $params = array(1 => array($id, 'Integer'));
     $query = "UPDATE civicrm_uf_group SET `add_to_group_id`= NULL WHERE `add_to_group_id` = %1";
     CRM_Core_DAO::executeQuery($query, $params);
     $query = "UPDATE civicrm_uf_group SET `limit_listings_group_id`= NULL WHERE `limit_listings_group_id` = %1";
     CRM_Core_DAO::executeQuery($query, $params);
     // make sure u delete all the entries from civicrm_mailing_group and civicrm_campaign_group
     // CRM-6186
     $query = "DELETE FROM civicrm_mailing_group where entity_table = 'civicrm_group' AND entity_id = %1";
     CRM_Core_DAO::executeQuery($query, $params);
     $query = "DELETE FROM civicrm_campaign_group where entity_table = 'civicrm_group' AND entity_id = %1";
     CRM_Core_DAO::executeQuery($query, $params);
     $query = "DELETE FROM civicrm_acl_entity_role where entity_table = 'civicrm_group' AND entity_id = %1";
     CRM_Core_DAO::executeQuery($query, $params);
     if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME, 'is_enabled')) {
         // clear any descendant groups cache if exists
         CRM_Core_BAO_Cache::deleteGroup('descendant groups for an org');
     }
     // delete from group table
     $group = new CRM_Contact_DAO_Group();
     $group->id = $id;
     $group->delete();
     $transaction->commit();
     CRM_Utils_Hook::post('delete', 'Group', $id, $group);
     // delete the recently created Group
     $groupRecent = array('id' => $id, 'type' => 'Group');
     CRM_Utils_Recent::del($groupRecent);
 }
 function __construct()
 {
     parent::__construct();
 }
Example #3
0
 /**
  * Returns the list of fields that can be exported
  *
  * @param bool $prefix
  *
  * @return array
  */
 static function &export($prefix = false)
 {
     if (!self::$_export) {
         self::$_export = array();
         $fields = self::fields();
         foreach ($fields as $name => $field) {
             if (CRM_Utils_Array::value('export', $field)) {
                 if ($prefix) {
                     self::$_export['subscription_history'] =& $fields[$name];
                 } else {
                     self::$_export[$name] =& $fields[$name];
                 }
             }
         }
     }
     return self::$_export;
 }
Example #4
0
 /**
  * Function to delete the group and all the object that connect to
  * this group. Incredibly destructive
  *
  * @param int $id group id
  *
  * @return null
  * @access public
  * @static
  *
  */
 static function discard($id)
 {
     require_once 'CRM/Utils/Hook.php';
     require_once 'CRM/Contact/DAO/SubscriptionHistory.php';
     CRM_Utils_Hook::pre('delete', 'Group', $id, CRM_Core_DAO::$_nullArray);
     require_once 'CRM/Core/Transaction.php';
     $transaction = new CRM_Core_Transaction();
     // added for CRM-1631 and CRM-1794
     // delete all subscribed mails with the selected group id
     require_once 'CRM/Mailing/Event/BAO/Subscribe.php';
     $subscribe = new CRM_Mailing_Event_BAO_Subscribe();
     $subscribe->deleteGroup($id);
     // delete all Subscription  records with the selected group id
     $subHistory = new CRM_Contact_DAO_SubscriptionHistory();
     $subHistory->group_id = $id;
     $subHistory->delete();
     // delete all crm_group_contact records with the selected group id
     require_once 'CRM/Contact/DAO/GroupContact.php';
     $groupContact = new CRM_Contact_DAO_GroupContact();
     $groupContact->group_id = $id;
     $groupContact->delete();
     // make all the 'add_to_group_id' field of 'civicrm_uf_group table', pointing to this group, as null
     $params = array(1 => array($id, 'Integer'));
     $query = "update civicrm_uf_group SET `add_to_group_id`= NULL where `add_to_group_id` = %1";
     CRM_Core_DAO::executeQuery($query, $params);
     $query = "update civicrm_uf_group SET `limit_listings_group_id`= NULL where `limit_listings_group_id` = %1";
     CRM_Core_DAO::executeQuery($query, $params);
     if (defined('CIVICRM_MULTISITE') && CIVICRM_MULTISITE) {
         // clear any descendant groups cache if exists
         require_once 'CRM/Core/BAO/Cache.php';
         $finalGroups =& CRM_Core_BAO_Cache::deleteGroup('descendant groups for an org');
     }
     // delete from group table
     $group = new CRM_Contact_DAO_Group();
     $group->id = $id;
     $group->delete();
     $transaction->commit();
     CRM_Utils_Hook::post('delete', 'Group', $id, $group);
     // delete the recently created Group
     require_once 'CRM/Utils/Recent.php';
     $groupRecent = array('id' => $id, 'type' => 'Group');
     CRM_Utils_Recent::del($groupRecent);
 }
Example #5
0
 /**
  * adds $value['foo_display'] for each $value['foo'] enum from civicrm_subscription_history
  *
  * @param array $values (reference)  the array up for enhancing
  * @return void
  */
 static function addDisplayEnums(&$values)
 {
     $enumFields =& CRM_Contact_DAO_SubscriptionHistory::getEnums();
     foreach ($enumFields as $enum) {
         if (isset($values[$enum])) {
             $values[$enum . '_display'] = CRM_Contact_DAO_SubscriptionHistory::tsEnum($enum, $values[$enum]);
         }
     }
 }
 function CRM_Contact_BAO_SubscriptionHistory()
 {
     parent::CRM_Contact_DAO_SubscriptionHistory();
 }