[eluser]Colin Williams[/eluser]
It needs to be like 'method' and you actually do $this->$method(). Sorry I wasn't clear about that.
Here's an example of securing methods that can be called with an array.
Code:
class Example extends Model {
var $allowed_actions;
function Example()
{
$this->allowed_actions = array('bake', 'frost', 'eat');
}
function recipe()
{
// Get the recipe action somehow and store it in $action...
if (in_array($action, $this->allowed_actions) and method_exists($this, $action))
{
$this->$action();
}
else
{
show_error('Action does not exist or is not allowed');
}
}
function bake()
{
}
[...]
}