More initial work

This commit is contained in:
Deon George
2014-09-01 23:01:01 +10:00
parent febaad9ea6
commit 2115c70db0
14 changed files with 570 additions and 6 deletions

View File

@@ -0,0 +1,25 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* Membership Database Application Module Method Model
*
* @package Membership Database
* @category Models
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_Group_Method extends ORM {
// Relationships
protected $_has_one = array(
'record_id'=>array(),
);
protected $_belongs_to = array(
'group'=>array(),
);
// This module doesnt keep track of column updates automatically
protected $_created_column = FALSE;
protected $_updated_column = FALSE;
}
?>

View File

@@ -0,0 +1,91 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* Membership Database Application Module Method Model
*
* @package Membership Database
* @category Models
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_Module_Method extends ORM {
// This module doesnt keep track of column updates automatically
protected $_created_column = FALSE;
protected $_updated_column = FALSE;
// Relationships
protected $_belongs_to = array(
'module'=>array(),
);
protected $_has_one = array(
'record_id'=>array(),
);
protected $_has_many = array(
'group'=>array('through'=>'group_method','foreign_key'=>'method_id')
);
protected $_sorting = array(
'name'=>'ASC',
);
protected $_nullifempty = array(
'menu_display',
);
protected $status;
public function controller_sub() {
return substr_count($this->name,'_') ? substr($this->name,($x=strpos($this->name,'_')),strpos($this->name,':')-$x) : '';
}
public function controller() {
return Kohana::classname(sprintf('Controller%s_%s',($this->directory() ? '_' : '').$this->directory(),$this->module->name).$this->controller_sub());
}
public function directory() {
return substr($this->name,0,substr_count($this->name,'_') ? strpos($this->name,'_') : strpos($this->name,':'));
}
public function method() {
return substr($this->name,strpos($this->name,':')+1);
}
/**
* Get our Module_Method object for this request
*/
public function request_mmo(Request $ro) {
list($c,$x) = substr_count($ro->controller(),'_') ? explode('_',$ro->controller(),2) : array($ro->controller(),'');
$mo = ORM::factory('Module',array('name'=>$c));
if ($mo->loaded() AND $mo->active) {
$method = strtolower($ro->directory() ? sprintf('%s:%s',$ro->directory() ? $ro->directory().($x ? '_'.$x : '') : $ro->action(),$ro->action()) : $ro->action());
// Get the method number
$mmo = $mo->module_method
->where('name','=',$method)
->find();
if ($mmo->loaded())
return $mmo;
}
}
public function status($status=NULL) {
if ($status)
$this->status = $status;
return $this->status;
}
public function url() {
if (! preg_match('/:/',$this->name))
return NULL;
list($type,$action) = preg_split('/:/',$this->name,2);
return URL::link($this->directory(),$this->module->name.$this->controller_sub().'/'.$action);
}
}
?>