More comment fixes
[civicrm-core.git] / api / v3 / Job.php
index 32acc25feea7c03b90fcf555cbdf731436f68639..b12d4ae515aa2d4937e478b1e9160d2cf9029f16 100644 (file)
@@ -25,7 +25,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  * new version of civicrm APIs. See blog post at
  * @subpackage API_Job
  * @copyright CiviCRM LLC (c) 2004-2014
  * $Id: Contact.php 30879 2010-11-22 15:45:55Z shot $
- *
  */
 
 /**
- * Adjust metadata for "Create" action
+ * Adjust metadata for "Create" action.
+ *
+ * The metadata is used for setting defaults, documentation & validation.
  *
- * The metadata is used for setting defaults, documentation & validation
  * @param array $params
  *   Array or parameters determined by getfields.
  */
@@ -56,63 +56,60 @@ function _civicrm_api3_job_create_spec(&$params) {
 }
 
 /**
- * create scheduled job
+ * Create scheduled job.
  *
  * @param array $params
  *   Associative array of property name/value pairs to insert in new job.
  *
  * @return array
- * {@getfields Job_create}
  */
 function civicrm_api3_job_create($params) {
   return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
 }
 
 /**
- * Retrieve one or more job
- * @param array input parameters
+ * Retrieve one or more job.
+ *
+ * @param array $params
+ *   input parameters
+ *
  * @return array
- *   api result array
- * {@getfields email_get}
  */
 function civicrm_api3_job_get($params) {
   return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
 }
 
 /**
- * Delete a job
+ * Delete a job.
  *
  * @param array $params
- *
- * @return array
- *   API Result Array
- * {@getfields Job_delete}
  */
 function civicrm_api3_job_delete($params) {
   _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
 }
 
 /**
- * Dumb wrapper to execute scheduled jobs. Always creates success - errors
- * and results are handled in the job log.
+ * Dumb wrapper to execute scheduled jobs.
+ *
+ * Always creates success - errors and results are handled in the job log.
  *
  * @param array $params
- *   (reference ) input parameters.
+ *   input parameters (unused).
  *
  * @return array
  *   API Result Array
  */
-function civicrm_api3_job_execute(/** @noinspection PhpUnusedParameterInspection */
-  $params) {
+function civicrm_api3_job_execute($params) {
+
   $facility = new CRM_Core_JobManager();
   $facility->execute(FALSE);
 
-  // always creates success - results are handled elsewhere
-  return civicrm_api3_create_success();
+  // Always creates success - results are handled elsewhere.
+  return civicrm_api3_create_success(1, $params);
 }
 
 /**
- * Adjust Metadata for Execute action
+ * Adjust Metadata for Execute action.
  *
  * @param array $params
  *   Array or parameters determined by getfields.
@@ -121,10 +118,10 @@ function _civicrm_api3_job_execute_spec(&$params) {
 }
 
 /**
- * Geocode group of contacts based on given params
+ * Geocode group of contacts based on given params.
  *
  * @param array $params
- *   (reference ) input parameters.
+ *   input parameters.
  *
  * @return array
  *   API Result Array
@@ -132,7 +129,6 @@ function _civicrm_api3_job_execute_spec(&$params) {
 function civicrm_api3_job_geocode($params) {
   $gc = new CRM_Utils_Address_BatchUpdate($params);
 
-
   $result = $gc->run();
 
   if ($result['is_error'] == 0) {
@@ -144,7 +140,7 @@ function civicrm_api3_job_geocode($params) {
 }
 
 /**
- * First check on Code documentation
+ * First check on Code documentation.
  *
  * @param array $params
  */
@@ -157,7 +153,7 @@ function _civicrm_api3_job_geocode_spec(&$params) {
 }
 
 /**
- * Send the scheduled reminders for all contacts (either for activities or events)
+ * Send the scheduled reminders for all contacts (either for activities or events).
  *
  * @param array $params
  *   (reference ) input parameters.
@@ -188,9 +184,10 @@ function civicrm_api3_job_send_reminder($params) {
   }
 }
 /**
- * Adjust metadata for "send_reminder" action
+ * Adjust metadata for "send_reminder" action.
+ *
+ * The metadata is used for setting defaults, documentation & validation.
  *
- * The metadata is used for setting defaults, documentation & validation
  * @param array $params
  *   Array or parameters determined by getfields.
  */
@@ -203,7 +200,7 @@ function _civicrm_api3_job_send_reminder(&$params) {
   );
 }
 /**
- * Execute a specific report instance and send the output via email
+ * Execute a specific report instance and send the output via email.
  *
  * @param array $params
  *   (reference ) input parameters.
@@ -226,12 +223,12 @@ function civicrm_api3_job_mail_report($params) {
 }
 
 /**
- *
  * This method allows to update Email Greetings, Postal Greetings and Addressee for a specific contact type.
+ *
  * IMPORTANT: You must first create valid option value before using via admin interface.
  * Check option lists for Email Greetings, Postal Greetings and Addressee
  *
- *                        id - Integer - greetings option group
+ * @todo - is this here by mistake or should it be added to _spec function :id - Integer - greetings option group.
  *
  * @param array $params
  *
@@ -256,9 +253,10 @@ function civicrm_api3_job_update_greeting($params) {
 }
 
 /**
- * Adjust Metadata for Get action
+ * Adjust Metadata for Get action.
+ *
+ * The metadata is used for setting defaults, documentation & validation.
  *
- * The metadata is used for setting defaults, documentation & validation
  * @param array $params
  *   Array or parameters determined by getfields.
  */
