Exemplo n.º 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);
     }
 }
 /**
  * big conversion function - takes old users & old content records and
  * convert them to the new ones
  */
 public function upgrade()
 {
     /* users */
     echo "converting cms_user...\n";
     $cms_user = new CmsUser();
     $oldusers = $cms_user->find_all();
     if (count($oldusers)) {
         echo "  " . count($oldusers) . " users found... moving to wildfire_user..\n";
         foreach ($oldusers as $olduser) {
             $user = new WildfireUser();
             $data = array('username' => $olduser->username, 'firstname' => $olduser->firstname, 'surname' => $olduser->surname, 'email' => $olduser->email, 'password' => $olduser->password, 'usergroup' => $olduser->usergroup);
             $user->update_attributes($data);
             echo '  converted: ' . $data['username'] . ' (' . $data['usergroup'] . ")\n";
         }
         echo "  all users converted..\n\n";
     } else {
         echo "  no users found\n\n";
     }
     /* convert sections - err, maybe later; tree structures */
     /* convert content*/
     echo "converting cms_content...\n";
     $old = new CmsContent();
     $oldcontents = $old->find_all();
     if (count($oldcontents) > 0) {
         echo "  " . count($oldcontents) . " content found... moving to wildfire_content..\n";
         foreach ($oldcontents as $oldcontent) {
             $content = new WildfireContent();
             $data = array('title' => $oldcontent->title, 'excerpt' => $oldcontent->excerpt, 'content' => $oldcontent->content, 'status' => $oldcontent->status, 'published' => $oldcontent->published, 'expires' => $oldcontent->expires, 'date_modified' => $oldcontent->date_modified, 'date_created' => $oldcontent->date_created, 'sort' => $oldcontent->sort, 'pageviews' => $oldcontent->pageviews, 'url' => $oldcontent->url, 'cms_section_id' => $oldcontent->cms_section_id, 'oldid' => $oldcontent->id);
             //find the author
             $oldauthor = new CmsUser($oldcontent->author_id);
             $author = new WildfireUser();
             $author = $author->filter(array('username' => $oldauthor->username, 'password' => $oldauthor->password))->first();
             $content = $content->update_attributes($data);
             $content->author = $author;
             echo "   converted: " . $data['title'] . '(' . $data['published'] . ")\n";
         }
         echo "  all content converted\n\n";
     } else {
         echo "  no content found..\n\n";
     }
 }
Exemplo n.º 3
0
 public function author_options()
 {
     $user = new WildfireUser();
     return options_from_collection($user->filter('usergroup > 9')->all(), "id", "fullname");
 }