Merge branch 4.5 into master
[civicrm-core.git] / CRM / Report / Utils / Report.php
index 4d73153b09a35406582f1bec8f704e5d1e034f9e..94667f7daea9d5a5743914099b2a67a3d2f98ab7 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /*
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
@@ -24,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -155,8 +154,8 @@ 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
@@ -191,7 +190,7 @@ WHERE  inst.report_id = %1";
 
     list($domainEmailName,
       $domainEmailAddress
-    ) = CRM_Core_BAO_Domain::getNameAndEmail();
+      ) = CRM_Core_BAO_Domain::getNameAndEmail();
 
     $params = array('id' => $instanceID);
     $instanceInfo = array();
@@ -200,13 +199,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();
@@ -252,8 +251,8 @@ WHERE  inst.report_id = %1";
     }
     // Add the headers.
     $csv .= implode($config->fieldSeparator,
-      $headers
-    ) . "\r\n";
+        $headers
+      ) . "\r\n";
 
     $displayRows = array();
     $value = NULL;
@@ -288,8 +287,8 @@ WHERE  inst.report_id = %1";
       }
       // Add the data row.
       $csv .= implode($config->fieldSeparator,
-        $displayRows
-      ) . "\r\n";
+          $displayRows
+        ) . "\r\n";
     }
 
     return $csv;
@@ -347,8 +346,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;
     }
@@ -363,9 +362,8 @@ WHERE  inst.report_id = %1";
    *
    * @param int $instanceId
    *
-   * @return boolean
+   * @return bool
    *   true if yes, else false
-   * @static
    */
   public static function isInstanceGroupRoleAllowed($instanceId) {
     if (!$instanceId) {
@@ -412,8 +410,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);
@@ -489,8 +487,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'
@@ -560,4 +558,5 @@ WHERE  report_id = %1";
     }
     return $instanceDetails[$reportUrl];
   }
+
 }