X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FSystem%2FDrupal.php;h=fda57c0385727286cb67e173ed0b285bf2121983;hb=5a604d61530b9960f810000684e3c2a6e27c7322;hp=b1e7e27a259d949570bfca3a308c9ab47d81e48e;hpb=a5ecff8d28e05ce7b2deae9fd4a0a3cc63ca853f;p=civicrm-core.git diff --git a/CRM/Utils/System/Drupal.php b/CRM/Utils/System/Drupal.php index b1e7e27a25..fda57c0385 100644 --- a/CRM/Utils/System/Drupal.php +++ b/CRM/Utils/System/Drupal.php @@ -1,7 +1,7 @@ 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. @@ -649,6 +645,33 @@ AND u.status = 1 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 * @@ -750,7 +773,8 @@ AND u.status = 1 } } 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); @@ -1041,6 +1065,32 @@ AND u.status = 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.