Rework service, change module_method configuration
This commit is contained in:
@@ -16,12 +16,45 @@ class Controller_Admin_Module extends Controller_Module {
|
||||
'list'=>TRUE,
|
||||
);
|
||||
|
||||
protected function _classes($dir,$class,$array=NULL,$key='') {
|
||||
$result = array();
|
||||
|
||||
if (is_null($array)) {
|
||||
$array = Kohana::list_files('classes');
|
||||
$array = $array['classes/Controller'];
|
||||
$key = 'classes/Controller';
|
||||
}
|
||||
|
||||
if (! $class)
|
||||
return array_keys($array);
|
||||
|
||||
if (! $dir) {
|
||||
if (! empty($array[$key.'/'.$class]))
|
||||
$result = Arr::merge($result,$this->_classes('','',$array[$key.'/'.$class],$key.'/'.$class));
|
||||
|
||||
if (! empty($array[$key.'/'.$class.'.php']))
|
||||
array_push($result,$key.'/'.$class);
|
||||
|
||||
} else {
|
||||
if (! empty($array[$key.'/'.$dir]))
|
||||
$result = Arr::merge($result,$this->_classes('',$class,$array[$key.'/'.$dir],$key.'/'.$dir));
|
||||
|
||||
if (! empty($array[$key.'/'.$dir.'/'.$class.'.php']))
|
||||
array_push($result,$key.'/'.$dir.'/'.$class);
|
||||
}
|
||||
|
||||
foreach ($result as $k=>$v)
|
||||
$result[$k] = str_replace('.php','',str_replace('/','_',preg_replace('/^classes\//','',$v)));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of methods for a class
|
||||
*/
|
||||
protected function _methods($class) {
|
||||
$class = Kohana::classname($class);
|
||||
// Get a list of methods this module has
|
||||
$ch = 'Controller_%s';
|
||||
$methods = $secure_actions = $auth_required = array();
|
||||
|
||||
// List of classes where all our methods are, including this one.
|
||||
@@ -30,20 +63,26 @@ class Controller_Admin_Module extends Controller_Module {
|
||||
|
||||
foreach ($classes as $c) {
|
||||
$x = URL::dir($c);
|
||||
$cn = Kohana::classname('Controller_'.($x ? $x.'_'.$class : $class));
|
||||
$cp = $this->_classes($x,$class);
|
||||
|
||||
if (class_exists($cn)) {
|
||||
$r = new ReflectionClass($cn);
|
||||
foreach ($cp as $cn)
|
||||
if (class_exists($cn)) {
|
||||
$sc = preg_replace(sprintf('/^Controller_%s%s_?/',$x ? $x.'_' : '',$class),'',$cn);
|
||||
$r = new ReflectionClass($cn);
|
||||
|
||||
$rdp = $r->getDefaultProperties();
|
||||
$secure_actions[$cn] = $rdp['secure_actions'];
|
||||
$auth_required[$cn] = $rdp['auth_required'];
|
||||
$rdp = $r->getDefaultProperties();
|
||||
$secure_actions[$cn] = $rdp['secure_actions'];
|
||||
$auth_required[$cn] = $rdp['auth_required'];
|
||||
|
||||
foreach ($r->getMethods() as $method) {
|
||||
if (preg_match('/^action_/',$method->name))
|
||||
array_push($methods,str_replace('action_',strtolower(($x ? $x.'_' : $x)),$method->name));
|
||||
foreach ($r->getMethods() as $method)
|
||||
if (preg_match('/^action_/',$method->name))
|
||||
array_push($methods,
|
||||
str_replace('action_',
|
||||
#strtolower(($x ? $x.'_' : '').($sc ? $sc.'_' : '')),
|
||||
strtolower($x.($sc ? '_'.$sc : '').':'),
|
||||
$method->name)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array('methods'=>$methods,'secure_actions'=>$secure_actions,'auth_required'=>$auth_required);
|
||||
|
@@ -39,7 +39,7 @@ class Controller_Reseller_Account extends Controller_Account {
|
||||
Block::add(array(
|
||||
'title'=>_('Customer List'),
|
||||
'body'=>Table::display(
|
||||
$this->filter(ORM::factory('Account')->list_active(),$this->ao->RTM->customers($this->ao->RTM),'sortkey(TRUE)','id'),
|
||||
$this->filter(ORM::factory('Account')->list_active(),$this->ao->RTM->customers($this->ao->RTM),'id','sortkey(TRUE)'),
|
||||
25,
|
||||
array(
|
||||
'id'=>array('label'=>'ID','url'=>URL::link('reseller','invoice/list/')),
|
||||
@@ -64,7 +64,7 @@ class Controller_Reseller_Account extends Controller_Account {
|
||||
Block::add(array(
|
||||
'title'=>_('Account Login Log'),
|
||||
'body'=>Table::display(
|
||||
$this->filter(ORM::factory('Account_Log')->find_all(),$this->ao->RTM->customers($this->ao->RTM),NULL,'account_id'),
|
||||
$this->filter(ORM::factory('Account_Log')->find_all(),$this->ao->RTM->customers($this->ao->RTM),'account_id'),
|
||||
25,
|
||||
array(
|
||||
'id'=>array('label'=>'ID'),
|
||||
|
@@ -52,9 +52,13 @@ class Controller_TemplateDefault extends lnApp_Controller_TemplateDefault {
|
||||
|
||||
/**
|
||||
* This will filter a search query to only return those accounts for a reseller
|
||||
* @todo Swap the order of these params and make flid necessary
|
||||
*
|
||||
* @param $o Our ORM Object that we are searching on
|
||||
* @param $fl Our array of items that we must return
|
||||
* @param $flid The ID that must be in the $fl
|
||||
* @param $sort Sort the results
|
||||
*/
|
||||
protected function filter($o,array $fl,$sort=NULL,$flid=NULL) {
|
||||
protected function filter($o,array $fl,$flid,$sort=NULL) {
|
||||
$result = array();
|
||||
|
||||
foreach ($o as $x)
|
||||
|
Reference in New Issue
Block a user