forked from extern/egroupware
Make all methods of common class static, to allow an easiert use.
eg: $owner_label = common::grab_owner_name($uid);
This commit is contained in:
parent
b8f6481688
commit
97126e417f
@ -1,50 +1,28 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* eGroupWare API - Commononly used functions *
|
||||
* This file written by Dan Kuykendall <seek3r@phpgroupware.org> *
|
||||
* and Joseph Engo <jengo@phpgroupware.org> *
|
||||
* and Mark Peters <skeeter@phpgroupware.org> *
|
||||
* and Lars Kneschke <lkneschke@linux-at-work.de> *
|
||||
* Functions commonly used by eGroupWare developers *
|
||||
* Copyright (C) 2000, 2001 Dan Kuykendall *
|
||||
* Copyright (C) 2003 Lars Kneschke *
|
||||
* -------------------------------------------------------------------------*
|
||||
* This library is part of the eGroupWare API *
|
||||
* http://www.egroupware.org *
|
||||
* ------------------------------------------------------------------------ *
|
||||
* This library is free software; you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as published by *
|
||||
* the Free Software Foundation; either version 2.1 of the License, *
|
||||
* or any later version. *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU Lesser General Public License for more details. *
|
||||
* You should have received a copy of the GNU Lesser General Public License *
|
||||
* along with this library; if not, write to the Free Software Foundation, *
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
||||
\**************************************************************************/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
$d1 = strtolower(@substr(EGW_API_INC,0,3));
|
||||
$d2 = strtolower(@substr(EGW_SERVER_ROOT,0,3));
|
||||
$d3 = strtolower(@substr(EGW_APP_INC,0,3));
|
||||
if($d1 == 'htt' || $d1 == 'ftp' || $d2 == 'htt' || $d2 == 'ftp' || $d3 == 'htt' || $d3 == 'ftp')
|
||||
{
|
||||
echo 'Failed attempt to break in via an old Security Hole!<br>'."\n";
|
||||
exit;
|
||||
}
|
||||
unset($d1);unset($d2);unset($d3);
|
||||
/**
|
||||
* eGroupWare API: Commononly used (static) functions
|
||||
*
|
||||
* This file written by Dan Kuykendall <seek3r@phpgroupware.org>
|
||||
* and Joseph Engo <jengo@phpgroupware.org>
|
||||
* and Mark Peters <skeeter@phpgroupware.org>
|
||||
* and Lars Kneschke <lkneschke@linux-at-work.de>
|
||||
* Functions commonly used by eGroupWare developers
|
||||
* Copyright (C) 2000, 2001 Dan Kuykendall
|
||||
* Copyright (C) 2003 Lars Kneschke
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package api
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* common class that contains commonly used functions
|
||||
*
|
||||
* common class containing commonly used static functions
|
||||
*/
|
||||
class common
|
||||
{
|
||||
var $debug_info; // An array with debugging info from the API
|
||||
var $found_files;
|
||||
static $debug_info; // An array with debugging info from the API
|
||||
static $found_files;
|
||||
|
||||
/**
|
||||
* Compares two Version strings and return 1 if str2 is newest (bigger version number) than str1
|
||||
@ -238,7 +216,7 @@
|
||||
* There may need to be some cleanup before hand
|
||||
* @param $call_footer boolean value to if true then call footer else exit
|
||||
*/
|
||||
function egw_exit($call_footer = False)
|
||||
static function egw_exit($call_footer = False)
|
||||
{
|
||||
if (!defined('EGW_EXIT'))
|
||||
{
|
||||
@ -246,7 +224,7 @@
|
||||
|
||||
if ($call_footer)
|
||||
{
|
||||
$this->egw_footer();
|
||||
self::egw_footer();
|
||||
}
|
||||
}
|
||||
exit;
|
||||
@ -276,7 +254,7 @@
|
||||
}
|
||||
|
||||
// Look at the note towards the top of this file (jengo)
|
||||
function filesystem_separator()
|
||||
static function filesystem_separator()
|
||||
{
|
||||
return filesystem_separator();
|
||||
}
|
||||
@ -286,7 +264,7 @@
|
||||
*
|
||||
* @param $error - array of errors
|
||||
*/
|
||||
function error_list($errors,$text='Error')
|
||||
static function error_list($errors,$text='Error')
|
||||
{
|
||||
if (!is_array($errors))
|
||||
{
|
||||
@ -307,7 +285,7 @@
|
||||
*/
|
||||
function check_owner($record,$link,$label,$extravars = '')
|
||||
{
|
||||
$this->debug_info[] = 'check_owner() is a depreciated function - use ACL instead';
|
||||
self::$debug_info[] = 'check_owner() is a depreciated function - use ACL instead';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -318,7 +296,7 @@
|
||||
* @param $lastname='' lastname
|
||||
* @param $accountid=0 id, to check if it's a user or group, otherwise the lid will be used
|
||||
*/
|
||||
function display_fullname($lid = '', $firstname = '', $lastname = '',$accountid=0)
|
||||
static function display_fullname($lid = '', $firstname = '', $lastname = '',$accountid=0)
|
||||
{
|
||||
if (! $lid && ! $firstname && ! $lastname)
|
||||
{
|
||||
@ -375,11 +353,11 @@
|
||||
*
|
||||
* @param $id account id
|
||||
*/
|
||||
function grab_owner_name($accountid = '')
|
||||
static function grab_owner_name($accountid = '')
|
||||
{
|
||||
$GLOBALS['egw']->accounts->get_account_name($accountid,$lid,$fname,$lname);
|
||||
|
||||
return $this->display_fullname($lid,$fname,$lname,$accountid);
|
||||
return self::display_fullname($lid,$fname,$lname,$accountid);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -395,7 +373,7 @@
|
||||
* @param $fontsize optional
|
||||
* @return string return html that displays the tabs
|
||||
*/
|
||||
function create_tabs($tabs, $selected, $fontsize = '')
|
||||
static function create_tabs($tabs, $selected, $fontsize = '')
|
||||
{
|
||||
$output_text = '<table border="0" cellspacing="0" cellpadding="0"><tr>';
|
||||
|
||||
@ -486,7 +464,7 @@
|
||||
* $appname can either be passed or derived from $GLOBALS['egw_info']['flags']['currentapp'];
|
||||
* @param $appname name of application
|
||||
*/
|
||||
function get_app_dir($appname = '')
|
||||
static function get_app_dir($appname = '')
|
||||
{
|
||||
if ($appname == '')
|
||||
{
|
||||
@ -520,7 +498,7 @@
|
||||
* $appname can either be passed or derived from $GLOBALS['egw_info']['flags']['currentapp'];
|
||||
* @param $appname name of application
|
||||
*/
|
||||
function get_inc_dir($appname = '')
|
||||
static function get_inc_dir($appname = '')
|
||||
{
|
||||
if (!$appname)
|
||||
{
|
||||
@ -556,7 +534,7 @@
|
||||
*/
|
||||
function list_themes()
|
||||
{
|
||||
$tpl_dir = $this->get_tpl_dir('phpgwapi');
|
||||
$tpl_dir = self::get_tpl_dir('phpgwapi');
|
||||
|
||||
if ($dh = @opendir($tpl_dir . SEP . 'css'))
|
||||
{
|
||||
@ -679,7 +657,7 @@
|
||||
* this is just a workaround for idots, better to use find_image, which has a fallback \
|
||||
* on a per image basis to the default dir
|
||||
*/
|
||||
function is_image_dir($dir)
|
||||
static function is_image_dir($dir)
|
||||
{
|
||||
if (!@is_dir($dir))
|
||||
{
|
||||
@ -706,7 +684,7 @@
|
||||
*
|
||||
* @param $appname application name optional can be derived from $GLOBALS['egw_info']['flags']['currentapp'];
|
||||
*/
|
||||
function get_image_dir($appname = '')
|
||||
static function get_image_dir($appname = '')
|
||||
{
|
||||
if ($appname == '')
|
||||
{
|
||||
@ -722,15 +700,15 @@
|
||||
$imagedir_default = EGW_SERVER_ROOT . '/' . $appname . '/templates/idots/images';
|
||||
$imagedir_olddefault = EGW_SERVER_ROOT . '/' . $appname . '/images';
|
||||
|
||||
if ($this->is_image_dir ($imagedir))
|
||||
if (self::is_image_dir ($imagedir))
|
||||
{
|
||||
return $imagedir;
|
||||
}
|
||||
elseif ($this->is_image_dir ($imagedir_default))
|
||||
elseif (self::is_image_dir ($imagedir_default))
|
||||
{
|
||||
return $imagedir_default;
|
||||
}
|
||||
elseif ($this->is_image_dir ($imagedir_olddefault))
|
||||
elseif (self::is_image_dir ($imagedir_olddefault))
|
||||
{
|
||||
return $imagedir_olddefault;
|
||||
}
|
||||
@ -745,7 +723,7 @@
|
||||
*
|
||||
* @param $appname appication name optional can be derived from $GLOBALS['egw_info']['flags']['currentapp'];
|
||||
*/
|
||||
function get_image_path($appname = '')
|
||||
static function get_image_path($appname = '')
|
||||
{
|
||||
if ($appname == '')
|
||||
{
|
||||
@ -761,23 +739,20 @@
|
||||
$imagedir_default = EGW_SERVER_ROOT . '/'.$appname.'/templates/idots/images';
|
||||
$imagedir_olddefault = EGW_SERVER_ROOT . '/'.$appname.'/templates/default/images';
|
||||
|
||||
if ($this->is_image_dir ($imagedir))
|
||||
if (self::is_image_dir($imagedir))
|
||||
{
|
||||
return $GLOBALS['egw_info']['server']['webserver_url'].'/'.$appname.'/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/images';
|
||||
}
|
||||
elseif ($this->is_image_dir ($imagedir_default))
|
||||
elseif (self::is_image_dir($imagedir_default))
|
||||
{
|
||||
return $GLOBALS['egw_info']['server']['webserver_url'].'/'.$appname.'/templates/idots/images';
|
||||
}
|
||||
elseif ($this->is_image_dir ($imagedir_olddefault))
|
||||
elseif (self::is_image_dir($imagedir_olddefault))
|
||||
{
|
||||
return $GLOBALS['egw_info']['server']['webserver_url'].'/'.$appname.'/templates/default/images';
|
||||
}
|
||||
else
|
||||
{
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches and image by a given search order (it maintains a cache of the existing images):
|
||||
@ -794,7 +769,7 @@
|
||||
{
|
||||
$imagedir = '/'.$appname.'/templates/'.$GLOBALS['egw_info']['user']['preferences']['common']['template_set'].'/images';
|
||||
|
||||
if (!@is_array($this->found_files[$appname]))
|
||||
if (!@is_array(self::$found_files[$appname]))
|
||||
{
|
||||
$imagedir_olddefault = '/'.$appname.'/templates/default/images';
|
||||
$imagedir_default = '/'.$appname.'/templates/idots/images';
|
||||
@ -806,7 +781,7 @@
|
||||
{
|
||||
if ($entry != '.' && $entry != '..')
|
||||
{
|
||||
$this->found_files[$appname][$entry] = $imagedir_olddefault;
|
||||
self::$found_files[$appname][$entry] = $imagedir_olddefault;
|
||||
}
|
||||
}
|
||||
$d->close();
|
||||
@ -819,7 +794,7 @@
|
||||
{
|
||||
if ($entry != '.' && $entry != '..')
|
||||
{
|
||||
$this->found_files[$appname][$entry] = $imagedir_default;
|
||||
self::$found_files[$appname][$entry] = $imagedir_default;
|
||||
}
|
||||
}
|
||||
$d->close();
|
||||
@ -832,7 +807,7 @@
|
||||
{
|
||||
if ($entry != '.' && $entry != '..')
|
||||
{
|
||||
$this->found_files[$appname][$entry] = $imagedir;
|
||||
self::$found_files[$appname][$entry] = $imagedir;
|
||||
}
|
||||
}
|
||||
$d->close();
|
||||
@ -851,58 +826,58 @@
|
||||
}
|
||||
|
||||
// first look in the selected template dir
|
||||
if(@$this->found_files[$appname][$image.$img_type[0]]==$imagedir)
|
||||
if(@self::$found_files[$appname][$image.$img_type[0]]==$imagedir)
|
||||
{
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].$this->found_files[$appname][$image.$img_type[0]].'/'.$image.$img_type[0];
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$img_type[0]].'/'.$image.$img_type[0];
|
||||
}
|
||||
elseif(@$this->found_files[$appname][$image.$img_type[1]]==$imagedir)
|
||||
elseif(@self::$found_files[$appname][$image.$img_type[1]]==$imagedir)
|
||||
{
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].$this->found_files[$appname][$image.$img_type[1]].'/'.$image.$img_type[1];
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$img_type[1]].'/'.$image.$img_type[1];
|
||||
}
|
||||
elseif(@$this->found_files[$appname][$image.$img_type[2]]==$imagedir)
|
||||
elseif(@self::$found_files[$appname][$image.$img_type[2]]==$imagedir)
|
||||
{
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].$this->found_files[$appname][$image.$img_type[2]].'/'.$image.$img_type[2];
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$img_type[2]].'/'.$image.$img_type[2];
|
||||
}
|
||||
// then look everywhere else
|
||||
elseif(isset($this->found_files[$appname][$image.$img_type[0]]))
|
||||
elseif(isset(self::$found_files[$appname][$image.$img_type[0]]))
|
||||
{
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].$this->found_files[$appname][$image.$img_type[0]].'/'.$image.$img_type[0];
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$img_type[0]].'/'.$image.$img_type[0];
|
||||
}
|
||||
elseif(isset($this->found_files[$appname][$image.$img_type[1]]))
|
||||
elseif(isset(self::$found_files[$appname][$image.$img_type[1]]))
|
||||
{
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].$this->found_files[$appname][$image.$img_type[1]].'/'.$image.$img_type[1];
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$img_type[1]].'/'.$image.$img_type[1];
|
||||
}
|
||||
elseif(isset($this->found_files[$appname][$image.$img_type[2]]))
|
||||
elseif(isset(self::$found_files[$appname][$image.$img_type[2]]))
|
||||
{
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].$this->found_files[$appname][$image.$img_type[2]].'/'.$image.$img_type[2];
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image.$img_type[2]].'/'.$image.$img_type[2];
|
||||
}
|
||||
elseif(isset($this->found_files[$appname][$image]))
|
||||
elseif(isset(self::$found_files[$appname][$image]))
|
||||
{
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].$this->found_files[$appname][$image].'/'.$image;
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$image].'/'.$image;
|
||||
}
|
||||
else
|
||||
{
|
||||
// searching the image in the api-dirs
|
||||
if (!isset($this->found_files['phpgwapi']))
|
||||
if (!isset(self::$found_files['phpgwapi']))
|
||||
{
|
||||
$this->find_image('phpgwapi','');
|
||||
}
|
||||
|
||||
if(isset($this->found_files['phpgwapi'][$image.$img_type[0]]))
|
||||
if(isset(self::$found_files['phpgwapi'][$image.$img_type[0]]))
|
||||
{
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].$this->found_files['phpgwapi'][$image.$img_type[0]].'/'.$image.$img_type[0];
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files['phpgwapi'][$image.$img_type[0]].'/'.$image.$img_type[0];
|
||||
}
|
||||
elseif(isset($this->found_files['phpgwapi'][$image.$img_type[1]]))
|
||||
elseif(isset(self::$found_files['phpgwapi'][$image.$img_type[1]]))
|
||||
{
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].$this->found_files['phpgwapi'][$image.$img_type[1]].'/'.$image.$img_type[1];
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files['phpgwapi'][$image.$img_type[1]].'/'.$image.$img_type[1];
|
||||
}
|
||||
elseif(isset($this->found_files['phpgwapi'][$image.$img_type[2]]))
|
||||
elseif(isset(self::$found_files['phpgwapi'][$image.$img_type[2]]))
|
||||
{
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].$this->found_files['phpgwapi'][$image.$img_type[2]].'/'.$image.$img_type[2];
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files['phpgwapi'][$image.$img_type[2]].'/'.$image.$img_type[2];
|
||||
}
|
||||
elseif(isset($this->found_files['phpgwapi'][$image]))
|
||||
elseif(isset(self::$found_files['phpgwapi'][$image]))
|
||||
{
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].$this->found_files['phpgwapi'][$image].'/'.$image;
|
||||
$imgfile = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files['phpgwapi'][$image].'/'.$image;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -942,9 +917,9 @@
|
||||
}
|
||||
while (empty($image_found) && list(,$img) = each($image))
|
||||
{
|
||||
if(isset($this->found_files[$appname][$img.$ext]))
|
||||
if(isset(self::$found_files[$appname][$img.$ext]))
|
||||
{
|
||||
$image_found = $GLOBALS['egw_info']['server']['webserver_url'].$this->found_files[$appname][$img.$ext].'/'.$img.$ext;
|
||||
$image_found = $GLOBALS['egw_info']['server']['webserver_url'].self::$found_files[$appname][$img.$ext].'/'.$img.$ext;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -980,7 +955,7 @@
|
||||
*
|
||||
* @deprecated inherit from egw_framework class in your template and use egw_framework::_navbar_vars()
|
||||
*/
|
||||
function navbar()
|
||||
static function navbar()
|
||||
{
|
||||
$GLOBALS['egw_info']['navbar'] = $GLOBALS['egw']->framework->_get_navbar_vars();
|
||||
}
|
||||
@ -990,7 +965,7 @@
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
function app_header()
|
||||
static function app_header()
|
||||
{
|
||||
if (file_exists(EGW_APP_INC . '/header.inc.php'))
|
||||
{
|
||||
@ -1003,7 +978,7 @@
|
||||
*
|
||||
* @deprecated use egw_framework::header(), $GLOBALS['egw']->framework->navbar() or better egw_framework::render($content)
|
||||
*/
|
||||
function egw_header()
|
||||
static function egw_header()
|
||||
{
|
||||
echo $GLOBALS['egw']->framework->header();
|
||||
|
||||
@ -1018,7 +993,7 @@
|
||||
*
|
||||
* @deprecated use egw_framework::footer() or egw_framework::render($content)
|
||||
*/
|
||||
function egw_footer()
|
||||
static function egw_footer()
|
||||
{
|
||||
if(is_object($GLOBALS['egw']->framework)) {
|
||||
echo $GLOBALS['egw']->framework->footer();
|
||||
@ -1031,7 +1006,7 @@
|
||||
* @deprecated use framework::_get_css()
|
||||
* @return string
|
||||
*/
|
||||
function get_css()
|
||||
static function get_css()
|
||||
{
|
||||
return $GLOBALS['egw']->framework->_get_css();
|
||||
}
|
||||
@ -1042,7 +1017,7 @@
|
||||
* @deprecated use framework::_get_js()
|
||||
* @return string the javascript to be included
|
||||
*/
|
||||
function get_java_script()
|
||||
static function get_java_script()
|
||||
{
|
||||
return $GLOBALS['egw']->framework->_get_js();
|
||||
}
|
||||
@ -1053,12 +1028,12 @@
|
||||
* @deprecated use framework::_get_js()
|
||||
* @returns string body attributes
|
||||
*/
|
||||
function get_body_attribs()
|
||||
static function get_body_attribs()
|
||||
{
|
||||
return $GLOBALS['egw']->framework->_get_body_attribs();
|
||||
}
|
||||
|
||||
function hex2bin($data)
|
||||
static function hex2bin($data)
|
||||
{
|
||||
$len = strlen($data);
|
||||
return @pack('H' . $len, $data);
|
||||
@ -1069,7 +1044,7 @@
|
||||
*
|
||||
* @param $data data (string?) to be encrypted
|
||||
*/
|
||||
function encrypt($data)
|
||||
static function encrypt($data)
|
||||
{
|
||||
return $GLOBALS['egw']->crypto->encrypt($data);
|
||||
}
|
||||
@ -1079,7 +1054,7 @@
|
||||
*
|
||||
* @param $data data to be decrypted
|
||||
*/
|
||||
function decrypt($data)
|
||||
static function decrypt($data)
|
||||
{
|
||||
return $GLOBALS['egw']->crypto->decrypt($data);
|
||||
}
|
||||
@ -1092,7 +1067,7 @@
|
||||
* @deprecated use auth::encrypt_password()
|
||||
* @param $password password to encrypt
|
||||
*/
|
||||
function encrypt_password($password,$sql=False)
|
||||
static function encrypt_password($password,$sql=False)
|
||||
{
|
||||
return auth::encrypt_password($password,$sql);
|
||||
}
|
||||
@ -1122,46 +1097,6 @@
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* temp wrapper to new hooks class
|
||||
*
|
||||
*/
|
||||
function hook($location, $appname = '', $no_permission_check = False)
|
||||
{
|
||||
echo '$'."GLOBALS['phpgw']common->hook()".' has been replaced. Please change to the new $'."GLOBALS['phpgw']hooks->process()".'. For now this will act as a wrapper<br>';
|
||||
return $GLOBALS['egw']->hooks->process($location, $order, $no_permission_check);
|
||||
}
|
||||
|
||||
/**
|
||||
* temp wrapper to new hooks class
|
||||
*
|
||||
*/
|
||||
// Note: $no_permission_check should *ONLY* be used when it *HAS* to be. (jengo)
|
||||
function hook_single($location, $appname = '', $no_permission_check = False)
|
||||
{
|
||||
echo '$'."GLOBALS['phpgw']common->hook_single()".' has been replaced. Please change to the new $'."GLOBALS['phpgw']hooks->single()".'. For now this will act as a wrapper<br>';
|
||||
return $GLOBALS['egw']->hooks->single($location, $order, $no_permission_check);
|
||||
}
|
||||
|
||||
/**
|
||||
* temp wrapper to new hooks class
|
||||
*
|
||||
*/
|
||||
function hook_count($location)
|
||||
{
|
||||
echo '$'."GLOBALS['phpgw']common->hook_count()".' has been replaced. Please change to the new $'."GLOBALS['phpgw']hooks->count()".'. For now this will act as a wrapper<br>';
|
||||
return $GLOBALS['egw']->hooks->count($location);
|
||||
}
|
||||
|
||||
/* Wrapper to the session->appsession() */
|
||||
function appsession($data = '##NOTHING##')
|
||||
{
|
||||
$this->debug_info[] = "\$GLOBALS['egw']->common->appsession() is a depreciated function"
|
||||
. " - use \$GLOBALS['egw']->session->appsession() instead";
|
||||
|
||||
return $GLOBALS['egw']->session->appsession('default','',$data);
|
||||
}
|
||||
|
||||
/**
|
||||
* return a formatted timestamp or current time
|
||||
*
|
||||
@ -1170,7 +1105,7 @@
|
||||
* @param boolean $adjust_to_usertime=true should datetime::tz_offset be added to $t or not, default true
|
||||
* @return string the formated date/time
|
||||
*/
|
||||
function show_date($t = 0, $format = '', $adjust_to_usertime=true)
|
||||
static function show_date($t = 0, $format = '', $adjust_to_usertime=true)
|
||||
{
|
||||
if (!$t)
|
||||
{
|
||||
@ -1206,7 +1141,7 @@
|
||||
* @param boolean $add_seperator=false add the separator specifed in the prefs or not, default no
|
||||
* @return string
|
||||
*/
|
||||
function dateformatorder($yearstr,$monthstr,$daystr,$add_seperator = False)
|
||||
static function dateformatorder($yearstr,$monthstr,$daystr,$add_seperator = False)
|
||||
{
|
||||
$dateformat = strtolower($GLOBALS['egw_info']['user']['preferences']['common']['dateformat']);
|
||||
$sep = substr($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'],1,1);
|
||||
@ -1231,7 +1166,7 @@
|
||||
* @param int/string $sec='' defaults to ''
|
||||
* @return string formated time
|
||||
*/
|
||||
function formattime($hour,$min,$sec='')
|
||||
static function formattime($hour,$min,$sec='')
|
||||
{
|
||||
$h12 = $hour;
|
||||
if ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '12')
|
||||
@ -1280,7 +1215,7 @@
|
||||
* @param string $domain=null domain-name or null to use eGW's default domain $GLOBALS['egw_info']['server']['mail_suffix]
|
||||
* @return string with email address
|
||||
*/
|
||||
function email_address($first,$last,$account,$domain=null)
|
||||
static function email_address($first,$last,$account,$domain=null)
|
||||
{
|
||||
//echo "<p align=right>common::email_address('$first','$last','$account')";
|
||||
// convert all european special chars to ascii, (c) RalfBecker-AT-egroupware.org ;-)
|
||||
@ -1321,45 +1256,6 @@
|
||||
return $email;
|
||||
}
|
||||
|
||||
// This is not the best place for it, but it needs to be shared bewteen Aeromail and SM
|
||||
/**
|
||||
* uses code in /email class msg to obtain the appropriate password for email
|
||||
*
|
||||
* @param (none - it will abtain the info it needs on its own)
|
||||
*/
|
||||
/*
|
||||
function get_email_passwd_ex()
|
||||
{
|
||||
// ---- Create the email Message Class if needed -----
|
||||
if (is_object($GLOBALS['egw']->msg))
|
||||
{
|
||||
$do_free_me = False;
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['egw']->msg =& CreateObject('email.mail_msg');
|
||||
$do_free_me = True;
|
||||
}
|
||||
// use the Msg class to obtain the appropriate password
|
||||
$tmp_prefs = $GLOBALS['egw']->preferences->read();
|
||||
if (!isset($tmp_prefs['email']['passwd']))
|
||||
{
|
||||
$email_passwd = $GLOBALS['egw_info']['user']['passwd'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$email_passwd = $GLOBALS['egw']->msg->decrypt_email_passwd($tmp_prefs['email']['passwd']);
|
||||
}
|
||||
// cleanup and return
|
||||
if ($do_free_me)
|
||||
{
|
||||
unset ($GLOBALS['egw']->msg);
|
||||
}
|
||||
return $email_passwd;
|
||||
}
|
||||
*/
|
||||
|
||||
// This is not the best place for it, but it needs to be shared bewteen Aeromail and SM
|
||||
/**
|
||||
* create email preferences
|
||||
*
|
||||
@ -1391,97 +1287,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
function create_emailpreferences($prefs,$accountid='')
|
||||
{
|
||||
$account_id = get_account_id($accountid);
|
||||
|
||||
// NEW EMAIL PASSWD METHOD (shared between SM and aeromail)
|
||||
$prefs['email']['passwd'] = $this->get_email_passwd_ex();
|
||||
|
||||
// Add default preferences info
|
||||
if (!isset($prefs['email']['userid']))
|
||||
{
|
||||
if ($GLOBALS['egw_info']['server']['mail_login_type'] == 'vmailmgr')
|
||||
{
|
||||
$prefs['email']['userid'] = $GLOBALS['egw']->accounts->id2name($account_id)
|
||||
. '@' . $GLOBALS['egw_info']['server']['mail_suffix'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$prefs['email']['userid'] = $GLOBALS['egw']->accounts->id2name($account_id);
|
||||
}
|
||||
}
|
||||
// Set Server Mail Type if not defined
|
||||
if (empty($GLOBALS['egw_info']['server']['mail_server_type']))
|
||||
{
|
||||
$GLOBALS['egw_info']['server']['mail_server_type'] = 'imap';
|
||||
}
|
||||
|
||||
// OLD EMAIL PASSWD METHOD
|
||||
if (!isset($prefs['email']['passwd']))
|
||||
{
|
||||
$prefs['email']['passwd'] = $GLOBALS['egw_info']['user']['passwd'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$prefs['email']['passwd'] = $this->decrypt($prefs['email']['passwd']);
|
||||
}
|
||||
// NEW EMAIL PASSWD METHOD Located at the begining of this function
|
||||
|
||||
if (!isset($prefs['email']['address']))
|
||||
{
|
||||
$prefs['email']['address'] = $GLOBALS['egw']->accounts->id2name($account_id)
|
||||
. '@' . $GLOBALS['egw_info']['server']['mail_suffix'];
|
||||
}
|
||||
if (!isset($prefs['email']['mail_server']))
|
||||
{
|
||||
$prefs['email']['mail_server'] = $GLOBALS['egw_info']['server']['mail_server'];
|
||||
}
|
||||
if (!isset($prefs['email']['mail_server_type']))
|
||||
{
|
||||
$prefs['email']['mail_server_type'] = $GLOBALS['egw_info']['server']['mail_server_type'];
|
||||
}
|
||||
if (!isset($prefs['email']['imap_server_type']))
|
||||
{
|
||||
$prefs['email']['imap_server_type'] = $GLOBALS['egw_info']['server']['imap_server_type'];
|
||||
}
|
||||
// These sets the mail_port server variable
|
||||
if ($prefs['email']['mail_server_type']=='imap')
|
||||
{
|
||||
$prefs['email']['mail_port'] = '143';
|
||||
}
|
||||
elseif ($prefs['email']['mail_server_type']=='pop3')
|
||||
{
|
||||
$prefs['email']['mail_port'] = '110';
|
||||
}
|
||||
elseif ($prefs['email']['mail_server_type']=='imaps')
|
||||
{
|
||||
$prefs['email']['mail_port'] = '993';
|
||||
}
|
||||
elseif ($prefs['email']['mail_server_type']=='pop3s')
|
||||
{
|
||||
$prefs['email']['mail_port'] = '995';
|
||||
}
|
||||
// This is going to be used to switch to the nntp class
|
||||
if (isset($GLOBALS['egw_info']['flags']['newsmode']) &&
|
||||
$GLOBALS['egw_info']['flags']['newsmode'])
|
||||
{
|
||||
$prefs['email']['mail_server_type'] = 'nntp';
|
||||
}
|
||||
// DEBUG
|
||||
//echo "<br>prefs['email']['passwd']: " .$prefs['email']['passwd'] .'<br>';
|
||||
return $prefs;
|
||||
}
|
||||
*/
|
||||
|
||||
// This will be moved into the applications area.
|
||||
/**
|
||||
* ?
|
||||
*
|
||||
* This will be moved into the applications area
|
||||
*/
|
||||
function check_code($code)
|
||||
static function check_code($code)
|
||||
{
|
||||
$s = '<br>';
|
||||
switch ($code)
|
||||
@ -1567,6 +1378,7 @@
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
|
||||
/**
|
||||
* process error message
|
||||
*
|
||||
@ -1574,7 +1386,7 @@
|
||||
* @param $line line
|
||||
* @param $file file
|
||||
*/
|
||||
function phpgw_error($error,$line = '', $file = '')
|
||||
static function phpgw_error($error,$line = '', $file = '')
|
||||
{
|
||||
echo '<p><b>eGroupWare internal error:</b><p>'.$error;
|
||||
if ($line)
|
||||
@ -1594,7 +1406,7 @@
|
||||
*
|
||||
* @param $array - array
|
||||
*/
|
||||
function create_phpcode_from_array($array)
|
||||
static function create_phpcode_from_array($array)
|
||||
{
|
||||
while (list($key, $val) = each($array))
|
||||
{
|
||||
@ -1643,7 +1455,7 @@
|
||||
*
|
||||
* @param array - array
|
||||
*/
|
||||
function debug_list_array_contents($array)
|
||||
static function debug_list_array_contents($array)
|
||||
{
|
||||
while (list($key, $val) = each($array))
|
||||
{
|
||||
@ -1686,7 +1498,7 @@
|
||||
* return a list of functionsin the API
|
||||
*
|
||||
*/
|
||||
function debug_list_core_functions()
|
||||
static function debug_list_core_functions()
|
||||
{
|
||||
echo '<br><b>core functions</b><br>';
|
||||
echo '<pre>';
|
||||
@ -1695,7 +1507,7 @@
|
||||
echo '</pre>';
|
||||
}
|
||||
|
||||
var $nextid_table = 'egw_nextid';
|
||||
const NEXTID_TABLE = 'egw_nextid';
|
||||
|
||||
/**
|
||||
* Return a value for the next id an app/class may need to insert values into LDAP
|
||||
@ -1705,15 +1517,14 @@
|
||||
* @param int $max=0 if != 0 maximum id allowed, if it would be exceeded we return false
|
||||
* @return int/boolean the next id or false if $max given and exceeded
|
||||
*/
|
||||
function next_id($appname,$min=0,$max=0)
|
||||
static function next_id($appname,$min=0,$max=0)
|
||||
{
|
||||
if (!$appname)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
$GLOBALS['egw']->db->select($this->nextid_table,'id',array('appname' => $appname),__LINE__,__FILE__);
|
||||
$id = $GLOBALS['egw']->db->next_record() ? $GLOBALS['egw']->db->f('id') : 0;
|
||||
$id = (int) $GLOBALS['egw']->db->select(self::NEXTID_TABLE,'id',array('appname' => $appname),__LINE__,__FILE__)->fetchSingle();
|
||||
|
||||
if ($max && $id >= $max)
|
||||
{
|
||||
@ -1723,7 +1534,7 @@
|
||||
|
||||
if($id < $min) $id = $min;
|
||||
|
||||
$GLOBALS['egw']->db->insert($this->nextid_table,array('id' => $id),array('appname' => $appname),__LINE__,__FILE__);
|
||||
$GLOBALS['egw']->db->insert(self::NEXTID_TABLE,array('id' => $id),array('appname' => $appname),__LINE__,__FILE__);
|
||||
|
||||
return (int)$id;
|
||||
}
|
||||
@ -1736,25 +1547,24 @@
|
||||
* @param int $max=0 if != 0 maximum id allowed, if it would be exceeded we return false
|
||||
* @return int current id in the next_id table for a particular app/class or -1 for no app and false if $max is exceeded.
|
||||
*/
|
||||
function last_id($appname,$min=0,$max=0)
|
||||
static function last_id($appname,$min=0,$max=0)
|
||||
{
|
||||
if (!$appname)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
$GLOBALS['egw']->db->select($this->nextid_table,'id',array('appname' => $appname),__LINE__,__FILE__);
|
||||
$id = $GLOBALS['egw']->db->next_record() ? $GLOBALS['egw']->db->f('id') : 0;
|
||||
$id = (int)$GLOBALS['egw']->db->select(self::NEXTID_TABLE,'id',array('appname' => $appname),__LINE__,__FILE__)->fetchSingle();
|
||||
|
||||
if (!$id || $id < $min)
|
||||
{
|
||||
return $this->next_id($appname,$min,$max);
|
||||
return self::next_id($appname,$min,$max);
|
||||
}
|
||||
if ($max && $id > $max)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
return (int)$id;
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1764,7 +1574,7 @@
|
||||
* @param string $referer='' referer string to use, default ('') use $_SERVER['HTTP_REFERER']
|
||||
* @return string
|
||||
*/
|
||||
function get_referer($default='',$referer='')
|
||||
static function get_referer($default='',$referer='')
|
||||
{
|
||||
if (!$referer) $referer = $_SERVER['HTTP_REFERER'];
|
||||
|
||||
@ -1785,23 +1595,23 @@
|
||||
}
|
||||
|
||||
// some depricated functions for the migration
|
||||
function phpgw_exit($call_footer = False)
|
||||
static function phpgw_exit($call_footer = False)
|
||||
{
|
||||
$this->egw_exit($call_footer);
|
||||
self::egw_exit($call_footer);
|
||||
}
|
||||
|
||||
function phpgw_final()
|
||||
static function phpgw_final()
|
||||
{
|
||||
$this->egw_final();
|
||||
self::egw_final();
|
||||
}
|
||||
|
||||
function phpgw_header()
|
||||
static function phpgw_header()
|
||||
{
|
||||
$this->egw_header();
|
||||
self::egw_header();
|
||||
}
|
||||
|
||||
function phpgw_footer()
|
||||
static function phpgw_footer()
|
||||
{
|
||||
$this->egw_footer();
|
||||
self::egw_footer();
|
||||
}
|
||||
}
|
||||
}//end common class
|
||||
|
Loading…
Reference in New Issue
Block a user