/** * function to create the event * * @param array $params reference array contains the values submitted by the form * * @return object * @access public * @static * */ public static function create(&$params) { $transaction = new CRM_Core_Transaction(); if (empty($params['is_template'])) { $params['is_template'] = 0; } // check if new event, if so set the created_id (if not set) // and always set created_date to now if (empty($params['id'])) { if (empty($params['created_id'])) { $session = CRM_Core_Session::singleton(); $params['created_id'] = $session->get('userID'); } $params['created_date'] = date('YmdHis'); } $event = self::add($params); CRM_Price_BAO_PriceSet::setPriceSets($params, $event, 'event'); if (is_a($event, 'CRM_Core_Error')) { CRM_Core_DAO::transaction('ROLLBACK'); return $event; } $session = CRM_Core_Session::singleton(); $contactId = $session->get('userID'); if (!$contactId) { $contactId = CRM_Utils_Array::value('contact_id', $params); } // Log the information on successful add/edit of Event $logParams = array('entity_table' => 'civicrm_event', 'entity_id' => $event->id, 'modified_id' => $contactId, 'modified_date' => date('Ymd')); CRM_Core_BAO_Log::add($logParams); if (!empty($params['custom']) && is_array($params['custom'])) { CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_event', $event->id); } $transaction->commit(); return $event; }