INFRA-132 - Move stray comments into docblocks
[civicrm-core.git] / CRM / Report / Utils / Report.php
index b69e75df694b4edc5e26ffe994f72e4a00b14c5e..a0a2bf9971e85f34c540c2ea91206a7553f43311 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 {
 
   /**
-   * @param null $instanceID
+   * @param int $instanceID
    *
    * @return null|string
    */
-  static function getValueFromUrl($instanceID = NULL) {
+  public static function getValueFromUrl($instanceID = NULL) {
     if ($instanceID) {
       $optionVal = CRM_Core_DAO::getFieldValue('CRM_Report_DAO_ReportInstance',
         $instanceID,
@@ -63,11 +63,11 @@ class CRM_Report_Utils_Report {
   }
 
   /**
-   * @param null $instanceID
+   * @param int $instanceID
    *
    * @return array|bool
    */
-  static function getValueIDFromUrl($instanceID = NULL) {
+  public static function getValueIDFromUrl($instanceID = NULL) {
     $optionVal = self::getValueFromUrl($instanceID);
 
     if ($optionVal) {
@@ -83,7 +83,7 @@ class CRM_Report_Utils_Report {
    *
    * @return mixed
    */
-  static function getInstanceIDForValue($optionVal) {
+  public static function getInstanceIDForValue($optionVal) {
     static $valId = array();
 
     if (!array_key_exists($optionVal, $valId)) {
@@ -102,7 +102,7 @@ WHERE  report_id = %1";
    *
    * @return mixed
    */
-  static function getInstanceIDForPath($path = NULL) {
+  public static function getInstanceIDForPath($path = NULL) {
     static $valId = array();
 
     // if $path is null, try to get it from url
@@ -123,19 +123,21 @@ WHERE  TRIM(BOTH '/' FROM CONCAT(report_id, '/', name)) = %1";
    * @param $urlValue
    * @param string $query
    * @param bool $absolute
-   * @param null $instanceID
+   * @param int $instanceID
    * @param array $drilldownReport
    *
    * @return bool|string
    */
-  static function getNextUrl($urlValue, $query = 'reset=1', $absolute = FALSE, $instanceID = NULL, $drilldownReport = array()) {
+  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}",
@@ -153,14 +155,16 @@ WHERE  TRIM(BOTH '/' FROM CONCAT(report_id, '/', name)) = %1";
     }
   }
 
-  // get instance count for a template
   /**
+   * get instance count for a template
    * @param $optionVal
    *
    * @return int|null|string
    */
-  static function getInstanceCount($optionVal) {
-    if (empty($optionVal)) return 0;
+  public static function getInstanceCount($optionVal) {
+    if (empty($optionVal)) {
+      return 0;
+    }
 
     $sql = "
 SELECT count(inst.id)
@@ -174,20 +178,20 @@ WHERE  inst.report_id = %1";
 
   /**
    * @param $fileContent
-   * @param null $instanceID
+   * @param int $instanceID
    * @param string $outputMode
    * @param array $attachments
    *
    * @return bool
    */
-  static function mailReport($fileContent, $instanceID = NULL, $outputMode = 'html', $attachments = array()) {
+  public static function mailReport($fileContent, $instanceID = NULL, $outputMode = 'html', $attachments = array()) {
     if (!$instanceID) {
       return FALSE;
     }
 
     list($domainEmailName,
       $domainEmailAddress
-    ) = CRM_Core_BAO_Domain::getNameAndEmail();
+      ) = CRM_Core_BAO_Domain::getNameAndEmail();
 
     $params = array('id' => $instanceID);
     $instanceInfo = array();
@@ -196,13 +200,13 @@ WHERE  inst.report_id = %1";
       $instanceInfo
     );
 
-    $params              = array();
+    $params = array();
     $params['groupName'] = 'Report Email Sender';
-    $params['from']      = '"' . $domainEmailName . '" <' . $domainEmailAddress . '>';
+    $params['from'] = '"' . $domainEmailName . '" <' . $domainEmailAddress . '>';
     //$domainEmailName;
-    $params['toName']  = "";
+    $params['toName'] = "";
     $params['toEmail'] = CRM_Utils_Array::value('email_to', $instanceInfo);
-    $params['cc']      = CRM_Utils_Array::value('email_cc', $instanceInfo);
+    $params['cc'] = CRM_Utils_Array::value('email_cc', $instanceInfo);
     $params['subject'] = CRM_Utils_Array::value('email_subject', $instanceInfo);
     if (empty($instanceInfo['attachments'])) {
       $instanceInfo['attachments'] = array();
@@ -218,7 +222,7 @@ WHERE  inst.report_id = %1";
    * @param CRM_Core_Form $form
    * @param $rows
    */
-  static function export2csv(&$form, &$rows) {
+  public static function export2csv(&$form, &$rows) {
     //Mark as a CSV file.
     header('Content-Type: text/csv');
 
@@ -233,7 +237,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 = '';
 
@@ -248,8 +252,8 @@ WHERE  inst.report_id = %1";
     }
     // Add the headers.
     $csv .= implode($config->fieldSeparator,
-      $headers
-    ) . "\r\n";
+        $headers
+      ) . "\r\n";
 
     $displayRows = array();
     $value = NULL;
@@ -284,8 +288,8 @@ WHERE  inst.report_id = %1";
       }
       // Add the data row.
       $csv .= implode($config->fieldSeparator,
-        $displayRows
-      ) . "\r\n";
+          $displayRows
+        ) . "\r\n";
     }
 
     return $csv;
@@ -294,7 +298,7 @@ WHERE  inst.report_id = %1";
   /**
    * @return mixed
    */
-  static function getInstanceID() {
+  public static function getInstanceID() {
 
     $config = CRM_Core_Config::singleton();
     $arg = explode('/', $_GET[$config->userFrameworkURLVar]);
@@ -311,7 +315,7 @@ WHERE  inst.report_id = %1";
   /**
    * @return string
    */
-  static function getInstancePath() {
+  public static function getInstancePath() {
     $config = CRM_Core_Config::singleton();
     $arg = explode('/', $_GET[$config->userFrameworkURLVar]);
 
@@ -325,11 +329,11 @@ WHERE  inst.report_id = %1";
   }
 
   /**
-   * @param $instanceId
+   * @param int $instanceId
    *
    * @return bool
    */
-  static function isInstancePermissioned($instanceId) {
+  public static function isInstancePermissioned($instanceId) {
     if (!$instanceId) {
       return TRUE;
     }
@@ -343,8 +347,8 @@ WHERE  inst.report_id = %1";
 
     if (!empty($instanceValues['permission']) &&
       (!(CRM_Core_Permission::check($instanceValues['permission']) ||
-          CRM_Core_Permission::check('administer Reports')
-        ))
+        CRM_Core_Permission::check('administer Reports')
+      ))
     ) {
       return FALSE;
     }
@@ -357,13 +361,13 @@ 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
+   * @return boolean
+   *   true if yes, else false
    * @static
-   * @access public
    */
-  static function isInstanceGroupRoleAllowed($instanceId) {
+  public static function isInstanceGroupRoleAllowed($instanceId) {
     if (!$instanceId) {
       return TRUE;
     }
@@ -393,7 +397,7 @@ WHERE  inst.report_id = %1";
    *
    * @return array
    */
-  static function processReport($params) {
+  public static function processReport($params) {
     $instanceId = CRM_Utils_Array::value('instanceId', $params);
 
     // hack for now, CRM-8358
@@ -408,8 +412,8 @@ WHERE  inst.report_id = %1";
     $messages = array("Report Mail Triggered...");
 
     $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', $optionVal, 'value');
-    $obj          = new CRM_Report_Page_Instance();
-    $is_error     = 0;
+    $obj = new CRM_Report_Page_Instance();
+    $is_error = 0;
     if (strstr(CRM_Utils_Array::value('name', $templateInfo), '_Form')) {
       $instanceInfo = array();
       CRM_Report_BAO_ReportInstance::retrieve(array('id' => $instanceId), $instanceInfo);
@@ -431,7 +435,7 @@ WHERE  inst.report_id = %1";
             'default' => 'null',
           ),
         ),
-        'ignoreKey' => TRUE
+        'ignoreKey' => TRUE,
       );
       $messages[] = $wrapper->run($templateInfo['name'], NULL, $arguments);
     }
@@ -457,12 +461,15 @@ 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
+   * @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)) {
@@ -482,8 +489,8 @@ WHERE  inst.report_id = %1";
         // (in other words, there's no point in propagating blank filters).
         foreach ($process_params as $field_name => $field_value) {
           $suffix_position = strrpos($field_name, '_');
-          $suffix          = substr($field_name, $suffix_position);
-          $basename        = substr($field_name, 0, $suffix_position);
+          $suffix = substr($field_name, $suffix_position);
+          $basename = substr($field_name, 0, $suffix_position);
           if ($suffix == '_min' || $suffix == '_max' ||
             $suffix == '_from' || $suffix == '_to' ||
             $suffix == '_relative'
@@ -536,10 +543,10 @@ WHERE  inst.report_id = %1";
    *
    * @return mixed
    */
-  static function getInstanceList($reportUrl) {
+  public static function getInstanceList($reportUrl) {
     static $instanceDetails = array();
 
-    if (!array_key_exists($reportUrl, $instanceDetails )) {
+    if (!array_key_exists($reportUrl, $instanceDetails)) {
       $instanceDetails[$reportUrl] = array();
 
       $sql = "
@@ -547,7 +554,7 @@ SELECT id, title FROM civicrm_report_instance
 WHERE  report_id = %1";
       $params = array(1 => array($reportUrl, 'String'));
       $result = CRM_Core_DAO::executeQuery($sql, $params);
-      while$result->fetch()) {
+      while ($result->fetch()) {
         $instanceDetails[$reportUrl][$result->id] = $result->title . " (ID: {$result->id})";
       }
     }