This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/application/classes/Model/Module/Method.php
2013-05-29 21:52:01 +10:00

74 lines
1.7 KiB
PHP

<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* OSB Application Module Method Model
*
* @package OSB
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Module_Method extends ORM_OSB {
// 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 $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
*/
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);
}
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() {
if (! preg_match('/_/',$this->name))
return NULL;
list($type,$action) = preg_split('/_/',$this->name,2);
return URL::link($type,$this->module->name.'/'.$action);
}
}
?>