Exemplo n.º 1
0
 /**
  * Perform the main actions of the page.
  * @global array Get the home page from the global configuration
  */
 protected function action()
 {
     parent::action();
     if ($this->user->logged_in()) {
         $this->setRedirect('home');
         return;
     }
     $access = I2CE::getUserAccess();
     $has_email = $access instanceof I2CE_UserAccess_Mechanism && $access->canChangePassword() && I2CE_User::hasDetail('email');
     $this->template->setBodyId("loginPage");
     $this->template->setDisplayDataImmediate('has_email', $has_email);
     if (!$this->isPost() || !$has_email) {
         return;
     }
     if ($this->post('submit') == "Reset") {
         if (I2CE_Validate::checkString($this->post('username')) && I2CE_User::userExists($this->post('username'), true)) {
             $user = new I2CE_User($this->post('username'), true, false, true);
             $email = $user->email;
             $valid_email = I2CE_Validate::checkEmail($email);
             $pass = trim(I2CE_User::generatePassword());
             if ($user->getRole() != 'guest' && $valid_email && $pass && $user->setPassword($pass)) {
                 if ($this->mailPassword($email, $this->post('username'), $pass)) {
                     $this->template->addTextNode("error_message", "Your password has been reset and mailed to you.");
                 } else {
                     $this->template->addTextNode("error_message", "Your password has been reset, but could not mailed to you. Please contact your system administrator");
                 }
             } else {
                 $this->template->addTextNode("error_message", "Your password could not be reset.  Please contact your system administrator to change your password.");
             }
         } else {
             $this->template->addTextNode("error_message", "Your username could not be found in the database.  Please contact your System Administrator.");
         }
     } elseif ($this->post('submit') == "View") {
         $usernames = I2CE_User::findUsersByInfo(false, array('email' => $this->post('email')));
         if (is_array($usernames) && count($usernames) == 1) {
             reset($usernames);
             $this->template->addText('<p id="error_message">Your username is: <b>' . current($usernames) . '</b><br />Enter it below to reset your password or return to the login page to login.</p>', 'p');
         } else {
             $this->template->addTextNode("error_message", "That email address was not found in the system.  Please contact your System Administrator.");
         }
     } else {
         $this->template->addTextNode("error_message", "Please click one of the submit buttons or only enter one text field.");
     }
 }
Exemplo n.º 2
0
 /**
  * Perform the main actions of the page.
  * @global array
  */
 protected function action()
 {
     $i2ce_config = I2CE::getConfig()->I2CE;
     parent::action();
     $fields = array("Name" => false, "Company" => false, "Title" => false, "Industry" => false, "Address" => false, "City" => false, "State" => false, "Postal_Code" => false, "Country" => false, "Telephone" => false, "Fax" => false, "Email" => false, "Comments" => false, "referer" => false);
     $valid = true;
     $err_msg = "";
     if ($this->isPost()) {
         $message = "";
         foreach ($fields as $name => $required) {
             if ($required && !I2CE_Validate::checkString($this->post($name))) {
                 $valid = false;
                 $err_msg .= "<li>{$name} is blank.</li>\n";
             }
             $message .= $name . ": " . $this->post($name) . "\n";
         }
         $message .= "Username : "******"\n";
         $message .= "User Role : " . $this->user->getRole() . "\n";
         if ($valid) {
             $this->template->addFile("feedback_thanks.html");
             $this->template->setDisplayData("return_link", 'home');
             I2CE_Mailer::mail($i2ce_config->feedback->to, array('Subject' => $i2ce_config->feedback->subject, 'From' => $this->post('Email')), $message);
             return;
         }
     }
     $this->template->addFile("feedback_form.html");
     if (array_key_exists('contact_address', $this->args) && $this->args['contact_address']) {
         if (($formNode = $this->template->getElementById('feedback_form')) instanceof DOMElement) {
             $formNode->setAttribute('action', 'mailto:' . $this->args['contact_address'] . '?Subject=iHRIS Feedback');
             $formNode->setAttribute('enctype', 'text/plain');
         }
     }
     if (!$valid && $err_msg != "") {
         $this->template->addText('<div id="error">There were some problems with your information:<ul>' . $err_msg . '</ul></div>');
     }
     if ($this->isPost()) {
         foreach ($fields as $name => $required) {
             if ($name == "Comments") {
                 $this->template->addText('<textarea name="Comments" rows="10" cols="45" id="Comments">' . $this->post($name) . '</textarea>', "textarea", $name);
             } else {
                 $this->template->setAttribute("value", $this->post($name), $name, ".");
             }
         }
     } else {
         $this->template->setAttribute("value", $_SERVER['HTTP_REFERER'], "referer", ".");
         if (!array_key_exists('auto_populate', $this->args) || $this->args['auto_populate']) {
             //defaults to true
             foreach (array('email' => 'Email', 'phone' => 'Phone', 'fax' => 'Fax') as $detail => $data) {
                 if (I2CE_User::hasDetail($detail)) {
                     $this->template->setDisplayDataImmediate($data, $this->user->{$detail});
                 }
             }
             $this->template->setDisplayDataImmediate('Name', $this->user->displayName());
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Try to generate a new password and assign it to the password and confirm variables.
  */
 public function tryGeneratePassword()
 {
     if (!I2CE_User::hasDetail('email')) {
         return false;
     }
     if (!I2CE_Validate::checkEmail($this->email)) {
         return false;
     }
     if ($this->generate_password) {
         $pass = I2CE_User::generatePassword();
         $this->__set('password', $pass);
         $this->__set('confirm', $pass);
     }
     return true;
 }
Exemplo n.º 4
0
 /**
  * Save the objects to the database.
  * 
  * Save the default object being edited and return to the view page.
  */
 protected function save()
 {
     if ($this->creatingNewUser()) {
         if (!$this->hasPermission('task(users_can_edit)')) {
             return false;
         }
         if (!$this->userObj instanceof I2CE_User_Form || !($username = $this->userObj->username)) {
             return false;
         }
         $accessMech = I2CE::getUserAccess();
         if ($accessMech->userExists($username, false)) {
             I2CE::raiseError("Trying to recreate existing user : " . $username);
             return false;
         }
         if (I2CE_User::hasDetail('creator')) {
             $this->userObj->creator = $this->user->username;
         }
     }
     return parent::save();
 }
Exemplo n.º 5
0
 /**
  * Perform the actions of the page.
  */
 protected function action()
 {
     if (!$this->isPost() && !$this->get_exists('username') && !$this->get_exists('add')) {
         if ($this->hasPermission('task(users_can_edit_all)')) {
             $this->template->addFile("user_list.html");
             $this->listUsersToEdit('user_list');
         } else {
             if ($this->hasPermission('task(users_can_edit)') && I2CE_User::hasDetail('creator')) {
                 $this->template->addFile("user_list.html");
                 $this->listUsersToEdit('user_list', $this->user->username);
             } else {
                 $this->userMessage("You can not edit users", 'notice', false);
                 return false;
             }
         }
     } else {
         parent::action();
     }
 }