Welcome Guest, Not a member yet? Register   Sign In
How to best organize module-determined content, which will be different for users
#4

I'd point towards option 2, but I'm a bit confused about your con on the idea. The only time you have to change many functions using the method described is if you change function names. You could go with if/else conditionals dependent on the access level or you could create a master function object with the common functionality, then create child objects named after the access level of the current user and include those by default. For instance, something along the lines of the following:



class BaseFunctionality extends CI_Controller{
  public function showSection(){
    $this->showTheStuff();
  }
}

class PaidFunctionality extends BaseFunctionality{
  public function showSection(){
    $this->dontShowThat();
  }
}

class PublicFunctionController extends CI_Controller{
  private $_access = "Base";
  public function __construct(){
    if(is_logged_in()){
      $this->_access = "Paid";
    }
  }
  public function do_something_cool(){
    $fn = "{$this->_access}Functionality";
    if(file_exists($this->$fn) && is_executable($this->$fn)){
      $this->$fn();
    }
  }
}
Reply


Messages In This Thread
RE: How to best organize module-determined content, which will be different for users - by maxxd - 12-03-2019, 09:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB