52 public function __construct()
80 if(!$this->settings->get(
'password_assistance'))
84 $this->
ilias->error_obj->raiseError($this->lng->txt(
'permission_denied'), $this->
ilias->error_obj->WARNING);
89 if(!$this->settings->get(
'setup_ok'))
91 die(
'Setup is not completed. Please run setup routine again.');
101 $this->lng->loadLanguageModule(
'pwassist');
103 $cmd = $this->ctrl->getCmd();
104 $next_class = $this->ctrl->getNextClass($this);
111 return $this->
$cmd();
115 if(!empty(
$_GET[
'key']))
133 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
136 $form->setFormAction($this->ctrl->getFormAction($this,
'submitAssistanceForm'));
137 $form->setTarget(
'_parent');
139 $username =
new ilTextInputGUI($this->lng->txt(
'username'),
'username');
141 $form->addItem($username);
145 $form->addItem($email);
147 $form->addCommandButton(
'submitAssistanceForm', $this->lng->txt(
'submit'));
157 ilStartUpGUI::initStartUpTemplate(
'tpl.pwassist_assistance.html',
true);
159 $this->tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'password_assistance'));
161 $this->tpl->setVariable
163 'TXT_ENTER_USERNAME_AND_EMAIL',
169 $this->lng->txt(
'pwassist_enter_username_and_email'),
170 '<a href="mailto:' . $this->settings->get(
'admin_email') .
'">' . $this->settings->get(
'admin_email') .
'</a>' 179 $this->tpl->setVariable(
'FORM', $form->getHTML());
197 if(!$form->checkInput())
199 $form->setValuesByPost();
204 $username = $form->getInput(
'username');
205 $email = $form->getInput(
'email');
209 $txt_key =
'pwassist_invalid_username_or_email';
213 if(strcasecmp($userObj->getEmail(), $email) != 0)
217 elseif(!strlen($email))
220 $txt_key =
'pwassist_no_email_found';
224 ($userObj->getAuthMode(
true) == AUTH_DEFAULT && AUTH_DEFAULT !=
AUTH_LOCAL)
228 $txt_key =
'pwassist_invalid_auth_mode';
237 $form->setValuesByPost();
250 $this->rbacreview->isAssigned($userObj->getId, ANONYMOUS_ROLE_ID) ||
251 $this->rbacreview->isAssigned($userObj->getId, SYSTEM_ROLE_ID)
255 $form->setValuesByPost();
261 $this->
showMessageForm(sprintf($this->lng->txt(
'pwassist_mail_sent'), $email));
279 require_once
'Services/Mail/classes/class.ilMailbox.php';
280 require_once
'Services/Mail/classes/class.ilMimeMail.php';
281 require_once
'include/inc.pwassist_session_handler.php';
286 count($pwassist_session) == 0 ||
287 $pwassist_session[
'expires'] < time() ||
298 $pwassist_session[
'pwassist_id'],
303 $protocol = $this->https->isDetected() ?
'https://' :
'http://';
305 $server_url = $protocol . $_SERVER[
'HTTP_HOST'] . substr($_SERVER[
'PHP_SELF'], 0, strrpos($_SERVER[
'PHP_SELF'],
'/')) .
'/';
310 $pwassist_url = $protocol . $_SERVER[
'HTTP_HOST']
311 . str_replace(
'ilias.php',
'pwassist.php', $_SERVER[
'PHP_SELF'])
312 .
'?client_id=' . $this->
ilias->getClientId()
313 . $delimiter .
'lang=' . $this->lng->getLangKey()
314 . $delimiter .
'key=' . $pwassist_session[
'pwassist_id'];
315 $alternative_pwassist_url = $protocol . $_SERVER[
'HTTP_HOST']
316 . str_replace(
'ilias.php',
'pwassist.php', $_SERVER[
'PHP_SELF'])
317 .
'?client_id=' . $this->
ilias->getClientId()
318 . $delimiter .
'lang=' . $this->lng->getLangKey()
319 . $delimiter .
'key=' . $pwassist_session[
'pwassist_id'];
321 $contact_address = $this->settings->get(
'admin_email');
324 $mm->Subject($this->lng->txt(
'pwassist_mail_subject'));
325 $mm->From($contact_address);
335 $this->lng->txt(
'pwassist_mail_body'),
338 $_SERVER[
'REMOTE_ADDR'],
340 'mailto:' . $contact_address,
341 $alternative_pwassist_url
354 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
357 $form->setFormAction($this->ctrl->getFormAction($this,
'submitAssignPasswordForm'));
358 $form->setTarget(
'_parent');
360 $username =
new ilTextInputGUI($this->lng->txt(
'username'),
'username');
362 $form->addItem($username);
366 $form->addItem($password);
369 $key->setValue($pwassist_id);
370 $form->addItem($key);
372 $form->addCommandButton(
'submitAssignPasswordForm', $this->lng->txt(
'submit'));
391 require_once
'include/inc.pwassist_session_handler.php';
392 require_once
'Services/Language/classes/class.ilLanguage.php';
397 $pwassist_id =
$_GET[
'key'];
403 count($pwassist_session) == 0 ||
404 $pwassist_session[
'expires'] < time()
411 ilStartUpGUI::initStartUpTemplate(
'tpl.pwassist_assignpassword.html',
true);
413 $this->tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'password_assistance'));
415 $this->tpl->setVariable(
'TXT_ENTER_USERNAME_AND_NEW_PASSWORD', $this->lng->txt(
'pwassist_enter_username_and_new_password'));
421 $this->tpl->setVariable(
'FORM', $form->getHTML());
445 require_once
'include/inc.pwassist_session_handler.php';
451 if(!$form->checkInput())
453 $form->setValuesByPost();
458 $username = $form->getInput(
'username');
459 $password = $form->getInput(
'password');
460 $pwassist_id = $form->getInput(
'key');
466 count($pwassist_session) == 0 ||
467 $pwassist_session[
'expires'] < time()
471 $form->setValuesByPost();
477 $is_successful =
true;
480 $userObj =
new ilObjUser($pwassist_session[
'user_id']);
483 $message = $this->lng->txt(
'user_does_not_exist');
484 $is_successful =
false;
489 if($is_successful && strcasecmp($userObj->getLogin(), $username) != 0)
491 $message = $this->lng->txt(
'pwassist_login_not_match');
492 $is_successful =
false;
498 $message = $this->lng->txt($error_lng_var);
499 $is_successful =
false;
508 $is_successful = $userObj->resetPassword($password, $password);
511 $message = $this->lng->txt(
'passwd_invalid');
529 $this->
showMessageForm(sprintf($this->lng->txt(
'pwassist_password_assigned'), $username));
534 $form->setValuesByPost();
545 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
548 $form->setFormAction($this->ctrl->getFormAction($this,
'submitUsernameAssistanceForm'));
549 $form->setTarget(
'_parent');
553 $form->addItem($email);
555 $form->addCommandButton(
'submitUsernameAssistanceForm', $this->lng->txt(
'submit'));
572 ilStartUpGUI::initStartUpTemplate(
'tpl.pwassist_username_assistance.html',
true);
574 $this->tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'password_assistance'));
576 $this->tpl->setVariable
578 'TXT_ENTER_USERNAME_AND_EMAIL',
584 $this->lng->txt(
'pwassist_enter_email'),
585 '<a href="mailto:' . $this->settings->get(
'admin_email') .
'">' . $this->settings->get(
'admin_email') .
'</a>' 594 $this->tpl->setVariable(
'FORM', $form->getHTML());
611 require_once
'Services/User/classes/class.ilObjUser.php';
612 require_once
'Services/Utilities/classes/class.ilUtil.php';
615 if(!$form->checkInput())
617 $form->setValuesByPost();
623 $email = $form->getInput(
'email');
630 if(!is_array($logins) || count($logins) < 1)
633 $form->setValuesByPost();
660 $this->
showMessageForm(sprintf($this->lng->txt(
'pwassist_mail_sent'), $email));
679 require_once
'Services/Mail/classes/class.ilMailbox.php';
680 require_once
'Services/Mail/classes/class.ilMimeMail.php';
681 require_once
'include/inc.pwassist_session_handler.php';
683 $protocol = $this->https->isDetected() ?
'https://' :
'http://';
685 $server_url = $protocol . $_SERVER[
'HTTP_HOST'] . substr($_SERVER[
'PHP_SELF'], 0, strrpos($_SERVER[
'PHP_SELF'],
'/')) .
'/';
686 $login_url = $server_url .
'pwassist.php' .
'?client_id=' . $this->
ilias->getClientId() .
'&lang=' . $this->lng->getLangKey();
687 $contact_address = $this->settings->get(
'admin_email');
690 $mm->Subject($this->lng->txt(
'pwassist_mail_subject'));
691 $mm->From($contact_address);
701 $this->lng->txt(
'pwassist_username_mail_body'),
702 join($logins,
",\n"),
704 $_SERVER[
'REMOTE_ADDR'],
706 'mailto:' . $contact_address,
720 ilStartUpGUI::initStartUpTemplate(
'tpl.pwassist_message.html',
true);
721 $this->tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'password_assistance'));
724 $this->tpl->setVariable(
'TXT_TEXT', str_replace(
"\\n",
'<br />', $text));
getAssignPasswordForm($pwassist_id)
getLogin()
get login / username public
db_pwassist_session_destroy($pwassist_id)
destroy session
sendPasswordAssistanceMail(ilObjUser $userObj)
Creates (or reuses) a password assistance session, and sends a password assistance mail to the specif...
db_pwassist_session_read($pwassist_id)
static isPasswordValidForUserContext($clear_text_password, $user, &$error_language_variable=null)
getUserIdByLogin($a_login)
showAssignPasswordForm(ilPropertyFormGUI $form=null, $pwassist_id='')
Assign password form.
getEmail()
get email address public
db_pwassist_session_find($user_id)
this class encapsulates the PHP mail() function.
getId()
get object id public
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
submitUsernameAssistanceForm()
Reads the submitted data from the password assistance form.
This class represents a text property in a property form.
redirection script todo: (a better solution should control the processing via a xml file) ...
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
showMessageForm($text)
This form is used to show a message to the user.
Password assistance facility for users who have forgotten their password or for users for whom no pas...
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
getUsernameAssistanceForm()
showAssistanceForm(ilPropertyFormGUI $form=null)
submitAssignPasswordForm()
Reads the submitted data from the password assistance form.
submitAssistanceForm()
Reads the submitted data from the password assistance form.
sendUsernameAssistanceMail($email, array $logins)
Creates (or reuses) a password assistance session, and sends a password assistance mail to the specif...
db_pwassist_session_write($pwassist_id, $maxlifetime, $user_id)
Writes serialized session data to the database.
showUsernameAssistanceForm(ilPropertyFormGUI $form=null)
Shows the password assistance form.
_getUserIdsByEmail($a_email)
STATIC METHOD get all user_ids of an email address.