/**
  * Reads the submitted data from the password assistance form.
  * The following form fields are read as HTTP POST parameters:
  * username
  * email
  * If the submitted username and email address matches an entry in the user data
  * table, then ILIAS creates a password assistance session for the user, and
  * sends a password assistance mail to the email address.
  * For details about the creation of the session and the e-mail see function
  * sendPasswordAssistanceMail().
  */
 public function submitAssistanceForm()
 {
     $form = $this->getAssistanceForm();
     if (!$form->checkInput()) {
         $form->setValuesByPost();
         $this->showAssistanceForm($form);
         return;
     }
     $username = $form->getInput('username');
     $email = $form->getInput('email');
     $userObj = null;
     $userid = ilObjUser::getUserIdByLogin($username);
     $txt_key = 'pwassist_invalid_username_or_email';
     if ($userid != 0) {
         $userObj = new ilObjUser($userid);
         if (strcasecmp($userObj->getEmail(), $email) != 0) {
             $userObj = null;
         } elseif (!strlen($email)) {
             $userObj = null;
             $txt_key = 'pwassist_no_email_found';
         } else {
             if ($userObj->getAuthMode(true) != AUTH_LOCAL || $userObj->getAuthMode(true) == AUTH_DEFAULT && AUTH_DEFAULT != AUTH_LOCAL) {
                 $userObj = null;
                 $txt_key = 'pwassist_invalid_auth_mode';
             }
         }
     }
     // No matching user object found?
     // Show the password assistance form again, and display an error message.
     if ($userObj == null) {
         ilUtil::sendFailure(str_replace("\\n", '', $this->lng->txt($txt_key)));
         $form->setValuesByPost();
         $this->showAssistanceForm($form);
     } else {
         // Matching user object found?
         // Check if the user is permitted to use the password assistance function,
         // and then send a password assistance mail to the email address.
         // FIXME: Extend this if-statement to check whether the user
         // has the permission to use the password assistance function.
         // The anonymous user and users who are system administrators are
         // not allowed to use this feature
         if ($this->rbacreview->isAssigned($userObj->getId, ANONYMOUS_ROLE_ID) || $this->rbacreview->isAssigned($userObj->getId, SYSTEM_ROLE_ID)) {
             ilUtil::sendFailure(str_replace("\\n", '', $this->lng->txt('pwassist_not_permitted')));
             $form->setValuesByPost();
             $this->showAssistanceForm($form);
         } else {
             $this->sendPasswordAssistanceMail($userObj);
             $this->showMessageForm(sprintf($this->lng->txt('pwassist_mail_sent'), $email));
         }
     }
 }