public function unique_app_scanner_name($str, $id){
$this->load->library('form_validation');
$uniqueNameCheck = $this->db->query('SELECT * FROM `app_scanners` WHERE `Username` = "'. $str .'" AND `id` NOT IN ('. $id .')');
if($uniqueNameCheck->num_rows() > 0){
$this->form_validation->set_message('unique_app_scanner_name', $this->lang->line('in_use'));
return FALSE;
}else{
return TRUE;
}
}
public function edit_app_scanner_validate($id){
if($this->is_logged_in()){
if(!empty($id)){
$appScannerCheck = $this->db->query('SELECT * FROM `app_scanners` WHERE `id` = "'.$id.'" AND `UserId` = "'.$this->get_user_id().'" ');
if($appScannerCheck->num_rows() > 0){
$appScannerResult = $appScannerCheck->result_array();
$this->load->library('form_validation');
$this->form_validation->set_rules('firstName', $this->lang->line('firstName'), 'required|trim|xss_clean');
$this->form_validation->set_rules('lastName', $this->lang->line('lastName'), 'required|trim|xss_clean');
$this->form_validation->set_rules('username', $this->lang->line('username'), 'required|trim|xss_clean|callback_unique_app_scanner_name['.$id.']');
$this->form_validation->set_rules('password', $this->lang->line('password'), 'trim');
$this->form_validation->set_rules('cPassword', $this->lang->line('repeat_password'), 'trim|matches[password]');
if($this->form_validation->run()){
$this->load->model('model_main');
$this->model_main->edit_app_scanner($id);
redirect("main/view_event/".$appScannerResult[0]['EventId']."/#tabs-3");
}else{
redirect("main/edit_app_scanner/".$id);
}
}else{
redirect("main/view_event/".$appScannerResult[0]['EventId']."/#tabs-3");
}
}else{
redirect(base_url());
}
}else{
redirect(base_url()."site/login");
}
}