Topics

User Functions

Events

There are no upcoming events

What's New

Stories

No new stories

Comments last 2 weeks

No new comments

Trackbacks last 2 weeks

No new trackback comments

Links last 2 weeks

No recent new links

NEW FILES last 14 days

No new files

Welcome to Geeklog Tuesday, May 21 2013 @ 07:24 AM EDT


 Forum Index > Extensions > Plugins New Topic Post Reply
 Giving admin priv for plugin to a user
   
asmaloney
 07/08/06 11:48PM (Read 1770 times)  
+++++
Full Member

Status: offline


Registered: 02/08/04
Posts: 214
I want to outline a problem I'm having in the hopes that either I'm misunderstanding something or someone can tell me how to fix it.

I have a plugin called foo with a feature called foo.admin and a group called Foo Admin. I want to give admin rights for the plugin to a specific user, so I added him to the group.

I expected that he would then get the Admin block with 'Foo' in it, but he doesn't.

So to track it down I started digging... Starting at COM_adminMenu it seems that the menu should show up if plugin_getadminoption_foo() returns an entry for the admin menu or if plugin_ismoderator_foo() returns true. Both of these are correct.

So following up the call chain... COM_formatBlock() looks ok, but COM_showBlocks() looks like it only checks the block permissions from the db, ignoring the plugin's request for an entry in the admin block.

So, if I'm understanding this correctly, there need to be a check in the 'foreach( $blocks as $A )' loop to special case the admin block...

Thoughts/comments/suggestions?

- Andy

 
Profile Email Website
 Quote
asmaloney
 07/09/06 12:02AM  
+++++
Full Member

Status: offline


Registered: 02/08/04
Posts: 214
Here's the solution I came up with:

In COM_showBlocks(), we special case the loop at the end to mimic the permission checks in COM_adminMenu().

I changed this:
PHP Formatted Code
    // Loop though resulting sorted array aand pass associative arays to COM_formatBlock
    foreach( $blocks as $A )
    {
        if( SEC_hasAccess( $A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) > 0 or $A['type'] == 'dynamic' )
        {
           $retval .= COM_formatBlock( $A, $_USER['noboxes'] );
        }
    }

 


to this:
PHP Formatted Code
    // Loop though resulting sorted array and pass associative arrays to COM_formatBlock
    foreach( $blocks as $A )
    {
        if ( $A['name'] == 'admin_block' )
        {
                        $plugin_options = PLG_getAdminOptions();
                        $nrows = count( $plugin_options );

                        if ( SEC_isModerator() ||
                                SEC_hasrights( 'story.edit,block.edit,topic.edit,event.edit,user.edit,plugin.edit,user.mail', 'OR' ) ||
                                ( $nrows > 0 ))
                        {
                                $retval .= COM_formatBlock( $A, $_USER['noboxes'] );
                        }
        }
        else if( SEC_hasAccess( $A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) > 0 or $A['type'] == 'dynamic' )
        {
           $retval .= COM_formatBlock( $A, $_USER['noboxes'] );
        }
    }

 


Anyone see any problems with this solution?

Thanks.

- Andy

 
Profile Email Website
 Quote
mevans
 07/09/06 12:50AM  
+++++
Full Member

Status: offline


Registered: 02/08/04
Posts: 393
Andy,

I just tried to duplicate your problem on my Geeklog 1.4.0sr4 sites and a Geeklog v1.3.11sr3 test site and I cannot re-create the problem. Everything is working exactly as it should.

Using my Media Gallery plugin, I have a feature: mediagallery.admin that is assigned to the group Media Gallery Admin. If I place a normal user in that group, the Admin menu does show with 2 option:

- Documentation
- Media Gallery

So, it appears to be working properly.

Double checking my group Media Gallery Admin, the only item that is checked in the Group editor is under the Rights section and mediagallery.admin is checked.

Have you verified that the feature is actually associated with the group?

My setup in functions.inc looks like this:

PHP Formatted Code

function plugin_getadminoption_mediagallery() {
    global $_CONF, $_TABLES, $LANG_MG00, $_MG_CONF;

    if (SEC_hasRights('mediagallery.admin') || SEC_ingroup('Root')) {
        return array($LANG_MG00['plugin'], $_CONF['site_admin_url'] . '/plugins/mediagallery/index.php', DB_count($_TABLES['mg_albums']));
    }
}

 


Hope this helps!
Mark

 
Profile Email
 Quote
asmaloney
 07/09/06 10:43AM  
+++++
Full Member

Status: offline


Registered: 02/08/04
Posts: 214
Mark,

Thanks for the response.

That led me down the right path... Someone [uh... ok, it was me] had turned off Member Read permissions on the Admin block. I'm sure the logic went "Why would any members ever need to see the Admin block?"

Should have been an obvious thing to check, but it wasn't last night...

Thanks for your help.

- Andy

 
Profile Email Website
 Quote
Anonymous: luddite
 07/09/06 02:12PM  

dizzy


heyo, I've been having problems also...
in previous versions of media gallery... (production site for my photobug wife and pics of our son), this was not an issue...
here are my errors

FYI, i'm using debian sarge(the latest), and I admin this box,

TYI
Lu

Warning: fopen(/home/user/logs/error.log): failed to open stream: Permission denied in /home/ludovicus/public_html/lib-common.php on line 1702

Warning: fopen(/home/user/logs/error.log): failed to open stream: Permission denied in /home/user/public_html/lib-common.php on line 1702

Warning: fopen(/home/user/logs/error.log): failed to open stream: Permission denied in /home/user/public_html/lib-common.php on line 1702

 
 Quote
mevans
 07/09/06 02:17PM  
+++++
Full Member

Status: offline


Registered: 02/08/04
Posts: 393
Lu,

That's a pretty simple issue to resolve. Make sure both the directory where error.log live (/home/user/logs/) and the file error.log are writable by the web server. Check and see who is the owner of the file and change it to the same user that the web server runs as (usually www or apache) and make sure the permissions will allow the web server to write to it. I usually set mine as 644 and have the same owner as the user the web server runs as.

let me know if that solves the issue.

Thanks!
Mark


 
Profile Email
 Quote
asmaloney
 07/09/06 02:23PM  
+++++
Full Member

Status: offline


Registered: 02/08/04
Posts: 214
luddite:

In the future, you might want to try starting a new thread instead of highjacking another unrelated one... It will make searching a lot easier and will lead to less confusion.

[And I won't get email notifying me of replies to my issue that have nothing to do with the discussion ]

Thanks.

- Andy

 
Profile Email Website
 Quote
Content generated in: 0.75 seconds
New Topic Post Reply

Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to post 
Filtered HTML Allowed 
Censored Content