From 52c02eb3a0cbec93ef7d41d3f7ccc8d312ee14d7 Mon Sep 17 00:00:00 2001 From: e107steved Date: Mon, 7 Jan 2008 22:30:29 +0000 Subject: [PATCH] Function for editable userclasses --- e107_admin/userclass2.php | 16 +++++++---- e107_handlers/userclass_class.php | 27 ++++++++++++++++--- .../English/admin/help/userclass2.php | 12 +++++---- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/e107_admin/userclass2.php b/e107_admin/userclass2.php index dc73baa85..1f2260e2e 100644 --- a/e107_admin/userclass2.php +++ b/e107_admin/userclass2.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/userclass2.php,v $ -| $Revision: 1.4 $ -| $Date: 2007-12-26 16:32:05 $ +| $Revision: 1.5 $ +| $Date: 2008-01-07 22:30:19 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -326,7 +326,7 @@ switch ($action) ".UCSLAN_24." "; - $text .= "'; + $text .= "'; // .r_userclass("userclass_editclass", $userclass_editclass, "off", "main,admin,classes,matchclass,public,nobody"). $text .= " ".UCSLAN_32." @@ -441,11 +441,17 @@ $ns->tablerender(UCSLAN_21, $text); $text .= $e_userclass->show_graphical_tree(TRUE); // Print with debug options $ns->tablerender(UCSLAN_21, $text); - $text = ""; + $text = "
Class rights for first 20 users in database
User IDDisp NameRaw classesInherited classes
+ "; $sql->db_Select('user','user_id,user_name,user_class',"ORDER BY user_id LIMIT 0,20",'no_where'); while ($row = $sql->db_Fetch()) { - $text .= ""; + $inherit = $e_userclass->get_all_user_classes($row['user_class']); + $text .= " + + + + "; } $text .= "
Class rights for first 20 users in database
User IDDisp NameRaw classesInherited classesEditable classes
".$row['user_id']."".$row['user_name']."".$row['user_class']."".$e_userclass->get_all_user_classes($row['user_class'])."
".$row['user_id']."".$row['user_name']."".$row['user_class']."".$inherit."".$e_userclass->get_editable_classes($inherit)."
"; $ns->tablerender(UCSLAN_21, $text); diff --git a/e107_handlers/userclass_class.php b/e107_handlers/userclass_class.php index 04c08941e..e436587fd 100644 --- a/e107_handlers/userclass_class.php +++ b/e107_handlers/userclass_class.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_handlers/userclass_class.php,v $ -| $Revision: 1.7 $ -| $Date: 2007-12-29 22:32:58 $ +| $Revision: 1.8 $ +| $Date: 2008-01-07 22:30:19 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -154,6 +154,27 @@ class user_class } + // Returns a list of user classes which can be edited by the specified classlist (defaults to current user's classes) + function get_editable_classes($class_list = USERCLASS_LIST) + { + $ret = array(); + $possibles = array_flip(explode(',',$class_list)); + foreach ($possibles as $uc => $uv) + { + $ec = $this->class_tree[$uc]['userclass_editclass']; + $vis = $this->class_tree[$uc]['userclass_visibility']; + if ( + (($ec == e_UC_PUBLIC) || isset($possibles[$ec])) + && + (($vis == e_UC_PUBLIC) || isset($possibles[$vis])) + ) + { + $ret[] = $uc; + } + } + return implode(',',$ret); + } + // Given a comma separated list, returns the minimum number of class memberships required to achieve this (i.e. strips classes 'above' another in the tree) // Requires the class tree to have been initialised @@ -801,7 +822,7 @@ class user_class_admin extends user_class $name_line = ''; if ($this->graph_debug) $name_line = $this->class_tree[$listnum]['userclass_id'].":"; $name_line .= $this->class_tree[$listnum]['userclass_name']; - if ($this->graph_debug) $name_line .= "[vis:".$this->class_tree[$listnum]['userclass_visibility']."] = ".$this->class_tree[$listnum]['userclass_accum']; + if ($this->graph_debug) $name_line .= "[vis:".$this->class_tree[$listnum]['userclass_visibility'].", edit:".$this->class_tree[$listnum]['userclass_editclass']."] = ".$this->class_tree[$listnum]['userclass_accum']; // Next (commented out) line gives a 'conventional' link // $ret .= "class icon".$this->class_tree[$listnum]['userclass_name'].""; $ret .= "class icon diff --git a/e107_languages/English/admin/help/userclass2.php b/e107_languages/English/admin/help/userclass2.php index 6b7d36f2f..17bb509a9 100644 --- a/e107_languages/English/admin/help/userclass2.php +++ b/e107_languages/English/admin/help/userclass2.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/help/userclass2.php,v $ -| $Revision: 1.2 $ -| $Date: 2007-12-22 12:39:24 $ +| $Revision: 1.3 $ +| $Date: 2008-01-07 22:30:29 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -44,11 +44,12 @@ switch (varsettrue($qs[0],'config')) case 'debug' : $text = "For advanced users only - shows the hierarchy of the classes, plus the assigned classes and the classes to which the first 20 site members have access.
The number in front of the class name is its unique ID (reference number). The 'Everyone' class has an ID of 0 (zero). E107 uses these IDs throughout to refer to classes.
- After the class name is the class visibility - [vis:253] for example. This means that the class will be visible in most selectors only if the current user is a member of class 253.
+ After the class name is the class visibility and editability - [vis:253, edit: 27] for example. This means that the class will be visible in most selectors only if the current user is a member of class 253, + and the user may edit their class membership only if they are a member of class 27.
Finally, after the '=', is a list of all classes above each class in the tree, plus the ID of that class. Thus a user who is a member of a particular class will be a member of all the classes in this list.

To help with understanding, the class membership of the first 20 members is shown. The first entry on each line shows the classes of which the user is a member. The - second entry lists all the classes where the user is a member once inheritance takes effect."; + second entry lists all the classes where the user is a member once inheritance takes effect. The third entry shows which class memberships they can edit"; break; case 'test' : case 'special' : @@ -61,7 +62,8 @@ switch (varsettrue($qs[0],'config')) then create a forum which only allowed users in the TEST class to access it.

The class name is displayed in drop-down lists and the like; in some places the more detailed description is also displayed.

The class icon may be displayed in various places on the site, if one is set.

- To allow users to determine whether they can be a member of a class, allow them to manage it.

+ To allow users to determine whether they can be a member of a class, allow them to manage it. If you set 'no-one' here, only the admins + can manage membership of the class

The 'visibility' field allows you to hide the class from most members - applies in some of the drop-down lists and checkboxes.

The 'class parent' allows you to set a hierarchy of classes, where the classes lower down the hierarchy also have the rights of their parent class, and that classes' parent, and so on. The resulting tree is shown in the lower part of the page; you can expand and contract branches by clicking on the '+' and '-' boxes.";