source: iPeer/app/views/users/edit.ctp @ 682eaae

3.1.xdevhotfixpagodaboxticket463
Last change on this file since 682eaae was 682eaae, checked in by Compass <pan.luo@…>, 6 years ago

Hide username field from instructor

As per IAM team requirements, PUID should not be shown to instructor. So
added a permission viewusername to determine if user has permission to
see the username field

  • Property mode set to 100644
File size: 2.1 KB
Line 
1<div>
2<?php
3echo $this->Form->create('User', array('id' => 'UserForm', 'url' => '/'.$this->params['url']['url']));
4echo '<input type="hidden" name="required" id="required" value="username" />';
5echo $this->Form->input('id');
6if (User::hasPermission('functions/viewusername'))
7{
8    echo $this->Form->input('username');
9}
10echo "<div id='usernameErr' class='red'></div>";
11echo $this->Form->input('first_name');
12echo $this->Form->input('last_name');
13echo $this->Form->input('email');
14echo $this->Form->input(
15  'Role.RolesUser.role_id',
16  array(
17    'default' => $roleDefault,
18    'label' => 'Role',
19    'options' => $roleOptions,
20  )
21);
22if (User::hasPermission('functions/user/admin')) {
23    echo $this->Form->input('Faculty',
24        array('label' => 'Faculty (admin only)'));
25}
26echo $this->Form->input('title');
27echo $this->Form->input('student_no', array('label' => 'Student Number'));
28echo $this->Form->input(
29  'Courses.id',
30  array(
31    'type' => 'select',
32    'multiple' => 'checkbox',
33    'options' => $coursesOptions,
34    'label' => "Put User in Course",
35    'selected' => $coursesSelected
36  )
37);
38?><div class=buttons><?php
39echo $this->Form->submit('Save');
40?></div><?php
41echo $this->Form->end();
42
43// dynamically check username availability
44echo $ajax->observeField(
45  'UserUsername',
46  array(
47    'update'=>'usernameErr',
48    'url'=>'checkDuplicateName/',
49    'frequency'=>1,
50    'loading'=>"Element.show('loading');",
51    'complete'=>"Element.hide('loading');stripe();"
52  )
53);
54
55?>
56</div>
57
58<?php
59if (User::hasPermission('functions/user/admin')) {
60    echo "
61<script type='text/javascript'>
62// If the user is supposed to be a student, disable adding as an
63// instructor. Any other role, disable adding as a student.
64jQuery('#RoleRolesUserRoleId').change(function() {
65    var str = jQuery('#RoleRolesUserRoleId option:selected').text();
66    if (str == 'admin') {
67        jQuery('#FacultyFaculty').removeAttr('disabled');
68    }
69    else {
70        jQuery('#FacultyFaculty').attr('disabled', 'disabled');
71    }
72});
73// run once on initial page load
74jQuery('#RoleRolesUserRoleId').change();
75</script>";
76}
77?>
Note: See TracBrowser for help on using the repository browser.