[geeklog-cvs] geeklog: E_ALL fixes dealing with Autotag Usuage permissions. Ad...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Sun Jan 9 12:08:17 EST 2011


changeset 8046:f733730a5207
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/f733730a5207
user: Tom <websitemaster at cogeco.net>
date: Sun Jan 09 12:07:05 2011 -0500
description:
E_ALL fixes dealing with Autotag Usuage permissions. Added SEC_getDefaultRootUser() function to return the first id for a root user.

diffstat:

 plugins/calendar/functions.inc    |   2 +-
 plugins/links/functions.inc       |  19 +++++++++++++------
 plugins/polls/functions.inc       |  23 +++++++++++++++--------
 plugins/staticpages/functions.inc |  21 ++++++++++++++-------
 system/lib-plugins.php            |   2 ++
 system/lib-security.php           |  23 +++++++++++++++++++++++
 system/lib-story.php              |  19 +++++++++++++------
 system/lib-user.php               |  19 +++++++++++++------
 8 files changed, 94 insertions(+), 34 deletions(-)

diffs (227 lines):

diff -r 0c7b968d333b -r f733730a5207 plugins/calendar/functions.inc
--- a/plugins/calendar/functions.inc	Sun Jan 09 10:16:41 2011 +0100
+++ b/plugins/calendar/functions.inc	Sun Jan 09 12:07:05 2011 -0500
@@ -1170,7 +1170,7 @@
             $group_id = DB_getItem($_TABLES['groups'], 'grp_id',
                                    "grp_name = 'Calendar Admin'");
         }
-        $owner_id = 2; // Admin
+        $owner_id = SEC_getDefaultRootUser();
 
         if (COM_getPermTag($owner_id, $group_id, $_CA_CONF['autotag_permissions_event'][0], $_CA_CONF['autotag_permissions_event'][1], $_CA_CONF['autotag_permissions_event'][2], $_CA_CONF['autotag_permissions_event'][3]) == $flag) {
             $tagnames[] = 'event';
diff -r 0c7b968d333b -r f733730a5207 plugins/links/functions.inc
--- a/plugins/links/functions.inc	Sun Jan 09 10:16:41 2011 +0100
+++ b/plugins/links/functions.inc	Sun Jan 09 12:07:05 2011 -0500
@@ -192,15 +192,22 @@
         } else {
             $flag = false;
         }
-        
-        $group_id = $_GROUPS['Links Admin'];
-        $owner_id = 2; // Admin
+        $tagnames = array();
+
+        if (isset($_GROUPS['Links Admin'])) {
+            $group_id = $_GROUPS['Links Admin'];
+        } else {
+            $group_id = DB_getItem($_TABLES['groups'], 'grp_id',
+                                   "grp_name = 'Links Admin'");
+        }
+        $owner_id = SEC_getDefaultRootUser();
+
         if (COM_getPermTag($owner_id, $group_id, $_LI_CONF['autotag_permissions_link'][0], $_LI_CONF['autotag_permissions_link'][1], $_LI_CONF['autotag_permissions_link'][2], $_LI_CONF['autotag_permissions_link'][3]) == $flag) {
-            $tagname[] = 'link';
+            $tagnames[] = 'link';
         }
         
