CRM-13737 drupal integration - Use basename fn to extract last dir in the url as...
[civicrm-core.git] / CRM / Utils / System / Base.php
index 2fceed28f0b1421f39c3e7720eaf0110eec7b020..e9acb7df1a1e9e58a8b0969715213585f344cb13 100644 (file)
@@ -87,10 +87,13 @@ abstract class CRM_Utils_System_Base {
     return $url;
   }
 
-  /*
-   * Currently this is just helping out the test class as defaults is calling it - maybe move fix to defaults
+  /**
+   * Determine the location of the CMS root.
+   *
+   * @return string|NULL local file system path to CMS root, or NULL if it cannot be determined
    */
   function cmsRootPath() {
+    return NULL;
   }
 
   /**
@@ -103,6 +106,17 @@ abstract class CRM_Utils_System_Base {
    */
   public abstract function getLoginURL($destination = '');
 
+  /**
+   * Determine the native ID of the CMS user
+   *
+   * @param $username
+   * @return int|NULL
+   */
+  function getUfId($username) {
+    $className = get_class($this);
+    throw new CRM_Core_Exception("Not implemented: {$className}->getUfId");
+  }
+
   /**
    * Set a init session with user object
    *
@@ -126,12 +140,46 @@ abstract class CRM_Utils_System_Base {
   }
 
   /**
-   * Perform an 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 $edit: The array of form values submitted by the user.
+   * Return default Site Settings
+   * @return array array
+   * - $url, (Joomla - non admin url)
+   * - $siteName,
+   * - $siteRoot
+   */
+  function getDefaultSiteSettings($dir) {
+    $config = CRM_Core_Config::singleton();
+    $url = $config->userFrameworkBaseURL;
+    return array($url, NULL, NULL);
+  }
+
+  /**
+   * Perform any post login activities required by the CMS -
+   * 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.
    *
-  function userLoginFinalize($edit = array()){
+   * @param array params
+   *
+   * FIXME: Document values accepted/required by $params
+   */
+  function userLoginFinalize($params = array()){
+  }
+
+  /**
+   * Set timezone in mysql so that timestamp fields show the correct time
+   */
+  function setMySQLTimeZone(){
+    $timeZoneOffset = $this->getTimeZoneOffset();
+    if($timeZoneOffset){
+      $sql = "SET time_zone = '$timeZoneOffset'";
+      CRM_Core_DAO::executequery($sql);
+    }
+  }
+
+  /**
+   * Get timezone from CMS
+   * @return boolean|string
+   */
+  function getTimeZoneOffset(){
   }
-  */
 }