当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Event_DAO_Event::delete方法代码示例

本文整理汇总了PHP中CRM_Event_DAO_Event::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Event_DAO_Event::delete方法的具体用法?PHP CRM_Event_DAO_Event::delete怎么用?PHP CRM_Event_DAO_Event::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Event_DAO_Event的用法示例。


在下文中一共展示了CRM_Event_DAO_Event::delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: del

 /**
  * Function to delete the event
  *
  * @param int $id event id
  *
  * @return mixed|null
  * @access public
  * @static
  *
  */
 static function del($id)
 {
     if (!$id) {
         return NULL;
     }
     CRM_Utils_Hook::pre('delete', 'Event', $id, CRM_Core_DAO::$_nullArray);
     $extends = array('event');
     $groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, NULL, $extends);
     foreach ($groupTree as $values) {
         $query = "DELETE FROM " . $values['table_name'] . " WHERE entity_id = " . $id;
         $params = array(1 => array($values['table_name'], 'string'), 2 => array($id, 'integer'));
         CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     }
     // price set cleanup, CRM-5527
     CRM_Price_BAO_PriceSet::removeFrom('civicrm_event', $id);
     $event = new CRM_Event_DAO_Event();
     $event->id = $id;
     if ($event->find(TRUE)) {
         $locBlockId = $event->loc_block_id;
         $result = $event->delete();
         if (!is_null($locBlockId)) {
             self::deleteEventLocBlock($locBlockId, $id);
         }
         CRM_Utils_Hook::post('delete', 'Event', $id, $event);
         return $result;
     }
     return NULL;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:38,代码来源:Event.php