-        if (is_array($tagname)) {
-            return $tagname;
+        if (count($tagnames) > 0) {
+            return $tagnames;
         }
     } elseif ($op == 'description') {
         return array (
diff -r 0c7b968d333b -r f733730a5207 plugins/polls/functions.inc
--- a/plugins/polls/functions.inc	Sun Jan 09 10:16:41 2011 +0100
+++ b/plugins/polls/functions.inc	Sun Jan 09 12:07:05 2011 -0500
@@ -1457,21 +1457,28 @@
         } else {
             $flag = false;
         }
-        
-        $group_id = $_GROUPS['Polls Admin'];
-        $owner_id = 2; // Admin
+        $tagnames = array();
+
+        if (isset($_GROUPS['Polls Admin'])) {
+            $group_id = $_GROUPS['Polls Admin'];
+        } else {
+            $group_id = DB_getItem($_TABLES['groups'], 'grp_id',
+                                   "grp_name = 'Polls Admin'");
+        }
+        $owner_id = SEC_getDefaultRootUser();     
+
         if (COM_getPermTag($owner_id, $group_id, $_PO_CONF['autotag_permissions_poll_vote'][0], $_PO_CONF['autotag_permissions_poll_vote'][1], $_PO_CONF['autotag_permissions_poll_vote'][2], $_PO_CONF['autotag_permissions_poll_vote'][3]) == $flag) {
-            $tagname[] = 'poll_vote';
+            $tagnames[] = 'poll_vote';
         }
         if (COM_getPermTag($owner_id, $group_id, $_PO_CONF['autotag_permissions_poll_result'][0], $_PO_CONF['autotag_permissions_poll_result'][1], $_PO_CONF['autotag_permissions_poll_result'][2], $_PO_CONF['autotag_permissions_poll_result'][3]) == $flag) {
-            $tagname[] = 'poll_result';
+            $tagnames[] = 'poll_result';
         }
         if (COM_getPermTag($owner_id, $group_id, $_PO_CONF['autotag_permissions_poll'][0], $_PO_CONF['autotag_permissions_poll'][1], $_PO_CONF['autotag_permissions_poll'][2], $_PO_CONF['autotag_permissions_poll'][3]) == $flag) {
-            $tagname[] = 'poll';
+            $tagnames[] = 'poll';
         }
         
-        if (is_array($tagname)) {
-            return $tagname;
+        if (count($tagnames) > 0) {
+            return $tagnames;
         }
     } elseif ($op == 'description') {
         return array (
diff -r 0c7b968d333b -r f733730a5207 plugins/staticpages/functions.inc
--- a/plugins/staticpages/functions.inc	Sun Jan 09 10:16:41 2011 +0100
+++ b/plugins/staticpages/functions.inc	Sun Jan 09 12:07:05 2011 -0500
@@ -1144,18 +1144,25 @@
         } else {
             $flag = false;
         }
-        
-        $group_id = $_GROUPS['Static Page Admin'];
-        $owner_id = 2; // Admin
+        $tagnames = array();
+
+        if (isset($_GROUPS['Static Page Admin'])) {
+            $group_id = $_GROUPS['Static Page Admin'];
+        } else {
+            $group_id = DB_getItem($_TABLES['groups'], 'grp_id',
+                                   "grp_name = 'Static Page Admin'");
+        }
+        $owner_id = SEC_getDefaultRootUser();          
+
         if (COM_getPermTag($owner_id, $group_id, $_SP_CONF['autotag_permissions_staticpage_content'][0], $_SP_CONF['autotag_permissions_staticpage_content'][1], $_SP_CONF['autotag_permissions_staticpage_content'][2], $_SP_CONF['autotag_permissions_staticpage_content'][3]) == $flag) {
-            $tagname[] = 'staticpage_content';
+            $tagnames[] = 'staticpage_content';
         }
         if (COM_getPermTag($owner_id, $group_id, $_SP_CONF['autotag_permissions_staticpage'][0], $_SP_CONF['autotag_permissions_staticpage'][1], $_SP_CONF['autotag_permissions_staticpage'][2], $_SP_CONF['autotag_permissions_staticpage'][3]) == $flag) {
-            $tagname[] = 'staticpage';
+            $tagnames[] = 'staticpage';
         }
         
-        if (is_array($tagname)) {
-            return $tagname;
+        if (count($tagnames) > 0) {
+            return $tagnames;
         }
     } elseif ($op == 'description') {
         return array (
diff -r 0c7b968d333b -r f733730a5207 system/lib-plugins.php
--- a/system/lib-plugins.php	Sun Jan 09 10:16:41 2011 +0100
+++ b/system/lib-plugins.php	Sun Jan 09 12:07:05 2011 -0500
@@ -1518,6 +1518,8 @@
     // Determine which Core Modules and Plugins support AutoLinks
     //                        'tag'   => 'module'
     $all_plugins = array_merge($_PLUGINS, array('story', 'user'));
+    
+    $autolinkModules = array();
 
     foreach ($all_plugins as $pi_name) {
         $function = 'plugin_autotags_' . $pi_name;
diff -r 0c7b968d333b -r f733730a5207 system/lib-security.php
--- a/system/lib-security.php	Sun Jan 09 10:16:41 2011 +0100
+++ b/system/lib-security.php	Sun Jan 09 12:07:05 2011 -0500
@@ -1785,4 +1785,27 @@
     return $modules;
 }
 
+/**
+* Returns the default Root user id
+*
+* @return   int   The id of the default Root user
+*
+*/
+function SEC_getDefaultRootUser()
+{
+    global $_TABLES;
+     
+    $rootgrp = DB_getItem ($_TABLES['groups'], 'grp_id',
+                           "grp_name = 'Root'");
+    
+    $sql = "SELECT u.uid FROM {$_TABLES['users']} u,{$_TABLES['group_assignments']} ga  
+            WHERE u.uid > 1 AND u.uid = ga.ug_uid AND (ga.ug_main_grp_id = $rootgrp)
+            GROUP BY u.uid ORDER BY u.uid ASC LIMIT 1";
+    
+    $result = DB_query ($sql);
+    $A = DB_fetchArray ($result);      
+    
+    return $A['uid'];
+}
+
 ?>
diff -r 0c7b968d333b -r f733730a5207 system/lib-story.php
--- a/system/lib-story.php	Sun Jan 09 10:16:41 2011 +0100
+++ b/system/lib-story.php	Sun Jan 09 12:07:05 2011 -0500
@@ -1145,15 +1145,22 @@
         } else {
             $flag = false;
         }
-        
-        $group_id = $_GROUPS['Story Admin'];
-        $owner_id = 2; // Admin
+        $tagnames = array();
+
+        if (isset($_GROUPS['Story Admin'])) {
+            $group_id = $_GROUPS['Story Admin'];
+        } else {
+            $group_id = DB_getItem($_TABLES['groups'], 'grp_id',
+                                   "grp_name = 'Story Admin'");
+        }
+        $owner_id = SEC_getDefaultRootUser();
+
         if (COM_getPermTag($owner_id, $group_id, $_CONF['autotag_permissions_story'][0], $_CONF['autotag_permissions_story'][1], $_CONF['autotag_permissions_story'][2], $_CONF['autotag_permissions_story'][3]) == $flag) {
-            $tagname[] = 'story';
+            $tagnames[] = 'story';
         }
         
-        if (is_array($tagname)) {
-            return $tagname;
+        if (count($tagnames) > 0) {
+            return $tagnames;
         }
     } elseif ($op == 'description') {
         return array (
diff -r 0c7b968d333b -r f733730a5207 system/lib-user.php
--- a/system/lib-user.php	Sun Jan 09 10:16:41 2011 +0100
+++ b/system/lib-user.php	Sun Jan 09 12:07:05 2011 -0500
@@ -1131,15 +1131,22 @@
         } else {
             $flag = false;
         }
-        
-        $group_id = $_GROUPS['User Admin'];
-        $owner_id = 2; // Admin
+        $tagnames = array();
+
+        if (isset($_GROUPS['User Admin'])) {
+            $group_id = $_GROUPS['User Admin'];
+        } else {
+            $group_id = DB_getItem($_TABLES['groups'], 'grp_id',
+                                   "grp_name = 'User Admin'");
+        }
+        $owner_id = SEC_getDefaultRootUser();   
+
         if (COM_getPermTag($owner_id, $group_id, $_CONF['autotag_permissions_user'][0], $_CONF['autotag_permissions_user'][1], $_CONF['autotag_permissions_user'][2], $_CONF['autotag_permissions_user'][3]) == $flag) {
-            $tagname[] = 'user';
+            $tagnames[] = 'user';
         }
         
-        if (is_array($tagname)) {
-            return $tagname;
+        if (count($tagnames) > 0) {
+            return $tagnames;
         }
     } elseif ($op == 'description') {
         return array (



More information about the geeklog-cvs mailing list