mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 13:17:24 +02:00
Userclasses - bug fixes, tidy display
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_files/shortcode/batch/usersettings_shortcodes.php,v $
|
||||
| $Revision: 1.7 $
|
||||
| $Date: 2008-01-06 21:16:23 $
|
||||
| $Revision: 1.8 $
|
||||
| $Date: 2008-01-08 22:24:14 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -103,32 +103,32 @@ if($parm == 'radio')
|
||||
SC_END
|
||||
|
||||
SC_BEGIN USERCLASSES
|
||||
global $sql, $pref, $tp, $curVal;
|
||||
global $e_userclass, $pref, $tp, $curVal;
|
||||
$ret = "";
|
||||
if(ADMIN && $curVal['user_id'] != USERID)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
if($sql->db_Select("userclass_classes", "*", "userclass_editclass IN(".$tp -> toDB($curVal['userclass_list'], true).") ORDER BY userclass_name"))
|
||||
{
|
||||
$ucList = $sql->db_getList();
|
||||
$ret = "<table style='width:95%'>";
|
||||
foreach($ucList as $row)
|
||||
if (!is_object($e_userclass)) $e_userclass = new user_class;
|
||||
$ucList = explode(',',$e_userclass->get_editable_classes()); // List of classes which this user can edit
|
||||
$ret = '';
|
||||
if(!count($ucList)) return;
|
||||
|
||||
$is_checked = array();
|
||||
foreach ($ucList as $cid)
|
||||
{
|
||||
$inclass = check_class($row['userclass_id'], $curVal['user_class']) ? TRUE : FALSE;
|
||||
if (check_class($cid, $curVal['user_class'])) $is_checked[$cid] = $cid;
|
||||
if(isset($_POST['class']))
|
||||
{
|
||||
$inclass = in_array($row['userclass_id'], $_POST['class']);
|
||||
$is_checked[$cid] = in_array($cid, $_POST['class']);
|
||||
}
|
||||
$frm_checked = $inclass ? "checked='checked'" : "";
|
||||
$ret .= "<tr><td class='defaulttext'>";
|
||||
$ret .= "<input type='checkbox' name='class[]' value='{$row['userclass_id']}' $frm_checked />\n";
|
||||
$ret .= $tp->toHTML($row['userclass_name'], "", "defs")."</td>";
|
||||
$ret .= "<td class='smalltext'>".$tp->toHTML($row['userclass_description'], "", "defs")."</td>";
|
||||
$ret .= "</tr>\n";
|
||||
}
|
||||
$ret .= "</table>\n";
|
||||
}
|
||||
$inclass = implode(',',$is_checked);
|
||||
|
||||
$ret = "<table style='width:95%'><tr><td class='defaulttext'>";
|
||||
$ret .= $e_userclass->vetted_tree('class',array($e_userclass,checkbox_desc),$inclass,'editable');
|
||||
$ret .= "</td></tr></table>\n";
|
||||
|
||||
return $ret;
|
||||
SC_END
|
||||
|
||||
|
@@ -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.8 $
|
||||
| $Date: 2008-01-07 22:30:19 $
|
||||
| $Revision: 1.9 $
|
||||
| $Date: 2008-01-08 22:24:22 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -158,20 +158,22 @@ class user_class
|
||||
function get_editable_classes($class_list = USERCLASS_LIST)
|
||||
{
|
||||
$ret = array();
|
||||
$blockers = array(e_UC_PUBLIC => 1, e_UC_READONLY => 1, e_UC_MEMBER => 1);
|
||||
$possibles = array_flip(explode(',',$class_list));
|
||||
foreach ($possibles as $uc => $uv)
|
||||
unset($possibles[e_UC_PUBLIC]);
|
||||
unset($possibles[e_UC_READONLY]);
|
||||
foreach ($this->class_tree as $uc => $uv)
|
||||
{
|
||||
if (!isset($blockers[$uc]))
|
||||
{
|
||||
$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]))
|
||||
)
|
||||
// echo "Check class: {$uc} editclass {$ec} in array: ".(isset($possibles[$ec]) ? 'yes' : 'no').'<br />';
|
||||
if (isset($possibles[$ec]))
|
||||
{
|
||||
$ret[] = $uc;
|
||||
}
|
||||
}
|
||||
}
|
||||
return implode(',',$ret);
|
||||
}
|
||||
|
||||
@@ -262,6 +264,17 @@ class user_class
|
||||
$ret = array();
|
||||
if (!$optlist) $optlist = 'public,guest,nobody,member,classes'; // Set defaults to simplify ongoing processing
|
||||
|
||||
if ($optlist == 'editable')
|
||||
{
|
||||
$temp = array_flip(explode(',',$this->get_editable_classes()));
|
||||
if ($just_ids) return $temp;
|
||||
foreach ($temp as $c => $t)
|
||||
{
|
||||
$temp[$c] = $this->class_tree[$c]['userclass_name'];
|
||||
}
|
||||
return $temp;
|
||||
}
|
||||
|
||||
$opt_arr = explode(',',$optlist);
|
||||
foreach ($opt_arr as $k => $v)
|
||||
{
|
||||
@@ -299,7 +312,7 @@ class user_class
|
||||
)
|
||||
)
|
||||
{
|
||||
$ret[$uc_id] = $this->class_tree[$uc_id]['userclass_name'];
|
||||
$ret[$uc_id] = $just_ids ? '1' : $this->class_tree[$uc_id]['userclass_name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -391,7 +404,6 @@ class user_class
|
||||
$current_value = str_replace(' ','',$current_value); // Simplifies parameter passing for the tidy-minded
|
||||
|
||||
$perms = $this->uc_required_class_list($optlist,TRUE); // List of classes which we can display
|
||||
|
||||
/* // Start with the fixed classes
|
||||
foreach ($this->fixed_classes as $c => $j)
|
||||
{
|
||||
|
@@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/usersettings.php,v $
|
||||
| $Revision: 1.19 $
|
||||
| $Date: 2008-01-06 21:16:16 $
|
||||
| $Revision: 1.20 $
|
||||
| $Date: 2008-01-08 22:24:14 $
|
||||
| $Author: e107steved $
|
||||
+----------------------------------------------------------------------------+
|
||||
|
||||
@@ -23,7 +23,6 @@ Admin log events:
|
||||
|
||||
*/
|
||||
|
||||
//echo "Starting usersettings<br />";
|
||||
|
||||
require_once("class2.php");
|
||||
require_once(e_HANDLER."ren_help.php");
|
||||
@@ -33,35 +32,6 @@ $ue = new e107_user_extended;
|
||||
//define("US_DEBUG",TRUE);
|
||||
define("US_DEBUG",FALSE);
|
||||
|
||||
/*
|
||||
These links look redundant
|
||||
if (isset($_POST['sub_news']))
|
||||
{
|
||||
header("location:".e_BASE."submitnews.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_POST['sub_link'])) {
|
||||
header("location:".e_PLUGIN."links_page/links.php?submit");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_POST['sub_download'])) {
|
||||
header("location:".e_BASE."upload.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_POST['sub_article'])) {
|
||||
header("location:".e_BASE."subcontent.php?article");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_POST['sub_review'])) {
|
||||
header("location:".e_BASE."subcontent.php?review");
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
if (!USER)
|
||||
{ // Must be logged in to change settings
|
||||
@@ -501,18 +471,20 @@ if (isset($_POST['updatesettings']))
|
||||
|
||||
|
||||
// Update Userclass - only if its the user changing their own data (admins can do it another way)
|
||||
if (!$_uid && $sql->db_Select("userclass_classes", "userclass_id", "userclass_editclass IN (".USERCLASS_LIST.")"))
|
||||
if (!$_uid)
|
||||
{
|
||||
if (!is_object($e_userclass)) $e_userclass = new user_class;
|
||||
$ucList = explode(',',$e_userclass->get_editable_classes()); // List of classes which this user can edit
|
||||
if (count($ucList))
|
||||
{
|
||||
$ucList = $sql->db_getList(); // List of classes which this user can edit
|
||||
if (US_DEBUG) $admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Usersettings test","Read editable list. Current user classes: ".$udata['user_class'],FALSE,LOG_TO_ROLLING);
|
||||
|
||||
$cur_classes = explode(",", $udata['user_class']); // Current class membership
|
||||
$newclist = array_flip($cur_classes); // Array keys are now the class IDs
|
||||
|
||||
// Update class list - we must take care to only change those classes a user can edit themselves
|
||||
foreach ($ucList as $c)
|
||||
foreach ($ucList as $cid)
|
||||
{
|
||||
$cid = $c['userclass_id'];
|
||||
if(!in_array($cid, $_POST['class']))
|
||||
{
|
||||
unset($newclist[$cid]);
|
||||
@@ -531,6 +503,7 @@ if (isset($_POST['updatesettings']))
|
||||
$changed_user_data['user_class'] = $nid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user