Merge pull request #2137 from pradpnayak/CRM-13310
[civicrm-core.git] / CRM / Utils / System / Drupal6.php
index 23fca40ec79ebb0cc2fef894d126f9fa28f3a80c..e5b6a1d66d4ff0dba661d69524a3a4613c8b14e2 100644 (file)
@@ -180,7 +180,7 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
     if (!$row) {
       return;
     }
+
     $user = NULL;
 
     if (!empty($row)) {
@@ -339,7 +339,7 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
         return FALSE;
     }
     // If the path is within the drupal directory we can add in the normal way
-    if (CRM_Utils_System_Drupal::formatResourceUrl($url)) {
+    if ($this->formatResourceUrl($url)) {
       drupal_add_js($url, 'module', $scope);
       return TRUE;
     }
@@ -384,7 +384,7 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
    * @access public
    */
   public function addStyleUrl($url, $region) {
-    if ($region != 'html-header' || !CRM_Utils_System_Drupal::formatResourceUrl($url)) {
+    if ($region != 'html-header' || !$this->formatResourceUrl($url)) {
       return FALSE;
     }
     drupal_add_css($url);
@@ -1016,6 +1016,29 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
       og_delete_subscription( $ogID, $drupalID );
   }
 
+  /**
+   * Get timezone from Drupal
+   * @return boolean|string
+   */
+  function getTimeZoneOffset(){
+    global $user;
+    if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
+      $timezone = $user->timezone;
+    } else {
+      $timezone = variable_get('date_default_timezone', null);
+    }
+    if(empty($timezone)){
+      return false;
+    }
+    $hour = $user->timezone / 3600;
+    $timeZoneOffset = sprintf("%02d:%02d", $timezone / 3600, ($timezone/60)%60 );
+    if($timeZoneOffset > 0){
+      $timeZoneOffset = '+' . $timeZoneOffset;
+    }
+    return $timeZoneOffset;
+  }
+
+
   /**
    * Reset any system caches that may be required for proper CiviCRM
    * integration.