root/trunk/app/views/elements/userform.ctp

Revision 2486, 3.6 KB (checked in by aarkerio, 7 days ago)

Helper updated

Line 
1<?php
2#debug( $this->data );
3if ($this->data['User']['id'] != $this->Session->read('Auth.User.id')):   #security check
4    echo $this->__getSupport();
5endif;
6
7echo $this->Html->para(null, $this->Html->image('avatars/'.$this->data['User']['avatar'], array('alt'=>$this->data['User']['username'], 'title'=>$this->data['User']['username']))); 
8
9echo $this->Form->create('User', array('onsubmit'=>'return chkForm()'));
10echo $this->Form->hidden('User.id');
11echo $this->Form->hidden('Profile.id');
12echo $this->Form->hidden('User.email');
13echo $this->Form->hidden('Profile.modified', array('value'=>'now()'));
14echo '<fieldset>';
15echo '<legend>'.$this->Session->read('Auth.User.username') .'\'s '.__('profile', True).'</legend>';
16echo $this->Html->div(Null, '<b>'.$this->data['User']['email'].'</b>');
17echo $this->Form->input('User.name', array('size' => 35, 'maxlength'=>50)); 
18   
19$langs = array('en'=>'English', 'es'=>'Español');
20echo $this->Form->input('User.lang', array('type'=>'select', 'options'=>$langs, 'label'=> __('Language',True)));
21
22echo $this->Form->input('Profile.cv', array('type'=>'textarea','cols' => 70, 'rows' => 7, 'label'=> __('profile',True)));
23echo $this->Form->input('Profile.phone', array('size' => 35, 'maxlength'=>50, 'label'=>__('Phone', True)));
24echo $this->Form->input('Profile.cellphone', array('size' => 35, 'maxlength'=>50, 'label'=>__('Cell Phone', True)));
25echo $this->Form->input('Profile.matricula', array('size'=>20,'maxlength'=>20,'title'=>__('If you are student, write your matricula number', True)));
26
27if ( $this->Session->read('Auth.User.group_id') < 3):  # admin and teachers
28    echo $this->Form->input('Profile.quote', array('size' => 70, 'maxlength' => 150, 'label'=>__('Quote', True)));
29    echo $this->Form->input('Profile.name_blog', array('size' => 45, 'maxlength' => 150, 'label'=>__('eduBlog name', True)));
30    echo $this->Form->input('Profile.tags', array('size' => 45, 'maxlength' => 150, 'label'=>'Tags'));
31    $styles = array('mexico'=>'México', 'basic'=>'Basic');
32    echo $this->Form->input('Profile.layout', array('type'=>'select', 'options'=>$styles, 'label'=>__('Layout',True)));
33endif;
34
35echo $this->Form->input('Profile.newsletter', array('type'=>'checkbox', 'label'=> __('Subscribe to newsletter', True))); 
36echo $this->Form->input('User.helps', array('type'=>'checkbox', 'label'=> __('Enable help messages', True))); 
37
38echo $this->Html->div(Null, $this->Form->input('User.pwd', array('size'=>9, 'maxlength'=>9, 'value'=>'', 
39      'label'=>__('Password', True))) . '  '.__('Left empty if you do not want to change', True), array('style'=>'clear:both;margin:25px 0 16px 0;'));
40echo '</fieldset>';
41echo $this->Form->end(__('Save', True));
42
43echo $this->Html->div('spaced');
44echo $this->Form->create('User', array('enctype'=>'multipart/form-data', 'action'=>'avatar'));
45echo $this->Form->hidden('User.id'); 
46?>
47<fieldset>
48<legend><?php __('Upload new avatar'); ?></legend>
49<?php
50 echo $this->Html->div(null, __('An image 50 x 50 pixels', True));
51 echo $this->Form->input('User.file', array('type'=>'file')); 
52 echo '</fieldset>';
53 echo $this->Form->end(__('Upload', True));
54 echo '</div>';
55 
56 # JS
57 echo $this->Html->scriptStart(); 
58?>
59function chkForm()
60{
61  var name      = document.getElementById("UserName");
62  var passwd    = document.getElementById("UserPwd");
63 
64  if (name.value.length < 6)
65  {
66    alert('<?php __('The name must be at least six characters');?>');
67    name.focus();
68    return false;
69  }
70 
71  if (passwd.value.length > 0  && passwd.value.length < 6)
72  {
73    alert('<?php __('The password must be at least five characters');?>');
74    passwd.focus();
75    return false;
76  }
77 
78return true;
79}
80<?php echo $this->Html->scriptEnd(); ?>
Note: See TracBrowser for help on using the browser.