示例#1
0
 function change_dets($id)
 {
     $this->is_user_allowed();
     $names = trim($this->input->get_post('c_person', TRUE));
     $userEmail = trim($this->input->get_post('email', TRUE));
     $phone = trim($this->input->get_post('phone', TRUE));
     $pass = genBigcode(8);
     //die();
     $filter = array('company_id' => $id);
     $dets = $this->c->get_details($filter);
     $old_email = trim($dets[0]->emailAddress);
     if ($old_email === trim($userEmail)) {
         $this->c->update_cperson($id);
         redirect('manageCompanies');
     } else {
         $filter = array('userEmail' => $old_email, 'company_id' => $id);
         $dets = $this->users->get_details($filter);
         $uid = trim($dets[0]->usersID);
         $url = base_url();
         $message = "Dear {$names},\r\nYou changed your login credentials. The new details are:\r\n Username: {$userEmail}\r\n  Password: {$pass}\r\nPlease click on the link bellow to access your account: {$url}.\r\n\r\nThis email was atomaticaly generated by the system";
         //		echo $message;
         //		die();
         $this->email->set_newline("\r\n");
         $this->email->from($this->forwardemail, $this->nicename);
         $this->email->subject('Changed login credentials.');
         $this->email->message($message);
         $this->email->to($userEmail);
         if (!$this->email->send()) {
             $data = array('updt_msg' => "Could not update user account details. The email server is not responding. Please try again later or contact admin.");
             $this->session->set_userdata($data);
             redirect('manageCompanies');
         } else {
             $this->c->update_cperson($id);
             $details = array('usersFullnames' => $names, 'userName' => $userEmail, 'userEmail' => $userEmail, 'userPassword' => md5($pass));
             $this->users->activate($uid, $details);
             //print_r($details);
             $data = array('updt_msg' => "Company default user details updated. Login credentials sent to {$userEmail}.");
             $this->session->set_userdata($data);
             redirect('manageCompanies');
         }
     }
 }
示例#2
0
 function edit_user($id)
 {
     $this->is_user_allowed();
     $names = trim($this->input->get_post('names', TRUE));
     $uname = trim($this->input->get_post('uname', TRUE));
     $userEmail = trim($this->input->get_post('userEmail', TRUE));
     $rights = trim($this->input->get_post('rights', TRUE));
     $roles = 3;
     //trim($this->input->get_post('roles',TRUE));
     $pass = genBigcode(8);
     $filter = array('userEmail' => $userEmail, 'company_id' => $this->session->userdata('companyID'));
     // print_r($filter);
     //die();
     $count = count($this->users->get_details($filter));
     // print_r($this->users->get_details($filter));
     // die();
     $filter = array('usersID' => $id);
     $dets = $this->users->get_details($filter);
     foreach ($dets as $row) {
         $old_email = trim($row->userEmail);
         $old_pass = trim($row->userPassword);
     }
     if ($old_email === trim($userEmail)) {
         $this->users->update($old_pass, $id, "y");
         $updt_msg = array('updt_msg' => "User details succesfully updated.");
         $this->session->set_userdata($updt_msg);
         redirect('manageUsers');
     } else {
         if ($count == 0) {
             $url = base_url();
             $message = "Dear {$names},\r\nYou changed your email address....... Your Login credentials are:\r\n Username: {$uname}\r\n  Password: {$pass}\r\nPlease click on the link bellow to access your accoutnt:{$url}.\r\n\r\nThis email was atomaticaly generated by the system";
             $this->email->set_newline("\r\n");
             $this->email->from($this->forwardemail, $this->nicename);
             $this->email->subject('Changed login credentials.');
             $this->email->message($message);
             $this->email->to($userEmail);
             if (!$this->email->send()) {
                 $data = array('updt_msg' => "Could not update user account details. The email server is not responding. Please try again later or contact admin.");
                 $this->session->set_userdata($data);
                 // echo "server error";
                 // die();
                 redirect('manageUsers');
             } else {
                 $this->users->update($pass, $id, 'y');
                 $data = array('updt_msg' => "User details successfully updated and details sent to {$userEmail}. Changes will take effect in your next login session.");
                 $this->session->set_userdata($data);
                 redirect('manageUsers');
             }
         } else {
             $data = array('updt_msg' => "An account with the email adddress: {$userEmail} already exists in our database.");
             $this->session->set_userdata($data);
             redirect('manageUsers');
         }
     }
 }