INFRA-132 - CRM/Report - phpcbf
[civicrm-core.git] / CRM / Report / Utils / Report.php
index 5ff5769c592423dcd117afd6fc39b70c24aece4b..7d8f6cb09da11d3df64b9310ce42995e0470f13a 100644 (file)
@@ -2,7 +2,7 @@
 
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  */
 class CRM_Report_Utils_Report {
 
-  static function getValueFromUrl($instanceID = NULL) {
+  /**
+   * @param int $instanceID
+   *
+   * @return null|string
+   */
+  public static function getValueFromUrl($instanceID = NULL) {
     if ($instanceID) {
       $optionVal = CRM_Core_DAO::getFieldValue('CRM_Report_DAO_ReportInstance',
         $instanceID,
@@ -57,7 +62,12 @@ class CRM_Report_Utils_Report {
     return $optionVal;
   }
 
-  static function getValueIDFromUrl($instanceID = NULL) {
+  /**
+   * @param int $instanceID
+   *
+   * @return array|bool
+   */
+  public static function getValueIDFromUrl($instanceID = NULL) {
     $optionVal = self::getValueFromUrl($instanceID);
 
     if ($optionVal) {
@@ -68,7 +78,12 @@ class CRM_Report_Utils_Report {
     return FALSE;
   }
 
-  static function getInstanceIDForValue($optionVal) {
+  /**
+   * @param $optionVal
+   *
+   * @return mixed
+   */
+  public static function getInstanceIDForValue($optionVal) {
     static $valId = array();
 
     if (!array_key_exists($optionVal, $valId)) {
@@ -82,7 +97,12 @@ WHERE  report_id = %1";
     return $valId[$optionVal];
   }
 
-  static function getInstanceIDForPath($path = NULL) {
+  /**
+   * @param null $path
+   *
+   * @return mixed
+   */
+  public static function getInstanceIDForPath($path = NULL) {
     static $valId = array();
 
     // if $path is null, try to get it from url
@@ -99,14 +119,25 @@ WHERE  TRIM(BOTH '/' FROM CONCAT(report_id, '/', name)) = %1";
     return CRM_Utils_Array::value($path, $valId);
   }
 
-  static function getNextUrl($urlValue, $query = 'reset=1', $absolute = FALSE, $instanceID = NULL, $drilldownReport = array()) {
+  /**
+   * @param $urlValue
+   * @param string $query
+   * @param bool $absolute
+   * @param int $instanceID
+   * @param array $drilldownReport
+   *
+   * @return bool|string
+   */
+  public static function getNextUrl($urlValue, $query = 'reset=1', $absolute = FALSE, $instanceID = NULL, $drilldownReport = array()) {
     if ($instanceID) {
-      $drilldownInstanceID = false;
-      if (array_key_exists($urlValue, $drilldownReport))
+      $drilldownInstanceID = FALSE;
+      if (array_key_exists($urlValue, $drilldownReport)) {
         $drilldownInstanceID = CRM_Core_DAO::getFieldValue('CRM_Report_DAO_ReportInstance', $instanceID, 'drilldown_id', 'id');
+      }
 
-      if (!$drilldownInstanceID)
+      if (!$drilldownInstanceID) {
         $drilldownInstanceID = self::getInstanceIDForValue($urlValue);
+      }
 
       if ($drilldownInstanceID) {
         return CRM_Utils_System::url("civicrm/report/instance/{$drilldownInstanceID}",
@@ -125,8 +156,14 @@ WHERE  TRIM(BOTH '/' FROM CONCAT(report_id, '/', name)) = %1";
   }
 
   // get instance count for a template
-  static function getInstanceCount($optionVal) {
-    if (empty($optionVal)) return 0;
+  /**
+   * @param $optionVal
+   *
+   * @return int|null|string
+   */
+  public static function getInstanceCount($optionVal) {
+    if (empty($optionVal)) { return 0;
+    }
 
     $sql = "
 SELECT count(inst.id)
@@ -138,8 +175,15 @@ WHERE  inst.report_id = %1";
     return $count;
   }
 
-  static function mailReport($fileContent, $instanceID = NULL, $outputMode = 'html', $attachments = array(
-    )) {
+  /**
+   * @param $fileContent
+   * @param int $instanceID
+   * @param string $outputMode
+   * @param array $attachments
+   *
+   * @return bool
+   */
+  public static function mailReport($fileContent, $instanceID = NULL, $outputMode = 'html', $attachments = array()) {
     if (!$instanceID) {
       return FALSE;
     }
@@ -173,7 +217,11 @@ WHERE  inst.report_id = %1";
     return CRM_Utils_Mail::send($params);
   }
 
-  static function export2csv(&$form, &$rows) {
+  /**
+   * @param CRM_Core_Form $form
+   * @param $rows
+   */
+  public static function export2csv(&$form, &$rows) {
     //Mark as a CSV file.
     header('Content-Type: text/csv');
 
@@ -188,7 +236,7 @@ WHERE  inst.report_id = %1";
    * Utility function for export2csv and CRM_Report_Form::endPostProcess
    * - make CSV file content and return as string.
    */
-  static function makeCsv(&$form, &$rows) {
+  public static function makeCsv(&$form, &$rows) {
     $config = CRM_Core_Config::singleton();
     $csv = '';
 
@@ -246,7 +294,10 @@ WHERE  inst.report_id = %1";
     return $csv;
   }
 
-  static function getInstanceID() {
+  /**
+   * @return mixed
+   */
+  public static function getInstanceID() {
 
     $config = CRM_Core_Config::singleton();
     $arg = explode('/', $_GET[$config->userFrameworkURLVar]);
@@ -260,7 +311,10 @@ WHERE  inst.report_id = %1";
     }
   }
 
-  static function getInstancePath() {
+  /**
+   * @return string
+   */
+  public static function getInstancePath() {
     $config = CRM_Core_Config::singleton();
     $arg = explode('/', $_GET[$config->userFrameworkURLVar]);
 
@@ -273,7 +327,12 @@ WHERE  inst.report_id = %1";
     }
   }
 
-  static function isInstancePermissioned($instanceId) {
+  /**
+   * @param int $instanceId
+   *
+   * @return bool
+   */
+  public static function isInstancePermissioned($instanceId) {
     if (!$instanceId) {
       return TRUE;
     }
@@ -301,13 +360,12 @@ WHERE  inst.report_id = %1";
    *
    * @instanceId string $str the report instance to check
    *
-   * @param $instanceId
+   * @param int $instanceId
    *
    * @return boolean true if yes, else false
    * @static
-   * @access public
    */
-  static function isInstanceGroupRoleAllowed($instanceId) {
+  public static function isInstanceGroupRoleAllowed($instanceId) {
     if (!$instanceId) {
       return TRUE;
     }
@@ -332,7 +390,12 @@ WHERE  inst.report_id = %1";
     return TRUE;
   }
 
-  static function processReport($params) {
+  /**
+   * @param array $params
+   *
+   * @return array
+   */
+  public static function processReport($params) {
     $instanceId = CRM_Utils_Array::value('instanceId', $params);
 
     // hack for now, CRM-8358
@@ -396,13 +459,14 @@ WHERE  inst.report_id = %1";
    * stipulated in $_GET or in a report Preview, but which haven't yet been
    * saved in the report instance.
    *
-   * @param array $defaults The report criteria that aren't coming in as submitted form values, as in CRM_Report_Form::_defaults
-   * @param array $params All effective report criteria, as in CRM_Report_Form::_params
+   * @param array $defaults
+   *   The report criteria that aren't coming in as submitted form values, as in CRM_Report_Form::_defaults.
+   * @param array $params
+   *   All effective report criteria, as in CRM_Report_Form::_params.
    *
    * @return string URL query string
    */
-  static function getPreviewCriteriaQueryParams($defaults = array(
-    ), $params = array()) {
+  public static function getPreviewCriteriaQueryParams($defaults = array(), $params = array()) {
     static $query_string;
     if (!isset($query_string)) {
       if (!empty($params)) {
@@ -471,7 +535,12 @@ WHERE  inst.report_id = %1";
     return $query_string;
   }
 
-  static function getInstanceList($reportUrl) {
+  /**
+   * @param $reportUrl
+   *
+   * @return mixed
+   */
+  public static function getInstanceList($reportUrl) {
     static $instanceDetails = array();
 
     if (!array_key_exists($reportUrl, $instanceDetails )) {