Xataface Switch User Module 0.1
Allow fast user switching for administrators of Xataface applications
|
00001 <?php 00002 /* 00003 * Xataface Switch User Module 00004 * Copyright (C) 2011 Steve Hannah <steve@weblite.ca> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Library General Public 00017 * License along with this library; if not, write to the 00018 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 * 00021 */ 00031 class modules_switch_user { 00032 00033 00040 private $baseURL = null; 00041 00042 00043 public function __construct(){ 00044 00045 00046 00047 $del = Dataface_Application::getInstance()->getDelegate(); 00048 $canSwitchUser = false; 00049 if ( method_exists($del, 'canSwitchUser') ){ 00050 $canSwitchUser = $del->canSwitchUser(); 00051 } 00052 if ( $canSwitchUser or @$_SESSION['original_user'] ){ 00053 $isOriginal = 'false'; 00054 if ( !@$_SESSION['original_user'] ) $isOriginal = 'true'; 00055 //$user = getUser(); 00056 $username = $_SESSION['UserName']; 00057 00058 00059 // Now work on our dependencies 00060 $mt = Dataface_ModuleTool::getInstance(); 00061 00062 // We require the XataJax module 00063 // The XataJax module activates and embeds the Javascript and CSS tools 00064 $mt->loadModule('modules_XataJax', 'modules/XataJax/XataJax.php'); 00065 00066 $js = Dataface_JavascriptTool::getInstance(); 00067 $js->addPath(dirname(__FILE__).DIRECTORY_SEPARATOR.'js', $this->getBaseURL().'/js'); 00068 00069 $css = Dataface_CSSTool::getInstance(); 00070 $css->addPath(dirname(__FILE__).DIRECTORY_SEPARATOR.'css', $this->getBaseURL().'/css'); 00071 $js->import('xataface/modules/switch_user/switch_user.js'); 00072 00073 } 00074 00075 } 00076 00077 00083 public function getBaseURL(){ 00084 if ( !isset($this->baseURL) ){ 00085 $this->baseURL = Dataface_ModuleTool::getInstance()->getModuleURL(__FILE__); 00086 } 00087 return $this->baseURL; 00088 } 00089 00090 }