function __construct()
 {
     /**
      * authentication
      **/
     $auth = new WaxAuthDb(array("encrypt" => false, "db_table" => $this->auth_database_table, "session_key" => "wildfire_user_cookie"));
     $this->current_user = $auth->get_user();
     if ($this->current_user->usergroup == 30) {
         $this->is_admin = true;
     }
     /**
      * module setup
      **/
     $this->before_filter("all", "check_authorised", array("login"));
     $this->configure_modules();
     $this->all_modules = CMSApplication::get_modules(true);
     if (!array_key_exists($this->module_name, CMSApplication::get_modules())) {
         Session::add_message('This component is not registered with the application.');
         $this->redirect_to('/admin/home/index');
     }
     /**
      * model instanciation
      **/
     $this->cm_conf = CmsConfiguration::get("general");
     if ($this->model_class) {
         $this->model = new $this->model_class($this->cm_conf['campaign_monitor_ClientID']);
         $this->model_name = WXInflections::underscore($this->model_class);
     }
     $this->sub_links["create"] = "Create New " . $this->display_name;
     $this->sub_links["view_subscriber"] = "View Subscribers";
     $this->sub_links["view_segments"] = "View Segments";
     if (!($this->this_page = WaxUrl::get("page"))) {
         $this->this_page = 1;
     }
 }
Exemple #2
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);
     }
 }
 /**
  * creates the module listing - filters on user level
  **/
 protected function configure_modules()
 {
     $config = CmsConfiguration::get("modules");
     if (!is_array($mods = $config["enabled_modules"])) {
         $mods = array();
     }
     if ($mods && $this->current_user->usergroup != "30") {
         foreach (CMSApplication::get_modules() as $module => $values) {
             if (!array_key_exists($module, $mods)) {
                 CMSApplication::unregister_module($module);
             }
         }
     }
 }