Esempio n. 1
0
 /**
  * Function to delete the location block associated with an event, 
  * if not being used by any other event.
  *
  * @param int $loc_block_id    location block id to be deleted
  * @param int $eventid         event id with which loc block is associated
  *
  * @access public
  * @static
  *
  */
 static function deleteEventLocBlock($locBlockId, $eventId = null)
 {
     $query = "SELECT count(ce.id) FROM civicrm_event ce WHERE ce.loc_block_id = {$locBlockId}";
     if ($eventId) {
         $query .= " AND ce.id != {$eventId};";
     }
     $locCount = CRM_Core_DAO::singleValueQuery($query);
     if ($locCount == 0) {
         require_once 'CRM/Core/BAO/Location.php';
         CRM_Core_BAO_Location::deleteLocBlock($locBlockId);
     }
 }
Esempio n. 2
0
 /**
  * DeleteLocBlock() method
  * delete the location block
  * created with various elements.
  */
 public function testDeleteLocBlock()
 {
     $this->_contactId = $this->individualCreate();
     //create test event record.
     $event = $this->eventCreate();
     $params['location'][1] = array('location_type_id' => 1, 'is_primary' => 1, 'address' => array('street_address' => 'Saint Helier St', 'supplemental_address_1' => 'Hallmark Ct', 'supplemental_address_2' => 'Jersey Village', 'city' => 'Newark', 'postal_code' => '01903', 'country_id' => 1228, 'state_province_id' => 1029, 'geo_code_1' => '18.219023', 'geo_code_2' => '-105.00973'), 'email' => array('1' => array('email' => '*****@*****.**')), 'phone' => array('1' => array('phone_type_id' => 1, 'phone' => '303443689'), '2' => array('phone_type_id' => 2, 'phone' => '9833910234')), 'im' => array('1' => array('name' => 'jane.doe', 'provider_id' => 1)));
     $params['entity_id'] = $event['id'];
     $params['entity_table'] = 'civicrm_event';
     //create location block.
     //with various elements
     //like address, phone, email, im.
     $location = CRM_Core_BAO_Location::create($params, NULL, TRUE);
     $locBlockId = CRM_Utils_Array::value('id', $location);
     //update event record with location block id
     $eventParams = array('id' => $event['id'], 'loc_block_id' => $locBlockId);
     CRM_Event_BAO_Event::add($eventParams);
     //delete the location block
     CRM_Core_BAO_Location::deleteLocBlock($locBlockId);
     //Now check DB for location elements.
     //Now check DB for Address
     $this->assertDBNull('CRM_Core_DAO_Address', 'Saint Helier St', 'id', 'street_address', 'Database check, Address deleted successfully.');
     //Now check DB for Email
     $this->assertDBNull('CRM_Core_DAO_Email', '*****@*****.**', 'id', 'email', 'Database check, Email deleted successfully.');
     //Now check DB for Phone
     $this->assertDBNull('CRM_Core_DAO_Phone', '303443689', 'id', 'phone', 'Database check, Phone deleted successfully.');
     //Now check DB for Mobile
     $this->assertDBNull('CRM_Core_DAO_Phone', '9833910234', 'id', 'phone', 'Database check, Mobile deleted successfully.');
     //Now check DB for IM
     $this->assertDBNull('CRM_Core_DAO_IM', 'jane.doe', 'id', 'name', 'Database check, IM deleted successfully.');
     //cleanup DB by deleting the record.
     $this->eventDelete($event['id']);
     $this->contactDelete($this->_contactId);
     //Now check DB for Event
     $this->assertDBNull('CRM_Event_DAO_Event', $event['id'], 'id', 'id', 'Database check, Event deleted successfully.');
 }
Esempio n. 3
0
 /**
  * Delete the location block associated with an event,
  * if not being used by any other event.
  *
  * @param $locBlockId
  *   Location block id to be deleted.
  * @param int $eventId
  *   Event with which loc block is associated.
  *
  */
 public static function deleteEventLocBlock($locBlockId, $eventId = NULL)
 {
     $query = "SELECT count(ce.id) FROM civicrm_event ce WHERE ce.loc_block_id = {$locBlockId}";
     if ($eventId) {
         $query .= " AND ce.id != {$eventId};";
     }
     $locCount = CRM_Core_DAO::singleValueQuery($query);
     if ($locCount == 0) {
         CRM_Core_BAO_Location::deleteLocBlock($locBlockId);
     }
 }