예제 #1
0
파일: Event.php 프로젝트: ksecor/civicrm
 /**
  * Takes a bunch of params that are needed to match certain criteria and
  * retrieves the relevant objects. Typically the valid params are only
  * contact_id. We'll tweak this function to be more full featured over a period
  * of time. This is the inverse function of create. It also stores all the retrieved
  * values in the default array
  *
  * @param array $params   (reference ) an assoc array of name/value pairs
  * @param array $defaults (reference ) an assoc array to hold the flattened values
  *
  * @return object CRM_Event_BAO_ManageEvent object
  * @access public
  * @static
  */
 static function retrieve(&$params, &$defaults)
 {
     $event = new CRM_Event_DAO_Event();
     $event->copyValues($params);
     if ($event->find(true)) {
         CRM_Core_DAO::storeValues($event, $defaults);
         return $event;
     }
     return null;
 }
예제 #2
0
 /**
  * function to add the event
  *
  * @param array $params reference array contains the values submitted by the form
  * 
  * @access public
  * @static 
  * @return object
  */
 static function add(&$params)
 {
     require_once 'CRM/Utils/System.php';
     CRM_Utils_System::flushCache();
     require_once 'CRM/Utils/Hook.php';
     if (CRM_Utils_Array::value('id', $params)) {
         CRM_Utils_Hook::pre('edit', 'Event', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'Event', null, $params);
     }
     $event = new CRM_Event_DAO_Event();
     $event->copyValues($params);
     $result = $event->save();
     if (CRM_Utils_Array::value('id', $params)) {
         CRM_Utils_Hook::post('edit', 'Event', $event->id, $event);
     } else {
         CRM_Utils_Hook::post('create', 'Event', $event->id, $event);
     }
     return $result;
 }
예제 #3
0
 /**
  * function to add the event
  *
  * @param array $params reference array contains the values submitted by the form
  *
  * @access public
  * @static
  *
  * @return object
  */
 static function add(&$params)
 {
     CRM_Utils_System::flushCache();
     $financialTypeId = NULL;
     if (!empty($params['id'])) {
         CRM_Utils_Hook::pre('edit', 'Event', $params['id'], $params);
         if (empty($params['skipFinancialType'])) {
             $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['id'], 'financial_type_id');
         }
     } else {
         CRM_Utils_Hook::pre('create', 'Event', NULL, $params);
     }
     $event = new CRM_Event_DAO_Event();
     $event->copyValues($params);
     $result = $event->save();
     if (!empty($params['id'])) {
         CRM_Utils_Hook::post('edit', 'Event', $event->id, $event);
     } else {
         CRM_Utils_Hook::post('create', 'Event', $event->id, $event);
     }
     if ($financialTypeId && !empty($params['financial_type_id']) && $financialTypeId != $params['financial_type_id']) {
         CRM_Price_BAO_PriceFieldValue::updateFinancialType($params['id'], 'civicrm_event', $params['financial_type_id']);
     }
     return $result;
 }