Example #1
0
 /**
  * Called from module::on_editor
  * @throws acl_exception
  */
 function on_editor($mod)
 {
     $this->module = $mod;
     $section = core::get_params('c');
     $id = (int) core::get_params('id');
     // module checks goes on top, so skip if section empty
     if (empty($section)) {
         return;
     }
     if (!core::module('users')->with_acls()) {
         return;
     }
     // override section acl / id
     if (isset($this->_actions[$section]['acl_id'])) {
         $id = core::get_params($this->_actions[$section]['acl_id']);
     }
     if (isset($this->_actions[$section]['acl'])) {
         $section = $this->_actions[$section]['acl'];
     }
     $op = 'read';
     // @todo check this
     $is_submitted = (bool) $this->request->get_post('is_submitted', 0);
     $_op = core::get_params('op');
     if ($_op == 'edit') {
         $op = 'update';
     }
     if ($_op == 'drop') {
         $op = 'delete';
     }
     if (empty($id) && $is_submitted) {
         $op = 'create';
     }
     if (!empty($id) && $is_submitted) {
         $op = 'update';
     }
     if (is_callable(array($mod, 'editor_check_acls'))) {
         $result = call_user_func(array($mod, 'editor_check_acls'), array('section' => &$section, 'section_id' => &$id, 'action' => &$op));
         // WARN! true skips checks
         if ($result === true) {
             return;
         }
     }
     $this->check_acls($section, $id, $op);
 }