CRM-14138 report_template.get_rows api make report id optional on getrows
authorEileen <eileen@fuzion.co.nz>
Mon, 27 Jan 2014 04:57:46 +0000 (17:57 +1300)
committerEileen McNaughton <eileen@fuzion.co.nz>
Tue, 28 Jan 2014 00:21:50 +0000 (13:21 +1300)
----------------------------------------
* CRM-14138: Report_template.getrows api - make report_id OR instance_id required (currently report id is required)
  http://issues.civicrm.org/jira/browse/CRM-14138

api/v3/ReportTemplate.php

index 782190bd2d5199abb9116d445365039bf42450f9..195b8eaf4b8668e00ca9da3a2edcbf1e9b968cd0 100644 (file)
@@ -87,11 +87,16 @@ function civicrm_api3_report_template_delete($params) {
  * @access public
  */
 function civicrm_api3_report_template_getrows($params) {
+  civicrm_api3_verify_one_mandatory($params, NULL, array('report_id', 'instance_id'));
   list($rows, $instance, $labels) = _civicrm_api3_report_template_getrows($params);
   return civicrm_api3_create_success($rows, $params, 'report_template', 'getrows', CRM_Core_DAO::$_nullObject, $labels);
 }
 
 function _civicrm_api3_report_template_getrows($params) {
+  if(empty($params['report_id'])) {
+    $params['report_id'] = civicrm_api3('report_instance', 'getvalue', array('id' => $params['instance_id'], 'return' => 'report_id'));
+  }
+
   $class = civicrm_api3('option_value', 'getvalue', array(
     'option_group_id' => 'report_template',
     'return' => 'name',
@@ -139,7 +144,6 @@ function civicrm_api3_report_template_getstatistics($params) {
  */
 function _civicrm_api3_report_template_getrows_spec(&$params) {
   $params['report_id'] = array(
-    'api.required' => TRUE,
     'title' => 'Report ID - eg. member/lapse',
   );
 }