Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Is it possible to handle "roles" dynamicly from the database?
  • Hey guys! new here. I've heard about fuel from a friend and literally fell in love with her. I'm working on a large-scale project -> a modular cms for facebook tabs
    now, i know that you can use roles and has_access and it a great option, but is it possible to manage the roles from the database? I'll give you an example:
    A user just purchased a license for a specific module, licenses are saved in the db like this (sql structure):
    id
    license_key
    registration_time
    update_time
    modules = array(
    array('module' => 'module_a', 'expire' => 1333067848, 'pages' => 2),
    array('module' => 'module_b', 'expire' => 1333027848, 'pages' => 1)
    )
    

    expire -> the last date a license can use this module (if expired throw an error)
    pages -> on how much facebook fan-pages a user can use the module (user can create several pages) I guess there will be more options in the next development phases, this is just a first thinking.
    Every user has a license key inside his profile_fields.
    So now the user logged into his dashboard and wants to manage a module.
    Is it possible to do so with the basic Auth pkg? or the roles must be declared in the config file?
    BTW I'm new to fuel, I've written so much unnecessary code and then I discovered that it is build-in so I prefer to ask before :) Thank you, all the devs working on it - you make the world a better place for us :)
  • Daniel Polito wrote on Wednesday 28th of March 2012:
    I also needed this once and i did the quick and dirty way as WanWizard said :D https://github.com/dbpolito/Fuel-DbGroups

    Hey Daniel! thanks for this one, great stuff :) i hope that when i get more familiar with fuel i'll start share some of my own packages
  • There are two options: The right way is to write an Auth driver that replaces/extends the current ACL driver, and uses the database instead of the data in the config file. The quick and dirty way is to add some code to the config file that loads the data from the database, and returns a compatible array, in which case the Auth classes will be none the wiser. And I think someone else has been working on a similar idea, so perhaps a search might save you some work.
  • I also needed this once and i did the quick and dirty way as WanWizard said :D https://github.com/dbpolito/Fuel-DbGroups

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion