2010-11-29 22:41:08 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* OSB Application Module Method Model
|
|
|
|
*
|
|
|
|
* @package OSB
|
|
|
|
* @category Models
|
|
|
|
* @author Deon George
|
2013-03-19 22:35:19 +00:00
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
|
|
|
* @license http://dev.osbill.net/license.html
|
2010-11-29 22:41:08 +00:00
|
|
|
*/
|
2012-12-10 21:48:30 +00:00
|
|
|
class Model_Module_Method extends ORM_OSB {
|
2013-04-26 01:42:09 +00:00
|
|
|
// This module doesnt keep track of column updates automatically
|
|
|
|
protected $_created_column = FALSE;
|
|
|
|
protected $_updated_column = FALSE;
|
|
|
|
|
2010-11-29 22:41:08 +00:00
|
|
|
// 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',
|
|
|
|
);
|
|
|
|
|
2013-05-29 11:43:59 +00:00
|
|
|
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,'_'));
|
|
|
|
}
|
|
|
|
|
2013-04-26 01:42:09 +00:00
|
|
|
/**
|
|
|
|
* Calculate the description for this method on any menu link
|
|
|
|
*/
|
|
|
|
public function menu_display() {
|
|
|
|
// @todo The test for value equal 1 is for legacy, remove when all updated.
|
|
|
|
if ($this->menu_display AND $this->menu_display != 1)
|
|
|
|
return $this->menu_display;
|
|
|
|
else
|
|
|
|
return sprintf('%s: %s',$this->module->name,$this->name);
|
|
|
|
}
|
2010-11-29 22:41:08 +00:00
|
|
|
|
2013-05-29 11:43:59 +00:00
|
|
|
public function method() {
|
|
|
|
return substr($this->name,strpos($this->name,'_')+1);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function status($status=NULL) {
|
|
|
|
if ($status)
|
|
|
|
$this->status = $status;
|
|
|
|
|
|
|
|
return $this->status;
|
|
|
|
}
|
|
|
|
|
2013-04-26 01:42:09 +00:00
|
|
|
public function url() {
|
|
|
|
if (! preg_match('/_/',$this->name))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
list($type,$action) = preg_split('/_/',$this->name,2);
|
2011-10-14 05:44:12 +00:00
|
|
|
|
2013-04-26 01:42:09 +00:00
|
|
|
return URL::link($type,$this->module->name.'/'.$action);
|
2011-10-14 05:44:12 +00:00
|
|
|
}
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
?>
|