unactivated users CLI cleanup; user management bugs fixed; working at CAPTCHA
[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 || ! empty($userdata['autogen_username'])): ?>
35                 <th><?php echo $this->lang->line('user_username'). ' <span class="required">*</span> : ' ?></th>
36                 <td>
37                   <?php if (empty($userdata['autogen_username'])): ?>
38                         <input type="text" name="username" size="16" value="<?php echo _set_value($userdata, 'username') ?>" />
39                   <?php else: ?>
40                         <input type="text" name="username" size="16" value="<?php echo $userdata['autogen_username'] ?>" />
41                   <?php endif ?>
42                 </td>
43           <?php else: ?>
44                 <th><?php echo $this->lang->line('user_username'). ' : ' ?></th>
45                 <td>
46                         &nbsp;<em><?php echo $userdata['username'] ?></em>
47                         <!--<input type="hidden" name="username" value="<?php echo $userdata['username'] ?>" />-->
48                 </td>
49           <?php endif ?>
50         </tr>
51         <tr><td></td><td><?php echo form_error('username') ?></td></tr>
52         
53   <?php // Register requires password ?>
54   <?php if (! $userdata):?>
55         <tr>
56                 <th><?php echo $this->lang->line('user_password'). ' <span class="required">*</span> : ' ?></th>
57                 <td>
58                         <input type="password" name="password" size="16" value="" />
59                 </td>
60         </tr>
61         <tr><td></td><td><?php echo form_error('password') ?></td></tr>
62         
63         <tr>
64                 <th><?php echo $this->lang->line('user_password_confirmation'). ' <span class="required">*</span> : ' ?></th>
65                 <td>
66                         <input type="password" name="password-confirmation" size="16" value="" />
67                 </td>
68         </tr>
69         <tr><td></td><td><?php echo form_error('password-confirmation') ?></td></tr>
70   <?php // Edit account data requires password reset ?>
71   <?php elseif ($userdata && $userdata['auth_src'] == 'internal'): ?>
72         <tr>
73                 <th><?php echo $this->lang->line('user_old_password'). ' <span class="required">*</span> : ' ?></th>
74                 <td>
75                         <input type="password" name="old-password" size="16" value="" />
76                 </td>
77         </tr>
78         <tr><td></td><td><?php echo form_error('old-password') ?></td></tr>
79         
80         <tr>
81                 <th><?php echo $this->lang->line('user_new_password'). ' <span class="required">*</span> : ' ?></th>
82                 <td>
83                         <input type="password" name="new-password" size="16" value="" />
84                 </td>
85         </tr>
86         <tr><td></td><td><?php echo form_error('new-password') ?></td></tr>
87         
88         <tr>
89                 <th><?php echo $this->lang->line('user_new_password_confirmation'). ' <span class="required">*</span> : ' ?></th>
90                 <td>
91                         <input type="password" name="new-password-confirmation" size="16" value="" />
92                 </td>
93         </tr>
94         <tr><td></td><td><?php echo form_error('new-password-confirmation') ?></td></tr>
95   <?php endif ?>
96         
97         <tr>
98                 <th><?php echo $this->lang->line('user_email'). ' <span class="required">*</span> : ' ?></th>
99                 <td>
100                         <input type="text" name="email" size="16" value="<?php echo _set_value($userdata, 'email') ?>" />
101                 </td>
102         </tr>
103         <tr><td></td><td><?php echo form_error('email') ?></td></tr>
104         
105         <tr><td></td><td>&nbsp;</td></tr>
106         
107         <tr>
108                 <th><?php echo $this->lang->line('user_first_name'). ' <span class="required">*</span> : ' ?></th>
109                 <td>
110                         <input type="text" name="first-name" size="16" value="<?php echo _set_value($userdata, 'first-name') ?>" />
111                 </td>
112         </tr>
113         <tr><td></td><td><?php echo form_error('first-name') ?></td></tr>
114         
115         <tr>
116                 <th><?php echo $this->lang->line('user_last_name'). ' <span class="required">*</span> : ' ?></th>
117                 <td>
118                         <input type="text" name="last-name" size="16" value="<?php echo _set_value($userdata, 'last-name') ?>" />
119                 </td>
120         </tr>
121         <tr><td></td><td><?php echo form_error('last-name') ?></td></tr>
122         
123         <tr>
124                 <th><?php echo $this->lang->line('user_sex'). ' <span class="required">*</span> : ' ?></th>
125                 <td>
126                         <?php echo form_dropdown('sex', 
127                                 array(
128                                         '0'=> $this->lang->line('user_sex_male'),
129                                         '1'=> $this->lang->line('user_sex_female')),
130                                 _set_value($userdata, 'sex', '0')
131                         ) ?>
132                 </td>
133         </tr>
134         <tr><td></td><td><?php echo form_error('sex') ?></td></tr>
135         
136         <tr>
137                 <th><?php echo $this->lang->line('user_birth_date'). ' : ' ?></th>
138                 <td>
139                         <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') ?>)
140                 </td>
141         </tr>
142         <tr><td></td><td><?php echo form_error('birth-date') ?></td></tr>
143         
144         <tr>
145                 <th><?php echo $this->lang->line('user_country'). ' <span class="required">*</span> : ' ?></th>
146                 <td>
147                         <?php echo country_dropdown('country', array('RO'), _set_value($userdata, 'country', 'RO')) ?>
148                 </td>
149         </tr>
150         <tr><td></td><td><?php echo form_error('country') ?></td></tr>
151         
152         <tr>
153                 <th><?php echo $this->lang->line('user_locality'). ' : ' ?></th>
154                 <td>
155                         <input type="text" name="locality" size="16" value="<?php echo _set_value($userdata, 'locality') ?>" />
156                 </td>
157         </tr>
158         <tr><td></td><td><?php echo form_error('locality') ?></td></tr>
159         
160   <?php if ($userdata && $userdata['picture']): ?>
161         <tr>
162                 <th><?php echo $this->lang->line('user_picture'). ' : ' ?></th>
163                 <td>
164                         <a href="<?php echo $userdata['picture'] ?>"><img src="<?php echo $userdata['picture_thumb'] ?>" alt="<?php echo $userdata['username'] ?>" /></a>
165                 </td>
166         </tr>
167         <tr><td></td><td></td></tr>
168   <?php endif ?>
169         
170         <tr>
171                 <th>
172                   <?php if (! $userdata || ($userdata && ! $userdata['picture'])): ?>
173                         <?php echo $this->lang->line('user_picture'). ' : ' ?>
174                   <?php else: ?>
175                         <?php echo $this->lang->line('user_change_picture'). ' : ' ?>
176                   <?php endif ?>
177                 </th>
178                 <td>
179                         <input type="file" name="picture" size="16" />
180                 </td>
181         </tr>
182         <tr><td></td><td><?php echo $error_upload ?></td></tr>
183         
184         <tr><td></td><td>&nbsp;</td></tr>
185         
186         <tr>
187                 <th><?php echo $this->lang->line('user_ui_lang'). ' : ' ?></th>
188                 <td>
189                         <?php echo available_languages_dropdown('ui-lang', _set_value($userdata, 'ui-lang', 'en')) ?>
190                 </td>
191         </tr>
192         <tr><td></td><td><?php echo form_error('ui-lang') ?></td></tr>
193         
194         <tr>
195                 <th><?php echo $this->lang->line('user_time_zone'). ' <span class="required">*</span> : ' ?></th>
196                 <td>
197                         <?php echo timezone_menu(_set_value($userdata, 'time-zone', 'UP2'), '', 'time-zone') ?>
198                 </td>
199         </tr>
200         <tr><td></td><td><?php echo form_error('time-zone') ?></td></tr>
201         
202         <tr><td></td><td>&nbsp;</td></tr>
203         
204         <tr>
205                 <td></td>
206                 <td>
207                   <?php if (! $userdata): ?>
208                         <input type="submit" value="<?php echo $this->lang->line('user_submit_register') ?>" />
209                   <?php else: ?>
210                         <input type="submit" value="<?php echo $this->lang->line('user_submit_save') ?>" />
211                   <?php endif ?>
212                 </td>
213         </tr>
214 </table>
215 </form>
216
217 <script type="text/javascript">
218         $(function() {
219                 $( "#birth-date" ).datepicker({
220                         dateFormat: "yy-mm-dd",
221                         changeMonth: true,
222                         changeYear: true,
223                         yearRange: '1910:2011',
224                         showOn: "both",
225                         buttonImage: "<?php echo site_url('img/calendar.gif') ?>",
226                         buttonImageOnly: true
227                 });
228         });
229 </script>