...
Code Block | ||||
---|---|---|---|---|
| ||||
<?php
class MyPluginPlugin extends Plugin {
...
public function install($plugin_id) {
Loader::loadModels($this, (array("Permissions"));
// Add a new permission group
$group = array('plugin_id' => $plugin_id, 'name' => "Permission Group Name", 'level' => "staff", 'alias' => "my_plugin");
$group_id = $this->Permissions->addGroup($group);
}
}
?> |
...
Every controller that inherits from AppController (either directly or indirectly) can enforce the ACL rules on the requested resource simply by invoking the requireLogin() method.
Code Block | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
<?php class ClientMain extends MyPluginController { public function preAction() { parent::preAction(); // Login required $this->requireLogin(); } public function index() { // Automatically protected by the ACL } } ?> |
...