source: iPeer/app/views/users/add.ctp @ c73a6cfd

3.1.xdevhotfixpagodaboxticket463
Last change on this file since c73a6cfd was c73a6cfd, checked in by John Hsu <john.hsu@…>, 6 years ago

Add User Faculty label fix.

"admin only" doesn't make sense when instructors can also select
faculties.

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