'label'=>'lang:user_locality',
'rules'=>'trim|ucwords|xss_clean|prep_for_form'
)
+ ),
+ 'activate'=> array(
+ array(
+ 'field'=>'activation-code',
+ 'label'=>'lang:user_activation_code',
+ 'rules'=>'trim|required|strtolower|callback__valid_activation_code|callback__do_activate'
+ )
+ ),
+ 'resend_activation'=> array(
+ array(
+ 'field'=>'email',
+ 'label'=>'lang:user_email',
+ 'rules'=>'trim|required|xss_clean|valid_email|callback__do_resend_activation'
+ )
)
);
private $import = FALSE;
private $activated_account = TRUE;
+ private $user_id = NULL;
public function __construct()
{
else
{
if (! $this->activated_account)
- header('Location: '. site_url('catalog/test'));
+ header('Location: '
+ . site_url("user/activate/{$this->user_id}"));
else if (! $this->import)
{
// Redirect to last page before login.
$data['password'] = $this->input->post('new-password');
$this->users_model->set_userdata($user_id, $data);
+
+ // Redirect to last page before login.
+ header('Location: '. site_url(urldecode_segments($redirect)));
}
// Registration
else
$data['password'] = $this->input->post('password');
$this->users_model->register($data);
+ $user_id = $this->users_model->get_userdata($data['username'],
+ "id");
+ $user_id = $user_id['id'];
+
+ // Redirect account activation page.
+ header('Location: '. site_url("user/activate/$user_id"));
}
-
- // Redirect to last page before login.
- header('Location: '. site_url(urldecode_segments($redirect)));
}
}
$this->load->view('html_end');
}
- public function activate($user_id, $activation_code)
+ public function activate($user_id, $method='', $activation_code='')
{
$user_id = intval($user_id);
- echo ''. $this->users_model->activate_account($user_id, $activation_code);
+ $userdata = $this->users_model->get_userdata($user_id,
+ 'email, a.activation_code');
+ $email = $userdata['email'];
+ //print_r($userdata['activation_code']);
+ $activated_account = ($userdata['activation_code'] == NULL);
+
+ $this->load->library('form_validation');
+
+ $this->form_validation->set_error_delimiters('<span class="error">',
+ '</span>');
+
+ $res_form_validation = FALSE;
+ if ($method == 'code')
+ {
+ $res_form_validation = $this->form_validation->run('activate');
+ }
+ else if ($method == 'resend')
+ {
+ $res_form_validation =
+ $this->form_validation->run('resend_activation');
+ }
+
+ if ($res_form_validation === FALSE)
+ {
+ $params = array(
+ 'title'=> $this->lang->line('user_title_activation')
+ .' – '
+ . $this->config->item('site_name'),
+ //'metas' => array('description'=>'')
+ );
+ $this->load->library('html_head_params', $params);
+
+ // **
+ // ** LOADING VIEWS
+ // **
+ $this->load->view('html_begin', $this->html_head_params);
+ $this->load->view('header', array());
+
+ if (! $activated_account)
+ {
+ $main_params['content'] =
+ $this->load->view('user/activate_view',
+ array('user_id'=> $user_id, 'email'=> $userdata['email']),
+ TRUE);
+ }
+ else
+ {
+ $main_params['content'] =
+ $this->load->view('user/activated_account_view',
+ NULL, TRUE);
+ }
+
+ $main_params['side'] = $this->load->view('side_default', NULL, TRUE);
+ $this->load->view('main', $main_params);
+
+ $this->load->view('footer');
+ $this->load->view('html_end');
+ }
+ else
+ {
+ if ($method == 'code')
+ {
+ // Redirect to a message which tells the user that the
+ // activation was successful.
+ header('Location: '. site_url("user/activate/$user_id"));
+ }
+ else if ($method == 'resend')
+ {
+ // Redirect to home page
+ header('Location: '. site_url());
+ }
+ }
}
public function _update_session_userdata($data)
return TRUE;
}
+
+ public function _valid_activation_code($activation_code)
+ {
+ return (preg_match('/^[a-fA-F0-9]{16}$/', $activation_code) == 1);
+ }
public function _do_login($username, $field_password)
{
if ($user['activation_code'] !== NULL)
{
$this->activated_account = FALSE;
+ $this->user_id = $user['id'];
return TRUE;
}
$this->import = (isset($user['import']) ? $user['import'] : FALSE);
return TRUE;
}
+
+ public function _do_activate($activation_code)
+ {
+ $user_id = $this->input->post('user-id');
+ if ($user_id === FALSE)
+ return FALSE;
+ $user_id = intval($user_id);
+
+ return $this->users_model->activate_account($user_id,
+ $activation_code);
+ }
+
+ public function _do_resend_activation($email)
+ {
+ return FALSE;
+ }
}
/* End of file user.php */
<?php
+// Merge with standard language entries.
include('system/language/english/form_validation_lang.php');
+// Login / Register/ Account / Profile
$lang['_valid_username'] = 'You must enter a valid username with letters, numbers, . (dots) or _ (underscores).';
$lang['_valid_username_or_email'] = "You must enter an e-mail address or a valid username.";
-$lang['_do_login'] = "Wrong %s, or wrong %s.";
-$lang['_valid_date'] = "Invalid %s! Use the specified format or leave the field blank if you don't want to specify it.";
-$lang['_valid_old_password'] = "Wrong %s.";
+$lang['_do_login'] = 'Wrong %s, or wrong %s.';
+$lang['_valid_date'] = 'Invalid %s! Use the specified format or leave the field blank if you don\'t want to specify it.';
+$lang['_valid_old_password'] = 'Wrong %s.';
$lang['_change_password_cond'] = 'If you want to change your password complete all three password related fields.';
$lang['_required_by_register'] = 'The %s field is required.';
+// Account Activation
+$lang['_valid_activation_code'] = 'Invalid activation code. You must provide 16 hexa characters.';
+$lang['_do_activate'] = 'Wrong activation code.';
+$lang['_do_resend_activation'] = 'An error occurred while resending your activation e-mail. This is not a permanent error. Please try again later.';
+
/* End of file form_validation_lang.php */
/* Location: ./system/language/english/form_validation_lang.php */
\ No newline at end of file
$lang['user_appelation'] = 'User';
+// Login / Register/ Account / Profile
$lang['user_username'] = 'User Name';
$lang['user_username_or_email'] = 'User Name or E-mail';
$lang['user_password'] = 'Password';
$lang['user_submit_register'] = 'Register';
$lang['user_submit_save'] = 'Save';
+// Account Activation
+$lang['user_title_activation'] = 'Account Activation';
+$lang['user_legend_activation'] = 'Activate your account';
+$lang['user_instruction_activation'] = 'Shortly after the registration you made you will receive an <em>activation e-mail</em> on your e-mail address you provided. In order to confirm that you are the owner of that e-mail address, follow the link there or enter the <em>activation code</em> also provided in that e-mail in the field below.';
+$lang['user_activation_code'] = 'Activation Code';
+$lang['user_submit_activate'] = 'Activate Account';
+$lang['user_legend_resend_activation'] = 'Resend the activation code';
+$lang['user_instruction_resend_activation'] = 'The <em>activation e-mail</em> can take up to a few minutes until it arrives in your inbox, so please be patient. If you entered a wrong e-mail address, you can change it by entering another one in the field below. Pressing <em>Resend</em> will cause us to retransmit you the <em>activation e-mail</em> on the address entered in this field.';
+$lang['user_submit_resend_activation'] = 'Resend Activation E-mail';
+$lang['user_msg_activated_account'] = 'Your account is active so you can <a href="%s">login</a>. You successfully validated your e-mail address through the <em>activation e-mail</em>.';
+
$lang['user_no_videos_uploaded'] = 'The user uploaded no videos.';
$lang['user_role_standard'] = 'Standard User';
* id, if it is string it is used as an username.
*
* @param mixed $user
+ * @param string $table_cols (optional) string with comma separated
+ * `users` table column names. Use a.activation_code to check user's
+ * account activation_code. If this value is NULL than the account is
+ * active.
+ * @return array associative array with userdata from DB
*/
- public function get_userdata($user)
+ public function get_userdata($user, $table_cols = '*')
{
if (is_int($user))
$cond = "id = $user";
else
$cond = "username = '$user'";
- $query = $this->db->query("SELECT * from `users`
+ $query = $this->db->query("SELECT $table_cols
+ FROM `users` u LEFT JOIN `users_unactivated` a
+ ON (u.id = a.user_id)
WHERE $cond");
if ($query->num_rows() === 0)
* <li>id, name, title, duration, thumbs_count, default_thumb, views => from DB</li>
* <li>shorted_title => ellipsized title</li>
* <li>video_url => P2P-Tube video URl</li>
- * <li>TODO: user_id, user_name</li>
+ * <li>user_id, user_name</li>
* <li>thumbs => thumbnail images' URLs</li>
* </ul>
*/
* video asset having keys: "src", "res", "par" and "ext". Value of key
* "src" is the video torrent formated as
* {name}_{format}.{video_ext}.{default_torrent_ext}</li>
- * <li>user_name => TODO: user name from `users` table</li>
+ * <li>username => user name from `users` table</li>
* <li>category_title => a human-friendly category name</li>
* <li>tags => associative list of "tag => score"</li>
* <li>date => date and time when the video was created</li>
{
$this->load->helper('video');
- $query = $this->db->query('SELECT *
- FROM `videos`
- WHERE id = ?', $id);
+ $query = $this->db->query("SELECT v.*, u.username
+ FROM `videos` v, `users` u
+ WHERE v.user_id = u.id AND v.id = $id");
$video = array();
if ($query->num_rows() > 0)
// Thumbnails
$video['thumbs'] = $this->get_thumbs($video['name'], $video['thumbs_count']);
- // TODO: user information
- $video['user_name'] = 'TODO';
-
return $video;
}
</li>
<?php else: ?>
- <li class="menu-right"><a href="<?php echo site_url('user/register/'. urlencode_segments(uri_string(), 'user/register')) ?>"
+ <li class="menu-right"><a href="<?php echo site_url('user/register') ?>"
<?php echo ($selected_menu == 'register' ? 'class="selected"' : '') ?>><?php echo $this->lang->line('ui_nav_menu_register') ?></a>
</li>
--- /dev/null
+<?php echo form_open("user/activate/$user_id/code") ?>
+<fieldset>
+<legend><?php echo $this->lang->line('user_legend_activation') ?></legend>
+
+<p><?php echo $this->lang->line('user_instruction_activation') ?></p>
+
+<input type="hidden" name="user-id" value="<?php echo $user_id ?>" />
+
+<label for="activation-code" class="strong"><?php echo $this->lang->line('user_activation_code') ?>:</label>
+<input type="text" name="activation-code" id="activation-code" value="<?php echo set_value('activation-code') ?>" size="24" />
+
+<input type="submit" value="<?php echo $this->lang->line('user_submit_activate') ?>" />
+
+<p><?php echo form_error('activation-code') ?></p>
+</fieldset>
+</form>
+
+<?php echo form_open("user/activate/$user_id/resend") ?>
+<fieldset>
+<legend><?php echo $this->lang->line('user_legend_resend_activation') ?></legend>
+
+<p><?php echo $this->lang->line('user_instruction_resend_activation') ?></p>
+
+<input type="hidden" name="user-id" value="<?php echo $user_id ?>" />
+
+<label for="email" class="strong"><?php echo $this->lang->line('user_email') ?>:</label>
+<input type="text" name="email" id="email" value="<?php echo set_value('email', $email) ?>" size="24" />
+
+<input type="submit" value="<?php echo $this->lang->line('user_submit_resend_activation') ?>" />
+
+<p><?php echo form_error('email') ?></p>
+</fieldset>
+</form>
\ No newline at end of file
--- /dev/null
+<p><?php echo sprintf($this->lang->line('user_msg_activated_account'),
+ site_url('user/login')) ?></p>
\ No newline at end of file
+<!-- OBSOLETE -->
+
<video controls="controls" width="800" height="600" preload="auto">
<source src="<?php echo $url ?>" type="video/ogg" />
Error: Your browser does not support HTML5 or the video format!
+<!-- OBSOLETE -->
+
<div id="vlc_container">No VLC</div>
<table id="nsTable">
<tr><td id="nsPlaybackCell"><input type=button value="Play" onClick="play();" />
<div id="video-info" style="clear: both">
<div id="video-upload-info">
<?php echo $this->lang->line('ui_uploaded_by') ?>
- <span id="video-date"><?php echo $video['user_name'] ?></span>
+ <span id="video-date"><a href="<?php echo site_url("user/profile/{$video['username']}") ?>"><?php echo $video['username'] ?></a></span>
<?php echo $this->lang->line('ui_on_date') ?>
<span id="video-date"><?php echo $video['date'] ?></span>
</div>
vertical-align: top;
}
+fieldset
+{
+ margin-bottom: 1em;
+}
+
+label.strong
+{
+ font-weight: bold;
+}
+
.error
{
color: red;