Exemple #1
0
 public function send($userID = NULL, $email = NULL)
 {
     $session_user = new User_model();
     if (!$session_user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) {
         redirect('Login/logout');
     }
     if (!$session_user->isAdvisor()) {
         redirect('Login/logout');
     }
     $this->load->library('email');
     $user = new User_model();
     $user->loadPropertiesFromPrimaryKey($userID);
     if ($user->getAdvisor()->getUserID() != $session_user->getUserID()) {
         redirect('Login/logout');
     }
     //Loads user's email if optional email wasn't set
     if ($email == NULL) {
         $email = $user->getEmailAddress();
     }
     //Array of characters to generate password
     $charset = array('!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '~', '=', '+', '_', '-', '?', '/', '>', '<', '.', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'w', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'W', 'Z');
     //Generate random password
     $passlen = mt_rand(8, 12);
     $pass = NULL;
     for ($i = 0; $i < $passlen; $i++) {
         $pass = $pass . $charset[mt_rand(0, count($charset) - 1)];
     }
     //Set user password
     //Email user their login information
     $this->email->from('*****@*****.**', 'Admin Name');
     $this->email->to('*****@*****.**');
     $this->email->subject('Subject');
     $this->email->message('Password: '******'Username: '******'headers', 'subject', 'body'));
     $user->setPassword($pass);
     //Email user their login information
     $this->load->library('email');
     $config['protocol'] = 'smtp';
     $config['smpt_crypt'] = 'ssl';
     $config['smtp_host'] = 'ssl://smtp.gmail.com';
     $config['smtp_port'] = '465';
     $config['smtp_user'] = '******';
     $config['smtp_pass'] = '******';
     $config['mailtype'] = 'html';
     $config['charset'] = 'utf-8';
     $config['newline'] = "\r\n";
     $config['validate'] = FALSE;
     $config['bcc_batch_mode'] = FALSE;
     $config['bcc_batch_size'] = 200;
     $this->email->initialize($config);
     $this->email->from('*****@*****.**', 'Senior');
     $list = array('*****@*****.**');
     $this->email->to($list);
     $this->email->reply_to('*****@*****.**', 'Senior');
     $this->email->subject('Subject');
     $this->email->message('Email works great!');
     if ($user->update() && $this->email->send()) {
         $_SESSION['activation.message'] = "Success!";
     } else {
         $_SESSION['activation.error'] = "Sending email failed!<br />" . $this->email->print_debugger();
     }
     redirect('Activation/index');
 }
Exemple #2
0
 /**
  * @param type $uID Identifies which user data to load.
  * @return Returns Filled userData if user is loaded successfully.
  */
 private function loadUserData($uID)
 {
     $userData = array('uID' => $uID, 'email' => NULL, 'fName' => NULL, 'mName' => NULL, 'lName' => NULL, 'roles' => array(NULL, False, False, False, False));
     $user = new User_model();
     $isLoaded = $user->loadPropertiesFromPrimaryKey($uID);
     if ($isLoaded) {
         $userData['email'] = $user->getEmailAddress();
         $userData = $this->loadUserName($userData, $user->getName());
         $userData['roles'] = $this->loadUserRoles($user);
         $userData['user'] = $user;
     }
     return $userData;
 }