Hey all back once agian for some advise, so here's the deal I am writing a module that will track network changes and what I want to accomplish is being able to have permissions for a set of categories in a dropdown menu. This would be like how in PostCalendar I can have multiple categories and lock certain users into one category or give them access to many, and when they view the calendar the drop down menu only shows them the categories they have permissions to view. I have taken a look at the code for PostCalendar and to be honest it doesn't make a whole lot of sense to me so I was hoping maybe one of you could help explain how I could accomplish this.
Thanks all
-SUNADMN
Watch
GitHub Core
Show your support for Zikula! Sign up at Github account and watch the Core project!
GitHub Modules
- mesteele101 responded to »ERR (3): E_USER_ERROR: Smarty error: [in pagesvar:pagesitem2en line XXX]…« 07:01 AM
- mazdev responded to »Pages 2.5.0 and updating - Page not found« 06:41 AM
- ehdwma created topic »Hide "Register new account" and change template to 3 col« 06:27 AM
- mesteele101 responded to »Zikula 1.3.3 - Selecting a category in Pages not working« 01:29 AM
- mdee created topic »How to implement returnpage ?« 01:00 AM
- nestormateo responded to »Fillters in Clip« 24. May
- damon responded to »Can the Updated Version Check be Turned Off (Z 1.3)« 24. May
Zikula Blog
- Anatomy of Open Source Projects on Mar 07
- Continuous Review on Mar 01
- Not Invented Here on Feb 24
- How to Contribute Your Code at Github on Jan 13
- 10 Steps to Coding-Nirvana: Tips for Successful Module Writing on Nov 12
- Submitting Bug Report Tickets That Get Results on Aug 17
- Cozi Tricks #1: Syntax Highlighting on Aug 07
Login
permissions and menu options??
-
**unknown user**
- Rank: Senior
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 2330
For the drop-down, if you're looping through an array of options to populate it, you can use the security check (in an IF statement) so that if they don't have permission, then it moves on to the next iteration in the loop, without outputting the one they aren't allowed to see. Hope that helps. -
**unknown user**
- Rank: Senior
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 2330
I assume you're using an array...can you give me some info on the array? Such as the $varName of the array...as well as the permission schema for the module...and I can probably write one in just a few mins... -
**unknown user**
- Rank: Softmore
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 413
I dont have anything written as of yet I am more working on the theory right this sec so I can decide where I need to go with design. The security would be setup like so:
module::category categoryname:: add|read|none
the idea is to have it when a user attempts to ADD an item to the system they have a drop down menu with the given categories they can add to does that make sense??
Thanks
-SUNADMN -
**unknown user**
- Rank: Senior
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 2330
Sorry for the delay.
I may have the permissions schema incorrect, but this should give you a start. I put it into a whole function to give you an idea of the context. There might be an easier/better way to do this, but this is how I approach it.
Code
function MyMod_make_menu()
{
$output = new pnHTML();
// Security check
// NO NEED TO GO ON IF NO OVERVIEW PERMISSION
if (!pnSecAuthAction(0, 'MyMod::Category', "$catName::", ACCESS_OVERVIEW))
{
$output->Text(_MYMOD_NOAUTH);
return $output->GetOutput();
}
// START A FORM
$output->FormStart(pnModURL('MyMod', 'user', 'someFunc'));
// BUILD ALL THE POSSIBLE OPTIONS
$options[] = array('id' => '0', 'name' => _MYMOD_OPTION_01);
$options[] = array('id' => '1', 'name' => _MYMOD_OPTION_02);
$options[] = array('id' => '2', 'name' => _MYMOD_OPTION_03);
// LOOP THROUGH ALL OPTIONS
foreach($options as $option)
{
// CHECK IF USER ALLOWED TO ADD
if (pnSecAuthAction(0, "MyMod::Category", "$catName::", ACCESS_ADD))
{
// RE-ASSIGN ALLOWED OPTIONS ONLY, IE. POPULATE THE MENU
$showopt[] = $option;
}
}
// OUTPUT THE DROP-DOWN
$output->FormSelectMultiple('MyMenu',$showopt,0,1);
// SUBMIT BUTTON
$output->FormSubmit(_MYMOD_SUBMIT);
// END FORM
$output->FormEnd();
// RETURN
return $output->GetOutput();
}
- Moderated by:
- Support