@@ -269,16 +267,17 @@ function _civicrm_api3_job_update_greeting_spec(&$params) {
     'type' => CRM_Utils_Type::T_STRING,
   );
   $params['gt'] = array(
-      'api.required' => 1,
-      'title' => 'Greeting Type',
-      'type' => CRM_Utils_Type::T_STRING,
+    'api.required' => 1,
+    'title' => 'Greeting Type',
+    'type' => CRM_Utils_Type::T_STRING,
   );
 }
 
 /**
- * Mass update pledge statuses
+ * Mass update pledge statuses.
  *
  * @param array $params
+ *
  * @return array
  */
 function civicrm_api3_job_process_pledge($params) {
@@ -296,7 +295,7 @@ function civicrm_api3_job_process_pledge($params) {
 }
 
 /**
- * Process mail queue
+ * Process mail queue.
  *
  * @param array $params
  *
@@ -314,7 +313,7 @@ function civicrm_api3_job_process_mailing($params) {
 }
 
 /**
- * Process sms queue
+ * Process sms queue.
  *
  * @param array $params
  *
@@ -331,7 +330,7 @@ function civicrm_api3_job_process_sms($params) {
 }
 
 /**
- * Job to get mail responses from civiMailing
+ * Job to get mail responses from civiMailing.
  *
  * @param array $params
  *
@@ -354,7 +353,7 @@ function civicrm_api3_job_fetch_bounces($params) {
 }
 
 /**
- * Job to get mail and create activities
+ * Job to get mail and create activities.
  *
  * @param array $params
  *
@@ -370,7 +369,7 @@ function civicrm_api3_job_fetch_activities($params) {
     CRM_Utils_Mail_EmailProcessor::processActivities();
     $values = array();
     $lock->release();
-    return civicrm_api3_create_success($values, $params,'mailing','activities');
+    return civicrm_api3_create_success($values, $params, 'mailing', 'activities');
   }
   catch (Exception $e) {
     $lock->release();
@@ -379,10 +378,10 @@ function civicrm_api3_job_fetch_activities($params) {
 }
 
 /**
- * Process participant statuses
+ * Process participant statuses.
  *
  * @param array $params
- *   (reference ) input parameters.
+ *  Input parameters.
  *
  * @return array
  *   array of properties, if error an array with an error id and error message
@@ -400,8 +399,9 @@ function civicrm_api3_job_process_participant($params) {
 
 
 /**
- * This api checks and updates the status of all membership records for a given domain using the calc_membership_status and
- * update_contact_membership APIs.
+ * This api checks and updates the status of all membership records for a given domain.
+ *
+ * The function uses the calc_membership_status and update_contact_membership APIs.
  *
  * IMPORTANT:
  * Sending renewal reminders has been migrated from this job to the Scheduled Reminders function as of 4.3.
@@ -409,11 +409,10 @@ function civicrm_api3_job_process_participant($params) {
  * @param array $params
  *   Input parameters NOT USED.
  *
- * @return boolean
+ * @return bool
  *   true if success, else false
  */
-function civicrm_api3_job_process_membership(/** @noinspection PhpUnusedParameterInspection */
-  $params) {
+function civicrm_api3_job_process_membership($params) {
   $lock = new CRM_Core_Lock('civimail.job.updateMembership');
   if (!$lock->isAcquired()) {
     return civicrm_api3_create_error('Could not acquire lock, another Membership Processing process is running');
@@ -423,7 +422,7 @@ function civicrm_api3_job_process_membership(/** @noinspection PhpUnusedParamete
   $lock->release();
 
   if ($result['is_error'] == 0) {
-    return civicrm_api3_create_success($result['messages']);
+    return civicrm_api3_create_success($result['messages'], $params);
   }
   else {
     return civicrm_api3_create_error($result['messages']);
@@ -436,7 +435,7 @@ function civicrm_api3_job_process_membership(/** @noinspection PhpUnusedParamete
  * @param array $params
  *   (reference ) input parameters.
  *
- * @return boolean
+ * @return bool
  *   true if success, else false
  */
 function civicrm_api3_job_process_respondent($params) {
@@ -458,7 +457,6 @@ function civicrm_api3_job_process_respondent($params) {
  *
  * @return array
  *   API Result Array
- *
  */
 function civicrm_api3_job_process_batch_merge($params) {
   $rgid = CRM_Utils_Array::value('rgid', $params);
@@ -478,6 +476,8 @@ function civicrm_api3_job_process_batch_merge($params) {
 }
 
 /**
+ * Metadata for batch merge function.
+ *
  * @param $params
  */
 function _civicrm_api3_job_process_batch_merge_spec(&$params) {
@@ -491,9 +491,7 @@ function _civicrm_api3_job_process_batch_merge_spec(&$params) {
   );
   $params['mode'] = array(
     'title' => 'Mode',
-    'description' => 'helps decide how to behave when there are conflicts.
-       A \'safe\' value skips the merge if there are no conflicts.
-       Does a force merge otherwise.',
+    'description' => 'helps decide how to behave when there are conflicts. A \'safe\' value skips the merge if there are no conflicts. Does a force merge otherwise.',
     'type' => CRM_Utils_Type::T_STRING,
   );
   $params['auto_flip'] = array(
@@ -504,14 +502,14 @@ function _civicrm_api3_job_process_batch_merge_spec(&$params) {
 }
 
 /**
- * Runs handlePaymentCron method in the specified payment processor
+ * Runs handlePaymentCron method in the specified payment processor.
  *
  * @param array $params
  *   Input parameters.
  *
- * Expected @params array keys are:
+ * Expected @params array keys are: INCORRECTLY DOCUMENTED AND SHOULD BE IN THE _spec function
+ * for retrieval via getfields.
  * {string  'processor_name' - the name of the payment processor, eg: Sagepay}
- *
  */
 function civicrm_api3_job_run_payment_cron($params) {
 
@@ -539,21 +537,20 @@ function civicrm_api3_job_run_payment_cron($params) {
 }
 
 /**
- * This api cleans up all the old session entries and temp tables. We recommend that sites run this on an hourly basis
+ * This api cleans up all the old session entries and temp tables.
  *
- * @param array $params
- *   (reference ) - sends in various config parameters to decide what needs to be cleaned.
+ * We recommend that sites run this on an hourly basis.
  *
- * @return boolean
- *   true if success, else false
+ * @param array $params
+ *   Sends in various config parameters to decide what needs to be cleaned.
  */
 function civicrm_api3_job_cleanup($params) {
-  $session   = CRM_Utils_Array::value('session', $params, true );
-  $tempTable = CRM_Utils_Array::value('tempTables', $params, true );
-  $jobLog    = CRM_Utils_Array::value('jobLog', $params, true );
-  $prevNext  = CRM_Utils_Array::value('prevNext', $params, true );
-  $dbCache   = CRM_Utils_Array::value('dbCache', $params, false);
-  $memCache  = CRM_Utils_Array::value('memCache', $params, false);
+  $session   = CRM_Utils_Array::value('session', $params, TRUE);
+  $tempTable = CRM_Utils_Array::value('tempTables', $params, TRUE);
+  $jobLog    = CRM_Utils_Array::value('jobLog', $params, TRUE);
+  $prevNext  = CRM_Utils_Array::value('prevNext', $params, TRUE);
+  $dbCache   = CRM_Utils_Array::value('dbCache', $params, FALSE);
+  $memCache  = CRM_Utils_Array::value('memCache', $params, FALSE);
 
   if ($session || $tempTable || $prevNext) {
     CRM_Core_BAO_Cache::cleanup($session, $tempTable, $prevNext);
@@ -574,26 +571,30 @@ function civicrm_api3_job_cleanup($params) {
 
 /**
  * Set expired relationships to disabled.
- * @param $params
+ *
+ * @param array $params
+ *
  * @return array
  * @throws \API_Exception
  */
-function civicrm_api3_job_disable_expired_relationships(/** @noinspection PhpUnusedParameterInspection */
-  $params) {
+function civicrm_api3_job_disable_expired_relationships($params) {
   $result = CRM_Contact_BAO_Relationship::disableExpiredRelationships();
   if (!$result) {
     throw new API_Exception('Failed to disable all expired relationships.');
   }
-  return civicrm_api3_create_success();
+  return civicrm_api3_create_success(1, $params);
 }
 
 /**
- * This api reloads all the smart groups. If the org has a large number of smart groups
- * it is recommended that they use the limit clause to limit the number of smart groups
- * evaluated on a per job basis. Might also help to increase the smartGroupCacheTimeout
- * and use the cache
+ * This api reloads all the smart groups.
+ *
+ * If the org has a large number of smart groups it is recommended that they use the limit clause
+ * to limit the number of smart groups evaluated on a per job basis.
+ *
+ * Might also help to increase the smartGroupCacheTimeout and use the cache.
  *
  * @param array $params
+ *
  * @return array
  * @throws \API_Exception
  */
@@ -605,7 +606,7 @@ function civicrm_api3_job_group_rebuild($params) {
 
   $limit = CRM_Utils_Array::value('limit', $params, 0);
 
-  CRM_Contact_BAO_GroupContactCache::loadAll(null, $limit);
+  CRM_Contact_BAO_GroupContactCache::loadAll(NULL, $limit);
   $lock->release();
 
   return civicrm_api3_create_success();