<?php defined('SYSPATH') or die('No direct access allowed.');

/**
 * This class provides MODULE management
 *
 * @package    lnApp
 * @subpackage Page/Module
 * @category   Controllers
 * @author     Deon George
 * @copyright  (c) 2010 Deon George
 * @license    http://dev.leenooks.net/license.html
 */
class Controller_Module extends Controller_TemplateDefault {
	public $secure_actions = array(
		'edit'=>TRUE,
		'list'=>TRUE,
		'menu'=>TRUE,
	);

	public function action_menu() {
		// Redirect us to the admin menu, no user facilities here!
		Request::current()->redirect('/admin/module/menu');
	}

	/**
	 * Get the list of methods for a class
	 */
	protected function _methods($class) {
		// Get a list of methods this module has
		$ch = 'Controller_%s';
		$methods = array();

		// List of classes where all our methods are, including this one.
		$classes = Kohana::config('config.method_directory');
		array_unshift($classes,'');

		foreach ($classes as $c) {
			$cn = sprintf($ch,$c ? $c.'_'.$class : $class);

			if (class_exists($cn)) {
				$r = new ReflectionClass($cn);

				foreach ($r->getMethods() as $method)
					if (preg_match('/^Controller_(.*_)?'.$class.'$/i',$method->class) AND ! preg_match('/^_/',$method->name))
						array_push($methods,str_replace('action_',($c ? $c.'_' : $c),$method->name));
			}
		}

		return $methods;
	}
}
?>