diff --git a/phpgwapi/inc/class.accounts_sql.inc.php b/phpgwapi/inc/class.accounts_sql.inc.php
index 3e08ff3930..79234d8491 100644
--- a/phpgwapi/inc/class.accounts_sql.inc.php
+++ b/phpgwapi/inc/class.accounts_sql.inc.php
@@ -90,10 +90,6 @@ class accounts_sql
{
$this->db = $GLOBALS['egw']->db;
}
- if (!is_object($GLOBALS['egw']->acl))
- {
- $GLOBALS['egw']->acl =& CreateObject('phpgwapi.acl');
- }
}
/**
@@ -162,10 +158,6 @@ class accounts_sql
// encrypt password if given or unset it if not
if ($data['account_passwd'])
{
- if (!is_object($GLOBALS['egw']->auth))
- {
- $GLOBALS['egw']->auth =& CreateObject('phpgwapi.auth');
- }
// if password it's not already entcrypted, do so now
if (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$data['account_passwd']) &&
!preg_match('/^[0-9a-f]{32}$/',$data['account_passwd'])) // md5 hash
@@ -222,10 +214,6 @@ class accounts_sql
}
if ($contact_id)
{
- if (!is_object($GLOBALS['egw']->contacts))
- {
- $GLOBALS['egw']->contacts =& CreateObject('phpgwapi.contacts');
- }
$GLOBALS['egw']->contacts->delete($contact_id,false); // false = allow to delete accounts (!)
}
return true;
@@ -332,10 +320,6 @@ class accounts_sql
function get_list($_type='both', $start = null,$sort = '', $order = '', $query = '', $offset = null, $query_type='')
{
//echo "
accounts_sql($_type,$start,$sort,$order,$query,$offset,$query_type)
\n";
- if (!is_object($GLOBALS['egw']->contacts))
- {
- $GLOBALS['egw']->contacts =& CreateObject('phpgwapi.contacts');
- }
static $order2contact = array(
'account_firstname' => 'n_given',
'account_lastname' => 'n_family',
diff --git a/phpgwapi/inc/class.common.inc.php b/phpgwapi/inc/class.common.inc.php
index bbbe04d322..553eab9101 100644
--- a/phpgwapi/inc/class.common.inc.php
+++ b/phpgwapi/inc/class.common.inc.php
@@ -312,36 +312,6 @@
exit;
}
- function egw_final()
- {
- if (!defined('EGW_FINAL'))
- {
- define('EGW_FINAL',True);
-
- if (is_object($GLOBALS['egw']->accounts))
- {
- $GLOBALS['egw']->accounts->save_session_cache();
- }
- if (is_object($GLOBALS['egw']->link))
- {
- $GLOBALS['egw']->link->save_session_cache();
- }
- // call the asyncservice check_run function if it is not explicitly set to cron-only
- //
- if (!$GLOBALS['egw_info']['server']['asyncservice']) // is default
- {
- ExecMethod('phpgwapi.asyncservice.check_run','fallback');
- }
- /* Clean up mcrypt */
- if (@is_object($GLOBALS['egw']->crypto))
- {
- $GLOBALS['egw']->crypto->cleanup();
- unset($GLOBALS['egw']->crypto);
- }
- $GLOBALS['egw']->db->disconnect();
- }
- }
-
/**
* return a random string of size $size
*
diff --git a/phpgwapi/inc/class.egw.inc.php b/phpgwapi/inc/class.egw.inc.php
index 3405e79883..e923e182eb 100644
--- a/phpgwapi/inc/class.egw.inc.php
+++ b/phpgwapi/inc/class.egw.inc.php
@@ -1,521 +1,561 @@
datetime)
+ * {
+ * $GLOBALS['egw']->datetime = CreateObject('phpgwapi.datetime');
+ * }
+ * You can now simply use $GLOBALS['egw']->datetime, and the egw class instanciates it for you on demand.
+ */
+class egw
+{
/**
- * New written class to create the eGW enviroment AND restore it from a php-session
- *
- * @author RalfBecker@outdoor-training.de
- * @copyright GPL
- * @package api
+ * Turn on debug mode. Will output additional data for debugging purposes.
+ * @var string
* @access public
*/
- class egw
+ var $debug = 0; // This will turn on debugging information.
+ /**
+ * Instance of the db-object
+ *
+ * @var egw_db
+ */
+ var $db;
+ /**
+ * Instance of the account object
+ *
+ * @var accounts
+ */
+ var $accounts;
+ /**
+ * Instace of the common object
+ *
+ * @var common
+ */
+ var $common;
+ /**
+ * Current app at the instancation of the class
+ *
+ * @var string
+ */
+ var $currentapp;
+
+ /**
+ * Constructor: Instantiates the sub-classes
+ *
+ * @author RalfBecker@outdoor-training.de
+ * @param array $domain_names array with valid egw-domain names
+ */
+ function __construct($domain_names=null)
{
- /**
- * Turn on debug mode. Will output additional data for debugging purposes.
- * @var string
- * @access public
- */
- var $debug = 0; // This will turn on debugging information.
- /**
- * Instance of the db-object
- *
- * @var egw_db
- */
- var $db;
- var $config_table = 'egw_config';
- /**
- * Instance of the account object
- *
- * @var accounts
- */
- var $accounts;
- /**
- * Instace of the common object
- *
- * @var common
- */
- var $common;
+ $GLOBALS['egw'] =& $this; // we need to be immediately available there for the other classes we instantiate
+ // for the migration: reference us to the old phpgw object
+ $GLOBALS['phpgw'] =& $this;
+ $this->setup($domain_names,True);
+ }
- /**
- * savant2 templating object
- *
- * @var tplsavant2
- */
- var $tplsav2;
-
- /**
- * Constructor: Instantiates the sub-classes
- *
- * @author RalfBecker@outdoor-training.de
- * @param array $domain_names array with valid egw-domain names
- */
- function egw($domain_names=null)
+ /**
+ * Called every time the constructor is called. Also called by sessions to ensure the correct db,
+ * in which case we do not recreate the session object.
+ * @author RalfBecker@outdoor-training.de (moved to setup() by milos@groupwhere.org
+ * @param array $domain_names array with valid egw-domain names
+ * @param boolean $createsessionobject True to create the session object (default=True)
+ */
+ function setup($domain_names,$createsessionobject=True)
+ {
+ // create the DB-object
+ $this->db = new egw_db();
+ if ($this->debug)
{
- $GLOBALS['egw'] =& $this; // we need to be immediately available there for the other classes we instantiate
- // for the migration: reference us to the old phpgw object
- $GLOBALS['phpgw'] =& $this;
- $this->setup($domain_names,True);
+ $this->db->Debug = 1;
}
+ $this->db->set_app('phpgwapi');
- /**
- * Called every time the constructor is called. Also called by sessions to ensure the correct db,
- * in which case we do not recreate the session object.
- * @author RalfBecker@outdoor-training.de (moved to setup() by milos@groupwhere.org
- * @param array $domain_names array with valid egw-domain names
- * @param boolean $createsessionobject True to create the session object (default=True)
- */
- function setup($domain_names,$createsessionobject=True)
+ $this->db->Halt_On_Error = 'no';
+ $this->db->connect(
+ $GLOBALS['egw_info']['server']['db_name'],
+ $GLOBALS['egw_info']['server']['db_host'],
+ $GLOBALS['egw_info']['server']['db_port'],
+ $GLOBALS['egw_info']['server']['db_user'],
+ $GLOBALS['egw_info']['server']['db_pass'],
+ $GLOBALS['egw_info']['server']['db_type']
+ );
+ // check if eGW is already setup, if not redirect to setup/
+ if (!$this->db->select(config::TABLE,'COUNT(config_name)',false,__LINE__,__FILE__)->fetchSingle())
{
- // create the DB-object
- $this->db =& CreateObject('phpgwapi.egw_db');
- if ($this->debug)
+ $setup_dir = str_replace($_SERVER['PHP_SELF'],'index.php','setup/');
+
+ // we check for the old table too, to not scare updating users ;-)
+ if ($this->db->select('phpgw_config','COUNT(config_name)',false,__LINE__,__FILE__)->fetchSingle())
{
- $this->db->Debug = 1;
- }
- $this->db->set_app('phpgwapi');
-
- $this->db->Halt_On_Error = 'no';
- $this->db->connect(
- $GLOBALS['egw_info']['server']['db_name'],
- $GLOBALS['egw_info']['server']['db_host'],
- $GLOBALS['egw_info']['server']['db_port'],
- $GLOBALS['egw_info']['server']['db_user'],
- $GLOBALS['egw_info']['server']['db_pass'],
- $GLOBALS['egw_info']['server']['db_type']
- );
- // check if eGW is already setup, if not redirect to setup/
- $this->db->select($this->config_table,'COUNT(config_name)',false,__LINE__,__FILE__);
- if(!$this->db->next_record())
- {
- $setup_dir = str_replace($_SERVER['PHP_SELF'],'index.php','setup/');
-
- // we check for the old table too, to not scare updating users ;-)
- $this->db->select('phpgw_config','COUNT(config_name)',false,__LINE__,__FILE__);
- if ($this->db->next_record())
- {
- throw new Exception('Fatal Error: You need to update eGroupWare before you can continue using it.',999);
- }
- else
- {
- throw new Exception('Fatal Error: It appears that you have not created the database tables for '
- .'eGroupWare. Click here to run setup.',999);
- }
- exit;
- }
- $this->db->Halt_On_Error = 'yes';
-
- // Set the DB's client charset if a system-charset is set
- $this->db->select($this->config_table,'config_value',array(
- 'config_app' => 'phpgwapi',
- 'config_name' => 'system_charset',
- ),__LINE__,__FILE__);
- if ($this->db->next_record() && $this->db->f(0))
- {
- $this->db->Link_ID->SetCharSet($this->db->f(0));
- }
- // load up the $GLOBALS['egw_info']['server'] array
- $this->db->select($this->config_table,'*',array('config_app' => 'phpgwapi'),__LINE__,__FILE__);
- while (($row = $this->db->row(true)))
- {
- $GLOBALS['egw_info']['server'][$row['config_name']] = stripslashes($row['config_value']);
- }
- // setup the other subclasses
- $this->log =& CreateObject('phpgwapi.errorlog');
- $this->translation =& CreateObject('phpgwapi.translation');
- $this->common =& CreateObject('phpgwapi.common');
- $this->hooks =& CreateObject('phpgwapi.hooks');
- $this->auth =& CreateObject('phpgwapi.auth');
- # maybe we can also include this file at another place
- # with PHP5 we can also use autoloading now
- include_once(EGW_INCLUDE_ROOT.'/phpgwapi/inc/class.accounts.inc.php');
- $this->accounts = accounts::getInstance();
- $this->acl =& CreateObject('phpgwapi.acl');
- /* Do not create the session object if called by the sessions class. This way
- * we ensure the correct db based on the user domain.
- */
- if($createsessionobject)
- {
- $this->session =& CreateObject('phpgwapi.sessions',$domain_names);
- }
- $this->preferences =& CreateObject('phpgwapi.preferences');
- $this->applications =& CreateObject('phpgwapi.applications');
- $this->contenthistory =& CreateObject('phpgwapi.contenthistory');
- $this->datetime =& CreateObject('phpgwapi.egw_datetime');
-
- include_once(EGW_INCLUDE_ROOT.'/phpgwapi/inc/class.error.inc.php');
-
- register_shutdown_function(array($this->common, 'egw_final'));
-
- if ($GLOBALS['egw_info']['flags']['currentapp'] != 'login' && $GLOBALS['egw_info']['flags']['currentapp'] != 'logout')
- {
- $this->verify_session();
- $this->applications->read_installed_apps(); // to get translated app-titles, has to be after verify_session
-
- $this->define_egw_constants();
-
- // setup the new eGW framework (template sets)
- $class = $GLOBALS['egw_info']['server']['template_set'].'_framework';
- require_once(EGW_INCLUDE_ROOT . '/phpgwapi/templates/' . $GLOBALS['egw_info']['server']['template_set'].
- '/class.'.$class.'.inc.php');
- $this->framework = new $class; // =& removed because of problems with php4, does not matter with php5 anyway!
-
- $this->check_app_rights();
-
- $this->load_optional_classes();
- }
- else // set the defines for login, in case it's more then just login
- {
- $this->define_egw_constants();
- }
- }
-
- /**
- * __wakeup function gets called by php while unserializing the egw-object, eg. reconnects to the DB
- *
- * @author RalfBecker@outdoor-training.de
- */
- function __wakeup()
- {
- $GLOBALS['egw'] =& $this; // we need to be immediately available there for the other classes we instantiate
- // for the migration: reference us to the old phpgw object
- $GLOBALS['phpgw'] =& $this;
- register_shutdown_function(array($this->common, 'egw_final'));
-
- $this->db->connect(); // we need to re-connect
- // Set the DB's client charset if a system-charset is set
- $this->db->select($this->config_table,'config_value',array(
- 'config_app' => 'phpgwapi',
- 'config_name' => 'system_charset',
- ),__LINE__,__FILE__);
- if ($this->db->next_record() && $this->db->f(0))
- {
- $this->db->Link_ID->SetCharSet($this->db->f(0));
- }
-
- if ($GLOBALS['egw_info']['system']['system_charset'])
- {
- $this->db->Link_ID->SetCharSet($GLOBALS['egw_info']['system']['system_charset']);
- }
- foreach(array('translation','hooks','auth','accounts','acl','session','preferences','applications','contenthistory','contacts') as $class)
- {
- if (is_object($this->$class->db))
- {
- $this->$class->db->Link_ID =& $this->db->Link_ID;
- }
- }
- $this->define_egw_constants();
- }
-
- /**
- * wakeup2 funcontion needs to be called after unserializing the egw-object
- *
- * It adapts the restored object/enviroment to the changed (current) application / page-request
- *
- * @author RalfBecker@outdoor-training.de
- */
- function wakeup2()
- {
- // do some application specific stuff, need to be done as we are different (current) app now
- if (is_object($this->template))
- {
- $this->template->set_root(EGW_APP_TPL);
- }
- $this->translation->add_app($GLOBALS['egw_info']['flags']['currentapp']);
-
- // verify the session
- $GLOBALS['egw']->verify_session();
- $GLOBALS['egw']->check_app_rights();
-
- $this->load_optional_classes();
- }
-
- /**
- * load optional classes by mentioning them in egw_info[flags][enable_CLASS_class] => true
- *
- * Also loads the template-class if not egw_info[flags][disable_Template_class] is set
- *
- * Maybe the whole thing should be depricated ;-)
- */
- function load_optional_classes()
- {
- // load classes explicitly mentioned
- foreach($GLOBALS['egw_info']['flags'] as $enable_class => $enable)
- {
- if ($enable && substr($enable_class,0,7) == 'enable_')
- {
- $enable_class = substr($enable_class,7,-6);
- $this->$enable_class =& CreateObject('phpgwapi.'.$enable_class);
- }
- }
-
- // load the template class, if not turned off
- if(!$GLOBALS['egw_info']['flags']['disable_Template_class'])
- {
- $this->template =& CreateObject('phpgwapi.Template',EGW_APP_TPL);
- }
-
- // output the header unless the developer turned it off
- if (!@$GLOBALS['egw_info']['flags']['noheader'])
- {
- $GLOBALS['egw']->common->egw_header();
- }
-
- // Load the (depricated) app include files if they exists
- if (EGW_APP_INC != "" && ! preg_match ('/phpgwapi/i', EGW_APP_INC) &&
- file_exists(EGW_APP_INC . '/functions.inc.php') && !isset($_GET['menuaction']))
- {
- include(EGW_APP_INC . '/functions.inc.php');
- }
- if (!@$GLOBALS['egw_info']['flags']['noheader'] && !@$GLOBALS['egw_info']['flags']['noappheader'] &&
- file_exists(EGW_APP_INC . '/header.inc.php') && !isset($_GET['menuaction']))
- {
- include(EGW_APP_INC . '/header.inc.php');
- }
- }
-
- /**
- * Verfiy there is a valid session
- *
- * One can specify a callback, which gets called if there's no valid session. If the callback returns true, the parameter
- * containst account-details (in keys login, passwd and passwd_type) to automatic create an (anonymous session)
- *
- * It also checks if enforce_ssl is set in the DB and redirects to the https:// version of the site.
- *
- * If there is no valid session and none could be automatic created, the function will redirect to login and NOT return
- */
- function verify_session()
- {
- if(isset($GLOBALS['egw_info']['server']['enforce_ssl']) && !$_SERVER['HTTPS'])
- {
- Header('Location: https://' . $GLOBALS['egw_info']['server']['hostname'] . $GLOBALS['egw_info']['server']['webserver_url'] . $_SERVER['REQUEST_URI']);
- exit;
- }
- // check if we have a session, if not try to automatic create one
- if ($this->session->verify()) return true;
-
- if (($account_callback = $GLOBALS['egw_info']['flags']['autocreate_session_callback']) && function_exists($account_callback) &&
- ($sessionid = $account_callback($account)) === true) // $account_call_back returns true, false or a session-id
- {
- $sessionid = $this->session->create($account);
- }
- if (!$sessionid)
- {
- //echo "account_callback='$account_callback', account=".print_r($account,true).", sessionid=$sessionid
\n"; exit;
- // we forward to the same place after the re-login
- if ($GLOBALS['egw_info']['server']['webserver_url'] && $GLOBALS['egw_info']['server']['webserver_url'] != '/')
- {
- list(,$relpath) = explode($GLOBALS['egw_info']['server']['webserver_url'],$_SERVER['PHP_SELF'],2);
- }
- else // the webserver-url is empty or just a slash '/' (eGW is installed in the docroot and no domain given)
- {
- if (preg_match('/^https?:\/\/[^\/]*\/(.*)$/',$relpath=$_SERVER['PHP_SELF'],$matches))
- {
- $relpath = $matches[1];
- }
- }
- // this removes the sessiondata if its saved in the URL
- $query = preg_replace('/[&]?sessionid(=|%3D)[^&]+&kp3(=|%3D)[^&]+&domain=.*$/','',$_SERVER['QUERY_STRING']);
- Header('Location: '.$GLOBALS['egw_info']['server']['webserver_url'].'/login.php?cd=10&phpgw_forward='.urlencode($relpath.(!empty($query) ? '?'.$query : '')));
- exit;
- }
- }
-
- /**
- * Verify the user has rights for the requested app
- *
- * If the user has no rights for the app (eg. called via URL) he get a permission denied page (this function does NOT return)
- */
- function check_app_rights()
- {
- if ($GLOBALS['egw_info']['flags']['currentapp'] != 'about')
- {
- // This will need to use ACL in the future
- if (!$GLOBALS['egw_info']['user']['apps'][$currentapp = $GLOBALS['egw_info']['flags']['currentapp']] ||
- ($GLOBALS['egw_info']['flags']['admin_only'] && !$GLOBALS['egw_info']['user']['apps']['admin']))
- {
- if ($currentapp == 'admin' || $GLOBALS['egw_info']['flags']['admin_only'])
- {
- throw new egw_exception_no_permission_admin();
- }
- else
- {
- throw new egw_exception_no_permission_app($currentapp);
- }
- // old code no longer called
- $this->common->egw_header();
- if ($GLOBALS['egw_info']['flags']['nonavbar'])
- {
- echo parse_navbar();
- }
- error_log('Permission denied, attempted to access '.$GLOBALS['egw_info']['flags']['currentapp']);
- $this->log->write(array('text'=>'W-Permissions, Attempted to access %1','p1'=>$GLOBALS['egw_info']['flags']['currentapp']));
-
- $this->tplsav2 = CreateObject('phpgwapi.tplsavant2'); // create it only when neccessary
- $this->tplsav2->assign('currentapp',$GLOBALS['egw_info']['flags']['currentapp']);
- $this->tplsav2->set_tpl_path($this->tplsav2->get_tpl_dir(false,'phpgwapi'));
- $this->tplsav2->display('appl_access_not_permitted.tpl.php');
- $this->common->egw_exit(True);
- }
- }
- }
-
- /**
- * create all the defines / constants of the eGW-environment (plus the deprecated phpgw ones)
- */
- function define_egw_constants()
- {
- define('SEP',filesystem_separator());
- define('EGW_ACL_READ',1);
- define('EGW_ACL_ADD',2);
- define('EGW_ACL_EDIT',4);
- define('EGW_ACL_DELETE',8);
- define('EGW_ACL_PRIVATE',16);
- define('EGW_ACL_GROUP_MANAGERS',32);
- define('EGW_ACL_CUSTOM_1',64);
- define('EGW_ACL_CUSTOM_2',128);
- define('EGW_ACL_CUSTOM_3',256);
- // and the old ones
- define('PHPGW_ACL_READ',1);
- define('PHPGW_ACL_ADD',2);
- define('PHPGW_ACL_EDIT',4);
- define('PHPGW_ACL_DELETE',8);
- define('PHPGW_ACL_PRIVATE',16);
- define('PHPGW_ACL_GROUP_MANAGERS',32);
- define('PHPGW_ACL_CUSTOM_1',64);
- define('PHPGW_ACL_CUSTOM_2',128);
- define('PHPGW_ACL_CUSTOM_3',256);
- // A few hacker resistant constants that will be used throught the program
- define('EGW_TEMPLATE_DIR', $this->common->get_tpl_dir('phpgwapi'));
- define('EGW_IMAGES_DIR', $this->common->get_image_path('phpgwapi'));
- define('EGW_IMAGES_FILEDIR', $this->common->get_image_dir('phpgwapi'));
- define('EGW_APP_ROOT', $this->common->get_app_dir());
- define('EGW_APP_INC', $this->common->get_inc_dir());
- define('EGW_APP_TPL', $this->common->get_tpl_dir());
- define('EGW_IMAGES', $this->common->get_image_path());
- define('EGW_APP_IMAGES_DIR', $this->common->get_image_dir());
- // and the old ones
- define('PHPGW_TEMPLATE_DIR',EGW_TEMPLATE_DIR);
- define('PHPGW_IMAGES_DIR',EGW_IMAGES_DIR);
- define('PHPGW_IMAGES_FILEDIR',EGW_IMAGES_FILEDIR);
- define('PHPGW_APP_ROOT',EGW_APP_ROOT);
- define('PHPGW_APP_INC',EGW_APP_INC);
- define('PHPGW_APP_TPL',EGW_APP_TPL);
- define('PHPGW_IMAGES',EGW_IMAGES);
- define('PHPGW_APP_IMAGES_DIR',EGW_APP_IMAGES_DIR);
- }
-
- /**
- * force the session cache to be re-created, because some of it's data changed
- *
- * Needs to be called if user-preferences, system-config or enabled apps of the current user have been changed and
- * the change should have immediate effect
- */
- function invalidate_session_cache()
- {
- unset($_SESSION['egw_info_cache']);
- unset($_SESSION['egw_included_files']);
- unset($_SESSION['egw_object_cache']);
- }
-
- /**
- * run string through htmlspecialchars and stripslashes
- *
- * @param string $s
- * @return string The string with html special characters replaced with entities
- */
- function strip_html($s)
- {
- return htmlspecialchars(stripslashes($s));
- }
-
- /**
- * Link url generator
- *
- * Used for backwards compatibility and as a shortcut. If no url is passed, it will use PHP_SELF. Wrapper to session->link()
- *
- * @param string $string The url the link is for
- * @param string/array $extravars Extra params to be passed to the url
- * @return string The full url after processing
- */
- function link($url = '', $extravars = '')
- {
- return $this->session->link($url, $extravars);
- }
-
- function redirect_link($url = '',$extravars='')
- {
- $this->redirect($this->session->link($url, $extravars));
- }
-
- /**
- * Handles redirects under iis and apache, it does NOT return (calls exit)
- *
- * This function handles redirects under iis and apache it assumes that $phpgw->link() has already been called
- *
- * @param string The url ro redirect to
- */
- function redirect($url = '')
- {
- /* global $HTTP_ENV_VARS; */
-
- $iis = @strpos($GLOBALS['HTTP_ENV_VARS']['SERVER_SOFTWARE'], 'IIS', 0);
-
- if(!$url)
- {
- $url = $_SERVER['PHP_SELF'];
- }
- if($iis)
- {
- echo "\n\n\nRedirecting to $url";
- echo "\n";
- echo "\n";
- echo "Please continue to this page
";
- echo "\n";
+ throw new Exception('Fatal Error: You need to update eGroupWare before you can continue using it.',999);
}
else
{
- Header("Location: $url");
- print("\n\n");
+ throw new Exception('Fatal Error: It appears that you have not created the database tables for '
+ .'eGroupWare. Click here to run setup.',999);
}
exit;
}
+ $this->db->Halt_On_Error = 'yes';
- /**
- * Shortcut to translation class
- *
- * This function is a basic wrapper to translation->translate()
- *
- * @deprecated only used in the old timetracker
- * @param string The key for the phrase
- * @see translation->translate()
- */
- function lang($key,$args=null)
+ // Set the DB's client charset if a system-charset is set
+ $system_charset = $this->db->select(config::TABLE,'config_value',array(
+ 'config_app' => 'phpgwapi',
+ 'config_name' => 'system_charset',
+ ),__LINE__,__FILE__)->fetchSingle();
+ if ($system_charset)
{
- if (!is_array($args))
- {
- $args = func_get_args();
- array_shift($args);
- }
- return $this->translation->translate($key,$args);
+ $this->db->Link_ID->SetCharSet($system_charset);
+ }
+ // load up the $GLOBALS['egw_info']['server'] array
+ foreach($this->db->select(config::TABLE,'*',array('config_app' => 'phpgwapi'),__LINE__,__FILE__) as $row)
+ {
+ $GLOBALS['egw_info']['server'][$row['config_name']] = stripslashes($row['config_value']);
+ }
+ //$GLOBALS['egw_info']['server'] = config::read('phpgwapi'); would unserialize arrays
+
+ // setup the other subclasses
+ $this->translation = new translation();
+ $this->common = new common();
+ $this->auth = new auth();
+ $this->accounts = accounts::getInstance();
+ $this->acl = new acl();
+ /* Do not create the session object if called by the sessions class. This way
+ * we ensure the correct db based on the user domain.
+ */
+ if($createsessionobject)
+ {
+ $this->session = new sessions($domain_names);
+ }
+ $this->preferences = new preferences();
+ $this->applications = new applications();
+
+ register_shutdown_function(array($this, 'shutdown'));
+
+ if ($GLOBALS['egw_info']['flags']['currentapp'] != 'login' && $GLOBALS['egw_info']['flags']['currentapp'] != 'logout')
+ {
+ $this->verify_session();
+ $this->applications->read_installed_apps(); // to get translated app-titles, has to be after verify_session
+
+ $this->define_egw_constants();
+
+ $this->check_app_rights();
+
+ $this->load_optional_classes();
+ }
+ else // set the defines for login, in case it's more then just login
+ {
+ $this->define_egw_constants();
}
}
+
+ /**
+ * __wakeup function gets called by php while unserializing the egw-object, eg. reconnects to the DB
+ *
+ * @author RalfBecker@outdoor-training.de
+ */
+ function __wakeup()
+ {
+ $GLOBALS['egw'] =& $this; // we need to be immediately available there for the other classes we instantiate
+ // for the migration: reference us to the old phpgw object
+ $GLOBALS['phpgw'] =& $this;
+
+ if ($GLOBALS['egw_info']['server']['system_charset'])
+ {
+ $this->db->Link_ID->SetCharSet($GLOBALS['egw_info']['server']['system_charset']);
+ }
+
+ register_shutdown_function(array($this, 'shutdown'));
+
+ $this->define_egw_constants();
+ }
+
+ /**
+ * wakeup2 funcontion needs to be called after unserializing the egw-object
+ *
+ * It adapts the restored object/enviroment to the changed (current) application / page-request
+ *
+ * @author RalfBecker@outdoor-training.de
+ */
+ function wakeup2()
+ {
+ // do some application specific stuff, need to be done as we are different (current) app now
+ if (isset($this->template))
+ {
+ $this->template->set_root(EGW_APP_TPL);
+ }
+ $this->translation->add_app($GLOBALS['egw_info']['flags']['currentapp']);
+
+ // verify the session
+ $GLOBALS['egw']->verify_session();
+ $GLOBALS['egw']->check_app_rights();
+
+ $this->load_optional_classes();
+ }
+
+ /**
+ * load optional classes by mentioning them in egw_info[flags][enable_CLASS_class] => true
+ *
+ * Also loads the template-class if not egw_info[flags][disable_Template_class] is set
+ *
+ * Maybe the whole thing should be depricated ;-)
+ */
+ function load_optional_classes()
+ {
+ // output the header unless the developer turned it off
+ if (!@$GLOBALS['egw_info']['flags']['noheader'])
+ {
+ $GLOBALS['egw']->common->egw_header();
+ }
+
+ // Load the (depricated) app include files if they exists
+ if (EGW_APP_INC != "" && ! preg_match ('/phpgwapi/i', EGW_APP_INC) &&
+ file_exists(EGW_APP_INC . '/functions.inc.php') && !isset($_GET['menuaction']))
+ {
+ include(EGW_APP_INC . '/functions.inc.php');
+ }
+ if (!@$GLOBALS['egw_info']['flags']['noheader'] && !@$GLOBALS['egw_info']['flags']['noappheader'] &&
+ file_exists(EGW_APP_INC . '/header.inc.php') && !isset($_GET['menuaction']))
+ {
+ include(EGW_APP_INC . '/header.inc.php');
+ }
+ }
+
+ /**
+ * Verfiy there is a valid session
+ *
+ * One can specify a callback, which gets called if there's no valid session. If the callback returns true, the parameter
+ * containst account-details (in keys login, passwd and passwd_type) to automatic create an (anonymous session)
+ *
+ * It also checks if enforce_ssl is set in the DB and redirects to the https:// version of the site.
+ *
+ * If there is no valid session and none could be automatic created, the function will redirect to login and NOT return
+ */
+ function verify_session()
+ {
+ if(isset($GLOBALS['egw_info']['server']['enforce_ssl']) && !$_SERVER['HTTPS'])
+ {
+ Header('Location: https://' . $GLOBALS['egw_info']['server']['hostname'] . $GLOBALS['egw_info']['server']['webserver_url'] . $_SERVER['REQUEST_URI']);
+ exit;
+ }
+ // check if we have a session, if not try to automatic create one
+ if ($this->session->verify()) return true;
+
+ if (($account_callback = $GLOBALS['egw_info']['flags']['autocreate_session_callback']) && function_exists($account_callback) &&
+ ($sessionid = $account_callback($account)) === true) // $account_call_back returns true, false or a session-id
+ {
+ $sessionid = $this->session->create($account);
+ }
+ if (!$sessionid)
+ {
+ //echo "account_callback='$account_callback', account=".print_r($account,true).", sessionid=$sessionid
\n"; exit;
+ // we forward to the same place after the re-login
+ if ($GLOBALS['egw_info']['server']['webserver_url'] && $GLOBALS['egw_info']['server']['webserver_url'] != '/')
+ {
+ list(,$relpath) = explode($GLOBALS['egw_info']['server']['webserver_url'],$_SERVER['PHP_SELF'],2);
+ }
+ else // the webserver-url is empty or just a slash '/' (eGW is installed in the docroot and no domain given)
+ {
+ if (preg_match('/^https?:\/\/[^\/]*\/(.*)$/',$relpath=$_SERVER['PHP_SELF'],$matches))
+ {
+ $relpath = $matches[1];
+ }
+ }
+ // this removes the sessiondata if its saved in the URL
+ $query = preg_replace('/[&]?sessionid(=|%3D)[^&]+&kp3(=|%3D)[^&]+&domain=.*$/','',$_SERVER['QUERY_STRING']);
+ Header('Location: '.$GLOBALS['egw_info']['server']['webserver_url'].'/login.php?cd=10&phpgw_forward='.urlencode($relpath.(!empty($query) ? '?'.$query : '')));
+ exit;
+ }
+ }
+
+ /**
+ * Verify the user has rights for the requested app
+ *
+ * If the user has no rights for the app (eg. called via URL) he get a permission denied page (this function does NOT return)
+ */
+ function check_app_rights()
+ {
+ $this->currentapp = $GLOBALS['egw_info']['flags']['currentapp']; // some apps change it later
+
+ if ($GLOBALS['egw_info']['flags']['currentapp'] != 'about')
+ {
+ // This will need to use ACL in the future
+ if (!$GLOBALS['egw_info']['user']['apps'][$currentapp = $GLOBALS['egw_info']['flags']['currentapp']] ||
+ ($GLOBALS['egw_info']['flags']['admin_only'] && !$GLOBALS['egw_info']['user']['apps']['admin']))
+ {
+ if ($currentapp == 'admin' || $GLOBALS['egw_info']['flags']['admin_only'])
+ {
+ throw new egw_exception_no_permission_admin();
+ }
+ throw new egw_exception_no_permission_app($currentapp);
+ }
+ }
+ }
+
+ /**
+ * create all the defines / constants of the eGW-environment (plus the deprecated phpgw ones)
+ */
+ function define_egw_constants()
+ {
+ define('SEP',filesystem_separator());
+ define('EGW_ACL_READ',1);
+ define('EGW_ACL_ADD',2);
+ define('EGW_ACL_EDIT',4);
+ define('EGW_ACL_DELETE',8);
+ define('EGW_ACL_PRIVATE',16);
+ define('EGW_ACL_GROUP_MANAGERS',32);
+ define('EGW_ACL_CUSTOM_1',64);
+ define('EGW_ACL_CUSTOM_2',128);
+ define('EGW_ACL_CUSTOM_3',256);
+ // and the old ones
+ define('PHPGW_ACL_READ',1);
+ define('PHPGW_ACL_ADD',2);
+ define('PHPGW_ACL_EDIT',4);
+ define('PHPGW_ACL_DELETE',8);
+ define('PHPGW_ACL_PRIVATE',16);
+ define('PHPGW_ACL_GROUP_MANAGERS',32);
+ define('PHPGW_ACL_CUSTOM_1',64);
+ define('PHPGW_ACL_CUSTOM_2',128);
+ define('PHPGW_ACL_CUSTOM_3',256);
+ // A few hacker resistant constants that will be used throught the program
+ define('EGW_TEMPLATE_DIR', $this->common->get_tpl_dir('phpgwapi'));
+ define('EGW_IMAGES_DIR', $this->common->get_image_path('phpgwapi'));
+ define('EGW_IMAGES_FILEDIR', $this->common->get_image_dir('phpgwapi'));
+ define('EGW_APP_ROOT', $this->common->get_app_dir());
+ define('EGW_APP_INC', $this->common->get_inc_dir());
+ define('EGW_APP_TPL', $this->common->get_tpl_dir());
+ define('EGW_IMAGES', $this->common->get_image_path());
+ define('EGW_APP_IMAGES_DIR', $this->common->get_image_dir());
+ // and the old ones
+ define('PHPGW_TEMPLATE_DIR',EGW_TEMPLATE_DIR);
+ define('PHPGW_IMAGES_DIR',EGW_IMAGES_DIR);
+ define('PHPGW_IMAGES_FILEDIR',EGW_IMAGES_FILEDIR);
+ define('PHPGW_APP_ROOT',EGW_APP_ROOT);
+ define('PHPGW_APP_INC',EGW_APP_INC);
+ define('PHPGW_APP_TPL',EGW_APP_TPL);
+ define('PHPGW_IMAGES',EGW_IMAGES);
+ define('PHPGW_APP_IMAGES_DIR',EGW_APP_IMAGES_DIR);
+ }
+
+ /**
+ * force the session cache to be re-created, because some of it's data changed
+ *
+ * Needs to be called if user-preferences, system-config or enabled apps of the current user have been changed and
+ * the change should have immediate effect
+ */
+ function invalidate_session_cache()
+ {
+ unset($_SESSION['egw_info_cache']);
+ unset($_SESSION['egw_object_cache']);
+ }
+
+ /**
+ * run string through htmlspecialchars and stripslashes
+ *
+ * @param string $s
+ * @return string The string with html special characters replaced with entities
+ */
+ function strip_html($s)
+ {
+ return htmlspecialchars(stripslashes($s));
+ }
+
+ /**
+ * Link url generator
+ *
+ * @param string $string The url the link is for
+ * @param string/array $extravars Extra params to be passed to the url
+ * @return string The full url after processing
+ */
+ function link($url = '', $extravars = '')
+ {
+ return $this->session->link($url, $extravars);
+ }
+
+ /**
+ * Redirects direct to a generated link
+ *
+ * @param string $string The url the link is for
+ * @param string/array $extravars Extra params to be passed to the url
+ * @return string The full url after processing
+ */
+ function redirect_link($url = '',$extravars='')
+ {
+ $this->redirect($this->session->link($url, $extravars));
+ }
+
+ /**
+ * Handles redirects under iis and apache, it does NOT return (calls exit)
+ *
+ * This function handles redirects under iis and apache it assumes that $phpgw->link() has already been called
+ *
+ * @param string The url ro redirect to
+ */
+ function redirect($url = '')
+ {
+ /* global $HTTP_ENV_VARS; */
+
+ $iis = @strpos($GLOBALS['HTTP_ENV_VARS']['SERVER_SOFTWARE'], 'IIS', 0);
+
+ if(!$url)
+ {
+ $url = $_SERVER['PHP_SELF'];
+ }
+ if($iis)
+ {
+ echo "\n\n\nRedirecting to $url";
+ echo "\n";
+ echo "\n";
+ echo "Please continue to this page
";
+ echo "\n";
+ }
+ else
+ {
+ Header("Location: $url");
+ print("\n\n");
+ }
+ exit;
+ }
+
+ /**
+ * Shortcut to translation class
+ *
+ * This function is a basic wrapper to translation->translate()
+ *
+ * @deprecated only used in the old timetracker
+ * @param string The key for the phrase
+ * @see translation->translate()
+ */
+ function lang($key,$args=null)
+ {
+ if (!is_array($args))
+ {
+ $args = func_get_args();
+ array_shift($args);
+ }
+ return $this->translation->translate($key,$args);
+ }
+
+ /**
+ * eGW's shutdown handler
+ */
+ function shutdown()
+ {
+ if (!defined('EGW_SHUTDOWN'))
+ {
+ define('EGW_SHUTDOWN',True);
+
+ if (isset($this->accounts))
+ {
+ $this->accounts->save_session_cache();
+ }
+ if (class_exists('egw_link',false)) // false = no autoload!
+ {
+ egw_link::save_session_cache();
+ }
+ // call the asyncservice check_run function if it is not explicitly set to cron-only
+ //
+ if (!$GLOBALS['egw_info']['server']['asyncservice']) // is default
+ {
+ ExecMethod('phpgwapi.asyncservice.check_run','fallback');
+ }
+ /* Clean up mcrypt */
+ if (isset($this->crypto))
+ {
+ $this->crypto->cleanup();
+ unset($this->crypto);
+ }
+ $this->db->disconnect();
+ }
+ }
+
+ /**
+ * Classes which get instanciated in a different name
+ *
+ * @var array
+ */
+ static $sub_objects = array(
+ 'log' => 'errorlog',
+ 'js' => 'javascript',
+ 'link' => 'bolink', // depricated use static egw_link methods
+ 'datetime' => 'egw_datetime',
+ 'session' => 'sessions',
+ 'framework' => true, // special handling in __get()
+ 'template' => 'Template',
+ );
+
+ /**
+ * Magic function to check if a sub-object is set
+ *
+ * @param string $name
+ * @return boolean
+ */
+ function __isset($name)
+ {
+ //error_log(__METHOD__."($name)");
+ return isset($this->$name);
+ }
+
+ /**
+ * Magic function to return a sub-object
+ *
+ * @param string $name
+ * @return mixed
+ */
+ function __get($name)
+ {
+ error_log(__METHOD__."($name)".function_backtrace());
+
+ if (isset($this->$name))
+ {
+ return $this->$name;
+ }
+
+ if (!isset(self::$sub_objects[$name]) && !class_exists($name))
+ {
+ error_log(__METHOD__.": There's NO $name object!");
+ return null;
+ }
+ switch($name)
+ {
+ case 'framework':
+ // setup the new eGW framework (template sets)
+ $class = $GLOBALS['egw_info']['server']['template_set'].'_framework';
+ require_once($file=EGW_INCLUDE_ROOT.'/phpgwapi/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/class.'.$class.'.inc.php');
+ if (!in_array($file,(array)$_SESSION['egw_required_files']))
+ {
+ $_SESSION['egw_required_files'][] = $file; // automatic load the used framework class, when the object get's restored
+ }
+ break;
+ case 'template': // need to be instancated for the current app
+ return $this->template = new Template($GLOBALS['egw']->common->get_tpl_dir($this->currentapp));
+ default:
+ $class = isset(self::$sub_objects[$name]) ? self::$sub_objects[$name] : $name;
+ break;
+ }
+ return $this->$name = new $class();
+ }
+}
diff --git a/phpgwapi/inc/class.egw_db.inc.php b/phpgwapi/inc/class.egw_db.inc.php
index f2d462a60b..8271c50149 100644
--- a/phpgwapi/inc/class.egw_db.inc.php
+++ b/phpgwapi/inc/class.egw_db.inc.php
@@ -255,7 +255,6 @@ class egw_db
{
$this->Type = $GLOBALS['egw_info']['server']['db_type'];
}
-
if (!$this->Link_ID)
{
foreach(array('Host','Database','User','Password') as $name)
@@ -368,6 +367,7 @@ class egw_db
ini_set('mssql.textlimit',2147483647);
ini_set('mssql.sizelimit',2147483647);
}
+ $new_connection = true;
}
else
{
@@ -377,9 +377,27 @@ class egw_db
// next ADOdb version: if (!$this->Link_ID->isConnected()) $this->Link_ID->Connect();
if (!$this->Link_ID->_connectionID) $this->Link_ID->Connect();
+ if ($new_connection && $GLOBALS['egw_info']['server']['sessions_type'] == 'php4-restore')
+ {
+ foreach(get_included_files() as $file)
+ {
+ if (strpos($file,'adodb') !== false && !in_array($file,(array)$_SESSION['egw_required_files']))
+ {
+ $_SESSION['egw_required_files'][] = $file;
+ }
+ }
+ }
//echo "".print_r($this->Link_ID->ServerInfo(),true)."
\n";
return $this->Link_ID;
}
+
+ /**
+ * Magic method to re-connect with the database, if the object get's restored from the session
+ */
+ function __wakeup()
+ {
+ $this->connect(); // we need to re-connect
+ }
/**
* changes defaults set in class-var $capabilities depending on db-type and -version
diff --git a/phpgwapi/inc/class.egw_framework.inc.php b/phpgwapi/inc/class.egw_framework.inc.php
index 07f1d87da1..e506a8e8b4 100644
--- a/phpgwapi/inc/class.egw_framework.inc.php
+++ b/phpgwapi/inc/class.egw_framework.inc.php
@@ -58,7 +58,7 @@ class egw_framework
if (!is_object($GLOBALS['egw']->framework))
{
- $GLOBALS['egw']->framework =& $this;
+ $GLOBALS['egw']->framework = $this;
}
}
@@ -387,25 +387,20 @@ class egw_framework
}
$options[$action] = $label;
}
- if (!is_object($GLOBALS['egw']->html))
- {
- $GLOBALS['egw']->html =& new html();
- }
- return $GLOBALS['egw']->html->select('quick_add','',$options,true,$options=' onchange="eval(this.value); this.value=0; return false;"');
+ return html::select('quick_add','',$options,true,$options=' onchange="eval(this.value); this.value=0; return false;"');
}
- function _get_notification_bell() {
- if (!is_object($GLOBALS['egw']->html))
- {
- $GLOBALS['egw']->html =& new html();
- }
- return $GLOBALS['egw']->html->div( $GLOBALS['egw']->html->a_href( $GLOBALS['egw']->html->image('notifications','notificationbell',lang('notifications')),
- 'javascript: notificationwindow_display();'
- ),
- 'id="notificationbell"', // options
- '', // class
- 'display: none' //style
- );
+ function _get_notification_bell()
+ {
+ return html::div(
+ html::a_href(
+ html::image('notifications','notificationbell',lang('notifications')),
+ 'javascript: notificationwindow_display();'
+ ),
+ 'id="notificationbell"', // options
+ '', // class
+ 'display: none' //style
+ );
}
@@ -597,11 +592,6 @@ class egw_framework
{
$java_script = '';
- if(!@is_object($GLOBALS['egw']->js))
- {
- $GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript');
- }
-
// always include javascript helper functions
$GLOBALS['egw']->js->validate_file('jsapi','jsapi');
@@ -715,5 +705,3 @@ if (!function_exists('display_sidebox'))
$GLOBALS['egw']->framework->sidebox($appname,$menu_title,$file);
}
}
-
-
diff --git a/phpgwapi/inc/class.javascript.inc.php b/phpgwapi/inc/class.javascript.inc.php
index e36ced9aa3..d303e0ea76 100644
--- a/phpgwapi/inc/class.javascript.inc.php
+++ b/phpgwapi/inc/class.javascript.inc.php
@@ -220,7 +220,7 @@
{
if ($browser)
{
- $browser_folder = strtolower(ExecMethod('phpgwapi.browser.get_agent'));
+ $browser_folder = html::$user_agent;
}
else
{
diff --git a/phpgwapi/inc/common_functions.inc.php b/phpgwapi/inc/common_functions.inc.php
index 345809ef0c..927332164d 100755
--- a/phpgwapi/inc/common_functions.inc.php
+++ b/phpgwapi/inc/common_functions.inc.php
@@ -686,22 +686,32 @@
if (class_exists($classname))
{
$args = func_get_args();
- if(count($args) == 1)
+ switch(count($args))
{
- $obj =& new $classname;
- }
- else
- {
- $code = '$obj =& new ' . $classname . '(';
- foreach($args as $n => $arg)
- {
- if ($n)
+ case 1:
+ $obj =& new $classname;
+ break;
+ case 2:
+ $obj =& new $classname($args[1]);
+ break;
+ case 3:
+ $obj =& new $classname($args[1],$args[2]);
+ break;
+ case 4:
+ $obj =& new $classname($args[1],$args[2],$args[3]);
+ break;
+ default:
+ $code = '$obj =& new ' . $classname . '(';
+ foreach($args as $n => $arg)
{
- $code .= ($n > 1 ? ',' : '') . '$args[' . $n . ']';
+ if ($n)
+ {
+ $code .= ($n > 1 ? ',' : '') . '$args[' . $n . ']';
+ }
}
- }
- $code .= ');';
- eval($code);
+ $code .= ');';
+ eval($code);
+ break;
}
}
if (!is_object($obj))
@@ -724,7 +734,6 @@
list($app,$class,$method) = explode('.',$acm);
if (!is_object($obj =& $GLOBALS[$class]))
{
- $newobj = 1;
$obj =& CreateObject($acm);
}
@@ -736,18 +745,8 @@
$args = func_get_args();
unset($args[0]);
- $code = '$return =& $obj->'.$method.'(';
- foreach ($args as $n => $arg)
- {
- if ($n)
- {
- $code .= ($n > 1 ? ',' : '') . '$args[' . $n . ']';
- }
- }
-
- eval($code.');');
- if($newobj) unset($obj);
- return $return;
+
+ return call_user_func_array(array($obj,$method),$args);
}
/**
@@ -791,12 +790,10 @@
{
return $GLOBALS[$classname]->$functionname($functionparams);
}
- else
- {
- return $GLOBALS[$classname]->$functionname();
- }
+ return $GLOBALS[$classname]->$functionname();
}
/* if the $method includes a parent class (multi-dimensional) then we have to work from it */
+/* RalfBecker: let's check if this is still in use, I don't think so:
elseif ($partscount >= 3)
{
$GLOBALS['methodparts'] = explode(".", $method);
@@ -804,14 +801,13 @@
$appname = $GLOBALS['methodparts'][0];
$classname = $GLOBALS['methodparts'][$classpartnum];
$functionname = $GLOBALS['methodparts'][$partscount];
- /* Now we clear these out of the array so that we can do a proper */
- /* loop and build the $parentobject */
+ // Now we clear these out of the array so that we can do a proper
+ // loop and build the $parentobject
unset ($GLOBALS['methodparts'][0]);
unset ($GLOBALS['methodparts'][$classpartnum]);
unset ($GLOBALS['methodparts'][$partscount]);
reset ($GLOBALS['methodparts']);
$firstparent = 'True';
-// while (list ($key, $val) = each ($GLOBALS['methodparts']))
foreach($GLOBALS['methodparts'] as $val)
{
if ($firstparent == 'True')
@@ -857,10 +853,8 @@
return $returnval;
}
}
- else
- {
- return "ExecMethod('$method'): error in parts!
".function_backtrace()."
\n";
- }
+*/
+ return "ExecMethod('$method'): error in parts!
".function_backtrace()."
\n";
}
/**
@@ -1170,7 +1164,7 @@
if ($remove-- < 0)
{
$ret[] = (isset($level['class'])?$level['class'].'::':'').$level['function'].
- (!$level['class'] ? '('.str_replace(EGW_SERVER_ROOT,'',$level['args'][0]).')' : '');
+ (!$level['class'] && !is_object($level['args'][0]) ? '('.str_replace(EGW_SERVER_ROOT,'',$level['args'][0]).')' : '');
}
}
if (is_array($ret))
diff --git a/phpgwapi/inc/functions.inc.php b/phpgwapi/inc/functions.inc.php
index 2f37753f52..7773335b26 100644
--- a/phpgwapi/inc/functions.inc.php
+++ b/phpgwapi/inc/functions.inc.php
@@ -66,27 +66,23 @@ if ($GLOBALS['egw_info']['server']['sessions_type'] == 'php4-restore' && $_REQUE
if ($GLOBALS['egw_info']['flags']['currentapp'] != 'login' && $GLOBALS['egw_info']['flags']['currentapp'] != 'logout')
{
- if (is_array($_SESSION['egw_info_cache']) && is_array($_SESSION['egw_included_files']) && $_SESSION['egw_object_cache'])
+ if (is_array($_SESSION['egw_info_cache']) && $_SESSION['egw_object_cache'])
{
- // marking the context as restored from the session, used by session->verify to not read the date from the db again
+ // marking the context as restored from the session, used by session->verify to not read the data from the db again
$GLOBALS['egw_info']['flags']['restored_from_session'] = true;
// restoring the egw_info-array
- $flags = $GLOBALS['egw_info']['flags'];
- $GLOBALS['egw_info'] = $_SESSION['egw_info_cache'];
- $GLOBALS['egw_info']['flags'] = $flags;
- unset($flags);
+ $GLOBALS['egw_info'] = array_merge($_SESSION['egw_info_cache'],array('flags' => $GLOBALS['egw_info']['flags']));
- // including the necessary class-definitions
- foreach($_SESSION['egw_included_files'] as $file)
+ // include required class-definitions
+ if (is_array($_SESSION['egw_required_files'])) // all classes, which can not be autoloaded
{
- if (basename($file) == 'class.config.inc.php') continue;
- //echo "about to include $file
\n";
- include_once($file);
- if (basename($file) == 'class.egw_framework.inc.php') break; // the rest is not needed and makes only problems
+ foreach($_SESSION['egw_required_files'] as $file)
+ {
+ require_once($file);
+ }
}
$GLOBALS['egw'] = unserialize($_SESSION['egw_object_cache']);
- include_once(EGW_API_INC.'/class.config.inc.php');
if (is_object($GLOBALS['egw']))
{
@@ -100,7 +96,7 @@ if ($GLOBALS['egw_info']['server']['sessions_type'] == 'php4-restore' && $_REQUE
$GLOBALS['egw_info'] = array('flags'=>$GLOBALS['egw_info']['flags']);
unset($GLOBALS['egw_info']['flags']['restored_from_session']);
unset($_SESSION['egw_info_cache']);
- unset($_SESSION['egw_included_files']);
+ unset($_SESSION['egw_required_files']);
unset($_SESSION['egw_object_cache']);
}
//echo "could not restore egw_info and the egw-object!!!
\n";
@@ -108,7 +104,7 @@ if ($GLOBALS['egw_info']['server']['sessions_type'] == 'php4-restore' && $_REQUE
else // destroy the session-cache if called by login or logout
{
unset($_SESSION['egw_info_cache']);
- unset($_SESSION['egw_included_files']);
+ unset($_SESSION['egw_required_files']);
unset($_SESSION['egw_object_cache']);
}
}
@@ -177,7 +173,7 @@ else
print_debug('domain',@$GLOBALS['egw_info']['user']['domain'],'api');
// the egw-object instanciates all sub-classes (eg. $GLOBALS['egw']->db) and the egw_info array
-$GLOBALS['egw'] =& CreateObject('phpgwapi.egw',array_keys($GLOBALS['egw_domain']));
+$GLOBALS['egw'] = new egw(array_keys($GLOBALS['egw_domain']));
if ($GLOBALS['egw_info']['flags']['currentapp'] != 'login')
{
@@ -194,18 +190,5 @@ if ($GLOBALS['egw_info']['server']['sessions_type'] == 'php4-restore' && $GLOBAL
$_SESSION['egw_info_cache'] = $GLOBALS['egw_info'];
unset($_SESSION['egw_info_cache']['flags']); // dont save the flags, they change on each request
- // exclude 1: caller, 2: the header.inc.php, 3: phpgwapi/setup/setup.inc.php, 4: phpgwapi/inc/functions.inc.php (this file)
- $_SESSION['egw_included_files'] = array();
- foreach(array_slice(get_included_files(),4) as $file)
- {
- switch(basename($file))
- {
- case 'header.inc.php': // needs EGW_TEMPLATE_DIR and is included anyway by common::egw_header()
- case 'functions.inc.php': // not needed/wanted at all
- break;
- default:
- $_SESSION['egw_included_files'][] = $file;
- }
- }
$_SESSION['egw_object_cache'] = serialize($GLOBALS['egw']);
}
diff --git a/phpgwapi/templates/idots/class.idots_framework.inc.php b/phpgwapi/templates/idots/class.idots_framework.inc.php
index 94a8ef1b1b..0e1570dd08 100644
--- a/phpgwapi/templates/idots/class.idots_framework.inc.php
+++ b/phpgwapi/templates/idots/class.idots_framework.inc.php
@@ -1,633 +1,608 @@
rewrite in 12/2006
- * @author Pim Snel author of the idots template set
- * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
- * @package api
- * @subpackage framework
- * @access public
- * @version $Id$
- */
+/**
+ * eGW idots template
+ *
+ * @link http://www.egroupware.org
+ * @author Ralf Becker rewrite in 12/2006
+ * @author Pim Snel author of the idots template set
+ * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
+ * @package api
+ * @subpackage framework
+ * @access public
+ * @version $Id$
+ */
- require_once(EGW_API_INC.'/class.egw_framework.inc.php');
- require_once(EGW_API_INC.'/class.Template.inc.php');
- require_once(EGW_API_INC.'/class.dragdrop.inc.php');
- require_once(EGW_API_INC.'/class.tplsavant2.inc.php');
-
- /**
- * eGW idots template
- *
- * The idots_framework class draws the default idots template. It's a phplib template based template-set.
- *
- * Other phplib template based template-sets should extend (not copy!) this class and reimplement methods they which to change.
- */
- class idots_framework extends egw_framework
- {
- /**
- * HTML of the sidebox menu, get's collected here by calls to $this->sidebox
- *
- * @var string
- */
- var $sidebox_content = '';
- /**
- * Instance of the phplib Template class for the API's template dir (EGW_TEMPLATE_DIR)
- *
- * @var Template
- */
- var $tpl;
- /**
- * Instance of the Savant template class
- *
- * @var tplsavant2
- */
- var $tplsav2;
- /**
- * true if $this->navbar() was called
- *
- * @var boolean
- */
- var $navbar_done;
-
- /**
- * Contains array with linked icons in the topmenu
- *
- * @var mixed
- * @access public
- */
- var $topmenu_icon_arr = array();
-
- /**
- * Constructor
- *
- * @param string $template='idots' name of the template
- * @return idots_framework
- */
- function idots_framework($template='idots')
- {
- $GLOBALS['egw_info']['flags']['include_xajax'] = True;
- $this->egw_framework($template); // call the constructor of the extended class
-
- $this->tplsav2 =& new tplsavant2();
- $this->tplsav2->set_tpl_path(EGW_SERVER_ROOT.SEP.'phpgwapi'.SEP.'templates'.SEP.'idots');
- }
-
- /**
- * Returns the html-header incl. the opening body tag
- *
- * @return string with html
- */
- function header()
- {
- // add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv)
- header('Content-type: text/html; charset='.$GLOBALS['egw']->translation->charset());
-
- // catch error echo'ed before the header, ob_start'ed in the header.inc.php
- $content = ob_get_contents();
- ob_end_clean();
-
- // the instanciation of the template has to be here and not in the constructor,
- // as the old Template class has problems if restored from the session (php-restore)
- $this->tpl =& new Template(EGW_TEMPLATE_DIR);
- $this->tpl->set_file(array('_head' => 'head.tpl'));
- $this->tpl->set_block('_head','head');
-
- $this->tpl->set_var($this->_get_header());
-
- $content .= $this->tpl->fp('out','head');
-
- $this->sidebox_content = ''; // need to be emptied here, as the object get's stored in the session
-
- return $content;
- }
-
- /**
- * Returns the html from the body-tag til the main application area (incl. opening div tag)
- *
- * @return string with html
- */
- function navbar()
- {
- if($GLOBALS['egw_info']['user']['preferences']['common']['show_general_menu'] != 'sidebox')
- {
+/**
+* eGW idots template
+*
+* The idots_framework class draws the default idots template. It's a phplib template based template-set.
+*
+* Other phplib template based template-sets should extend (not copy!) this class and reimplement methods they which to change.
+*/
+class idots_framework extends egw_framework
+{
+ /**
+ * HTML of the sidebox menu, get's collected here by calls to $this->sidebox
+ *
+ * @var string
+ */
+ var $sidebox_content = '';
+ /**
+ * Instance of the phplib Template class for the API's template dir (EGW_TEMPLATE_DIR)
+ *
+ * @var Template
+ */
+ var $tpl;
+ /**
+ * Instance of the Savant template class
+ *
+ * @var tplsavant2
+ */
+ var $tplsav2;
+ /**
+ * true if $this->navbar() was called
+ *
+ * @var boolean
+ */
+ var $navbar_done;
+
+ /**
+ * Contains array with linked icons in the topmenu
+ *
+ * @var mixed
+ * @access public
+ */
+ var $topmenu_icon_arr = array();
+
+ /**
+ * Constructor
+ *
+ * @param string $template='idots' name of the template
+ * @return idots_framework
+ */
+ function idots_framework($template='idots')
+ {
+ $GLOBALS['egw_info']['flags']['include_xajax'] = True;
+ $this->egw_framework($template); // call the constructor of the extended class
+
+ $this->tplsav2 =& new tplsavant2();
+ $this->tplsav2->set_tpl_path(EGW_SERVER_ROOT.SEP.'phpgwapi'.SEP.'templates'.SEP.'idots');
+ }
+
+ /**
+ * Returns the html-header incl. the opening body tag
+ *
+ * @return string with html
+ */
+ function header()
+ {
+ // add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv)
+ header('Content-type: text/html; charset='.$GLOBALS['egw']->translation->charset());
+
+ // catch error echo'ed before the header, ob_start'ed in the header.inc.php
+ $content = ob_get_contents();
+ ob_end_clean();
+
+ // the instanciation of the template has to be here and not in the constructor,
+ // as the old Template class has problems if restored from the session (php-restore)
+ $this->tpl =& new Template(EGW_TEMPLATE_DIR);
+ $this->tpl->set_file(array('_head' => 'head.tpl'));
+ $this->tpl->set_block('_head','head');
+
+ $this->tpl->set_var($this->_get_header());
+
+ $content .= $this->tpl->fp('out','head');
+
+ $this->sidebox_content = ''; // need to be emptied here, as the object get's stored in the session
+
+ return $content;
+ }
+
+ /**
+ * Returns the html from the body-tag til the main application area (incl. opening div tag)
+ *
+ * @return string with html
+ */
+ function navbar()
+ {
+ if($GLOBALS['egw_info']['user']['preferences']['common']['show_general_menu'] != 'sidebox')
+ {
$GLOBALS['egw']->hooks->process('topmenu_info');
$content = $this->topmenu();
- }
-
- $this->navbar_done = true;
-
- // the navbar
- $this->tpl->set_file(array('navbar' => 'navbar.tpl'));
-
- $this->tpl->set_block('navbar','extra_blocks_header','extra_block_header');
- $this->tpl->set_block('navbar','extra_block_row','extra_block_row');
- $this->tpl->set_block('navbar','extra_block_row_raw','extra_block_row_raw');
- $this->tpl->set_block('navbar','extra_block_row_no_link','extra_block_row_no_link');
- $this->tpl->set_block('navbar','extra_block_spacer','extra_block_spacer');
- $this->tpl->set_block('navbar','extra_blocks_footer','extra_blocks_footer');
- $this->tpl->set_block('navbar','sidebox_hide_header','sidebox_hide_header');
- $this->tpl->set_block('navbar','sidebox_hide_footer','sidebox_hide_footer');
- $this->tpl->set_block('navbar','appbox','appbox');
- $this->tpl->set_block('navbar','navbar_footer','navbar_footer');
-
- $this->tpl->set_block('navbar','upper_tab_block','upper_tabs');
- $this->tpl->set_block('navbar','app_icon_block','app_icons');
- $this->tpl->set_block('navbar','app_title_block','app_titles');
- $this->tpl->set_block('navbar','app_extra_block','app_extra_icons');
- $this->tpl->set_block('navbar','app_extra_icons_div');
- $this->tpl->set_block('navbar','app_extra_icons_icon');
-
- $this->tpl->set_block('navbar','navbar_header','navbar_header');
-
- $apps = $this->_get_navbar_apps();
- $vars = $this->_get_navbar($apps);
-
- $this->tpl->set_var($vars);
- $content .= $this->tpl->fp('out','navbar_header');
-
- // general (app-unspecific) sidebox menu
- if($GLOBALS['egw_info']['user']['preferences']['common']['show_general_menu'] == 'sidebox')
- //if($GLOBALS['egw_info']['user']['preferences']['common']['show_general_sideboxmenu']!='no')
- {
+ }
+
+ $this->navbar_done = true;
+
+ // the navbar
+ $this->tpl->set_file(array('navbar' => 'navbar.tpl'));
+
+ $this->tpl->set_block('navbar','extra_blocks_header','extra_block_header');
+ $this->tpl->set_block('navbar','extra_block_row','extra_block_row');
+ $this->tpl->set_block('navbar','extra_block_row_raw','extra_block_row_raw');
+ $this->tpl->set_block('navbar','extra_block_row_no_link','extra_block_row_no_link');
+ $this->tpl->set_block('navbar','extra_block_spacer','extra_block_spacer');
+ $this->tpl->set_block('navbar','extra_blocks_footer','extra_blocks_footer');
+ $this->tpl->set_block('navbar','sidebox_hide_header','sidebox_hide_header');
+ $this->tpl->set_block('navbar','sidebox_hide_footer','sidebox_hide_footer');
+ $this->tpl->set_block('navbar','appbox','appbox');
+ $this->tpl->set_block('navbar','navbar_footer','navbar_footer');
+
+ $this->tpl->set_block('navbar','upper_tab_block','upper_tabs');
+ $this->tpl->set_block('navbar','app_icon_block','app_icons');
+ $this->tpl->set_block('navbar','app_title_block','app_titles');
+ $this->tpl->set_block('navbar','app_extra_block','app_extra_icons');
+ $this->tpl->set_block('navbar','app_extra_icons_div');
+ $this->tpl->set_block('navbar','app_extra_icons_icon');
+
+ $this->tpl->set_block('navbar','navbar_header','navbar_header');
+
+ $apps = $this->_get_navbar_apps();
+ $vars = $this->_get_navbar($apps);
+
+ $this->tpl->set_var($vars);
+ $content .= $this->tpl->fp('out','navbar_header');
+
+ // general (app-unspecific) sidebox menu
+ if($GLOBALS['egw_info']['user']['preferences']['common']['show_general_menu'] == 'sidebox')
+ //if($GLOBALS['egw_info']['user']['preferences']['common']['show_general_sideboxmenu']!='no')
+ {
$menu_title = lang('General Menu');
-
+
$file['Home'] = $apps['home']['url'];
if($GLOBALS['egw_info']['user']['apps']['preferences'])
{
- $file['Preferences'] = $apps['preferences']['url'];
+ $file['Preferences'] = $apps['preferences']['url'];
+ }
+ if($GLOBALS['egw_info']['user']['apps']['manual'] && $apps['manual'])
+ {
+ $file['manual'] = array(
+ 'text' => 'manual',
+ 'no_lang' => false,
+ 'target' => $apps['manual']['target'],
+ 'link' => $apps['manual']['url']
+ );
}
- if($GLOBALS['egw_info']['user']['apps']['manual'] && $apps['manual'])
- {
- $file['manual'] = array('text' => 'manual',
- 'no_lang' => false,
- 'target' => $apps['manual']['target'],
- 'link' => $apps['manual']['url']);
- }
$file += array(
- /*array(
- 'text' => lang('About %1',$GLOBALS['egw_info']['apps'][$GLOBALS['egw_info']['flags']['currentapp']]['title']),
- 'no_lang' => True,
- 'link' => $apps['about']['url']
- ),*/
- $GLOBALS['egw_info']['user']['userid'] != 'anonymous' ? 'Logout' : 'Login' =>$apps['logout']['url']
+ $GLOBALS['egw_info']['user']['userid'] != 'anonymous' ? 'Logout' : 'Login' =>$apps['logout']['url']
);
$this->sidebox('',$menu_title,$file);
- }
-
- $GLOBALS['egw']->hooks->single('sidebox_menu',$GLOBALS['egw_info']['flags']['currentapp']);
-
- if($this->sidebox_content)
- {
+ }
+
+ $GLOBALS['egw']->hooks->single('sidebox_menu',$GLOBALS['egw_info']['flags']['currentapp']);
+
+ if($this->sidebox_content)
+ {
if($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox'])
{
- $this->tpl->set_var('lang_show_menu',lang('show menu'));
- $content .= $this->tpl->parse('out','sidebox_hide_header');
-
- $content .= $this->sidebox_content; // content from calls to $this->sidebox
-
- $content .= $this->tpl->parse('out','sidebox_hide_footer');
-
- $var['sideboxcolstart']='';
-
- $this->tpl->set_var($var);
- $content .= $this->tpl->parse('out','appbox');
- $var['remove_padding'] = 'style="padding-left:0px;"';
- $var['sideboxcolend'] = '';
+ $this->tpl->set_var('lang_show_menu',lang('show menu'));
+ $content .= $this->tpl->parse('out','sidebox_hide_header');
+
+ $content .= $this->sidebox_content; // content from calls to $this->sidebox
+
+ $content .= $this->tpl->parse('out','sidebox_hide_footer');
+
+ $var['sideboxcolstart']='';
+
+ $this->tpl->set_var($var);
+ $content .= $this->tpl->parse('out','appbox');
+ $var['remove_padding'] = 'style="padding-left:0px;"';
+ $var['sideboxcolend'] = '';
}
else
{
- $GLOBALS['phpgw']->preferences->read_repository();
-
- $prefs = array();
-
- if ($GLOBALS['egw_info']['user']['preferences']['common'])
- {
- $sideboxwidth = $GLOBALS['egw_info']['user']['preferences']['common']['idotssideboxwidth'];
- }
- if(intval($sideboxwidth)<1)
- {
- $sideboxwidth = 203;
- }
-
- $var['menu_link'] = '';
-
- $var['sideboxcolstart'] = '';
- $var['sideboxcolstart'] .= ' ';
- $var['remove_padding'] = '';
- $this->tpl->set_var($var);
- $content .= $this->tpl->parse('out','appbox');
-
- $content .= $this->sidebox_content;
-
- $var['sideboxcolend'] = ' | ';
-
- $this->tplsav2->assign('sideboxwidth', $sideboxwidth);
-
- $GLOBALS['egw_info']['flags']['need_footer'] .= $this->tplsav2->fetch('sidebox_dhtml.tpl.php');
+ $GLOBALS['phpgw']->preferences->read_repository();
+
+ $prefs = array();
+
+ if ($GLOBALS['egw_info']['user']['preferences']['common'])
+ {
+ $sideboxwidth = $GLOBALS['egw_info']['user']['preferences']['common']['idotssideboxwidth'];
+ }
+ if((int)$sideboxwidth < 1)
+ {
+ $sideboxwidth = 203;
+ }
+
+ $var['menu_link'] = '';
+
+ $var['sideboxcolstart'] = '';
+ $var['sideboxcolstart'] .= ' ';
+ $var['remove_padding'] = '';
+ $this->tpl->set_var($var);
+ $content .= $this->tpl->parse('out','appbox');
+
+ $content .= $this->sidebox_content;
+
+ $var['sideboxcolend'] = ' | ';
+
+ $this->tplsav2->assign('sideboxwidth', $sideboxwidth);
+
+ $GLOBALS['egw_info']['flags']['need_footer'] .= $this->tplsav2->fetch('sidebox_dhtml.tpl.php');
}
- }
- else
- {
+ }
+ else
+ {
$var['sideboxcolend']='';
- }
-
- $this->tpl->set_var($var);
- $content .= $this->tpl->parse('out','navbar_footer');
-
- // depricated (!) application header, if not disabled
- // ToDo: check if it can be removed
- if(!@$GLOBALS['egw_info']['flags']['noappheader'] && @isset($_GET['menuaction']))
- {
+ }
+
+ $this->tpl->set_var($var);
+ $content .= $this->tpl->parse('out','navbar_footer');
+
+ // depricated (!) application header, if not disabled
+ // ToDo: check if it can be removed
+ if(!@$GLOBALS['egw_info']['flags']['noappheader'] && @isset($_GET['menuaction']))
+ {
list($app,$class,$method) = explode('.',$_GET['menuaction']);
if(is_array($GLOBALS[$class]->public_functions) && $GLOBALS[$class]->public_functions['header'])
{
- ob_start();
- $GLOBALS[$class]->header();
- $content .= ob_get_contents();
- ob_end_clean();
+ ob_start();
+ $GLOBALS[$class]->header();
+ $content .= ob_get_contents();
+ ob_end_clean();
}
- }
-
- // hook after navbar
- ob_start();
- $GLOBALS['egw']->hooks->process('after_navbar');
- $content .= ob_get_contents();
- ob_end_clean();
-
- return $content;
- }
-
- /**
- * displays a login screen
- *
- * @param string $extra_vars for login url
- */
- function login_screen($extra_vars)
- {
- $tmpl =& new Template($GLOBALS['egw_info']['server']['template_dir']);
- if (!is_object($GLOBALS['egw']->html))
- {
- require_once(EGW_API_INC.'/class.html.inc.php');
- $GLOBALS['egw']->html = new html;
- }
- $tmpl->set_file(array('login_form' => 'login.tpl'));
-
- $tmpl->set_var('lang_message',$GLOBALS['loginscreenmessage']);
-
- $last_loginid = $_COOKIE['last_loginid'];
-
- if($GLOBALS['egw_info']['server']['show_domain_selectbox'])
- {
+ }
+
+ // hook after navbar
+ ob_start();
+ $GLOBALS['egw']->hooks->process('after_navbar');
+ $content .= ob_get_contents();
+ ob_end_clean();
+
+ return $content;
+ }
+
+ /**
+ * displays a login screen
+ *
+ * @param string $extra_vars for login url
+ */
+ function login_screen($extra_vars)
+ {
+ $tmpl =& new Template($GLOBALS['egw_info']['server']['template_dir']);
+
+ $tmpl->set_file(array('login_form' => 'login.tpl'));
+
+ $tmpl->set_var('lang_message',$GLOBALS['loginscreenmessage']);
+
+ $last_loginid = $_COOKIE['last_loginid'];
+
+ if($GLOBALS['egw_info']['server']['show_domain_selectbox'])
+ {
foreach($GLOBALS['egw_domain'] as $domain => $data)
{
- $domains[$domain] = $domain;
+ $domains[$domain] = $domain;
}
$tmpl->set_var(array(
- 'lang_domain' => lang('domain'),
- 'select_domain' => $GLOBALS['egw']->html->select('logindomain',$_COOKIE['last_domain'],$domains,true),
+ 'lang_domain' => lang('domain'),
+ 'select_domain' => html::select('logindomain',$_COOKIE['last_domain'],$domains,true),
));
- }
- else
- {
+ }
+ else
+ {
/* trick to make domain section disapear */
$tmpl->set_block('login_form','domain_selection');
$tmpl->set_var('domain_selection',$GLOBALS['egw_info']['user']['domain'] ?
- $GLOBALS['egw']->html->input_hidden('logindomain',$GLOBALS['egw_info']['user']['domain']) : '');
-
+ html::input_hidden('logindomain',$GLOBALS['egw_info']['user']['domain']) : '');
+
if($last_loginid !== '')
{
- reset($GLOBALS['egw_domain']);
- list($default_domain) = each($GLOBALS['egw_domain']);
-
- if($_COOKIE['last_domain'] != $default_domain && !empty($_COOKIE['last_domain']))
- {
- $last_loginid .= '@' . $_COOKIE['last_domain'];
- }
+ reset($GLOBALS['egw_domain']);
+ list($default_domain) = each($GLOBALS['egw_domain']);
+
+ if($_COOKIE['last_domain'] != $default_domain && !empty($_COOKIE['last_domain']))
+ {
+ $last_loginid .= '@' . $_COOKIE['last_domain'];
+ }
}
- }
-
- require_once(EGW_API_INC.'/class.config.inc.php');
- $cnf_reg =& new config('registration');
- $cnf_reg->read_repository();
- $config_reg = $cnf_reg->config_data;
- unset($cnf_reg);
-
- if($config_reg['enable_registration'] == 'True')
- {
+ }
+
+ $config_reg = config::read('registration');
+
+ if($config_reg['enable_registration'] == 'True')
+ {
if ($config_reg['register_link'] == 'True')
{
- $reg_link=' '.lang('Not a user yet? Register now').'
';
+ $reg_link=' '.lang('Not a user yet? Register now').'
';
}
if ($config_reg['lostpassword_link'] == 'True')
{
- $lostpw_link=' '.lang('Lost password').'
';
+ $lostpw_link=' '.lang('Lost password').'
';
}
if ($config_reg['lostid_link'] == 'True')
{
- $lostid_link=' '.lang('Lost Login Id').'
';
+ $lostid_link=' '.lang('Lost Login Id').'
';
}
-
+
/* if at least one option of "registration" is activated display the registration section */
if($config_reg['register_link'] == 'True' || $config_reg['lostpassword_link'] == 'True' || $config_reg['lostid_link'] == 'True')
{
- $tmpl->set_var(array(
- 'register_link' => $reg_link,
- 'lostpassword_link' => $lostpw_link,
- 'lostid_link' => $lostid_link,
- ));
+ $tmpl->set_var(array(
+ 'register_link' => $reg_link,
+ 'lostpassword_link' => $lostpw_link,
+ 'lostid_link' => $lostid_link,
+ ));
}
else
{
- /* trick to make registration section disapear */
- $tmpl->set_block('login_form','registration');
- $tmpl->set_var('registration','');
+ /* trick to make registration section disapear */
+ $tmpl->set_block('login_form','registration');
+ $tmpl->set_var('registration','');
}
- }
-
- $tmpl->set_var('login_url', $GLOBALS['egw_info']['server']['webserver_url'] . '/login.php' . $extra_vars);
- $tmpl->set_var('version',$GLOBALS['egw_info']['server']['versions']['phpgwapi']);
- $tmpl->set_var('cd',check_logoutcode($_GET['cd']));
- $tmpl->set_var('cookie',$last_loginid);
-
- $tmpl->set_var('lang_username',lang('username'));
- $tmpl->set_var('lang_password',lang('password'));
- $tmpl->set_var('lang_login',lang('login'));
-
- $tmpl->set_var('website_title', $GLOBALS['egw_info']['server']['site_title']);
- $tmpl->set_var('template_set',$this->template);
-
- if (substr($GLOBALS['egw_info']['server']['login_logo_file'],0,4) == 'http')
- {
+ }
+
+ $tmpl->set_var('login_url', $GLOBALS['egw_info']['server']['webserver_url'] . '/login.php' . $extra_vars);
+ $tmpl->set_var('version',$GLOBALS['egw_info']['server']['versions']['phpgwapi']);
+ $tmpl->set_var('cd',check_logoutcode($_GET['cd']));
+ $tmpl->set_var('cookie',$last_loginid);
+
+ $tmpl->set_var('lang_username',lang('username'));
+ $tmpl->set_var('lang_password',lang('password'));
+ $tmpl->set_var('lang_login',lang('login'));
+
+ $tmpl->set_var('website_title', $GLOBALS['egw_info']['server']['site_title']);
+ $tmpl->set_var('template_set',$this->template);
+
+ if (substr($GLOBALS['egw_info']['server']['login_logo_file'],0,4) == 'http')
+ {
$var['logo_file'] = $GLOBALS['egw_info']['server']['login_logo_file'];
- }
- else
- {
+ }
+ else
+ {
$var['logo_file'] = $GLOBALS['egw']->common->image('phpgwapi',$GLOBALS['egw_info']['server']['login_logo_file']?$GLOBALS['egw_info']['server']['login_logo_file']:'logo');
- }
- $var['logo_url'] = $GLOBALS['egw_info']['server']['login_logo_url']?$GLOBALS['egw_info']['server']['login_logo_url']:'http://www.eGroupWare.org';
- if (substr($var['logo_url'],0,4) != 'http')
- {
+ }
+ $var['logo_url'] = $GLOBALS['egw_info']['server']['login_logo_url']?$GLOBALS['egw_info']['server']['login_logo_url']:'http://www.eGroupWare.org';
+ if (substr($var['logo_url'],0,4) != 'http')
+ {
$var['logo_url'] = 'http://'.$var['logo_url'];
- }
- $var['logo_title'] = $GLOBALS['egw_info']['server']['login_logo_title']?$GLOBALS['egw_info']['server']['login_logo_title']:'www.eGroupWare.org';
- $tmpl->set_var($var);
-
- /* language section if activated in site config */
- if (@$GLOBALS['egw_info']['server']['login_show_language_selection'])
- {
+ }
+ $var['logo_title'] = $GLOBALS['egw_info']['server']['login_logo_title']?$GLOBALS['egw_info']['server']['login_logo_title']:'www.eGroupWare.org';
+ $tmpl->set_var($var);
+
+ /* language section if activated in site config */
+ if (@$GLOBALS['egw_info']['server']['login_show_language_selection'])
+ {
$tmpl->set_var(array(
- 'lang_language' => lang('Language'),
- 'select_language' => $GLOBALS['egw']->html->select('lang',$GLOBALS['egw_info']['user']['preferences']['common']['lang'],
- $GLOBALS['egw']->translation->get_installed_langs(),true),
+ 'lang_language' => lang('Language'),
+ 'select_language' => html::select('lang',$GLOBALS['egw_info']['user']['preferences']['common']['lang'],
+ $GLOBALS['egw']->translation->get_installed_langs(),true),
));
- }
- else
- {
+ }
+ else
+ {
$tmpl->set_block('login_form','language_select');
$tmpl->set_var('language_select','');
- }
-
- /********************************************************\
- * Check if authentification via cookies is allowed *
- * and place a time selectbox, how long cookie is valid *
- \********************************************************/
-
- if($GLOBALS['egw_info']['server']['allow_cookie_auth'])
- {
+ }
+
+ /********************************************************\
+ * Check if authentification via cookies is allowed *
+ * and place a time selectbox, how long cookie is valid *
+ \********************************************************/
+
+ if($GLOBALS['egw_info']['server']['allow_cookie_auth'])
+ {
$tmpl->set_block('login_form','remember_me_selection');
$tmpl->set_var('lang_remember_me',lang('Remember me'));
- $tmpl->set_var('select_remember_me',$GLOBALS['egw']->html->select('remember_me', 'forever', array(
- false => lang('not'),
- '1hour' => lang('1 Hour'),
- '1day' => lang('1 Day'),
- '1week'=> lang('1 Week'),
- '1month' => lang('1 Month'),
- 'forever' => lang('Forever'),
+ $tmpl->set_var('select_remember_me',html::select('remember_me', 'forever', array(
+ false => lang('not'),
+ '1hour' => lang('1 Hour'),
+ '1day' => lang('1 Day'),
+ '1week'=> lang('1 Week'),
+ '1month' => lang('1 Month'),
+ 'forever' => lang('Forever'),
),true));
- }
- else
- {
+ }
+ else
+ {
/* trick to make remember_me section disapear */
$tmpl->set_block('login_form','remember_me_selection');
$tmpl->set_var('remember_me_selection','');
- }
- $tmpl->set_var('autocomplete', ($GLOBALS['egw_info']['server']['autocomplete_login'] ? 'autocomplete="off"' : ''));
-
- if (!is_object($GLOBALS['egw']->js))
- {
- require_once(EGW_API_INC.'/class.javascript.inc.php');
- $GLOBALS['egw']->js = new javascript();
- }
- $GLOBALS['egw']->js->set_onload('document.login_form.login.focus();');
-
- $this->render($tmpl->fp('loginout','login_form'),false,false);
- }
-
- /**
- * displays a login denied message
- */
- function denylogin_screen()
- {
- $tmpl =& new Template($GLOBALS['egw_info']['server']['template_dir']);
-
- $tmpl->set_file(array(
+ }
+ $tmpl->set_var('autocomplete', ($GLOBALS['egw_info']['server']['autocomplete_login'] ? 'autocomplete="off"' : ''));
+
+ $GLOBALS['egw']->js->set_onload('document.login_form.login.focus();');
+
+ $this->render($tmpl->fp('loginout','login_form'),false,false);
+ }
+
+ /**
+ * displays a login denied message
+ */
+ function denylogin_screen()
+ {
+ $tmpl =& new Template($GLOBALS['egw_info']['server']['template_dir']);
+
+ $tmpl->set_file(array(
'login_form' => 'login_denylogin.tpl'
- ));
-
- $tmpl->set_var(array(
+ ));
+
+ $tmpl->set_var(array(
'template_set' => 'default',
'deny_msg' => lang('Oops! You caught us in the middle of system maintainance.').
'
'.lang('Please, check back with us shortly.'),
- ));
- $this->render($tmpl->fp('loginout','login_form'),false,false);
- }
-
- /**
- * Get navbar as array to eg. set as vars for a template (from idots' navbar.inc.php)
- *
- * Reimplemented so set the vars for the navbar itself (uses $this->tpl and the blocks a and b)
- *
- * @internal PHP5 protected
- * @param array $apps navbar apps from _get_navbar_apps
- * @return array
- */
- function _get_navbar($apps)
- {
- $var = parent::_get_navbar($apps);
-
- if($GLOBALS['egw_info']['user']['preferences']['common']['show_general_menu'] != 'sidebox')
- {
+ ));
+ $this->render($tmpl->fp('loginout','login_form'),false,false);
+ }
+
+ /**
+ * Get navbar as array to eg. set as vars for a template (from idots' navbar.inc.php)
+ *
+ * Reimplemented so set the vars for the navbar itself (uses $this->tpl and the blocks a and b)
+ *
+ * @internal PHP5 protected
+ * @param array $apps navbar apps from _get_navbar_apps
+ * @return array
+ */
+ function _get_navbar($apps)
+ {
+ $var = parent::_get_navbar($apps);
+
+ if($GLOBALS['egw_info']['user']['preferences']['common']['show_general_menu'] != 'sidebox')
+ {
$var['current_users'] = '';
$var['quick_add'] = '';
$var['user_info']='';
- }
-
- if($GLOBALS['egw_info']['user']['preferences']['common']['click_or_onmouseover'] == 'onmouseover')
- {
+ }
+
+ if($GLOBALS['egw_info']['user']['preferences']['common']['click_or_onmouseover'] == 'onmouseover')
+ {
$var['show_menu_event'] = 'onMouseOver';
- }
- else
- {
+ }
+ else
+ {
$var['show_menu_event'] = 'onClick';
- }
-
- if($GLOBALS['egw_info']['user']['userid'] == 'anonymous')
- {
- require_once(EGW_API_INC.'/class.config.inc.php');
- $cnf_reg =& new config('registration');
- $cnf_reg->read_repository();
- $config_reg = $cnf_reg->config_data;
- unset($cnf_reg);
-
+ }
+
+ if($GLOBALS['egw_info']['user']['userid'] == 'anonymous')
+ {
+ $config_reg = config::read('registration');
+
$this->tpl->set_var(array(
- 'url' => $GLOBALS['egw']->link('/logout.php'),
- 'title' => lang('Login'),
+ 'url' => $GLOBALS['egw']->link('/logout.php'),
+ 'title' => lang('Login'),
));
$this->tpl->fp('upper_tabs','upper_tab_block');
if ($config_reg[enable_registration]=='True' && $config_reg[register_link]=='True')
{
- $this->tpl->set_var(array(
- 'url' => $GLOBALS['egw']->link('/registration/index.php'),
- 'title' => lang('Register'),
- ));
+ $this->tpl->set_var(array(
+ 'url' => $GLOBALS['egw']->link('/registration/index.php'),
+ 'title' => lang('Register'),
+ ));
}
- }
-
- if (!($max_icons=$GLOBALS['egw_info']['user']['preferences']['common']['max_icons']))
- {
+ }
+
+ if (!($max_icons=$GLOBALS['egw_info']['user']['preferences']['common']['max_icons']))
+ {
$max_icons = 30;
- }
-
- if($GLOBALS['egw_info']['user']['preferences']['common']['start_and_logout_icons'] == 'no')
- {
+ }
+
+ if($GLOBALS['egw_info']['user']['preferences']['common']['start_and_logout_icons'] == 'no')
+ {
$tdwidth = 100 / $max_icons;
- }
- else
- {
+ }
+ else
+ {
$tdwidth = 100 / ($max_icons+1); // +1 for logout
- }
- $this->tpl->set_var('tdwidth',round($tdwidth));
-
- // not shown in the navbar
- foreach($apps as $app => $app_data)
- {
+ }
+ $this->tpl->set_var('tdwidth',round($tdwidth));
+
+ // not shown in the navbar
+ foreach($apps as $app => $app_data)
+ {
if ($app != 'preferences' && $app != 'about' && $app != 'logout' && $app != 'manual' &&
- ($app != 'home' || $GLOBALS['egw_info']['user']['preferences']['common']['start_and_logout_icons'] != 'no'))
+ ($app != 'home' || $GLOBALS['egw_info']['user']['preferences']['common']['start_and_logout_icons'] != 'no'))
{
- $this->tpl->set_var($app_data);
-
- if($i < $max_icons)
- {
- $this->tpl->set_var($app_data);
- if($GLOBALS['egw_info']['user']['preferences']['common']['navbar_format'] != 'text')
- {
- $this->tpl->fp('app_icons','app_icon_block',true);
- }
- if($GLOBALS['egw_info']['user']['preferences']['common']['navbar_format'] != 'icons')
- {
- $this->tpl->fp('app_titles','app_title_block',true);
- }
- }
- else // generate extra icon layer shows icons and/or text
- {
- $this->tpl->fp('app_extra_icons','app_extra_block',true);
- }
- $i++;
+ $this->tpl->set_var($app_data);
+
+ if($i < $max_icons)
+ {
+ $this->tpl->set_var($app_data);
+ if($GLOBALS['egw_info']['user']['preferences']['common']['navbar_format'] != 'text')
+ {
+ $this->tpl->fp('app_icons','app_icon_block',true);
+ }
+ if($GLOBALS['egw_info']['user']['preferences']['common']['navbar_format'] != 'icons')
+ {
+ $this->tpl->fp('app_titles','app_title_block',true);
+ }
+ }
+ else // generate extra icon layer shows icons and/or text
+ {
+ $this->tpl->fp('app_extra_icons','app_extra_block',true);
+ }
+ $i++;
}
- }
- // settings for the extra icons dif
- if ($i <= $max_icons) // no extra icon div
- {
+ }
+ // settings for the extra icons dif
+ if ($i <= $max_icons) // no extra icon div
+ {
$this->tpl->set_var('app_extra_icons_div','');
$this->tpl->set_var('app_extra_icons_icon','');
- }
- else
- {
+ }
+ else
+ {
$var['lang_close'] = lang('Close');
$var['lang_show_more_apps'] = lang('show_more_apps');
- }
- if ($GLOBALS['egw_info']['user']['preferences']['common']['start_and_logout_icons'] != 'no' &&
- $GLOBALS['egw_info']['user']['userid'] != 'anonymous')
- {
+ }
+ if ($GLOBALS['egw_info']['user']['preferences']['common']['start_and_logout_icons'] != 'no' &&
+ $GLOBALS['egw_info']['user']['userid'] != 'anonymous')
+ {
$this->tpl->set_var($apps['logout']);
if($GLOBALS['egw_info']['user']['preferences']['common']['navbar_format'] != 'text')
{
- $this->tpl->fp('app_icons','app_icon_block',true);
+ $this->tpl->fp('app_icons','app_icon_block',true);
}
if($GLOBALS['egw_info']['user']['preferences']['common']['navbar_format'] != 'icons')
{
- $this->tpl->fp('app_titles','app_title_block',true);
+ $this->tpl->fp('app_titles','app_title_block',true);
}
- }
-
- if($GLOBALS['egw_info']['user']['preferences']['common']['navbar_format'] == 'icons')
- {
+ }
+
+ if($GLOBALS['egw_info']['user']['preferences']['common']['navbar_format'] == 'icons')
+ {
$var['app_titles'] = ' | ';
- }
- return $var;
- }
-
- /**
- * Add menu items to the topmenu template class to be displayed
- *
- * @param string $app application name
- * @param mixed $alt_label string with alternative menu item label default value = null
- * @param string $urlextra string with alternate additional code inside -tag
- * @access protected
- * @return void
- */
- function _add_topmenu_item($app,$alt_label=null)
- {
- $_item['url'] = $this->apps[$app]['url'];
- $_item['urlextra'] = $this->apps[$app]['target'];
- $_item['label'] = ($alt_label?$alt_label:$this->apps[$app]['title']);
- $this->tplsav2->menuitems[$app] = $_item;
- $this->tplsav2->icon_or_star = $GLOBALS['egw_info']['server']['webserver_url'] . '/phpgwapi/templates/'.$this->template.'/images'.'/orange-ball.png';
- }
-
- /**
- * Add info items to the topmenu template class to be displayed
- *
- * @param string $content html of item
- * @access protected
- * @return void
- */
- function _add_topmenu_info_item($content)
- {
- $this->tplsav2->menuinfoitems[] = $content;
- }
-
- /**
- * Display the string with html of the topmenu if its enabled
- *
- * @return void
- */
- function topmenu()
- {
+ }
+ return $var;
+ }
+
+ /**
+ * Add menu items to the topmenu template class to be displayed
+ *
+ * @param string $app application name
+ * @param mixed $alt_label string with alternative menu item label default value = null
+ * @param string $urlextra string with alternate additional code inside -tag
+ * @access protected
+ * @return void
+ */
+ function _add_topmenu_item($app,$alt_label=null)
+ {
+ $_item['url'] = $this->apps[$app]['url'];
+ $_item['urlextra'] = $this->apps[$app]['target'];
+ $_item['label'] = ($alt_label?$alt_label:$this->apps[$app]['title']);
+ $this->tplsav2->menuitems[$app] = $_item;
+ $this->tplsav2->icon_or_star = $GLOBALS['egw_info']['server']['webserver_url'] . '/phpgwapi/templates/'.$this->template.'/images'.'/orange-ball.png';
+ }
+
+ /**
+ * Add info items to the topmenu template class to be displayed
+ *
+ * @param string $content html of item
+ * @access protected
+ * @return void
+ */
+ function _add_topmenu_info_item($content)
+ {
+ $this->tplsav2->menuinfoitems[] = $content;
+ }
+
+ /**
+ * Display the string with html of the topmenu if its enabled
+ *
+ * @return void
+ */
+ function topmenu()
+ {
$this->tplsav2->menuitems = array();
$this->tplsav2->menuinfoitems = array();
-
+
$this->apps = $this->_get_navbar_apps();
-
+
$this->_add_topmenu_item('home');
-
+
if($GLOBALS['egw_info']['user']['apps']['preferences'])
{
$this->_add_topmenu_item('preferences');
}
-
+
if($GLOBALS['egw_info']['user']['apps']['manual'] && $this->apps['manual'])
- {
- $this->_add_topmenu_item('manual');
- }
-
+ {
+ $this->_add_topmenu_item('manual');
+ }
+
//$this->_add_topmenu_item('about',lang('About %1',$GLOBALS['egw_info']['apps'][$GLOBALS['egw_info']['flags']['currentapp']]['title']));
$this->_add_topmenu_item('logout');
$this->tplsav2->assign('info_icons',$this->topmenu_icon_arr);
-
+
if($GLOBALS['egw_info']['user']['apps']['notifications'])
{
$this->_add_topmenu_info_item($this->_get_notification_bell());
@@ -635,164 +610,162 @@
$this->_add_topmenu_info_item($this->_user_time_info());
$this->_add_topmenu_info_item($this->_current_users());
$this->_add_topmenu_info_item($this->_get_quick_add());
-
+
return $this->tplsav2->fetch('topmenu.tpl.php');
- }
-
- /**
- * called by hooks to add an icon in the topmenu info location
- *
- * @param string $id unique element id
- * @param string $icon_src src of the icon image. Make sure this nog height then 18pixels
- * @param string $iconlink where the icon links to
- * @param booleon $blink set true to make the icon blink
- * @param mixed $tooltip string containing the tooltip html, or null of no tooltip
- * @access public
- * @return void
- */
- function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null)
- {
- $icon_arr['id'] = $id;
- $icon_arr['blink'] = $blink;
- $icon_arr['link'] = $iconlink;
- $icon_arr['image'] = $icon_src;
-
- if(!is_null($tooltip))
- {
- if (!is_object($GLOBALS['egw']->html))
- {
- require_once(EGW_API_INC.'/class.html.inc.php');
- $GLOBALS['egw']->html = new html;
- }
- $icon_arr['tooltip'] = $GLOBALS['egw']->html->tooltip($tooltip);
- }
-
- $this->topmenu_icon_arr[]=$icon_arr;
- }
-
- /**
- * Returns the html from the closing div of the main application area to the closing html-tag
- *
- * @return string html or null if no footer needed/wanted
- */
- function footer()
- {
- static $footer_done;
- if ($footer_done++) return; // prevent multiple footers, not sure we still need this (RalfBecker)
-
- if (!isset($GLOBALS['egw_info']['flags']['nofooter']) || !$GLOBALS['egw_info']['flags']['nofooter'])
- {
+ }
+
+ /**
+ * called by hooks to add an icon in the topmenu info location
+ *
+ * @param string $id unique element id
+ * @param string $icon_src src of the icon image. Make sure this nog height then 18pixels
+ * @param string $iconlink where the icon links to
+ * @param booleon $blink set true to make the icon blink
+ * @param mixed $tooltip string containing the tooltip html, or null of no tooltip
+ * @access public
+ * @return void
+ */
+ function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null)
+ {
+ $icon_arr['id'] = $id;
+ $icon_arr['blink'] = $blink;
+ $icon_arr['link'] = $iconlink;
+ $icon_arr['image'] = $icon_src;
+
+ if(!is_null($tooltip))
+ {
+ $icon_arr['tooltip'] = html::tooltip($tooltip);
+ }
+
+ $this->topmenu_icon_arr[]=$icon_arr;
+ }
+
+ /**
+ * Returns the html from the closing div of the main application area to the closing html-tag
+ *
+ * @return string html or null if no footer needed/wanted
+ */
+ function footer()
+ {
+ static $footer_done;
+ if ($footer_done++) return; // prevent multiple footers, not sure we still need this (RalfBecker)
+
+ if (!isset($GLOBALS['egw_info']['flags']['nofooter']) || !$GLOBALS['egw_info']['flags']['nofooter'])
+ {
// get the (depricated) application footer
$content = $this->_get_app_footer();
-
+
// run the hook navbar_end
// ToDo: change to return the content
ob_start();
$GLOBALS['egw']->hooks->process('navbar_end');
$content .= ob_get_contents();
ob_end_clean();
-
+
// eg. javascript, which need to be at the end of the page
if ($GLOBALS['egw_info']['flags']['need_footer'])
{
- $content .= $GLOBALS['egw_info']['flags']['need_footer'];
+ $content .= $GLOBALS['egw_info']['flags']['need_footer'];
}
-
+
// do the template sets footer, former parse_navbar_end function
// this closes the application area AND renders the closing body- and html-tag
if ($this->navbar_done)
{
- $this->tpl->set_file(array('footer' => 'footer.tpl'));
- $this->tpl->set_var($this->_get_footer());
- $content .= $this->tpl->fp('out','footer');
+ $this->tpl->set_file(array('footer' => 'footer.tpl'));
+ $this->tpl->set_var($this->_get_footer());
+ $content .= $this->tpl->fp('out','footer');
}
elseif (!isset($GLOBALS['egw_info']['flags']['noheader']) || !$GLOBALS['egw_info']['flags']['noheader'])
{
- $content .= "