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 static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Exemple #3
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);
     }
 }
Exemple #4
0
<?php

define("DEALERS", true);
CMSApplication::register_module("dealer", array("display_name" => "Dealers", "link" => "/admin/dealer/"));
CMSApplication::register_module("domain", array("display_name" => "Dealer Domains", "link" => "/admin/domain/", 'split' => true));
CMSApplication::register_module("testdrive", array("display_name" => "Test Drive Requests", "link" => "/admin/testdrive/", 'split' => true));
CMSApplication::register_module("brochure", array("display_name" => "Brochure Requests", "link" => "/admin/brochure/", 'split' => true));
CMSApplication::register_module("tracking", array("display_name" => "Tracking", "link" => "/admin/tracking/", 'split' => true));
if (!defined("CONTENT_MODEL")) {
    $con = new ApplicationController(false, false);
    define("CONTENT_MODEL", $con->cms_content_class);
}
if (!defined("DEALER_MODEL")) {
    if (!$con) {
        $con = new ApplicationController(false, false);
    }
    define("DEALER_MODEL", $con->dealer_class);
}
WaxEvent::add(CONTENT_MODEL . ".setup", function () {
    $model = WaxEvent::data();
    if (!$model->columns['dealers']) {
        $model->define("dealers", "ManyToManyField", array('target_model' => DEALER_MODEL, 'group' => 'relationships'));
    }
});
//add a link from the users to a dealership
WaxEvent::add("WildfireUser.setup", function () {
    $obj = WaxEvent::data();
    $obj->define("dealer", "ForeignKey", array('target_model' => DEALER_MODEL, 'group' => 'relationships', 'col_name' => "dealer_id"));
});
//add in this so it will block all views of the branch & join the created user to the dealership
WaxEvent::add(DEALER_MODEL . ".user_creation", function () {
<?php

CMSApplication::register_module("advertising", array('plugin_name' => 'wildfire.advertising.advanced', 'assets_for_cms' => true, "display_name" => "Advertising", "link" => "/admin/advertising/", 'split' => true));
if (!defined("CONTENT_MODEL")) {
    $con = new ApplicationController(false, false);
    define("CONTENT_MODEL", $con->cms_content_class);
}
WaxEvent::add(CONTENT_MODEL . ".setup", function () {
    $model = WaxEvent::data();
    if (!$model->columns['ads']) {
        $model->define("ads", "ManyToManyField", array('target_model' => 'WildfireAdvertAdvanced', "eager_loading" => true, "join_model_class" => "WaxModelWeightedJoin", "join_order" => "weight DESC", 'group' => 'advertising', 'module' => 'advertising', 'extra_fields_view' => '_advertising_extra_fields', 'existing_media_list' => '_existing_ad_list'));
    }
});
<?php

CMSApplication::register_module("media.flickr", array("hidden" => true, "plugin_name" => "wildfire.media.flickr", 'assets_for_cms' => true));
WildfireMedia::$classes[] = 'WildfireFlickrFile';
Exemple #7
0
<?php

/* Each plugin can make use of a a file called setup.php which can be used to initialise
	 any required setup.
*/
define("CMS_VERSION", "0.5-devel");
define("CMS_DIR", dirname(__FILE__));
CMSApplication::register_module("home", array("display_name" => "Dashboard", "link" => "/admin/home/", 'auth_level' => 0));
CMSApplication::register_module("settings", array("display_name" => "Settings", "link" => "/admin/settings/", 'auth_level' => 30));
CMSApplication::register_module("sections", array("display_name" => "Site Sections", "link" => "/admin/sections/", 'auth_level' => 30));
CMSApplication::register_module("categories", array("display_name" => "Categories", "link" => "/admin/categories/", 'auth_level' => 20));
CMSApplication::register_module("content", array("display_name" => "Content", "link" => "/admin/content/", 'auth_level' => 10));
CMSApplication::register_module("comments", array("display_name" => "Comments", "link" => "/admin/comments/", 'auth_level' => 5));
CMSApplication::register_module("files", array("display_name" => "Files", "link" => "/admin/files/", 'auth_level' => 0));
CMSApplication::register_module("users", array("display_name" => "CMS Users", "link" => "/admin/users/", 'auth_level' => 30));
//CMSApplication::register_module("email", array("display_name"=>"Email", "link"=>"/admin/email/", 'auth_level'=>30));
Autoloader::include_from_registry('CMSHelper');
Autoloader::register_helpers();
 /**
  * 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);
             }
         }
     }
 }