66        $this->ctrl = 
$DIC->ctrl();
 
   67        $this->lng = 
$DIC->language();
 
   68        $this->rbacreview = 
$DIC->rbac()->review();
 
   69        $this->tpl = 
$DIC->ui()->mainTemplate();
 
   71        $this->
ilias = $DIC[
'ilias'];
 
   72        $this->ilErr = 
$DIC[
'ilErr'];
 
   73        $this->
help = $DIC->help();
 
   74        $this->actor = 
$DIC->user();
 
   76        $this->
help->setScreenIdComponent(
'init');
 
   85        if (!$this->
settings->get(
'setup_ok')) {
 
   86            $this->ilErr->raiseError(
'Setup is not completed. Please run setup routine again.', $this->ilErr->FATAL);
 
   89        if (!$this->
settings->get(
'password_assistance')) {
 
   90            $this->ilErr->raiseError($this->lng->txt(
'permission_denied'), $this->ilErr->MESSAGE);
 
   93        if ($this->actor->getId() > 0 && !$this->actor->isAnonymous()) {
 
   94            $this->ilErr->raiseError($this->lng->txt(
'permission_denied'), $this->ilErr->MESSAGE);
 
  100        if (
$lang != 
null && 
$lang != 
'' && $this->lng->getLangKey() != 
$lang) {
 
  103        $this->lng->loadLanguageModule(
'pwassist');
 
  105        $cmd = $this->ctrl->getCmd();
 
  106        $next_class = $this->ctrl->getNextClass($this);
 
  108        switch ($next_class) {
 
  110                if ($cmd != 
'' && method_exists($this, $cmd)) {
 
  111                    return $this->$cmd();
 
  113                    if (!empty(
$_GET[
'key'])) {
 
  129        return rtrim(ILIAS_HTTP_PATH, 
'/');
 
  137    protected function buildUrl(
string $script, array $queryParameters) : string
 
  139        $url = implode(
'/', [
 
  146            http_build_query($queryParameters, 
null, 
'&')
 
  157        require_once 
'Services/Form/classes/class.ilPropertyFormGUI.php';
 
  160        $form->setFormAction($this->ctrl->getFormAction($this, 
'submitAssistanceForm'));
 
  161        $form->setTarget(
'_parent');
 
  163        $username = 
new ilTextInputGUI($this->lng->txt(
'username'), 
'username');
 
  164        $username->setRequired(
true);
 
  165        $form->addItem($username);
 
  168        $email->setRequired(
true);
 
  171        $form->addCommandButton(
'submitAssistanceForm', $this->lng->txt(
'submit'));
 
  181        $this->
help->setSubScreenId(
'password_assistance');
 
  183        $tpl = ilStartUpGUI::initStartUpTemplate(
'tpl.pwassist_assistance.html', 
true);
 
  185        $tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'password_assistance'));
 
  188            'TXT_ENTER_USERNAME_AND_EMAIL',
 
  193                    $this->lng->txt(
'pwassist_enter_username_and_email'),
 
  202        $tpl->setVariable(
'FORM', $form->getHTML());
 
  221        if (!$form->checkInput()) {
 
  222            $form->setValuesByPost();
 
  227        $username = $form->getInput(
'username');
 
  228        $email = trim($form->getInput(
'email'));
 
  231        if (!is_numeric($usrId) || !($usrId > 0)) {
 
  233                'Could not process password assistance form (reason: no user found) %s / %s',
 
  239                sprintf($this->lng->txt(
'pwassist_mail_sent'), 
$email),
 
  240                self::PERMANENT_LINK_TARGET_PW
 
  246        if (
$GLOBALS[
'DIC'][
'ilSetting']->
get(
'auth_mode')) {
 
  247            $defaultAuth = 
$GLOBALS[
'DIC'][
'ilSetting']->get(
'auth_mode');
 
  250        $user = new \ilObjUser($usrId);
 
  251        $emailAddresses = array_map(
'strtolower', [$user->getEmail(), $user->getSecondEmail()]);
 
  253        if (!in_array(strtolower(
$email), $emailAddresses)) {
 
  254            if (0 === strlen(implode(
'', $emailAddresses))) {
 
  256                    'Could not process password assistance form (reason: account without email addresses): %s / %s',
 
  262                    'Could not process password assistance form (reason: account email addresses differ from input): %s / %s',
 
  270                ($user->getAuthMode(
true) == $defaultAuth && $defaultAuth != 
AUTH_LOCAL)
 
  276                'Could not process password assistance form (reason: not permitted for accounts using external authentication sources): %s / %s',
 
  285                'Could not process password assistance form (reason: not permitted for system user or anonymous): %s / %s',
 
  290            $this->sendPasswordAssistanceMail($user);
 
  294            sprintf($this->lng->txt(
'pwassist_mail_sent'), 
$email),
 
  295            self::PERMANENT_LINK_TARGET_PW
 
  310    public function sendPasswordAssistanceMail(
ilObjUser $userObj)
 
  314        require_once 
'include/inc.pwassist_session_handler.php';
 
  319            !is_array($pwassist_session) ||
 
  320            count($pwassist_session) == 0 ||
 
  321            $pwassist_session[
'expires'] < time() ||
 
  331                $pwassist_session[
'pwassist_id'],
 
  340                'client_id' => $this->
ilias->getClientId(),
 
  341                'lang' => $this->lng->getLangKey(),
 
  342                'key' => $pwassist_session[
'pwassist_id']
 
  346        $alternative_pwassist_url = $this->
buildUrl(
 
  349                'client_id' => $this->
ilias->getClientId(),
 
  350                'lang' => $this->lng->getLangKey(),
 
  351                'key' => $pwassist_session[
'pwassist_id']
 
  356        $senderFactory = 
$DIC[
"mail.mime.sender.factory"];
 
  357        $sender = $senderFactory->system();
 
  360        $mm->Subject($this->lng->txt(
'pwassist_mail_subject'), 
true);
 
  368                    $this->lng->txt(
'pwassist_mail_body'),
 
  370                    $this->getBaseUrl() . 
'/',
 
  373                    'mailto:' . 
$DIC->settings()->get(
"admin_email"),
 
  374                    $alternative_pwassist_url
 
  387        require_once 
'Services/Form/classes/class.ilPropertyFormGUI.php';
 
  390        $form->setFormAction($this->ctrl->getFormAction($this, 
'submitAssignPasswordForm'));
 
  391        $form->setTarget(
'_parent');
 
  393        $username = 
new ilTextInputGUI($this->lng->txt(
'username'), 
'username');
 
  394        $username->setRequired(
true);
 
  395        $form->addItem($username);
 
  404        $key->setValue($pwassist_id);
 
  405        $form->addItem($key);
 
  407        $form->addCommandButton(
'submitAssignPasswordForm', $this->lng->txt(
'submit'));
 
  426        require_once 
'include/inc.pwassist_session_handler.php';
 
  427        require_once 
'Services/Language/classes/class.ilLanguage.php';
 
  429        $this->
help->setSubScreenId(
'password_input');
 
  433            $pwassist_id = 
$_GET[
'key'];
 
  439            !is_array($pwassist_session) ||
 
  440            count($pwassist_session) == 0 ||
 
  441            $pwassist_session[
'expires'] < time()
 
  446            $tpl = ilStartUpGUI::initStartUpTemplate(
'tpl.pwassist_assignpassword.html', 
true);
 
  448            $tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'password_assistance'));
 
  450            $tpl->setVariable(
'TXT_ENTER_USERNAME_AND_NEW_PASSWORD', $this->lng->txt(
'pwassist_enter_username_and_new_password'));
 
  455            $tpl->setVariable(
'FORM', $form->getHTML());
 
  479        require_once 
'include/inc.pwassist_session_handler.php';
 
  485        if (!$form->checkInput()) {
 
  486            $form->setValuesByPost();
 
  491        $username = $form->getInput(
'username');
 
  493        $pwassist_id = $form->getInput(
'key');
 
  499            !is_array($pwassist_session) ||
 
  500            count($pwassist_session) == 0 ||
 
  501            $pwassist_session[
'expires'] < time()
 
  504            $form->setValuesByPost();
 
  508            $is_successful = 
true;
 
  512            if (!$userObj || !($userObj instanceof \
ilObjUser)) {
 
  513                $message = $this->lng->txt(
'user_does_not_exist');
 
  514                $is_successful = 
false;
 
  519            if ($is_successful && strcasecmp($userObj->
getLogin(), $username) != 0) {
 
  520                $message = $this->lng->txt(
'pwassist_login_not_match');
 
  521                $is_successful = 
false;
 
  526                $message = $this->lng->txt($error_lng_var);
 
  527                $is_successful = 
false;
 
  534            if ($is_successful) {
 
  536                if (!$is_successful) {
 
  537                    $message = $this->lng->txt(
'passwd_invalid');
 
  543            if ($is_successful) {
 
  552            if ($is_successful) {
 
  555                    sprintf($this->lng->txt(
'pwassist_password_assigned'), $username),
 
  556                    self::PERMANENT_LINK_TARGET_PW
 
  560                $form->setValuesByPost();
 
  571        require_once 
'Services/Form/classes/class.ilPropertyFormGUI.php';
 
  574        $form->setFormAction($this->ctrl->getFormAction($this, 
'submitUsernameAssistanceForm'));
 
  575        $form->setTarget(
'_parent');
 
  578        $email->setRequired(
true);
 
  581        $form->addCommandButton(
'submitUsernameAssistanceForm', $this->lng->txt(
'submit'));
 
  598        $this->
help->setSubScreenId(
'username_assistance');
 
  600        $tpl = ilStartUpGUI::initStartUpTemplate(
'tpl.pwassist_username_assistance.html', 
true);
 
  602        $tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'password_assistance'));
 
  605            'TXT_ENTER_USERNAME_AND_EMAIL',
 
  610                    $this->lng->txt(
'pwassist_enter_email'),
 
  619        $tpl->setVariable(
'FORM', $form->getHTML());
 
  637        require_once 
'Services/User/classes/class.ilObjUser.php';
 
  638        require_once 
'Services/Utilities/classes/class.ilUtil.php';
 
  641        if (!$form->checkInput()) {
 
  642            $form->setValuesByPost();
 
  648        $email = trim($form->getInput(
'email'));
 
  651        if (is_array($logins) && count($logins) > 0) {
 
  652            $this->sendUsernameAssistanceMail(
$email, $logins);
 
  655                'Could not sent username assistance emails to (reason: no user found): %s',
 
  661            $this->lng->txt(
'pwassist_mail_sent_generic'),
 
  662            self::PERMANENT_LINK_TARGET_NAME
 
  678    public function sendUsernameAssistanceMail(
$email, array $logins)
 
  682        require_once 
'Services/Mail/classes/class.ilMailbox.php';
 
  683        require_once 
'Services/Mail/classes/class.ilMail.php';
 
  684        require_once 
'Services/Mail/classes/class.ilMimeMail.php';
 
  685        require_once 
'include/inc.pwassist_session_handler.php';
 
  690                'client_id' => $this->
ilias->getClientId(),
 
  691                'lang' => $this->lng->getLangKey()
 
  696        $senderFactory = 
$DIC[
"mail.mime.sender.factory"];
 
  697        $sender = $senderFactory->system();
 
  700        $mm->Subject($this->lng->txt(
'pwassist_mail_subject'), 
true);
 
  708                    $this->lng->txt(
'pwassist_username_mail_body'),
 
  709                    join(
",\n", $logins),
 
  713                    'mailto:' . $DIC->settings()->get(
"admin_email"),
 
  727        $tpl = ilStartUpGUI::initStartUpTemplate(
'tpl.pwassist_message.html', 
true);
 
  728        $tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'password_assistance'));
 
  731        $tpl->setVariable(
'TXT_TEXT', str_replace(
"\\n", 
'<br />', $text));
 
  741        $this->tpl->setPermanentLink(
'usr', 
null, 
$context);
 
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
An exception for terminatinating execution or to throw for unit testing.
static getLogger($a_component_id)
Get component logger.
static getUserIdByLogin($a_login)
getEmail()
get email address @access public
getLogin()
get login / username @access public
setLastPasswordChangeToNow()
static getUserLoginsByEmail($a_email)
get all user login names of an email address
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
update()
update object in db
getId()
get object id @access public
Password assistance facility for users who have forgotten their password or for users for whom no pas...
showAssistanceForm(ilPropertyFormGUI $form=null)
const PERMANENT_LINK_TARGET_PW
submitUsernameAssistanceForm()
Reads the submitted data from the password assistance form.
showUsernameAssistanceForm(ilPropertyFormGUI $form=null)
Shows the password assistance form.
submitAssistanceForm()
Reads the submitted data from the password assistance form.
buildUrl(string $script, array $queryParameters)
getBaseUrl()
Returns the ILIAS http path without a trailing /.
fillPermanentLink($context)
getAssignPasswordForm($pwassist_id)
getUsernameAssistanceForm()
showAssignPasswordForm(ilPropertyFormGUI $form=null, $pwassist_id='')
Assign password form.
showMessageForm($text, string $permanent_link_context)
This form is used to show a message to the user.
submitAssignPasswordForm()
Reads the submitted data from the password assistance form.
const PERMANENT_LINK_TARGET_NAME
static printToGlobalTemplate($tpl)
This class represents a text property in a property form.
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static isPasswordValidForUserContext($clear_text_password, $user, &$error_language_variable=null)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
db_pwassist_session_destroy($pwassist_id)
destroy session
db_pwassist_session_find($user_id)
db_pwassist_session_write($pwassist_id, $maxlifetime, $user_id)
Writes serialized session data to the database.
db_pwassist_session_read($pwassist_id)
redirection script todo: (a better solution should control the processing via a xml file)