users can add pictures to their profiles; users can like and dislike videos
[living-lab-site.git] / application / views / user / register_view.php
1 <?php
2 function _set_value($userdata, $field, $default = '')
3 {
4         $post_value = set_value($field, $default);
5         
6         if (! $userdata)
7                 return $post_value;
8
9         return ($post_value === $default 
10                 ? $userdata[ str_replace('-','_',$field) ]
11                 : $post_value);
12 }
13
14 if (!$userdata)
15         echo form_open_multipart("user/register/$redirect");
16 else
17         echo form_open_multipart("user/account/$redirect");
18 ?>
19
20 <?php if ($userdata): ?>
21 <input type="hidden" name="user-id" value="<?php echo $userdata['id'] ?>" />
22 <input type="hidden" name="username" value="<?php echo $userdata['username'] ?>" />
23 <?php endif ?>
24
25 <table class="form">
26         <tr>
27                 <td></td>
28                 <td><span class="required"><?php echo $this->lang->line('user_note_required_fields') ?></span></td>
29         </tr>
30         
31         <tr><td></td><td>&nbsp;</td></tr>
32
33         <tr>
34           <?php if (! $userdata): ?>
35                 <th><?php echo $this->lang->line('user_username'). ' <span class="required">*</span> : ' ?></th>
36                 <td>
37                         <input type="text" name="username" size="16" value="<?php echo _set_value($userdata, 'username') ?>" />
38                 </td>
39           <?php else: ?>
40                 <th><?php echo $this->lang->line('user_username'). ' : ' ?></th>
41                 <td>
42                         &nbsp;<em><?php echo $userdata['username'] ?></em>
43                 </td>`
44           <?php endif ?>
45         </tr>
46         <tr><td></td><td><?php echo form_error('username') ?></td></tr>
47         
48   <?php // Register requires password ?>
49   <?php if (! $userdata):?>
50         <tr>
51                 <th><?php echo $this->lang->line('user_password'). ' <span class="required">*</span> : ' ?></th>
52                 <td>
53                         <input type="password" name="password" size="16" value="" />
54                 </td>
55         </tr>
56         <tr><td></td><td><?php echo form_error('password') ?></td></tr>
57         
58         <tr>
59                 <th><?php echo $this->lang->line('user_password_confirmation'). ' <span class="required">*</span> : ' ?></th>
60                 <td>
61                         <input type="password" name="password-confirmation" size="16" value="" />
62                 </td>
63         </tr>
64         <tr><td></td><td><?php echo form_error('password-confirmation') ?></td></tr>
65   <?php // Edit account data requires password reset ?>
66   <?php elseif ($userdata && $userdata['auth_src'] == 'internal'): ?>
67         <tr>
68                 <th><?php echo $this->lang->line('user_old_password'). ' <span class="required">*</span> : ' ?></th>
69                 <td>
70                         <input type="password" name="old-password" size="16" value="" />
71                 </td>
72         </tr>
73         <tr><td></td><td><?php echo form_error('old-password') ?></td></tr>
74         
75         <tr>
76                 <th><?php echo $this->lang->line('user_new_password'). ' <span class="required">*</span> : ' ?></th>
77                 <td>
78                         <input type="password" name="new-password" size="16" value="" />
79                 </td>
80         </tr>
81         <tr><td></td><td><?php echo form_error('new-password') ?></td></tr>
82         
83         <tr>
84                 <th><?php echo $this->lang->line('user_new_password_confirmation'). ' <span class="required">*</span> : ' ?></th>
85                 <td>
86                         <input type="password" name="new-password-confirmation" size="16" value="" />
87                 </td>
88         </tr>
89         <tr><td></td><td><?php echo form_error('new-password-confirmation') ?></td></tr>
90   <?php endif ?>
91         
92         <tr>
93                 <th><?php echo $this->lang->line('user_email'). ' <span class="required">*</span> : ' ?></th>
94                 <td>
95                         <input type="text" name="email" size="16" value="<?php echo _set_value($userdata, 'email') ?>" />
96                 </td>
97         </tr>
98         <tr><td></td><td><?php echo form_error('email') ?></td></tr>
99         
100         <tr><td></td><td>&nbsp;</td></tr>
101         
102         <tr>
103                 <th><?php echo $this->lang->line('user_first_name'). ' <span class="required">*</span> : ' ?></th>
104                 <td>
105                         <input type="text" name="first-name" size="16" value="<?php echo _set_value($userdata, 'first-name') ?>" />
106                 </td>
107         </tr>
108         <tr><td></td><td><?php echo form_error('first-name') ?></td></tr>
109         
110         <tr>
111                 <th><?php echo $this->lang->line('user_last_name'). ' <span class="required">*</span> : ' ?></th>
112                 <td>
113                         <input type="text" name="last-name" size="16" value="<?php echo _set_value($userdata, 'last-name') ?>" />
114                 </td>
115         </tr>
116         <tr><td></td><td><?php echo form_error('last-name') ?></td></tr>
117         
118         <tr>
119                 <th><?php echo $this->lang->line('user_birth_date'). ' : ' ?></th>
120                 <td>
121                         <input type="text" name="birth-date" id="birth-date" size="16" value="<?php echo _set_value($userdata, 'birth-date') ?>" /> (<?php echo $this->lang->line('user_date_format_hint') ?>)
122                 </td>
123         </tr>
124         <tr><td></td><td><?php echo form_error('birth-date') ?></td></tr>
125         
126         <tr>
127                 <th><?php echo $this->lang->line('user_country'). ' <span class="required">*</span> : ' ?></th>
128                 <td>
129                         <?php echo country_dropdown('country', array('RO'), _set_value($userdata, 'country', 'RO')) ?>
130                 </td>
131         </tr>
132         <tr><td></td><td><?php echo form_error('country') ?></td></tr>
133         
134         <tr>
135                 <th><?php echo $this->lang->line('user_locality'). ' : ' ?></th>
136                 <td>
137                         <input type="text" name="locality" size="16" value="<?php echo _set_value($userdata, 'locality') ?>" />
138                 </td>
139         </tr>
140         <tr><td></td><td><?php echo form_error('locality') ?></td></tr>
141         
142   <?php if ($userdata && $userdata['picture']): ?>
143         <tr>
144                 <th><?php echo $this->lang->line('user_picture'). ' : ' ?></th>
145                 <td>
146                         <img src="<?php echo site_url("data/user_pictures/{$userdata['picture']}") ?>" alt="<?php echo $userdata['username'] ?>" />
147                 </td>
148         </tr>
149         <tr><td></td><td></td></tr>
150   <?php endif ?>
151         
152         <tr>
153                 <th>
154                   <?php if (! $userdata || ($userdata && ! $userdata['picture'])): ?>
155                         <?php echo $this->lang->line('user_picture'). ' : ' ?>
156                   <?php else: ?>
157                         <?php echo $this->lang->line('user_change_picture'). ' : ' ?>
158                   <?php endif ?>
159                 </th>
160                 <td>
161                         <input type="file" name="picture" size="16" />
162                 </td>
163         </tr>
164         <tr><td></td><td><?php echo $error_upload ?></td></tr>
165         
166         <tr><td></td><td>&nbsp;</td></tr>
167         
168         <tr>
169                 <th><?php echo $this->lang->line('user_ui_lang'). ' : ' ?></th>
170                 <td>
171                         <?php echo available_languages_dropdown('ui-lang', _set_value($userdata, 'ui-lang', 'en')) ?>
172                 </td>
173         </tr>
174         <tr><td></td><td><?php echo form_error('ui-lang') ?></td></tr>
175         
176         <tr>
177                 <th><?php echo $this->lang->line('user_time_zone'). ' <span class="required">*</span> : ' ?></th>
178                 <td>
179                         <?php echo timezone_menu(_set_value($userdata, 'time-zone', 'UP2'), '', 'time-zone') ?>
180                 </td>
181         </tr>
182         <tr><td></td><td><?php echo form_error('time-zone') ?></td></tr>
183         
184         <tr><td></td><td>&nbsp;</td></tr>
185         
186         <tr>
187                 <td></td>
188                 <td>
189                   <?php if (! $userdata): ?>
190                         <input type="submit" value="<?php echo $this->lang->line('user_submit_register') ?>" />
191                   <?php else: ?>
192                         <input type="submit" value="<?php echo $this->lang->line('user_submit_save') ?>" />
193                   <?php endif ?>
194                 </td>
195         </tr>
196 </table>
197 </form>
198
199 <script type="text/javascript">
200         $(function() {
201                 $( "#birth-date" ).datepicker({
202                         dateFormat: "yy-mm-dd",
203                         changeMonth: true,
204                         changeYear: true,
205                         yearRange: '1910:2011',
206                         showOn: "both",
207                         buttonImage: "<?php echo site_url('img/calendar.gif') ?>",
208                         buttonImageOnly: true
209                 });
210         });
211 </script>