Example #1
0
 public function user_creation()
 {
     $dealer_class = get_class($this);
     $user = new WildfireUser();
     if ($this->client_id && !($found = $user->filter("username", $this->client_id)->first())) {
         $user_attrs = array('username' => $this->client_id, 'firstname' => $this->title, 'password' => $this->client_id . date("Y"));
         $this->wu = $user = $user->update_attributes($user_attrs);
         $allowed_modules = $dealer_class::$allowed_modules;
         foreach (CMSApplication::get_modules() as $name => $info) {
             //if the module isnt listed at all, then block access to it
             if (!$allowed_modules[$name]) {
                 $block = new WildfirePermissionBlacklist();
                 $block->update_attributes(array($user->table . "_id" => $user->primval, 'class' => $name, 'operation' => "index"));
             } else {
                 $class = "Admin" . Inflections::camelize($name, true) . "Controller";
                 $obj = new $class(false, false);
                 $operations = array_merge($obj->operation_actions, array('index'));
                 $mods = $allowed_modules[$name];
                 $section_class = $obj->model_class;
                 $section_model = new $section_class();
                 //find all possible tabs for the model
                 $tabs = array('details');
                 foreach ($section_model->columns as $col => $info) {
                     if ($info[1]['group']) {
                         $tabs[] = strtolower($info[1]['group']);
                     }
                 }
                 $tabs = array_unique($tabs);
                 //block operations or tabs
                 foreach ($operations as $op) {
                     //if its not set, block it
                     if (!isset($mods[$op])) {
                         $block = new WildfirePermissionBlacklist();
                         $block->update_attributes(array($user->table . "_id" => $user->primval, 'class' => $name, 'operation' => $op));
                     } else {
                         //if it is, block tabs that havent been listed
                         foreach ($tabs as $tab_i => $tab) {
                             if (in_array($tab, $mods[$op])) {
                                 unset($tabs[$tab_i]);
                             }
                         }
                     }
                 }
                 foreach ($tabs as $tab) {
                     $block = new WildfirePermissionBlacklist();
                     $block->update_attributes(array($user->table . "_id" => $user->primval, 'class' => $name, 'operation' => "tab-" . $tab));
                 }
             }
         }
         $block = new WildfirePermissionBlacklist();
         foreach ($this->pages as $page) {
             $block->update_attributes(array($user->table . "_id" => $user->primval, 'class' => CONTENT_MODEL, 'operation' => "tree", "value" => $page->primval));
         }
         WaxEvent::run($dealer_class . ".user_creation", $this);
     }
 }
Example #2
0
 public function author_options()
 {
     $user = new WildfireUser();
     return options_from_collection($user->filter('usergroup > 9')->all(), "id", "fullname");
 }