queryCanEditClass($classID) >= $editLevel) { return TRUE; } if ($redirect) { header('location:'.SITEURL); exit; } return FALSE; // Next bit probably redundant - editing of some parts of system class data is allowed. if(!$uc->isEditableClass($class_id)) { if(!$redirect) return false; e107::getMessage()->addSession(UCSLAN_90, E_MESSAGE_ERROR); header('location:'.e_SELF); exit; } return true; } if (e_QUERY) { // BC - SO MUCH BAD, never do this at home!!! if(isset($_GET['action'])) { $uc_qs = array($_GET['action'], $_GET['id']); } else $uc_qs = explode('.', e_QUERY); } $action = varset($uc_qs[0]); $params = varset($uc_qs[1],''); e107::setRegistry('pageParams', $uc_qs); //AJAX request check is already made by the API if(e_AJAX_REQUEST) { $class_num = intval($params); if ($action == 'edit') { require_once(e_HANDLER.'js_helper.php'); $jshelper = new e_jshelper(); if(!checkAllowed($class_num, false)) { //This will raise an error //'Access denied' is the message which will be thrown //by the JS AJAX handler e_jshelper::sendAjaxError('403', 'Access denied. '.UCSLAN_90); } elseif($sql->db_Select('userclass_classes', '*', "userclass_id='".$class_num."' ")) { $row = $sql->db_Fetch(MYSQL_ASSOC); //Response action - reset all group checkboxes $jshelper->addResponseAction('reset-checked', array('group_classes_select' => '0')); //it's grouped userclass if ($row['userclass_type'] == UC_TYPE_GROUP) { //Response action - show group, hide standard $jshelper->addResponseAction('element-invoke-by-id', array('show' => 'userclass_type_groups', 'hide' => 'userclass_type_standard')); //fill in the classes array $tmp = explode(',',$row['userclass_accum']); foreach ($tmp as $uid) { $row['group_classes_select_'.$uid] = $uid; } } else { //hide group, show standard rows $jshelper->addResponseAction('element-invoke-by-id', array('hide' => 'userclass_type_groups', 'show' => 'userclass_type_standard')); } unset($row['userclass_accum']); $jshelper->addResponseAction('fill-form', $row); $jshelper->sendResponse('XML'); // $jshelper->sendResponse('JSON'); - another option (tested) - faster transfer! } else { e_jshelper::sendAjaxError('500', 'Database read error!'); } } exit; } e107::getJs()->headerCore('core/admin.js'); /* * Authorization should be done a bit later! */ require_once("auth.php"); $emessage = e107::getMessage(); //--------------------------------------------------- // Set Initial Classes //--------------------------------------------------- if (isset($_POST['set_initial_classes'])) { $changed = $pref['init_class_stage'] != intval($_POST['init_class_stage']); $pref['init_class_stage'] = intval($_POST['init_class_stage']); $temp = array(); foreach ($_POST['init_classes'] as $ic) { $temp[] = intval($ic); } $newval = implode(',', $temp); $temp = varset($pref['initial_user_classes'],''); if ($temp != $newval) $changed = TRUE; if ($changed) { $pref['initial_user_classes'] = $newval; save_prefs(); userclass2_adminlog("05","New: {$newval}, Old: {$temp}, Stage: ".$pref['init_class_stage']); $message = UCSLAN_41; } else { $message = UCSLAN_42; } } //--------------------------------------------------- // Delete existing class //--------------------------------------------------- if (isset($_POST['etrigger_delete']) && !empty($_POST['etrigger_delete'])) { $classID = intval(array_shift(array_keys($_POST['etrigger_delete']))); //checkAllowed($classID); if ($e_userclass->queryCanDeleteClass($classID)) { if ($e_userclass->delete_class($class_id) !== FALSE) { userclass2_adminlog("02","ID:{$class_id} (".$e_userclass->uc_get_classname($classID).")"); if ($sql->db_Select('user', 'user_id, user_class', "user_class = '{$classID}' OR user_class REGEXP('^{$classID},') OR user_class REGEXP(',{$classID},') OR user_class REGEXP(',{$classID}$')")) { // Delete existing users from class while ($row = $sql->db_Fetch(MYSQL_ASSOC)) { $uidList[$row['user_id']] = $row['user_class']; } $e_userclass->class_remove($classID, $uidList); } $e_pref = e107::getConfig(); if($e_pref->isData('frontpage/'.$classID)) { $e_pref->removePref('frontpage/'.$classID)->save(false); } /*if (isset($pref['frontpage'][$class_id])) { unset($pref['frontpage'][$class_id]); // (Should work with both 0.7 and 0.8 front page methods) save_prefs(); }*/ $emessage->add(UCSLAN_3, E_MESSAGE_SUCCESS); } else { $emessage->add(UCSLAN_10, E_MESSAGE_ERROR); } } else { $emessage->add(UCSLAN_10, E_MESSAGE_ERROR); } } //--------------------------------------------------- // Add/Edit class information //--------------------------------------------------- if (isset($_POST['createclass'])) // Add or edit { $fullEdit = TRUE; // Most of the time, we are allowed to edit everything $do_tree = FALSE; // Set flag to rebuild tree if no errors $forwardVals = FALSE; // Set to ripple through existing values to a subsequent pass $tempID = intval(varset($_POST['userclass_id'], -1)); if (($tempID < 0) && $e_userclass->ucGetClassIDFromName($class_record['userclass_name'])) { $emessage->add(UCSLAN_63, E_MESSAGE_WARNING); // Duplicate name $forwardVals = TRUE; } if ($tempID > 0) { $fullEdit = $e_userclass->queryCanEditClass($tempID) == 2; } $class_record = array( 'userclass_description' => varset($tp->toDB($_POST['userclass_description']),''), 'userclass_editclass' => intval(varset($_POST['userclass_editclass'],0)), 'userclass_parent' => intval(varset($_POST['userclass_parent'],0)), 'userclass_visibility' => intval(varset($_POST['userclass_visibility'],0)), 'userclass_icon' => $tp->toDB(varset($_POST['userclass_icon'],'')) ); if ($fullEdit) { $class_record['userclass_name'] = varset($tp->toDB($_POST['userclass_name']),''); $class_record['userclass_type'] = intval(varset($_POST['userclass_type'],UC_TYPE_STD)); if ($class_record['userclass_type'] == UC_TYPE_GROUP) { $temp = array(); foreach ($_POST['group_classes_select'] as $gc) { $temp[] = intval($gc); } $class_record['userclass_accum'] = implode(',',$temp); } } if ($e_userclass->checkAdminInfo($class_record, $tempID) === FALSE) { $emessage->add(UCSLAN_86); // Some fixed values changed $forwardVals = TRUE; } if (!$forwardVals) { if ($tempID > 0) { // Editing existing class here checkAllowed($tempID); $class_record['userclass_id'] = $tempID; $e_userclass->save_edited_class($class_record); userclass2_adminlog('03',"ID:{$class_record['userclass_id']} (".$class_record['userclass_name'].")"); $do_tree = TRUE; //$message .= UCSLAN_5; $emessage->add(UCSLAN_5, E_MESSAGE_SUCCESS); } else { // Creating new class if($class_record['userclass_name']) { if (getperms("0") || ($class_record['userclass_editclass'] && check_class($class_record['userclass_editclass']))) { $i = $e_userclass->findNewClassID(); if ($i === FALSE) { //$message = UCSLAN_85; $emessage->add(UCSLAN_85, E_MESSAGE_WARNING); } else { $class_record['userclass_id'] = $i; $e_userclass->add_new_class($class_record); userclass2_adminlog("01","ID:{$class_record['userclass_id']} (".$class_record['userclass_name'].")"); $do_tree = TRUE; //$message .= UCSLAN_6; $emessage->add(UCSLAN_6, E_MESSAGE_SUCCESS); } } else { header("location:".SITEURL); exit; } } else { // Class name required //$message = UCSLAN_37; $emessage->add(UCSLAN_37, E_MESSAGE_ERROR); $forwardVals = TRUE; } } } if ($do_tree) { $e_userclass->calc_tree(); $e_userclass->save_tree(); } } if ($message) { $emessage->add($message); } class uclassFrm extends e_form { function userclass_type($curVal,$mode) { $types = array( UC_TYPE_STD => UCSLAN_80, UC_TYPE_GROUP => UCSLAN_81 ); return varset($types[$curVal]); } } if(!e_QUERY || $action == 'list') { $uc->show_existing(); } if(isset($_GET['id']) && $_GET['action'] == 'edit') { $action = 'config'; $_POST['existing'] = $_GET['id']; } switch ($action) { //----------------------------------- // Class management //----------------------------------- case 'config' : $fullEdit = TRUE; if(isset($_POST['existing'])) { $params = 'edit'; $class_num = intval(varset($_POST['existing'],0)); $fullEdit = $e_userclass->queryCanEditClass($class_num) == 2; } else { $class_num = intval(varset($uc_qs[2],0)); } $userclass_id = 0; // Set defaults for new class to start with $userclass_name = ''; $userclass_description = ''; $userclass_editclass = e_UC_ADMIN; $userclass_visibility = e_UC_ADMIN; $userclass_parent = e_UC_NOBODY; $userclass_icon = ''; $userclass_type = UC_TYPE_STD; $userclass_groupclass = ''; if ($params == 'edit' || $forwardVals) { if (!$forwardVals) { // Get the values from DB (else just recycle data uer was trying to store) checkAllowed($class_num); $sql->db_Select('userclass_classes', '*', "userclass_id='".intval($class_num)."' "); $class_record = $sql->db_Fetch(); $userclass_id = $class_record['userclass_id']; // Update fields from DB if editing } $userclass_name = $class_record['userclass_name']; $userclass_description = $class_record['userclass_description']; $userclass_editclass = $class_record['userclass_editclass']; $userclass_visibility = $class_record['userclass_visibility']; $userclass_parent = $class_record['userclass_parent']; $userclass_icon = $class_record['userclass_icon']; $userclass_type = $class_record['userclass_type']; if ($userclass_type == UC_TYPE_GROUP) { $userclass_groupclass = $class_record['userclass_accum']; } } $class_total = $sql->db_Count('userclass_classes', '(*)'); $text = "
Class rights for first 20 users in database | ||||
User ID | Disp Name | Raw classes | Inherited classes | Editable classes |
".$row['user_id']." | ".$row['user_name']." | ".$row['user_class']." | ".$inherit." | ".$e_userclass->get_editable_classes($inherit)." |