renamed ExecObject() to ExecMethod()

This commit is contained in:
seek3r 2001-08-07 16:02:55 +00:00
parent 149888c36d
commit c85008c270

View File

@ -40,12 +40,12 @@
@param $classname name of class
@param $p1-$p16 class parameters (all optional)
*/
function CreateObject($class,
function CreateObject($class,
$p1='_UNDEF_',$p2='_UNDEF_',$p3='_UNDEF_',$p4='_UNDEF_',
$p5='_UNDEF_',$p6='_UNDEF_',$p7='_UNDEF_',$p8='_UNDEF_',
$p9='_UNDEF_',$p10='_UNDEF_',$p11='_UNDEF_',$p12='_UNDEF_',
$p13='_UNDEF_',$p14='_UNDEF_',$p15='_UNDEF_',$p16='_UNDEF_')
{
{
global $phpgw_info;
/* error_reporting(0); */
@ -82,7 +82,7 @@
}
/* error_reporting(E_ERROR | E_WARNING | E_PARSE); */
return $obj;
}
}
/*!
@function ExecObject
@ -92,18 +92,18 @@
and if the class file has not been included it will do so. <br>
Syntax: ExecObject('app.class', 'constructor_params'); <br>
Example1: ExecObject('phpgwapi.acl.read');
@param $object to execute
@param $method to execute
@param $functionparams function param should be an array
@param $loglevel developers choice of logging level
@param $classparams params to be sent to the contructor
*/
function ExecObject($object, $functionparams = '_UNDEF_', $loglevel = 3, $classparams = '_UNDEF_')
function ExecMethod($method, $functionparams = '_UNDEF_', $loglevel = 3, $classparams = '_UNDEF_')
{
/* Need to make sure this is working against a single dimensional object */
$partscount = substr_count($object, '.');
$partscount = substr_count($method, '.');
if ($partscount == 2)
{
list($appname,$classname,$functionname) = explode(".", $object);
list($appname,$classname,$functionname) = explode(".", $method);
if (!is_object($GLOBALS[$classname]))
{
if ($classparams != '_UNDEF_' && $classparams != True)
@ -125,22 +125,22 @@ function ExecObject($object, $functionparams = '_UNDEF_', $loglevel = 3, $classp
return $GLOBALS[$classname]->$functionname();
}
}
/* if the $object includes a parent class (multi-dimensional) then we have to work from it */
/* if the $method includes a parent class (multi-dimensional) then we have to work from it */
elseif ($partscount >= 3)
{
$GLOBALS['objectparts'] = explode(".", $object);
$GLOBALS['methodparts'] = explode(".", $method);
$classpartnum = $partscount - 1;
$appname = $GLOBALS['objectparts'][0];
$classname = $GLOBALS['objectparts'][$classpartnum];
$functionname = $GLOBALS['objectparts'][$partscount];
$appname = $GLOBALS['methodparts'][0];
$classname = $GLOBALS['methodparts'][$classpartnum];
$functionname = $GLOBALS['methodparts'][$partscount];
/* Now I clear these out of the array so that I can do a proper */
/* loop and build the $parentobject */
unset ($GLOBALS['objectparts'][0]);
unset ($GLOBALS['objectparts'][$classpartnum]);
unset ($GLOBALS['objectparts'][$partscount]);
reset ($GLOBALS['objectparts']);
unset ($GLOBALS['methodparts'][0]);
unset ($GLOBALS['methodparts'][$classpartnum]);
unset ($GLOBALS['methodparts'][$partscount]);
reset ($GLOBALS['methodparts']);
$firstparent = 'True';
while (list ($key, $val) = each ($GLOBALS['objectparts']))
while (list ($key, $val) = each ($GLOBALS['methodparts']))
{
if ($firstparent == 'True')
{
@ -152,7 +152,7 @@ function ExecObject($object, $functionparams = '_UNDEF_', $loglevel = 3, $classp
$parentobject .= '->'.$val;
}
}
unset($GLOBALS['objectparts']);
unset($GLOBALS['methodparts']);
eval ('$isobject = is_object('.$parentobject.'->'.$classname.');');
if (!$isobject)
{
@ -193,8 +193,8 @@ function ExecObject($object, $functionparams = '_UNDEF_', $loglevel = 3, $classp
@function lang
@abstract function to handle multilanguage support
*/
function lang($key,$m1='',$m2='',$m3='',$m4='',$m5='',$m6='',$m7='',$m8='',$m9='',$m10='')
{
function lang($key,$m1='',$m2='',$m3='',$m4='',$m5='',$m6='',$m7='',$m8='',$m9='',$m10='')
{
if(gettype($m1) == 'array')
{
$vars = $m1;
@ -205,13 +205,13 @@ function ExecObject($object, $functionparams = '_UNDEF_', $loglevel = 3, $classp
}
$value = $GLOBALS['phpgw']->translation->translate("$key",$vars);
return $value;
}
}
/* Just a temp wrapper. ###DELETE_ME#### (Seek3r) */
function check_code($code)
{
function check_code($code)
{
return $GLOBALS['phpgw']->common->check_code($code);
}
}
/*!
@function get_account_id()
@ -225,8 +225,8 @@ function ExecObject($object, $functionparams = '_UNDEF_', $loglevel = 3, $classp
@param $account_id either a name or an id
@param $default_id either a name or an id
*/
function get_account_id($account_id = '',$default_id = '')
{
function get_account_id($account_id = '',$default_id = '')
{
if (gettype($account_id) == 'integer')
{
return $account_id;
@ -254,15 +254,15 @@ function ExecObject($object, $functionparams = '_UNDEF_', $loglevel = 3, $classp
return $GLOBALS['phpgw']->accounts->name2id($account_id);
}
}
}
}
/*!
@function filesystem_separator()
@abstract sets the file system seperator depending on OS
@result file system separator
*/
function filesystem_separator()
{
function filesystem_separator()
{
if (PHP_OS == 'Windows' || PHP_OS == 'OS/2')
{
return '\\';
@ -271,10 +271,10 @@ function ExecObject($object, $functionparams = '_UNDEF_', $loglevel = 3, $classp
{
return '/';
}
}
}
function _debug_array($array)
{
function _debug_array($array)
{
if(floor(phpversion()) == 4)
{
echo '<pre>'; print_r($array); echo '</pre>';
@ -283,16 +283,16 @@ function ExecObject($object, $functionparams = '_UNDEF_', $loglevel = 3, $classp
{
echo '<pre>'; var_dump($array); echo '</pre>';
}
}
}
function print_debug($text='')
{
function print_debug($text='')
{
if (isset($GLOBALS['debugme']) &&
$GLOBALS['debugme'] == 'on')
{
echo 'debug: '.$text.'<br>';
}
}
}
// print_debug('core functions are done');
/****************************************************************************\
@ -300,55 +300,55 @@ function ExecObject($object, $functionparams = '_UNDEF_', $loglevel = 3, $classp
\****************************************************************************/
// error_reporting(7);
/* Make sure the header.inc.php is current. */
if ($GLOBALS['phpgw_info']['server']['versions']['header'] < $GLOBALS['phpgw_info']['server']['versions']['current_header'])
{
if ($GLOBALS['phpgw_info']['server']['versions']['header'] < $GLOBALS['phpgw_info']['server']['versions']['current_header'])
{
echo '<center><b>You need to port your settings to the new header.inc.php version.</b></center>';
exit;
}
}
/* Make sure the developer is following the rules. */
if (!isset($GLOBALS['phpgw_info']['flags']['currentapp']))
{
if (!isset($GLOBALS['phpgw_info']['flags']['currentapp']))
{
$phpgw->log->write(array('text'=>'W-MissingFlags, currentapp flag not set'));
echo '<b>!!! YOU DO NOT HAVE YOUR $phpgw_info["flags"]["currentapp"] SET !!!';
echo '<br>!!! PLEASE CORRECT THIS SITUATION !!!</b>';
}
}
magic_quotes_runtime(false);
print_debug('sane environment');
magic_quotes_runtime(false);
print_debug('sane environment');
/****************************************************************************\
* Multi-Domain support *
\****************************************************************************/
/* make them fix their header */
if (!isset($GLOBALS['phpgw_domain']))
{
if (!isset($GLOBALS['phpgw_domain']))
{
echo '<center><b>The administrator must upgrade the header.inc.php file before you can continue.</b></center>';
exit;
}
reset($GLOBALS['phpgw_domain']);
$default_domain = each($GLOBALS['phpgw_domain']);
$GLOBALS['phpgw_info']['server']['default_domain'] = $default_domain[0];
unset ($default_domain); // we kill this for security reasons
}
reset($GLOBALS['phpgw_domain']);
$default_domain = each($GLOBALS['phpgw_domain']);
$GLOBALS['phpgw_info']['server']['default_domain'] = $default_domain[0];
unset ($default_domain); // we kill this for security reasons
/* This code will handle virtdomains so that is a user logins with user@domain.com, it will switch into virtualization mode. */
if (isset($domain))
{
if (isset($domain))
{
$GLOBALS['phpgw_info']['user']['domain'] = $domain;
}
elseif (isset($login) && isset($logindomain))
{
}
elseif (isset($login) && isset($logindomain))
{
if (!ereg ("\@", $login))
{
$login = $login."@".$logindomain;
}
$GLOBALS['phpgw_info']['user']['domain'] = $logindomain;
unset ($logindomain);
}
elseif (isset($login) && !isset($logindomain))
{
}
elseif (isset($login) && !isset($logindomain))
{
if (ereg ("\@", $login))
{
$login_array = explode("@", $login);
@ -359,85 +359,85 @@ function ExecObject($object, $functionparams = '_UNDEF_', $loglevel = 3, $classp
$GLOBALS['phpgw_info']['user']['domain'] = $GLOBALS['phpgw_info']['server']['default_domain'];
$login = $login . '@' . $GLOBALS['phpgw_info']['user']['domain'];
}
}
}
if (@isset($GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]))
{
if (@isset($GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]))
{
$GLOBALS['phpgw_info']['server']['db_host'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_host'];
$GLOBALS['phpgw_info']['server']['db_name'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_name'];
$GLOBALS['phpgw_info']['server']['db_user'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_user'];
$GLOBALS['phpgw_info']['server']['db_pass'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_pass'];
$GLOBALS['phpgw_info']['server']['db_type'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_type'];
}
else
{
}
else
{
$GLOBALS['phpgw_info']['server']['db_host'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_host'];
$GLOBALS['phpgw_info']['server']['db_name'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_name'];
$GLOBALS['phpgw_info']['server']['db_user'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_user'];
$GLOBALS['phpgw_info']['server']['db_pass'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_pass'];
$GLOBALS['phpgw_info']['server']['db_type'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_type'];
}
}
if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'login' && ! $GLOBALS['phpgw_info']['server']['show_domain_selectbox'])
{
if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'login' && ! $GLOBALS['phpgw_info']['server']['show_domain_selectbox'])
{
unset ($GLOBALS['phpgw_domain']); // we kill this for security reasons
}
unset ($domain); // we kill this to save memory
}
unset ($domain); // we kill this to save memory
@print_debug('domain: '.$GLOBALS['phpgw_info']['user']['domain']);
@print_debug('domain: '.$GLOBALS['phpgw_info']['user']['domain']);
/****************************************************************************\
* These lines load up the API, fill up the $phpgw_info array, etc *
\****************************************************************************/
/* Load main class */
$GLOBALS['phpgw'] = CreateObject('phpgwapi.phpgw');
$GLOBALS['phpgw'] = CreateObject('phpgwapi.phpgw');
/************************************************************************\
* Load up the main instance of the db class. *
\************************************************************************/
$GLOBALS['phpgw']->db = CreateObject('phpgwapi.db');
$GLOBALS['phpgw']->db->Host = $GLOBALS['phpgw_info']['server']['db_host'];
$GLOBALS['phpgw']->db->Type = $GLOBALS['phpgw_info']['server']['db_type'];
$GLOBALS['phpgw']->db->Database = $GLOBALS['phpgw_info']['server']['db_name'];
$GLOBALS['phpgw']->db->User = $GLOBALS['phpgw_info']['server']['db_user'];
$GLOBALS['phpgw']->db->Password = $GLOBALS['phpgw_info']['server']['db_pass'];
if ($GLOBALS['phpgw']->debug)
{
$GLOBALS['phpgw']->db = CreateObject('phpgwapi.db');
$GLOBALS['phpgw']->db->Host = $GLOBALS['phpgw_info']['server']['db_host'];
$GLOBALS['phpgw']->db->Type = $GLOBALS['phpgw_info']['server']['db_type'];
$GLOBALS['phpgw']->db->Database = $GLOBALS['phpgw_info']['server']['db_name'];
$GLOBALS['phpgw']->db->User = $GLOBALS['phpgw_info']['server']['db_user'];
$GLOBALS['phpgw']->db->Password = $GLOBALS['phpgw_info']['server']['db_pass'];
if ($GLOBALS['phpgw']->debug)
{
$GLOBALS['phpgw']->db->Debug = 1;
}
}
$GLOBALS['phpgw']->db->Halt_On_Error = 'no';
@$GLOBALS['phpgw']->db->query("select count(*) from phpgw_config");
if (! @$GLOBALS['phpgw']->db->next_record())
{
$GLOBALS['phpgw']->db->Halt_On_Error = 'no';
@$GLOBALS['phpgw']->db->query("select count(*) from phpgw_config");
if (! @$GLOBALS['phpgw']->db->next_record())
{
$setup_dir = ereg_replace($PHP_SELF,'index.php','setup/');
echo '<center><b>Fatal Error:</b> It appears that you have not created the database tables for '
.'phpGroupWare. Click <a href="' . $setup_dir . '">here</a> to run setup.</center>';
exit;
}
$GLOBALS['phpgw']->db->Halt_On_Error = 'yes';
}
$GLOBALS['phpgw']->db->Halt_On_Error = 'yes';
/* Fill phpgw_info["server"] array */
// An Attempt to speed things up using cache premise
$GLOBALS['phpgw']->db->query("select config_value from phpgw_config WHERE config_app='phpgwapi' and config_name='cache_phpgw_info'",__LINE__,__FILE__);
if ($GLOBALS['phpgw']->db->num_rows())
{
$GLOBALS['phpgw']->db->query("select config_value from phpgw_config WHERE config_app='phpgwapi' and config_name='cache_phpgw_info'",__LINE__,__FILE__);
if ($GLOBALS['phpgw']->db->num_rows())
{
$GLOBALS['phpgw']->db->next_record();
$GLOBALS['phpgw_info']['server']['cache_phpgw_info'] = stripslashes($GLOBALS['phpgw']->db->f('config_value'));
}
}
$cache_query = "select content from phpgw_app_sessions where"
$cache_query = "select content from phpgw_app_sessions where"
." sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config'";
$GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__);
$server_info_cache = $GLOBALS['phpgw']->db->num_rows();
$GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__);
$server_info_cache = $GLOBALS['phpgw']->db->num_rows();
if(@$GLOBALS['phpgw_info']['server']['cache_phpgw_info'] && $server_info_cache)
{
if(@$GLOBALS['phpgw_info']['server']['cache_phpgw_info'] && $server_info_cache)
{
$GLOBALS['phpgw']->db->next_record();
$GLOBALS['phpgw_info']['server'] = unserialize(stripslashes($GLOBALS['phpgw']->db->f('content')));
}
else
{
}
else
{
$GLOBALS['phpgw']->db->query("select * from phpgw_config WHERE config_app='phpgwapi'",__LINE__,__FILE__);
while ($GLOBALS['phpgw']->db->next_record())
{
@ -458,43 +458,43 @@ function ExecObject($object, $functionparams = '_UNDEF_', $loglevel = 3, $classp
}
$GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__);
}
}
unset($cache_query);
unset($server_info_cache);
}
unset($cache_query);
unset($server_info_cache);
/************************************************************************\
* Required classes *
\************************************************************************/
$GLOBALS['phpgw']->common = CreateObject('phpgwapi.common');
$GLOBALS['phpgw']->hooks = CreateObject('phpgwapi.hooks');
$GLOBALS['phpgw']->auth = CreateObject('phpgwapi.auth');
$GLOBALS['phpgw']->accounts = CreateObject('phpgwapi.accounts');
$GLOBALS['phpgw']->acl = CreateObject('phpgwapi.acl');
$GLOBALS['phpgw']->session = CreateObject('phpgwapi.sessions');
$GLOBALS['phpgw']->preferences = CreateObject('phpgwapi.preferences');
$GLOBALS['phpgw']->applications = CreateObject('phpgwapi.applications');
$GLOBALS['phpgw']->translation = CreateObject('phpgwapi.translation');
$GLOBALS['phpgw']->log = CreateObject('phpgwapi.errorlog');
$GLOBALS['phpgw']->common = CreateObject('phpgwapi.common');
$GLOBALS['phpgw']->hooks = CreateObject('phpgwapi.hooks');
$GLOBALS['phpgw']->auth = CreateObject('phpgwapi.auth');
$GLOBALS['phpgw']->accounts = CreateObject('phpgwapi.accounts');
$GLOBALS['phpgw']->acl = CreateObject('phpgwapi.acl');
$GLOBALS['phpgw']->session = CreateObject('phpgwapi.sessions');
$GLOBALS['phpgw']->preferences = CreateObject('phpgwapi.preferences');
$GLOBALS['phpgw']->applications = CreateObject('phpgwapi.applications');
$GLOBALS['phpgw']->translation = CreateObject('phpgwapi.translation');
$GLOBALS['phpgw']->log = CreateObject('phpgwapi.errorlog');
// $GLOBALS['phpgw']->datetime = CreateObject('phpgwapi.datetime');
print_debug('main class loaded');
if (! isset($phpgw_info['flags']['included_classes']['error']) ||
print_debug('main class loaded');
if (! isset($phpgw_info['flags']['included_classes']['error']) ||
! $phpgw_info['flags']['included_classes']['error'])
{
{
$phpgw_info['flags']['included_classes']['error'] = True;
include(PHPGW_INCLUDE_ROOT.'/phpgwapi/inc/class.error.inc.php');
}
}
/****************************************************************************\
* This is a global constant that should be used *
* instead of / or \ in file paths *
\****************************************************************************/
define('SEP',filesystem_separator());
define('SEP',filesystem_separator());
/****************************************************************************\
* Stuff to use if logging in or logging out *
\****************************************************************************/
if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'login' || $GLOBALS['phpgw_info']['flags']['currentapp'] == 'logout')
{
if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'login' || $GLOBALS['phpgw_info']['flags']['currentapp'] == 'logout')
{
if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'login')
{
if (@$login != '')
@ -509,9 +509,9 @@ function ExecObject($object, $functionparams = '_UNDEF_', $loglevel = 3, $classp
* Everything from this point on will ONLY happen if *
* the currentapp is not login or logout *
\****************************************************************************/
}
else
{
}
else
{
if (! $GLOBALS['phpgw']->session->verify())
{
Header('Location: ' . $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->session->link('/login.php','cd=10')));
@ -663,6 +663,6 @@ function ExecObject($object, $functionparams = '_UNDEF_', $loglevel = 3, $classp
{
include(PHPGW_APP_INC . '/header.inc.php');
}
}
}
error_reporting(E_ERROR | E_WARNING | E_PARSE);
error_reporting(E_ERROR | E_WARNING | E_PARSE);