INFRA-132 - Fix comment spacing
[civicrm-core.git] / api / v3 / Event.php
index 0566c134f015d23b63889f7b1b6bd2fb26113c55..50be6b175694b04d13fe2c53581d103ef01de2e8 100644 (file)
@@ -2,7 +2,7 @@
 
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -47,7 +47,8 @@
  *
  * This API is used for creating a Event
  *
- * @param  array   $params   input parameters
+ * @param array $params
+ *   Input parameters.
  * Allowed @params array keys are:
  * {@getfields event_create}
  *
@@ -72,13 +73,15 @@ function civicrm_api3_event_create($params) {
  * Adjust Metadata for Create action
  *
  * The metadata is used for setting defaults, documentation & validation
- * @param array $params array or parameters determined by getfields
+ * @param array $params
+ *   Array or parameters determined by getfields.
  */
 function _civicrm_api3_event_create_spec(&$params) {
   $params['start_date']['api.required'] = 1;
   $params['title']['api.required'] = 1;
   $params['is_active']['api.default'] = 1;
   $params['financial_type_id']['api.aliases'] = array('contribution_type_id');
+  $params['is_template']['api.default'] = 0;
 }
 
 /**
@@ -87,8 +90,8 @@ function _civicrm_api3_event_create_spec(&$params) {
  * the core code or schema - this means we have to provide support for api calls (where possible)
  * across schema changes.
  */
-function _civicrm_api3_event_create_legacy_support_42(&$params){
-  if(!empty($params['payment_processor_id'])){
+function _civicrm_api3_event_create_legacy_support_42(&$params) {
+  if (!empty($params['payment_processor_id'])) {
     $params['payment_processor'] = CRM_Core_DAO::VALUE_SEPARATOR . $params['payment_processor_id'] . CRM_Core_DAO::VALUE_SEPARATOR;
   }
 }
@@ -97,10 +100,11 @@ function _civicrm_api3_event_create_legacy_support_42(&$params){
  * Get Event record.
  *
  *
- * @param  array  $params     an associative array of name/value property values of civicrm_event
+ * @param array $params
+ *   An associative array of name/value property values of civicrm_event.
  * {@getfields event_get}
  *
- * @return  Array of all found event property values.
+ * @return Array of all found event property values.
  * @access public
  *
  */
@@ -127,13 +131,6 @@ function civicrm_api3_event_get($params) {
   $eventDAO = new CRM_Event_BAO_Event();
   _civicrm_api3_dao_set_filter($eventDAO, $params, TRUE, 'Event');
 
-  if (!empty($params['is_template'])) {
-    $eventDAO->whereAdd( '( is_template = 1 )' );
-  }
-  elseif(empty($eventDAO->id)){
-    $eventDAO->whereAdd('( is_template IS NULL ) OR ( is_template = 0 )');
-  }
-
   if (!empty($params['isCurrent'])) {
     $eventDAO->whereAdd('(start_date >= CURDATE() || end_date >= CURDATE())');
   }
@@ -153,11 +150,10 @@ function civicrm_api3_event_get($params) {
     }
     _civicrm_api3_event_get_legacy_support_42($event, $eventDAO->id);
     _civicrm_api3_custom_data_get($event[$eventDAO->id], 'Event', $eventDAO->id, NULL, $eventDAO->event_type_id);
-    if(!empty($options['return'])) {
+    if (!empty($options['return'])) {
       $event[$eventDAO->id]['price_set_id'] = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $eventDAO->id);
     }
   }
-  //end of the loop
 
   return civicrm_api3_create_success($event, $params, 'event', 'get', $eventDAO);
 }
@@ -166,7 +162,8 @@ function civicrm_api3_event_get($params) {
  * Adjust Metadata for Get action
  *
  * The metadata is used for setting defaults, documentation & validation
- * @param array $params array or parameters determined by getfields
+ * @param array $params
+ *   Array or parameters determined by getfields.
  */
 function _civicrm_api3_event_get_spec(&$params) {
   $params['financial_type_id']['api.aliases'] = array('contribution_type_id');
@@ -178,10 +175,10 @@ function _civicrm_api3_event_get_spec(&$params) {
  * the core code or schema - this means we have to provide support for api calls (where possible)
  * across schema changes.
  */
-function _civicrm_api3_event_get_legacy_support_42(&$event, $event_id){
-  if(!empty($event[$event_id]['payment_processor'])){
-    $processors = explode(CRM_Core_DAO::VALUE_SEPARATOR,$event[$event_id]['payment_processor']);
-    if(count($processors) == 3 ){
+function _civicrm_api3_event_get_legacy_support_42(&$event, $event_id) {
+  if (!empty($event[$event_id]['payment_processor'])) {
+    $processors = explode(CRM_Core_DAO::VALUE_SEPARATOR, $event[$event_id]['payment_processor']);
+    if (count($processors) == 3) {
       $event[$event_id]['payment_processor_id'] = $processors[1];
     }
   }
@@ -192,7 +189,8 @@ function _civicrm_api3_event_get_legacy_support_42(&$event, $event_id){
  *
  * This API is used for deleting a event
  *
- * @param  Array  $params    array containing event_id to be deleted
+ * @param array $paramsArray containing event_id to be deleted.
+ *   Array containing event_id to be deleted.
  *
  * @return boolean        true if success, error otherwise
  * @access public
@@ -206,16 +204,18 @@ function civicrm_api3_event_delete($params) {
 /*
 
 /**
- * Function to add 'is_full' & 'available_seats' to the return array. (this might be better in the BAO)
+ * add 'is_full' & 'available_seats' to the return array. (this might be better in the BAO)
  * Default BAO function returns a string if full rather than a Bool - which is more appropriate to a form
  *
- * @param array $event return array of the event
- * @param int $event_id Id of the event to be updated
+ * @param array $event
+ *   Return array of the event.
+ * @param int $event_id
+ *   Id of the event to be updated.
  *
  */
 /**
  * @param $event
- * @param $event_id
+ * @param int $event_id
  */
 function _civicrm_api3_event_getisfull(&$event, $event_id) {
   $eventFullResult = CRM_Event_BAO_Participant::eventFull($event_id, 1);
@@ -230,9 +230,10 @@ function _civicrm_api3_event_getisfull(&$event, $event_id) {
 
 
 /**
- * @see _civicrm_api3_generic_getlist_params.
+ * @see _civicrm_api3_generic_getlist_params
  *
- * @param $request array
+ * @param $request
+ *   Array.
  */
 function _civicrm_api3_event_getlist_params(&$request) {
   $fieldsToReturn = array('start_date', 'event_type_id', 'title', 'summary');
@@ -247,8 +248,10 @@ function _civicrm_api3_event_getlist_params(&$request) {
 /**
  * @see _civicrm_api3_generic_getlist_output
  *
- * @param $result array
- * @param $request array
+ * @param $result
+ *   Array.
+ * @param $request
+ *   Array.
  *
  * @return array
  */