首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Moodle:经过用户ID(user id) 获取用户权限

2014-01-12 
Moodle:通过用户ID(user id) 获取用户权限?phprequire_once(../config.php) // under root if(!is_sit

Moodle:通过用户ID(user id) 获取用户权限
<?phprequire_once("../config.php"); // under root if(!is_siteadmin()){global $COURSE, $USER;$queryrole = $DB->get_records('role_assignments',array('userid'=>$USER->id));//echo '<pre>'; print_r($queryrole); echo '</pre>';//$role_ids = array();//foreach($queryrole as $qrole){ $role_ids[] = $qrole->roleid; }//echo '<pre>'; print_r(implode(',', $role_ids)); echo '</pre>'; die;//$role_id = max($role_ids);//if(!is_siteadmin()) exit('<script>location="/moodle/my/"</script>');//echo '<pre>'; print_r($role_id); echo '</pre>';//echo 'My Role ID is :'.$role_id; die;$students_and_teachers = array('3', //Teacher'4', //Non-editing teacher'5', //Student'6', //Guest'7', //Authenticated user'8', //Authenticated user on frontpage'9', //Online Student'10', //onsite student'15', //ManagerAssistant '16', //TA);//if(!$role_id OR in_array($role_id, $students_and_teachers)) exit('<script>location="/moodle/my/"</script>');$except = FALSE;foreach($queryrole as $qrole) if(!in_array($qrole->roleid, $students_and_teachers)) { $except = TRUE; break; } if(!$except) exit('<script>location="/moodle/my/"</script>');}

?

?

?

热点排行