<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.4 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
/**
* Drupal specific stuff goes here
*/
-class CRM_Utils_System_Drupal extends CRM_Utils_System_Base {
- function __construct() {
- $this->is_drupal = TRUE;
- $this->supports_form_extensions = TRUE;
- }
+class CRM_Utils_System_Drupal extends CRM_Utils_System_DrupalBase {
/**
* Function to create a user in Drupal.
return TRUE;
}
+ /**
+ * Perform any post login activities required by the UF -
+ * e.g. for drupal: records a watchdog message about the new session, saves the login timestamp,
+ * calls hook_user op 'login' and generates a new session.
+ *
+ * @param array params
+ *
+ * FIXME: Document values accepted/required by $params
+ */
+ function userLoginFinalize($params = array()){
+ user_login_finalize($params);
+ }
+
+ /**
+ * Determine the native ID of the CMS user
+ *
+ * @param $username
+ * @return int|NULL
+ */
+ function getUfId($username) {
+ $user = user_load_by_name($username);
+ if (empty($user->uid)) {
+ return NULL;
+ }
+ return $user->uid;
+ }
+
/**
* Set a message in the UF to display to a user
*
}
}
require_once 'includes/bootstrap.inc';
- drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+ // @ to suppress notices eg 'DRUPALFOO already defined'.
+ @drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// explicitly setting error reporting, since we cannot handle drupal related notices
error_reporting(1);
}
}
+ /**
+ * 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);
+ }
+ $tzObj = new DateTimeZone($timezone);
+ $dateTime = new DateTime("now", $tzObj);
+ $tz = $tzObj->getOffset($dateTime);
+
+ if(empty($tz)){
+ return false;
+ }
+
+ $timeZoneOffset = sprintf("%02d:%02d", $tz / 3600, ($tz/60)%60 );
+
+ if($timeZoneOffset > 0){
+ $timeZoneOffset = '+' . $timeZoneOffset;
+ }
+ return $timeZoneOffset;
+ }
/**
* Reset any system caches that may be required for proper CiviCRM
* integration.