Updates to Module administration
This commit is contained in:
parent
14fd3ba24e
commit
86afba378c
@ -22,25 +22,110 @@ class Controller_Admin_Module extends Controller_Module {
|
|||||||
protected function _methods($class) {
|
protected function _methods($class) {
|
||||||
// Get a list of methods this module has
|
// Get a list of methods this module has
|
||||||
$ch = 'Controller_%s';
|
$ch = 'Controller_%s';
|
||||||
$methods = array();
|
$methods = $secure_actions = $auth_required = array();
|
||||||
|
|
||||||
// List of classes where all our methods are, including this one.
|
// List of classes where all our methods are, including this one.
|
||||||
$classes = URL::$method_directory;
|
$classes = URL::$method_directory;
|
||||||
array_unshift($classes,'');
|
array_unshift($classes,'');
|
||||||
|
|
||||||
foreach ($classes as $c) {
|
foreach ($classes as $c) {
|
||||||
$cn = Kohana::classname('Controller_'.$c ? $c.'_'.$class : $class);
|
$x = URL::dir($c);
|
||||||
|
$cn = Kohana::classname('Controller_'.($x ? $x.'_'.$class : $class));
|
||||||
|
|
||||||
if (class_exists($cn)) {
|
if (class_exists($cn)) {
|
||||||
$r = new ReflectionClass($cn);
|
$r = new ReflectionClass($cn);
|
||||||
|
|
||||||
foreach ($r->getMethods() as $method)
|
$rdp = $r->getDefaultProperties();
|
||||||
if (preg_match('/^Controller_(.*_)?'.$class.'$/i',$method->class) AND ! preg_match('/^_/',$method->name))
|
$secure_actions[$cn] = $rdp['secure_actions'];
|
||||||
array_push($methods,str_replace('action_',($c ? $c.'_' : $c),$method->name));
|
$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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $methods;
|
return array('methods'=>$methods,'secure_actions'=>$secure_actions,'auth_required'=>$auth_required);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit a Module Configuration
|
||||||
|
*/
|
||||||
|
public function action_edit() {
|
||||||
|
$id = $this->request->param('id');
|
||||||
|
$mo = ORM::factory('Module',$id);
|
||||||
|
|
||||||
|
$methods = array();
|
||||||
|
|
||||||
|
if (! $mo->loaded()) {
|
||||||
|
SystemMessage::factory()
|
||||||
|
->title(_('Invalid Module ID'))
|
||||||
|
->type('error')
|
||||||
|
->body(sprintf(_('Module with ID %s doesnt appear to exist?'),$id));
|
||||||
|
|
||||||
|
HTTP::redirect(URL::link('admin','module/list'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$mm = $this->_methods($mo->name);
|
||||||
|
$methods['exist'] = array();
|
||||||
|
foreach ($mo->module_method->find_all() as $mmo) {
|
||||||
|
if (in_array($mmo->name,$mm['methods'])) {
|
||||||
|
$k = array_search($mmo->name,$mm['methods']);
|
||||||
|
unset($mm['methods'][$k]);
|
||||||
|
|
||||||
|
$mmo->status('INDB');
|
||||||
|
} else
|
||||||
|
$mmo->status('ORPHAN');
|
||||||
|
|
||||||
|
if (! empty($mm['secure_actions'][$mmo->controller()][$mmo->method()]))
|
||||||
|
unset($mm['secure_actions'][$mmo->controller()][$mmo->method()]);
|
||||||
|
|
||||||
|
array_push($methods['exist'],$mmo);
|
||||||
|
}
|
||||||
|
|
||||||
|
$methods['missing'] = array();
|
||||||
|
foreach ($mm['methods'] as $k=>$method) {
|
||||||
|
$mmo = ORM::factory('Module_Method');
|
||||||
|
$mmo->module_id = $mo->id;
|
||||||
|
$mmo->name = $method;
|
||||||
|
|
||||||
|
if (! empty($mm['auth_required'][$mmo->controller()]) AND $mm['auth_required'][$mmo->controller()])
|
||||||
|
$mmo->status('MISSING');
|
||||||
|
|
||||||
|
array_push($methods['missing'],$mmo);
|
||||||
|
}
|
||||||
|
|
||||||
|
Block::factory()
|
||||||
|
->title(sprintf('%s: %s ',_('Defined Module Methods For'),$mo->display('name')))
|
||||||
|
->title_icon('icon-cog')
|
||||||
|
->body(Table::factory()
|
||||||
|
->data($methods['exist'])
|
||||||
|
->columns(array(
|
||||||
|
'id'=>'ID',
|
||||||
|
'name'=>'Name',
|
||||||
|
'notes'=>'Notes',
|
||||||
|
'menu_display'=>'Menu',
|
||||||
|
'status()'=>'Status',
|
||||||
|
))
|
||||||
|
->prepend(array(
|
||||||
|
'id'=>array('url'=>URL::link('admin','module_method/edit/')),
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
|
Block::factory()
|
||||||
|
->title(sprintf('%s: %s ',_('Missing Module Methods For'),$mo->display('name')))
|
||||||
|
->title_icon('icon-exclamation-sign')
|
||||||
|
->body(Table::factory()
|
||||||
|
->data($methods['missing'])
|
||||||
|
->columns(array(
|
||||||
|
'name'=>'Name',
|
||||||
|
'status()'=>'Status',
|
||||||
|
))
|
||||||
|
->prepend(array(
|
||||||
|
'name'=>array('url'=>URL::link('admin','module_method/add/'.$mo->id.'/')),
|
||||||
|
))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,82 +134,23 @@ class Controller_Admin_Module extends Controller_Module {
|
|||||||
public function action_list() {
|
public function action_list() {
|
||||||
$mo = ORM::factory('Module');
|
$mo = ORM::factory('Module');
|
||||||
|
|
||||||
Block::add(array(
|
Block::factory()
|
||||||
'title'=>_('Defined Modules'),
|
->title('Defined Modules')
|
||||||
'body'=>Table::display(
|
->title_icon('icon-cog')
|
||||||
$mo->find_all(),
|
->body(Table::factory()
|
||||||
25,
|
->data($mo->find_all())
|
||||||
array(
|
->jssort(TRUE)
|
||||||
'id'=>array('label'=>'ID','url'=>URL::link('admin','module/edit/')),
|
->columns(array(
|
||||||
'name'=>array('label'=>'Name'),
|
'id'=>'ID',
|
||||||
'status'=>array('label'=>'Active'),
|
'name'=>'Name',
|
||||||
),
|
'notes'=>'Notes',
|
||||||
array(
|
'status(TRUE)'=>'Active',
|
||||||
'page'=>TRUE,
|
'external(TRUE)'=>'External',
|
||||||
'type'=>'list',
|
))
|
||||||
)),
|
->prepend(array(
|
||||||
));
|
'id'=>array('url'=>URL::link('admin','module/edit/')),
|
||||||
}
|
))
|
||||||
|
);
|
||||||
/**
|
|
||||||
* Edit a Module Configuration
|
|
||||||
*
|
|
||||||
* @todo Highlight those methods that have security, but the class does not have auth_required set to YES or the method isnt defined in secure_actions
|
|
||||||
*/
|
|
||||||
public function action_edit() {
|
|
||||||
$mid = $this->request->param('id');
|
|
||||||
$mo = ORM::factory('Module',$mid);
|
|
||||||
|
|
||||||
if (! $mo->loaded()) {
|
|
||||||
SystemMessage::add(array(
|
|
||||||
'title'=>_('Invalid Module ID'),
|
|
||||||
'type'=>'error',
|
|
||||||
'body'=>sprintf(_('Module with ID %s doesnt appear to exist?'),$mid),
|
|
||||||
));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$output = '';
|
|
||||||
$methods = $this->_methods($mo->name);
|
|
||||||
|
|
||||||
// Show methods defined in the DB already.
|
|
||||||
Block::add(array(
|
|
||||||
'title'=>sprintf('%s: %s ',_('Defined Module Methods For'),$mo->display('name')),
|
|
||||||
'body'=>Table::display(
|
|
||||||
$mo->module_method->find_all(),
|
|
||||||
25,
|
|
||||||
array(
|
|
||||||
'id'=>array('label'=>'ID','url'=>URL::link('admin','module_method/edit/')),
|
|
||||||
'name'=>array('label'=>'Name'),
|
|
||||||
'notes'=>array('label'=>'Notes'),
|
|
||||||
'menu_display'=>array('label'=>'Menu'),
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'page'=>TRUE,
|
|
||||||
'type'=>'list',
|
|
||||||
)),
|
|
||||||
));
|
|
||||||
|
|
||||||
// Show new methods NOT defined in the DB already.
|
|
||||||
foreach ($mo->module_method->find_all() as $meo)
|
|
||||||
if (($method = array_search($meo->name,$methods)) !== false)
|
|
||||||
unset($methods[$method]);
|
|
||||||
|
|
||||||
if (count($methods))
|
|
||||||
Block::add(array(
|
|
||||||
'title'=>sprintf('%s: %s ',_('Undefined Module Methods For'),$mo->display('name')),
|
|
||||||
'body'=>Table::display(
|
|
||||||
$methods,
|
|
||||||
25,
|
|
||||||
array(
|
|
||||||
'__VALUE__'=>array('label'=>'Name','url'=>URL::link('admin','module_method/add/'.$mo->id)),
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'page'=>TRUE,
|
|
||||||
'type'=>'list',
|
|
||||||
)),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -18,120 +18,95 @@ class Controller_Admin_Module_Method extends Controller_Admin_Module {
|
|||||||
$method = $this->request->param('sid');
|
$method = $this->request->param('sid');
|
||||||
|
|
||||||
$mo = ORM::factory('Module',$id);
|
$mo = ORM::factory('Module',$id);
|
||||||
$mmo = ORM::factory('Module_Method');
|
$mm = $this->_methods($mo->name);
|
||||||
|
|
||||||
if (! $mo->loaded() OR ! in_array($method,$this->_methods($mo->name)))
|
if (! $mo->loaded() OR ! in_array($method,$mm['methods']))
|
||||||
throw new Kohana_Exception('Method (:method) does not exist in :class',array(':method'=>$method,':class'=>$mo->name));
|
HTTP::redirect(URL::link('admin','module/list'));
|
||||||
|
|
||||||
|
if ($_POST) {
|
||||||
|
$mmo = $mo->module_method;
|
||||||
$mmo->name = $method;
|
$mmo->name = $method;
|
||||||
$mmo->module_id = $mo->id;
|
$mmo->module_id = $mo->id;
|
||||||
$mmo->values($_POST);
|
$mmo->values($_POST);
|
||||||
|
|
||||||
$output = '';
|
if (! $mmo->check() OR ! $mmo->save())
|
||||||
|
throw HTTP_Exception::factory(501,'Unable to save data :post',array(':post'=>serialize($_POST)));
|
||||||
|
|
||||||
if ($_POST AND $mmo->values($_POST)->check()) {
|
SystemMessage::factory()
|
||||||
$mmo->save();
|
->title('Record added')
|
||||||
|
->type('success')
|
||||||
if ($mmo->saved()) {
|
->body(_('Method record has been added.'));
|
||||||
SystemMessage::add(array(
|
|
||||||
'title'=>_('Method Added'),
|
|
||||||
'type'=>'info',
|
|
||||||
'body'=>sprintf(_('Method %s defined to database'),$mmo->name),
|
|
||||||
));
|
|
||||||
|
|
||||||
HTTP::redirect(URL::link('admin','/module/edit/'.$mo->id));
|
HTTP::redirect(URL::link('admin','/module/edit/'.$mo->id));
|
||||||
|
|
||||||
} else {
|
|
||||||
SystemMessage::add(array(
|
|
||||||
'title'=>_('Method Not Saved'),
|
|
||||||
'type'=>'error',
|
|
||||||
'body'=>sprintf(_('Unable to define Method %s to database?'),$mmo->name),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$output .= View::factory('module/admin/method_add')
|
Block::factory()
|
||||||
->set('module',$mo)
|
->title(sprintf(_('Add Method (%s) to Database for (%s)'),strtoupper($method),strtoupper($mo->name)))
|
||||||
->set('method',$mmo);
|
->title_icon('icon-plus-sign')
|
||||||
|
->type('form-horizontal')
|
||||||
Block::add(array(
|
->body(View::factory('module/method/admin/add')
|
||||||
'title'=>sprintf(_('Add Method (%s) to Database for (%s)'),strtoupper($mmo->name),strtoupper($mo->name)),
|
->set('name',$method)
|
||||||
'body'=>$output,
|
->set('o',$mo)
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit a Module Configuration
|
* Edit a Module Configuration
|
||||||
*
|
|
||||||
* @param int $mid Module ID
|
|
||||||
*/
|
*/
|
||||||
public function action_edit() {
|
public function action_edit() {
|
||||||
$mid = $this->request->param('id');
|
$id = $this->request->param('id');
|
||||||
$mmo = ORM::factory('Module_Method',$mid);
|
$mmo = ORM::factory('Module_Method',$id);
|
||||||
|
|
||||||
if (! $mmo->loaded()) {
|
if (! $mmo->loaded()) {
|
||||||
SystemMessage::add(array(
|
SystemMessage::factory()
|
||||||
'title'=>_('Invalid Method ID'),
|
->title(_('Invalid Method ID'))
|
||||||
'type'=>'error',
|
->type('error')
|
||||||
'body'=>sprintf(_('Method with ID %s doesnt appear to exist?'),$mid),
|
->body(sprintf(_('Method with ID %s doesnt appear to exist?'),$id));
|
||||||
));
|
|
||||||
|
|
||||||
return;
|
HTTP::redirect(URL::link('admin','module/list'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = '';
|
|
||||||
|
|
||||||
// The groups that can run this method.
|
|
||||||
$groups = ORM::factory('Group');
|
|
||||||
|
|
||||||
if ($_POST) {
|
if ($_POST) {
|
||||||
foreach ($groups->find_all() as $go) {
|
$mmo->values($_POST);
|
||||||
|
|
||||||
|
if (! $mmo->check() OR ! $mmo->save())
|
||||||
|
throw HTTP_Exception::factory(501,'Unable to save data :post',array(':post'=>serialize($_POST)));
|
||||||
|
|
||||||
|
foreach (ORM::factory('Group')->find_all() as $go) {
|
||||||
// If the group was defined and no longer
|
// If the group was defined and no longer
|
||||||
if ($mmo->has('group',$go) AND (! isset($_POST['groups']) OR ! in_array($go->id,$_POST['groups']))) {
|
if ($mmo->has('group',$go) AND (! isset($_POST['groups']) OR ! in_array($go->id,$_POST['groups']))) {
|
||||||
$gm = ORM::factory('Group_Method',array('method_id'=>$mmo->id,'group_id'=>$go->id));
|
$gmo = ORM::factory('Group_Method',array('method_id'=>$mmo->id,'group_id'=>$go->id));
|
||||||
|
|
||||||
if (! $gm->delete())
|
if (! $gmo->delete())
|
||||||
SystemMessage::add(array(
|
SystemMessage::factory()
|
||||||
'title'=>_('Unable to DELETE Group Method'),
|
->title(_('Unable to DELETE Group Method'))
|
||||||
'type'=>'error',
|
->type('error')
|
||||||
'body'=>sprintf(_('Unable to delete Group Method for method %s and group %s'),$mmo->name,$go->name),
|
->body(sprintf(_('Unable to delete Group Method for method %s and group %s'),$mmo->name,$go->name));
|
||||||
));
|
|
||||||
|
|
||||||
// If the group was not defined and now is
|
// If the group was not defined and now is
|
||||||
} elseif (! $mmo->has('group',$go) AND isset($_POST['groups']) AND in_array($go->id,$_POST['groups'])) {
|
} elseif (! $mmo->has('group',$go) AND isset($_POST['groups']) AND in_array($go->id,$_POST['groups'])) {
|
||||||
$gm = ORM::factory('Group_Method')
|
$gmo = ORM::factory('Group_Method')
|
||||||
->values(array(
|
->values(array(
|
||||||
'method_id'=>$mmo->id,
|
'method_id'=>$mmo->id,
|
||||||
'group_id'=>$go->id,
|
'group_id'=>$go->id,
|
||||||
));
|
));
|
||||||
|
|
||||||
if (! $gm->check() OR ! $gm->save())
|
if (! $gmo->check() OR ! $gmo->save())
|
||||||
SystemMessage::add(array(
|
SystemMessage::factory()
|
||||||
'title'=>_('Unable to SAVE Group Method'),
|
->title(_('Unable to SAVE Group Method'))
|
||||||
'type'=>'error',
|
->type('error')
|
||||||
'body'=>sprintf(_('Unable to save Group Method for method %s and group %s'),$mmo->name,$go->name),
|
->body(sprintf(_('Unable to save Group Method for method %s and group %s'),$mmo->name,$go->name));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$output .= Form::open();
|
Block::factory()
|
||||||
|
->title(sprintf(_('Configure access to method (%s::%s)'),$mmo->controller(),$mmo->method()))
|
||||||
$output .= View::factory('module/admin/method_detail_head');
|
->title_icon('icon-plus-sign')
|
||||||
foreach ($groups->find_all() as $go) {
|
->type('form')
|
||||||
$output .= View::factory('module/admin/method_detail_body')
|
->body(View::factory('module/method/admin/edit')
|
||||||
->set('group',$go)
|
->set('o',$mmo)
|
||||||
->set('defined',$mmo->has('group',$go));
|
);
|
||||||
}
|
|
||||||
$output .= View::factory('module/admin/method_detail_foot');
|
|
||||||
|
|
||||||
$output .= '<div>'.Form::submit('submit',_('Update'),array('class'=>'form_button')).'</div>';
|
|
||||||
$output .= Form::close();
|
|
||||||
|
|
||||||
Block::add(array(
|
|
||||||
'title'=>sprintf(_('%s->%s Method'),strtoupper($mmo->module->name),strtoupper($mmo->name)),
|
|
||||||
'body'=>$output,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -90,7 +90,6 @@ class Controller_Reseller_Account extends Controller_Account {
|
|||||||
->span(6)
|
->span(6)
|
||||||
->body(Table::factory()
|
->body(Table::factory()
|
||||||
->data($ao->service->list_active())
|
->data($ao->service->list_active())
|
||||||
->jssort('service')
|
|
||||||
->columns(array(
|
->columns(array(
|
||||||
'id'=>'ID',
|
'id'=>'ID',
|
||||||
'service_name()'=>'Service',
|
'service_name()'=>'Service',
|
||||||
|
@ -22,7 +22,6 @@ class Controller_User_Welcome extends Controller_Welcome {
|
|||||||
->span(6)
|
->span(6)
|
||||||
->body(Table::factory()
|
->body(Table::factory()
|
||||||
->data($this->ao->service->list_active())
|
->data($this->ao->service->list_active())
|
||||||
->jssort('service')
|
|
||||||
->columns(array(
|
->columns(array(
|
||||||
'id'=>'ID',
|
'id'=>'ID',
|
||||||
'service_name()'=>'Service',
|
'service_name()'=>'Service',
|
||||||
|
@ -9,5 +9,19 @@
|
|||||||
* @license http://dev.osbill.net/license.html
|
* @license http://dev.osbill.net/license.html
|
||||||
*/
|
*/
|
||||||
class Model_Auth_RoleDefault extends Model_Auth_Role {
|
class Model_Auth_RoleDefault extends Model_Auth_Role {
|
||||||
|
/**
|
||||||
|
* Show a bootstrap label button for a field with a boolean value
|
||||||
|
*/
|
||||||
|
public function label_bool($column,$render=FALSE) {
|
||||||
|
if (! isset($this->_table_columns[$column]))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (! $render)
|
||||||
|
return $this->display($column);
|
||||||
|
|
||||||
|
return View::factory(Config::theme().'/label/bool')
|
||||||
|
->set('label',$this->$column ? 'label-success' : '')
|
||||||
|
->set('column',$this->display($column));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -21,11 +21,13 @@ class Model_Module extends ORM_OSB {
|
|||||||
'module_method'=>array('far_key'=>'id'),
|
'module_method'=>array('far_key'=>'id'),
|
||||||
);
|
);
|
||||||
protected $_sorting = array(
|
protected $_sorting = array(
|
||||||
'status'=>'DESC',
|
|
||||||
'name'=>'ASC',
|
'name'=>'ASC',
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $_display_filters = array(
|
protected $_display_filters = array(
|
||||||
|
'external'=>array(
|
||||||
|
array('StaticList_YesNo::get',array(':value')),
|
||||||
|
),
|
||||||
'name'=>array(
|
'name'=>array(
|
||||||
array('strtoupper',array(':value')),
|
array('strtoupper',array(':value')),
|
||||||
),
|
),
|
||||||
@ -34,6 +36,10 @@ class Model_Module extends ORM_OSB {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public function external($render=FALSE) {
|
||||||
|
return $this->label_bool('external',$render);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an instance of this Module's Model
|
* Return an instance of this Module's Model
|
||||||
*
|
*
|
||||||
|
@ -29,6 +29,16 @@ class Model_Module_Method extends ORM_OSB {
|
|||||||
'name'=>'ASC',
|
'name'=>'ASC',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
protected $status;
|
||||||
|
|
||||||
|
public function controller() {
|
||||||
|
return Kohana::classname(sprintf('Controller%s_%s',($this->directory() ? '_' : '').$this->directory(),$this->module->name));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function directory() {
|
||||||
|
return substr($this->name,0,strpos($this->name,'_'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the description for this method on any menu link
|
* Calculate the description for this method on any menu link
|
||||||
*/
|
*/
|
||||||
@ -40,6 +50,17 @@ class Model_Module_Method extends ORM_OSB {
|
|||||||
return sprintf('%s: %s',$this->module->name,$this->name);
|
return sprintf('%s: %s',$this->module->name,$this->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function method() {
|
||||||
|
return substr($this->name,strpos($this->name,'_')+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function status($status=NULL) {
|
||||||
|
if ($status)
|
||||||
|
$this->status = $status;
|
||||||
|
|
||||||
|
return $this->status;
|
||||||
|
}
|
||||||
|
|
||||||
public function url() {
|
public function url() {
|
||||||
if (! preg_match('/_/',$this->name))
|
if (! preg_match('/_/',$this->name))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -171,6 +171,21 @@ abstract class ORM_OSB extends ORM {
|
|||||||
return array_key_exists($key,$this->$column) ? $this->{$column}[$key] : NULL;
|
return array_key_exists($key,$this->$column) ? $this->{$column}[$key] : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a bootstrap label button for a field with a boolean value
|
||||||
|
*/
|
||||||
|
public function label_bool($column,$render=FALSE) {
|
||||||
|
if (! isset($this->_table_columns[$column]))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (! $render)
|
||||||
|
return $this->display($column);
|
||||||
|
|
||||||
|
return View::factory(Config::theme().'/label/bool')
|
||||||
|
->set('label',$this->$column ? 'label-success' : '')
|
||||||
|
->set('column',$this->display($column));
|
||||||
|
}
|
||||||
|
|
||||||
final public function module() {
|
final public function module() {
|
||||||
return ORM::factory(Kohana::classname($this->name));
|
return ORM::factory(Kohana::classname($this->name));
|
||||||
}
|
}
|
||||||
@ -223,15 +238,7 @@ abstract class ORM_OSB extends ORM {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function status($render=FALSE) {
|
public function status($render=FALSE) {
|
||||||
if (! isset($this->_table_columns['status']))
|
return $this->label_bool('status',$render);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (! $render)
|
|
||||||
return $this->display('status');
|
|
||||||
|
|
||||||
return View::factory(Config::theme().'/status')
|
|
||||||
->set('label',$this->status ? 'label-success' : '')
|
|
||||||
->set('status',$this->display('status'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
<?php echo Form::open(); ?>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td class="head">Module</td>
|
|
||||||
<td><?php echo $module->name; ?></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="head">Name</td>
|
|
||||||
<td><?php echo $method->name; ?></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="head">Notes</td>
|
|
||||||
<td><?php echo Form::input('notes',$method->name); ?></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="head">Menu Display</td>
|
|
||||||
<td><?php echo StaticList_YesNo::form('menu_display',0); ?></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<?php echo Form::submit('submit',_('Add'),array('class'=>'form_button')); ?>
|
|
||||||
<?php echo Form::close(); ?>
|
|
@ -1,8 +0,0 @@
|
|||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<a href="<?php echo URL::link('admin','group/edit/'.$group->id,TRUE); ?>"><?php echo $group->display('name'); ?></a>
|
|
||||||
</td>
|
|
||||||
<td><?php echo $group->display('notes'); ?></td>
|
|
||||||
<td><?php echo $group->display('status'); ?></td>
|
|
||||||
<td><?php echo Form::checkbox('groups[]',$group->id,$defined); ?></td>
|
|
||||||
</tr>
|
|
@ -1 +0,0 @@
|
|||||||
</table>
|
|
@ -1,8 +0,0 @@
|
|||||||
<!-- //@todo Translation required -->
|
|
||||||
<table class="box-left">
|
|
||||||
<tr class="head">
|
|
||||||
<td>Method</td>
|
|
||||||
<td>Notes</td>
|
|
||||||
<td>Group Active</td>
|
|
||||||
<td>Method Enabled</td>
|
|
||||||
</tr>
|
|
18
application/views/module/method/admin/add.php
Normal file
18
application/views/module/method/admin/add.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<div class="row">
|
||||||
|
<div class="span10 offset1">
|
||||||
|
<fieldset>
|
||||||
|
<legend>Add Method</legend>
|
||||||
|
|
||||||
|
<?php echo Form::input('name',$name,array('label'=>'Method','disabled')); ?>
|
||||||
|
<?php echo Form::input('notes','',array('label'=>'Description','placeholder'=>'Method Description','class'=>'span8')); ?>
|
||||||
|
<?php echo Form::input('menu_display','',array('label'=>'Menu Title','placeholder'=>'Menu Title')); ?>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="offset2">
|
||||||
|
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||||
|
<button type="button" class="btn">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div> <!-- /span10 -->
|
||||||
|
</div> <!-- /row -->
|
47
application/views/module/method/admin/edit.php
Normal file
47
application/views/module/method/admin/edit.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<div class="row">
|
||||||
|
<div class="span10 offset1">
|
||||||
|
<fieldset>
|
||||||
|
<legend>Configure Method </legend>
|
||||||
|
|
||||||
|
<?php echo Form::input('notes',$o->notes,array('label'=>'Description','placeholder'=>'Method Description','class'=>'span8')); ?>
|
||||||
|
<?php echo Form::input('menu_display',$o->menu_display,array('label'=>'Menu Title','placeholder'=>'Menu Title')); ?>
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
</div> <!-- /span10 -->
|
||||||
|
</div> <!-- /row -->
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="span10 offset1">
|
||||||
|
<fieldset>
|
||||||
|
<legend>Configure Method Security</legend>
|
||||||
|
|
||||||
|
<table class="table table-striped table-condensed table-hover" id="list-table">
|
||||||
|
<thead><tr>
|
||||||
|
<th>Method</th>
|
||||||
|
<th>Notes</th>
|
||||||
|
<th>Group Active</th>
|
||||||
|
<th>Method Enable</th>
|
||||||
|
</tr></thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<?php foreach (ORM::factory('Group')->find_all() as $go) : ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo HTML::anchor(URL::link('admin','group/edit/'.$go->id,TRUE),$go->display('name')); ?></td>
|
||||||
|
<td><?php echo $go->display('notes'); ?></td>
|
||||||
|
<td><?php echo $go->label_bool('status',TRUE); ?></td>
|
||||||
|
<td><?php echo Form::checkbox('groups[]',$go->id,$o->has('group',$go)); ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="offset2">
|
||||||
|
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||||
|
<button type="button" class="btn">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
</div> <!-- /span10 -->
|
||||||
|
</div> <!-- /row -->
|
@ -3,8 +3,6 @@
|
|||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Add Export Data Map</legend>
|
<legend>Add Export Data Map</legend>
|
||||||
|
|
||||||
<p>Available <?php $o->module->table_name(); ?> Columns to display</p>
|
|
||||||
|
|
||||||
<?php echo Form::select('item_id',$o->list_itemsnoexport($module,$emo->id),NULL,array('label'=>'Product')); ?>
|
<?php echo Form::select('item_id',$o->list_itemsnoexport($module,$emo->id),NULL,array('label'=>'Product')); ?>
|
||||||
<?php echo Form::input('map_data[account]','Internet:ADSL Supply',array('label'=>'Accounting Code','placeholder'=>'Account Code')); ?>
|
<?php echo Form::input('map_data[account]','Internet:ADSL Supply',array('label'=>'Accounting Code','placeholder'=>'Account Code')); ?>
|
||||||
<?php echo Form::input('map_data[item]','ADSL:ADSL2',array('label'=>'Inventory Code','placeholder'=>'Inventory Code')); ?>
|
<?php echo Form::input('map_data[item]','ADSL:ADSL2',array('label'=>'Inventory Code','placeholder'=>'Inventory Code')); ?>
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit ab1adad456578500a4be8edd8635c560e25417f7
|
Subproject commit 8ba0ced1911cc1a824088a28a4008cf647de9f41
|
Reference in New Issue
Block a user