2013-02-12 11:14:59 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request. Uses the [Route] class to determine what
|
|
|
|
* [Controller] to send the request to.
|
|
|
|
*
|
2013-03-19 22:35:19 +00:00
|
|
|
* @package OSB
|
|
|
|
* @category Modifications
|
2013-02-12 11:14:59 +00:00
|
|
|
* @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
|
2013-02-12 11:14:59 +00:00
|
|
|
*/
|
|
|
|
class Request extends Kohana_Request {
|
|
|
|
/**
|
|
|
|
* Sets and gets the directory for the controller.
|
|
|
|
*
|
|
|
|
* We override the Kohana version, so that we can have short directory URLs.
|
|
|
|
* eg: admin=>a,reseller=>r.
|
|
|
|
*
|
|
|
|
* @param string $directory Directory to execute the controller from
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function directory($directory = NULL) {
|
|
|
|
// If $directory is NULL, we are a getter and see if we need to expand the directory
|
|
|
|
if ($directory === NULL AND $this->_directory)
|
|
|
|
$this->_directory = URL::dir($this->_directory);
|
|
|
|
|
|
|
|
return parent::directory($directory);
|
|
|
|
}
|
2013-04-26 01:42:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get our Module_Method object for this request
|
|
|
|
*/
|
|
|
|
public function mmo() {
|
|
|
|
static $result = FALSE;
|
|
|
|
|
|
|
|
if (is_null($result) OR $result)
|
|
|
|
return $result;
|
|
|
|
|
|
|
|
$result = NULL;
|
|
|
|
|
2013-06-04 11:50:41 +00:00
|
|
|
list($c,$x) = substr_count($this->_controller,'_') ? explode('_',$this->_controller,2) : array($this->_controller,'');
|
|
|
|
|
|
|
|
$mo = ORM::factory('Module',array('name'=>$c));
|
2013-04-26 01:42:09 +00:00
|
|
|
|
|
|
|
if ($mo->loaded() AND $mo->status) {
|
2013-06-04 11:50:41 +00:00
|
|
|
$method = strtolower($this->_directory ? sprintf('%s:%s',$this->_directory.($x ? '_'.$x : ''),$this->_action) : $this->_action);
|
2013-04-26 01:42:09 +00:00
|
|
|
|
|
|
|
// Get the method number
|
2013-06-04 11:50:41 +00:00
|
|
|
$mmo = $mo->module_method
|
|
|
|
->where('name','=',$method)
|
|
|
|
->or_where('name','=',str_replace(':','_',$method)) // @todo This is temporary until all our method names have a colon delimiter
|
|
|
|
->find();
|
2013-04-26 01:42:09 +00:00
|
|
|
|
|
|
|
if ($mmo->loaded())
|
|
|
|
$result = $mmo;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
2013-02-12 11:14:59 +00:00
|
|
|
}
|
|
|
|
?>
|