Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared and individual settings #3

Open
Dandeyl opened this issue Jan 30, 2014 · 4 comments
Open

Shared and individual settings #3

Dandeyl opened this issue Jan 30, 2014 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Dandeyl
Copy link

Dandeyl commented Jan 30, 2014

Hi anlutro and thank you for this nice package. I wanted to ask if in a future release it could be possible to have shared and individual settings. As far as I see you can only have one of the two at the moment.

With shared I mean settings, that are the same for everyone. If you change the name of the website in a CMS, it gets changed for everyone.
If you change the backend interface language you sometimes don't want other users to be affected.

Is this realizable?

@anlutro
Copy link
Owner

anlutro commented Jan 31, 2014

Currently it's possible to add dynamic fields to the database settings (the logged in user's ID, for example - described in the readme) in order to have separate settings. It's also possible to use the setPath method when using the JSON store if you want to dynamically set the path of the file. Do you have any suggestions beyond this?

@anlutro anlutro closed this as completed Jan 31, 2014
@anlutro anlutro reopened this Jan 31, 2014
@Dandeyl
Copy link
Author

Dandeyl commented Jan 31, 2014

Okay, I didn't know about setPath. It would be possible with two different files then. Neat, I really like this package. :)

One way that came into my mind was defining scopes, instead of extra columns. Although I'm not sure if this wouldn't overcomplicate things.

// define a scope
Setting::setScope('user', [
    'path' => 'path/to/cfg.json',
    'extrafields' => ['user_id' => Auth::user()->id]
]);

// setting only for this user
Setting::setUser('interface.language', 'no');

Setting::getUser('interface.language');

@anlutro
Copy link
Owner

anlutro commented Jan 31, 2014

It's a pretty tricky problem... If you use Setting::get you would want to get from both shared and user-specific settings, but if you use Setting::set that should maybe not affect user-specific settings? This may over-complicate things.

@Dandeyl
Copy link
Author

Dandeyl commented Feb 2, 2014

Don't know if I got you right but my idea was basically, that you can set up scopes for different settings.
You still have the main settings file, accessible via Setting::get and Setting::set. This one uses the default configuration to determine the file path / database table to write to.

Additionally, you can set up "scopes" (or whatever you want to call them). If you set up the scope called "section1" with

Setting::setupScope('section1', [
    'path' => 'path/to/section1.json'
]);

you can write to that configuration file using Setting::setSection1('key', 'value); and read from it using Setting:getSection1('key');

If you use the default Setting::get('key') you still read from the file defined in the default configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants