mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Check Username for uniqueness b4 adding/editing
This commit is contained in:
@@ -151,6 +151,7 @@ class User extends CI_Controller {
|
||||
$this->load->library('Genfunctions');
|
||||
|
||||
$this->form_validation->set_rules('user_name', 'Username', 'required');
|
||||
$this->form_validation->set_rules('user_name', 'Username', 'required|callback_check_username');
|
||||
$this->form_validation->set_rules('user_email', 'E-mail', 'required');
|
||||
$this->form_validation->set_rules('user_password', 'Password', 'required');
|
||||
$this->form_validation->set_rules('user_type', 'Type', 'required');
|
||||
@@ -373,6 +374,7 @@ class User extends CI_Controller {
|
||||
$this->load->library('Genfunctions');
|
||||
|
||||
$this->form_validation->set_rules('user_name', 'Username', 'required|xss_clean');
|
||||
$this->form_validation->set_rules('user_name', 'Username', 'required|callback_check_username');
|
||||
$this->form_validation->set_rules('user_email', 'E-mail', 'required|xss_clean');
|
||||
if($this->session->userdata('user_type') == 99)
|
||||
{
|
||||
@@ -1446,6 +1448,15 @@ class User extends CI_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
function check_username($username) {
|
||||
if (($this->session->userdata('user_name') != $username) && ($this->user_model->exists($username) > 0)) {
|
||||
$this->form_validation->set_message('check_username', sprintf(__("Couldn't set account to this username. Please try another one than \"%s\"."), $username));
|
||||
return FALSE;
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
function check_email($mail) {
|
||||
if (($this->session->userdata('user_email') != $mail) && ($this->user_model->exists_by_email($mail) > 0)) {
|
||||
$this->form_validation->set_message('check_email', sprintf(__("Couldn't set account to this email. Please try another address than \"%s\"."), $mail));
|
||||
|
||||
Reference in New Issue
Block a user