示例2: del

 /**
  * Function to delete the event
  *
  * @param int $id  event id
  *
  * @access public
  * @static
  *
  */
 static function del($id)
 {
     if (!$id) {
         return null;
     }
     require_once 'CRM/Utils/Hook.php';
     CRM_Utils_Hook::pre('delete', 'Event', $id, CRM_Core_DAO::$_nullArray);
     require_once 'CRM/Core/BAO/CustomGroup.php';
     $extends = array('event');
     $groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail(null, null, $extends);
     foreach ($groupTree as $values) {
         $query = "DELETE FROM " . $values['table_name'] . " WHERE entity_id = " . $id;
         $params = array(1 => array($values['table_name'], 'string'), 2 => array($id, 'integer'));
         CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     }
     $dependencies = array('CRM_Core_DAO_OptionGroup' => array('name' => 'civicrm_event.amount.' . $id), 'CRM_Core_DAO_UFJoin' => array('entity_id' => $id, 'entity_table' => 'civicrm_event'));
     require_once 'CRM/Core/BAO/OptionGroup.php';
     foreach ($dependencies as $daoName => $values) {
         require_once str_replace('_', DIRECTORY_SEPARATOR, $daoName) . ".php";
         eval('$dao = new ' . $daoName . '( );');
         if ($daoName == 'CRM_Core_DAO_OptionGroup') {
             $dao->name = $values['name'];
             $dao->find();
             while ($dao->fetch()) {
                 CRM_Core_BAO_OptionGroup::del($dao->id);
             }
         } else {
             foreach ($values as $fieldName => $fieldValue) {
                 $dao->{$fieldName} = $fieldValue;
             }
             $dao->find();
             while ($dao->fetch()) {
                 $dao->delete();
             }
         }
     }
     require_once 'CRM/Core/OptionGroup.php';
     CRM_Core_OptionGroup::deleteAssoc("civicrm_event.amount.{$id}.discount.%", "LIKE");
     // price set cleanup, CRM-5527
     require_once 'CRM/Price/BAO/Set.php';
     CRM_Price_BAO_Set::removeFrom('civicrm_event', $id);
     require_once 'CRM/Event/DAO/Event.php';
     $event = new CRM_Event_DAO_Event();
     $event->id = $id;
     if ($event->find(true)) {
         $locBlockId = $event->loc_block_id;
         $result = $event->delete();
         if (!is_null($locBlockId)) {
             self::deleteEventLocBlock($locBlockId, $id);
         }
         CRM_Utils_Hook::post('delete', 'Event', $id, $event);
         return $result;
     }
     return null;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:64,代码来源:Event.php

示例3: testEventGeneration

 /**
  * Testing Event Generation through Entity Recursion.
  */
 public function testEventGeneration()
 {
     //Event set initial params
     $daoEvent = new CRM_Event_DAO_Event();
     $daoEvent->title = 'Test event for Recurring Entity';
     $daoEvent->event_type_id = 3;
     $daoEvent->is_public = 1;
     $daoEvent->start_date = date('YmdHis', strtotime('2014-10-26 10:30:00'));
     $daoEvent->end_date = date('YmdHis', strtotime('2014-10-28 10:30:00'));
     $daoEvent->created_date = date('YmdHis');
     $daoEvent->is_active = 1;
     $daoEvent->save();
     $this->assertDBNotNull('CRM_Event_DAO_Event', $daoEvent->id, 'id', 'id', 'Check DB if event was created');
     //Create tell a friend for event
     $daoTellAFriend = new CRM_Friend_DAO_Friend();
     $daoTellAFriend->entity_table = 'civicrm_event';
     $daoTellAFriend->entity_id = $daoEvent->id;
     // join with event
     $daoTellAFriend->title = 'Testing tell a friend';
     $daoTellAFriend->is_active = 1;
     $daoTellAFriend->save();
     $this->assertDBNotNull('CRM_Friend_DAO_Friend', $daoTellAFriend->id, 'id', 'id', 'Check DB if tell a friend was created');
     // time to use recursion
     $recursion = new CRM_Core_BAO_RecurringEntity();
     $recursion->entity_id = $daoEvent->id;
     $recursion->entity_table = 'civicrm_event';
     $recursion->dateColumns = array('start_date');
     $recursion->schedule = array('entity_value' => $daoEvent->id, 'start_action_date' => $daoEvent->start_date, 'start_action_condition' => 'monday', 'repetition_frequency_unit' => 'week', 'repetition_frequency_interval' => 1, 'start_action_offset' => 4, 'used_for' => 'event');
     $recursion->linkedEntities = array(array('table' => 'civicrm_tell_friend', 'findCriteria' => array('entity_id' => $recursion->entity_id, 'entity_table' => 'civicrm_event'), 'linkedColumns' => array('entity_id'), 'isRecurringEntityRecord' => TRUE));
     $interval = $recursion->getInterval($daoEvent->start_date, $daoEvent->end_date);
     $recursion->intervalDateColumns = array('end_date' => $interval);
     $generatedEntities = $recursion->generate();
     $this->assertArrayHasKey('civicrm_event', $generatedEntities, 'Check if generatedEntities has civicrm_event as required key');
     $expectedDates = array('20141027103000' => '20141029103000', '20141103103000' => '20141105103000', '20141110103000' => '20141112103000', '20141117103000' => '20141119103000');
     $this->assertCount($recursion->schedule['start_action_offset'], $generatedEntities['civicrm_event'], 'Check if the number of events created are right');
     $actualDates = array();
     foreach ($generatedEntities['civicrm_event'] as $key => $val) {
         $this->assertDBNotNull('CRM_Event_DAO_Event', $val, 'id', 'id', 'Check if repeating events were created.');
         $startDate = date('YmdHis', strtotime(CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $val, 'start_date', 'id')));
         $endDate = date('YmdHis', strtotime(CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $val, 'end_date', 'id')));
         $actualDates[$startDate] = $endDate;
     }
     $resultDates = array_diff($actualDates, $expectedDates);
     $this->assertEquals(0, count($resultDates), "Check if all the value in expected array matches actual array");
     foreach ($generatedEntities['civicrm_tell_friend'] as $key => $val) {
         $this->assertDBNotNull('CRM_Friend_DAO_Friend', $val, 'id', 'id', 'Check if friends were created in loop');
         $this->assertDBCompareValue('CRM_Friend_DAO_Friend', $val, 'entity_id', 'id', $generatedEntities['civicrm_event'][$key], 'Check DB if correct FK was maintained with event for Friend');
     }
     $this->assertCount($recursion->schedule['start_action_offset'], $generatedEntities['civicrm_tell_friend'], 'Check if the number of tell a friend records are right');
     // set mode to ALL, i.e any change to changing event affects all related recurring activities
     $recursion->mode(3);
     $daoEvent->find(TRUE);
     $daoEvent->title = 'Event Changed';
     $daoEvent->save();
     // check if other events were affected
     foreach ($generatedEntities['civicrm_event'] as $entityID) {
         $this->assertDBCompareValue('CRM_Event_DAO_Event', $entityID, 'title', 'id', 'Event Changed', 'Check if title was updated');
     }
     end($generatedEntities['civicrm_event']);
     $key = key($generatedEntities['civicrm_event']);
     end($generatedEntities['civicrm_tell_friend']);
     $actKey = key($generatedEntities['civicrm_tell_friend']);
     //Check if both(event/tell a friend) keys are same
     $this->assertEquals($key, $actKey, "Check if both the keys are same");
     //Cross check event exists before we test deletion
     $searchParamsEventBeforeDelete = array('entity_id' => $generatedEntities['civicrm_event'][$key], 'entity_table' => 'civicrm_event');
     $expectedValuesEventBeforeDelete = array('entity_id' => $generatedEntities['civicrm_event'][$key], 'entity_table' => 'civicrm_event');
     $this->assertDBCompareValues('CRM_Core_DAO_RecurringEntity', $searchParamsEventBeforeDelete, $expectedValuesEventBeforeDelete);
     //Cross check event exists before we test deletion
     $searchParamsTellAFriendBeforeDelete = array('entity_id' => $generatedEntities['civicrm_tell_friend'][$actKey], 'entity_table' => 'civicrm_tell_friend');
     $expectedValuesTellAFriendBeforeDelete = array('entity_id' => $generatedEntities['civicrm_tell_friend'][$actKey], 'entity_table' => 'civicrm_tell_friend');
     $this->assertDBCompareValues('CRM_Core_DAO_RecurringEntity', $searchParamsTellAFriendBeforeDelete, $expectedValuesTellAFriendBeforeDelete);
     //Delete an event from recurring set and respective linked entity should be deleted from civicrm_recurring_entity_table
     $daoRecurEvent = new CRM_Event_DAO_Event();
     $daoRecurEvent->id = $generatedEntities['civicrm_event'][$key];
     if ($daoRecurEvent->find(TRUE)) {
         $daoRecurEvent->delete();
         $daoRecurEvent->free();
     }
     //Check if this event_id was deleted
     $this->assertDBNull('CRM_Event_DAO_Event', $generatedEntities['civicrm_event'][$key], 'id', 'id', 'Check if event was deleted');
     $searchParams = array('entity_id' => $generatedEntities['civicrm_event'][$key], 'entity_table' => 'civicrm_event');
     $compareParams = array();
     $this->assertDBCompareValues('CRM_Core_DAO_RecurringEntity', $searchParams, $compareParams);
     //Find tell_a_friend id if that was deleted from civicrm
     $searchActParams = array('entity_id' => $generatedEntities['civicrm_tell_friend'][$actKey], 'entity_table' => 'civicrm_tell_friend');
     $compareActParams = array();
     $this->assertDBCompareValues('CRM_Friend_DAO_Friend', $searchActParams, $compareActParams);
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:92,代码来源:RecurringEntityTest.php


注:本文中的CRM_Event_DAO_Event::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。