</tr> <tr> <td><label for="rid">Role:</label></td> <td><?php if (isset($_SESSION['rid']) && $_SESSION['rid'] == 1) { print select_role('rid', $old_rid); } elseif (isset($_SESSION['rid']) && $_SESSION['rid'] != 1) { print load_name_from_rid($old_rid); } ?> </td> </tr> <tr> <td>Belonged courses:</td> <td><?php print view_user_courses($uid); ?> </td> </tr> <tr> <td><input onclick="checkPass();" type="submit" name="submit" value="Save" /></td> <td><a class="button" href="?p=user">Cancel</a></td> </tr> </table> </form> <script type="text/javascript"> function checkPass() { if ($("input[name=pass]").val() != $("input[name=pass1]").val()) { $("span#check_pass").css("display","block"); $("span#check_pass").text("Password not match"); return false;
function view_user($uid) { //Return user account, for every authenticated user's use $output = ''; $user = user_load($uid); $course_users = course_users_load($uid); $output .= '<table>'; $output .= '<tr><th>User ID</th><th>Username</th><th>Mail</th><th>Role</th><th>Courses</th><th colspan="2">Operations</th></tr>'; $output .= '<tr>'; $output .= '<td>' . $user['User_ID'] . '</td>'; $output .= '<td>' . $user['User_Username'] . '</td>'; $output .= '<td>' . $user['User_Mail'] . '</td>'; $output .= '<td>' . load_name_from_rid($user['Role_ID']) . '</td>'; $output .= '<td>' . view_user_courses($user['User_ID']) . '</td>'; $output .= '<td class="center"><form method="POST" action="?p=user/edit"><input type="hidden" name="uid" value="' . $user['User_ID'] . '" /><input type="hidden" name="old_name" value="' . $user['User_Username'] . '" /><input type="hidden" name="old_fullname" value="' . $user['User_Fullname'] . '" /><input type="hidden" name="old_mail" value="' . $user['User_Mail'] . '" /><input type="hidden" name="old_rid" value="' . $user['Role_ID'] . '" /><input name="user_edit" type="submit" value="Edit"/></form></td>'; $output .= $_SESSION['rid'] != 2 && $_SESSION['rid'] != 3 ? '<td class="center"><form method="POST" action="?p=user/delete"><input type="hidden" name="uid" value="' . $user['User_ID'] . '" /><input name="user_delete" type="submit" value="Delete"/></form></td>' : '<td class="empty"></td>'; $output .= '</tr>'; $output .= '</table>'; return $output; }