1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-08 07:36:32 +02:00

Tidy up (mostly comments)

This commit is contained in:
SteveD
2013-01-01 10:39:30 +00:00
parent 6f2ad44d0a
commit 6b6512b06b

View File

@@ -2,7 +2,7 @@
/* /*
* e107 website system * e107 website system
* *
* Copyright (C) 2008-2012 e107 Inc (e107.org) * Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
* *
@@ -386,7 +386,7 @@ class user_class
matchclass - if 'classes' is set, this option will only show the classes that the user is a member of matchclass - if 'classes' is set, this option will only show the classes that the user is a member of
blank - puts an empty option at the top of select dropdowns blank - puts an empty option at the top of select dropdowns
filter - only show those classes where member is in a class permitted to view them - e.g. as the new 'visible to' field - added for 0.8 filter - only show those classes where member is in a class permitted to view them - e.g. as the new 'visible to' field - added for 2.0
force - show all classes (subject to the other options, including matchclass) - added for 2.0 force - show all classes (subject to the other options, including matchclass) - added for 2.0
all - alias for 'force' all - alias for 'force'
@@ -960,7 +960,7 @@ class user_class
$ret = array(); $ret = array();
$classList = str_replace(' ','', $classList); // clean up white spaces $classList = str_replace(' ','', $classList); // clean up white spaces
if ($includeAncestors) $classList = $this->get_all_user_classes($classList); if ($includeAncestors) $classList = $this->get_all_user_classes($classList);
$class_regex = "(^|,)(".str_replace(",", "|", $classList).")(,|$)"; $class_regex = '(^|,)('.str_replace(',', '|', $classList).')(,|$)';
$qry = "SELECT user_id,{$fieldList} FROM `#user` WHERE user_class REGEXP '{$class_regex}' ORDER BY '{$orderBy}'"; $qry = "SELECT user_id,{$fieldList} FROM `#user` WHERE user_class REGEXP '{$class_regex}' ORDER BY '{$orderBy}'";
if ($this->sql_r->db_Select_gen($qry)) if ($this->sql_r->db_Select_gen($qry))
{ {
@@ -974,39 +974,45 @@ class user_class
} }
//======================================================================== /**========================================================================
// Functions from previous userclass_class handler * Functions from previous userclass_class handler
//======================================================================== * ========================================================================
// Implemented for backwards compatibility/convenience. * Implemented for backwards compatibility/convenience.
// ************** DEPRECATED - use new class-based functions * ************** DEPRECATED - use new class-based functions **************
// Refer to the corresponding class-based functions for full details *
* Functionality should be sufficiently similar to the original functions to not notice (and will
/* * be more consistent with the preferred class-based functions).
With $optlist you can now specify which classes are shown in the dropdown. *
All or none can be included, separated by comma (or whatever). * Refer to the corresponding class-based functions for full details
Valid options are: *
public * Consistent interface:
guest *
nobody * @param string $fieldname - name to use for the element
member * @param mixed $curval - current value of field - as CSV if multiple values
readonly * @param string $mode = (off|admin...) - affects display -
admin * @param string $optlist - comma-separated list which specifies the classes to be shown:
main - main admin * public
classes - shows all classes * guest
matchclass - if 'classes' is set, this option will only show the classes that the user is a member of * nobody
* member
filter - only show those classes where member is in a class permitted to view them - i.e. as the new 'visible to' field * readonly
force - show all classes (subject to the other options, including matchclass) * admin
* main - main admin
$mode = 'off' turns off listing of admin/main admin classes unless enabled in $optlist (can probably be deprecated - barely used) * classes - shows all classes
* matchclass - if 'classes' is set, this option will only show the classes that the user is a member of
*/ *
* filter - only show those classes where member is in a class permitted to view them - i.e. as the new 'visible to' field
* force - show all classes (subject to the other options, including matchclass)
*
* $mode = 'off' turns off listing of admin/main admin classes unless enabled in $optlist (can probably be deprecated - barely used)
*
*/
function r_userclass($fieldname, $curval = 0, $mode = "off", $optlist = "") function r_userclass($fieldname, $curval = 0, $mode = "off", $optlist = "")
{ {
// echo "Call r_userclass{$fieldname}, CV: {$curval} opts: {$optlist}<br />"; // echo "Call r_userclass{$fieldname}, CV: {$curval} opts: {$optlist}<br />";
global $e_userclass; global $e_userclass;
if ($mode != 'off') if ($mode != 'off')
{ // Handle legacy code { // Handle legacy code
@@ -1023,7 +1029,7 @@ function r_userclass($fieldname, $curval = 0, $mode = "off", $optlist = "")
// $curval is a comma separated list of class IDs for boxes which are checked. // $curval is a comma separated list of class IDs for boxes which are checked.
function r_userclass_check($fieldname, $curval = '', $optlist = "") function r_userclass_check($fieldname, $curval = '', $optlist = "")
{ {
// echo "Call r_userclass_check: {$curval}<br />"; // echo "Call r_userclass_check: {$curval}<br />";
global $e_userclass; global $e_userclass;
if (!is_object($e_userclass)) $e_userclass = new user_class; if (!is_object($e_userclass)) $e_userclass = new user_class;
$ret = $e_userclass->uc_checkboxes($fieldname,$curval,$optlist); $ret = $e_userclass->uc_checkboxes($fieldname,$curval,$optlist);
@@ -1432,7 +1438,7 @@ class user_class_admin extends user_class
{ {
if (!isset($this->class_tree[$i])) return $i; if (!isset($this->class_tree[$i])) return $i;
} }
// Big system!! Assign a class in the 0.8-only block above 255 // Big system!! Assign a class in the 2.0-only block above 255
for ($i = e_UC_SPECIAL_END+1; ($i < 32767); $i++) for ($i = e_UC_SPECIAL_END+1; ($i < 32767); $i++)
{ {
if (!isset($this->class_tree[$i])) return $i; if (!isset($this->class_tree[$i])) return $i;
@@ -1476,7 +1482,7 @@ class user_class_admin extends user_class
/** /**
* Save class data after editing * Save class data after editing
* TODO: use new array function *
* @param array $classrec - class data * @param array $classrec - class data
* @return boolean TRUE on success, FALSE on failure * @return boolean TRUE on success, FALSE on failure
* *
@@ -1590,7 +1596,7 @@ class user_class_admin extends user_class
/** /**
* Delete a class, and all users who are members of that class. * Delete a class, and update class membership for all users who are members of that class.
* @param integer $classID > 0 * @param integer $classID > 0
* @return boolean TRUE on success, FALSE on error * @return boolean TRUE on success, FALSE on error
*/ */
@@ -1600,10 +1606,10 @@ class user_class_admin extends user_class
{ {
if ($this->sql_r->db_Select('user', 'user_id, user_class', "user_class REGEXP '(^|,){$classID}(,|$)'")) if ($this->sql_r->db_Select('user', 'user_id, user_class', "user_class REGEXP '(^|,){$classID}(,|$)'"))
{ {
$sql2 = new db; $sql2 = e107::getDb('sql2');
while ($row = $this->sql_r->db_Fetch()) while ($row = $this->sql_r->db_Fetch())
{ {
$newClass = self::ucRemove($classID,$row['user_class']); $newClass = self::ucRemove($classID, $row['user_class']);
$sql2->db_Update('user', "user_class = '{$newClass}' WHERE user_id = {$row['user_id']}"); $sql2->db_Update('user', "user_class = '{$newClass}' WHERE user_id = {$row['user_id']}");
} }
} }