2008-11-26 22:50:40 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* AgileBill - Open Billing Software
|
|
|
|
*
|
|
|
|
* This body of work is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the Open AgileBill License
|
|
|
|
* License as published at http://www.agileco.com/agilebill/license1-4.txt
|
2009-08-03 04:10:16 +00:00
|
|
|
*
|
|
|
|
* Originally authored by Tony Landis, AgileBill LLC
|
|
|
|
*
|
|
|
|
* Recent modifications by Deon George
|
|
|
|
*
|
|
|
|
* @author Deon George <deonATleenooksDOTnet>
|
|
|
|
* @copyright 2009 Deon George
|
|
|
|
* @link http://osb.leenooks.net
|
2008-11-26 22:50:40 +00:00
|
|
|
*
|
|
|
|
* @link http://www.agileco.com/
|
|
|
|
* @copyright 2004-2008 Agileco, LLC.
|
|
|
|
* @license http://www.agileco.com/agilebill/license1-4.txt
|
2009-08-03 04:10:16 +00:00
|
|
|
* @author Tony Landis <tony@agileco.com>
|
2008-11-26 22:50:40 +00:00
|
|
|
* @package AgileBill
|
2009-08-03 04:10:16 +00:00
|
|
|
* @subpackage Core
|
2008-11-26 22:50:40 +00:00
|
|
|
*/
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The main AgileBill Method Class
|
|
|
|
*
|
|
|
|
* @package AgileBill
|
|
|
|
* @subpackage Core
|
|
|
|
*/
|
|
|
|
class CORE_method {
|
|
|
|
public function do_all() {
|
|
|
|
global $C_auth,$C_sess,$C_debug,$C_translate,$VAR;
|
|
|
|
|
|
|
|
# If we dont have anything to do, we'll return
|
|
|
|
if (empty($VAR['do']))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (! is_array($VAR['do'])) {
|
|
|
|
$C_debug->alert(sprintf('VAR[do] is NOT an array (%s), how did you get here?',serialize($VAR['do'])));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($VAR['do'] as $value) {
|
|
|
|
if (preg_match('/:/',$value)) {
|
|
|
|
list($module,$method) = explode(':',$value,2);
|
|
|
|
$C_translate->value['core']['module_name'] = sprintf('<b><u>%s:%s</u></b>',$module,$method);
|
|
|
|
|
|
|
|
if ($module && $method) {
|
|
|
|
if ($C_auth->auth_method_by_name($module,$method)) {
|
|
|
|
if (file_exists($file = sprintf('%s/%s/%s.inc.php',PATH_MODULES,$module,$module))) {
|
|
|
|
include_once($file);
|
|
|
|
|
|
|
|
if (class_exists($module) && method_exists($module,$method)) {
|
2010-11-29 22:41:08 +00:00
|
|
|
eval(sprintf('$%s = new %s(%s);$%s->%s($VAR,$%s);',
|
|
|
|
$module,$module,isset($VAR['id']) ? $VAR['id'] : 'null',$module,$method,$module));
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
$C_debug->alert($C_translate->translate('method_non_existant','core',''));
|
2008-11-26 22:50:40 +00:00
|
|
|
}
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
$C_debug->alert($C_translate->translate('module_non_existant','core',''));
|
2008-11-26 22:50:40 +00:00
|
|
|
}
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
$C_debug->alert($C_translate->translate('module_non_auth','core',''));
|
2008-11-26 22:50:40 +00:00
|
|
|
}
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
} else {
|
2008-11-26 22:50:40 +00:00
|
|
|
$C_debug->alert($C_translate->translate('method_invalid','core',''));
|
|
|
|
}
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
$C_debug->alert($C_translate->translate('method_invalid','core',''));
|
2008-11-26 22:50:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-29 22:41:08 +00:00
|
|
|
/**
|
|
|
|
* Execute a method that supports output for a template
|
|
|
|
*/
|
|
|
|
public function exetm($module,$method) {
|
|
|
|
return $this->exe($module,'tm'.$method);
|
|
|
|
}
|
|
|
|
|
2009-08-03 04:10:16 +00:00
|
|
|
/**
|
|
|
|
* Execute a modules method
|
|
|
|
*/
|
|
|
|
public function exe($module,$method) {
|
|
|
|
global $C_auth,$C_sess,$C_debug,$C_translate,$VAR;
|
2008-11-26 22:50:40 +00:00
|
|
|
|
2009-08-03 04:10:16 +00:00
|
|
|
$C_translate->value['core']['module_name'] = sprintf('%s:%s',$module,$method);
|
|
|
|
|
|
|
|
if ($module != '' && $method != '' && gettype($module) == 'string' && gettype($method) == 'string') {
|
|
|
|
if ($C_auth->auth_method_by_name($module,$method)) {
|
|
|
|
$this->exe_noauth($module,$method);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$this->result = false;
|
|
|
|
$this->error = $C_translate->translate('module_non_auth','core','');
|
2008-11-26 22:50:40 +00:00
|
|
|
}
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
$this->result = false;
|
2008-11-26 22:50:40 +00:00
|
|
|
$this->error = $C_translate->translate('method_invalid','core','');
|
|
|
|
}
|
2009-08-03 04:10:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute a modules method
|
|
|
|
*/
|
|
|
|
public function exe_noauth($module,$method) {
|
|
|
|
global $C_auth,$C_sess,$C_debug,$C_translate,$VAR;
|
|
|
|
|
|
|
|
$args = null;
|
|
|
|
|
|
|
|
if (count(func_get_args())>2) {
|
|
|
|
$args = func_get_args();
|
|
|
|
array_shift($args);
|
|
|
|
array_shift($args);
|
2008-11-26 22:50:40 +00:00
|
|
|
}
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
$C_translate->value['core']['module_name'] = sprintf('%s:%s',$module,$method);
|
|
|
|
|
|
|
|
if ($module != '' && $method != '' && gettype($module) == 'string' && gettype($method) == 'string') {
|
|
|
|
if (file_exists($file = sprintf('%s/%s/%s.inc.php',PATH_MODULES,$module,$module))) {
|
|
|
|
include_once($file);
|
|
|
|
|
|
|
|
if (class_exists($module) && method_exists($module,$method)) {
|
2010-11-29 22:41:08 +00:00
|
|
|
eval(sprintf('$%s = new %s(%s);$%s->%s($VAR,$%s,$args);',
|
|
|
|
$module,$module,(isset($VAR['id']) ? $VAR['id'] : 'null'),$module,$method,$module));
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
global $smarty;
|
|
|
|
|
|
|
|
$smarty->assign_by_ref('return',$account);
|
|
|
|
$this->result = true;
|
|
|
|
$this->error = false;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$this->result = false;
|
|
|
|
$this->error = $C_translate->translate('method_non_existant','core','');
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$this->result = false;
|
|
|
|
$this->error = $C_translate->translate('module_non_existant','core','');
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$this->result = false;
|
|
|
|
$this->error = $C_translate->translate('method_invalid','core','');
|
2008-11-26 22:50:40 +00:00
|
|
|
}
|
2009-08-03 04:10:16 +00:00
|
|
|
}
|
2008-11-26 22:50:40 +00:00
|
|
|
}
|
2009-08-03 04:10:16 +00:00
|
|
|
?>
|