Welcome Guest, Not a member yet? Register   Sign In
Modular multi-user admin structure
#1

[eluser]Olien[/eluser]
Hi All,

I have a project and would like to get some advises on how I could structure it, may be some of you already have done something similar.

My company is hosting a good number of websites, in which we integrate several solutions, like forms, ecommerce, survey etc...
These solutions are usually small programs with their own admin area, that we copy on each site, no global code.

Now I need to come up with a new admin solution, that would be global (all clients would connect to the same admin) and modular, so going forward we can re-write these old programs and integrate them in this global admin area.

What I have in mind is creating the 'master' admin, that will contain the main layout of the app, and the default modules/packages (default ecommerce admin, form admin, survey admin...).
Then when a client logs in, it would load the different modules they have with their own settings, but I should be able to overwrite some part of a module, as well as load totally custom ones.

So all clients by default use the same Survey admin page, but for a specific client I could overwrite or extend its model, view or controller. A bit like how we can extend a CI library.

Thanks for any help or experience you'll share. Let me know if that needs clarifications...


#2

[eluser]CroNiX[/eluser]
It sounds like just a simple permissions based or user role based auth system could do that. Then when the person logs in, check what account type, or their user ID, they are and redirect them to "their" controller (master/forms/ecommerce/survey/etc) which would load the appropriate models/etc for that user role.
#3

[eluser]Olien[/eluser]
Thanks for the quick reply.
Since their will be many clients, potentially hundreds, I would like to avoid creating a controller for each.
That would be easier to maintain, and non-programmers here have to be able to setup a new client.

Let's say there is a module Survey with:
Survey/
controller/main.php
model/survey_model.php
view/index.php

Then there is a Clients directory, by default it will be empty.

All clients going to mydomain.com/survey (routed properly) would load this default module.
But if for a client, Smith, we created a custom Clients/Smith/Survey/model/survey_model.php, the survey module would load this model instead, which would ideally just extend the default one.

I don't know how to do that with that structure, or if that's possible.
The goal is not to follow exactly that structure but to be able to easily setup clients, if possible without creating any additional php file unless when a customization is needed.

Thanks again for the support.


#4

[eluser]Olien[/eluser]
I created a 'module' controller that serves as a loader.
First it looks into the third_party directory, then into the clients directory.

Code:
class Module extends CI_Controller
{
function __construct(){
  parent::__construct();
  $this->client_id = 'smith';
}

public function _remap($method, $params = array())
{
  if(is_dir(APPPATH.'third_party/'.$method))
   $this->load->add_package_path(APPPATH.'third_party/'.$method.'/', TRUE);
  if(is_dir(APPPATH.'clients/'.$this->client_id.'/'.$method))
   $this->load->add_package_path(APPPATH.'clients/'.$this->client_id.'/'.$method.'/');
  $this->load->library($method);
  if ( isset($params[0]) and method_exists($this->$method, $params[0])){
   return call_user_func_array(array($this->$method, $params[0]), $params);
  }else
   show_404();
}
}

Obviously the client name will be dynamic, depending on who's logged in.
The way it is, it allows me to extend the default library per client when needed, or to overwrite a model or view ... file.
I don't know if that's the best way to do it, but it's working.





Theme © iAndrew 2016 - Forum software by © MyBB