57 $this->ctrl = $DIC->ctrl();
58 $this->lng = $DIC->language();
59 $this->rbacreview = $DIC->rbac()->review();
60 $this->tpl = $DIC->ui()->mainTemplate();
62 $this->
ilias = $DIC[
'ilias'];
63 $this->ilErr = $DIC[
'ilErr'];
72 if (!$this->
settings->get(
'password_assistance')) {
73 $this->ilErr->raiseError($this->lng->txt(
'permission_denied'), $this->ilErr->FATAL);
77 if (!$this->
settings->get(
'setup_ok')) {
78 $this->ilErr->raiseError(
'Setup is not completed. Please run setup routine again.', $this->ilErr->FATAL);
84 if (
$lang != null &&
$lang !=
'' && $this->lng->getLangKey() !=
$lang) {
87 $this->lng->loadLanguageModule(
'pwassist');
89 $cmd = $this->ctrl->getCmd();
90 $next_class = $this->ctrl->getNextClass($this);
92 switch ($next_class) {
94 if ($cmd !=
'' && method_exists($this, $cmd)) {
97 if (!empty(
$_GET[
'key'])) {
113 return rtrim(ILIAS_HTTP_PATH,
'/');
121 protected function buildUrl(
string $script, array $queryParameters) : string
123 $url = implode(
'/', [
130 http_build_query($queryParameters, null,
'&')
141 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
144 $form->setTitle($this->lng->txt(
'password_assistance'));
145 $form->setFormAction($this->ctrl->getFormAction($this,
'submitAssistanceForm'));
146 $form->setTarget(
'_parent');
148 $username =
new ilTextInputGUI($this->lng->txt(
'username'),
'username');
150 $form->addItem($username);
153 $email->setRequired(
true);
156 $form->addCommandButton(
'submitAssistanceForm', $this->lng->txt(
'submit'));
166 ilStartUpGUI::initStartUpTemplate(
'tpl.pwassist_assistance.html',
true);
168 $this->tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'password_assistance'));
170 $this->tpl->setVariable(
171 'TXT_ENTER_USERNAME_AND_EMAIL',
176 $this->lng->txt(
'pwassist_enter_username_and_email'),
185 $this->tpl->setVariable(
'FORM',
$form->getHTML());
204 if (!
$form->checkInput()) {
205 $form->setValuesByPost();
210 $username =
$form->getInput(
'username');
214 if (!is_numeric($usrId) || !($usrId > 0)) {
216 'Could not process password assistance form (reason: no user found) %s / %s',
226 if (
$GLOBALS[
'DIC'][
'ilSetting']->
get(
'auth_mode')) {
227 $defaultAuth =
$GLOBALS[
'DIC'][
'ilSetting']->get(
'auth_mode');
230 $user = new \ilObjUser($usrId);
231 $emailAddresses = array_map(
'strtolower', [
$user->getEmail(),
$user->getSecondEmail()]);
233 if (!in_array(strtolower(
$email), $emailAddresses)) {
234 if (0 === strlen(implode(
'', $emailAddresses))) {
236 'Could not process password assistance form (reason: account without email addresses): %s / %s',
242 'Could not process password assistance form (reason: account email addresses differ from input): %s / %s',
250 (
$user->getAuthMode(
true) == $defaultAuth && $defaultAuth !=
AUTH_LOCAL)
256 'Could not process password assistance form (reason: not permitted for accounts using external authentication sources): %s / %s',
261 $this->rbacreview->isAssigned(
$user->getId(), ANONYMOUS_ROLE_ID) ||
262 $this->rbacreview->isAssigned(
$user->getId(), SYSTEM_ROLE_ID)
265 'Could not process password assistance form (reason: not permitted for system user or anonymous): %s / %s',
270 $this->sendPasswordAssistanceMail(
$user);
287 public function sendPasswordAssistanceMail(
ilObjUser $userObj)
291 require_once
'include/inc.pwassist_session_handler.php';
296 !is_array($pwassist_session) ||
297 count($pwassist_session) == 0 ||
298 $pwassist_session[
'expires'] < time() ||
308 $pwassist_session[
'pwassist_id'],
317 'client_id' => $this->
ilias->getClientId(),
318 'lang' => $this->lng->getLangKey(),
319 'key' => $pwassist_session[
'pwassist_id']
323 $alternative_pwassist_url = $this->
buildUrl(
326 'client_id' => $this->
ilias->getClientId(),
327 'lang' => $this->lng->getLangKey(),
328 'key' => $pwassist_session[
'pwassist_id']
333 $senderFactory = $DIC[
"mail.mime.sender.factory"];
334 $sender = $senderFactory->system();
337 $mm->Subject($this->lng->txt(
'pwassist_mail_subject'),
true);
345 $this->lng->txt(
'pwassist_mail_body'),
350 'mailto:' . $DIC->settings()->get(
"admin_email"),
351 $alternative_pwassist_url
364 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
367 $form->setFormAction($this->ctrl->getFormAction($this,
'submitAssignPasswordForm'));
368 $form->setTarget(
'_parent');
370 $username =
new ilTextInputGUI($this->lng->txt(
'username'),
'username');
372 $form->addItem($username);
380 $key->setValue($pwassist_id);
383 $form->addCommandButton(
'submitAssignPasswordForm', $this->lng->txt(
'submit'));
402 require_once
'include/inc.pwassist_session_handler.php';
403 require_once
'Services/Language/classes/class.ilLanguage.php';
407 $pwassist_id =
$_GET[
'key'];
413 !is_array($pwassist_session) ||
414 count($pwassist_session) == 0 ||
415 $pwassist_session[
'expires'] < time()
420 ilStartUpGUI::initStartUpTemplate(
'tpl.pwassist_assignpassword.html',
true);
422 $this->tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'password_assistance'));
424 $this->tpl->setVariable(
'TXT_ENTER_USERNAME_AND_NEW_PASSWORD', $this->lng->txt(
'pwassist_enter_username_and_new_password'));
429 $this->tpl->setVariable(
'FORM',
$form->getHTML());
453 require_once
'include/inc.pwassist_session_handler.php';
459 if (!
$form->checkInput()) {
460 $form->setValuesByPost();
465 $username =
$form->getInput(
'username');
467 $pwassist_id =
$form->getInput(
'key');
473 !is_array($pwassist_session) ||
474 count($pwassist_session) == 0 ||
475 $pwassist_session[
'expires'] < time()
478 $form->setValuesByPost();
482 $is_successful =
true;
486 if (!$userObj || !($userObj instanceof \
ilObjUser)) {
487 $message = $this->lng->txt(
'user_does_not_exist');
488 $is_successful =
false;
493 if ($is_successful && strcasecmp($userObj->
getLogin(), $username) != 0) {
494 $message = $this->lng->txt(
'pwassist_login_not_match');
495 $is_successful =
false;
500 $message = $this->lng->txt($error_lng_var);
501 $is_successful =
false;
508 if ($is_successful) {
510 if (!$is_successful) {
511 $message = $this->lng->txt(
'passwd_invalid');
517 if ($is_successful) {
525 if ($is_successful) {
527 $this->
showMessageForm(sprintf($this->lng->txt(
'pwassist_password_assigned'), $username));
530 $form->setValuesByPost();
541 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
544 $form->setFormAction($this->ctrl->getFormAction($this,
'submitUsernameAssistanceForm'));
545 $form->setTarget(
'_parent');
548 $email->setRequired(
true);
551 $form->addCommandButton(
'submitUsernameAssistanceForm', $this->lng->txt(
'submit'));
568 ilStartUpGUI::initStartUpTemplate(
'tpl.pwassist_username_assistance.html',
true);
570 $this->tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'password_assistance'));
572 $this->tpl->setVariable(
573 'TXT_ENTER_USERNAME_AND_EMAIL',
578 $this->lng->txt(
'pwassist_enter_email'),
587 $this->tpl->setVariable(
'FORM',
$form->getHTML());
605 require_once
'Services/User/classes/class.ilObjUser.php';
606 require_once
'Services/Utilities/classes/class.ilUtil.php';
609 if (!
$form->checkInput()) {
610 $form->setValuesByPost();
619 if (is_array($logins) && count($logins) > 0) {
620 $this->sendUsernameAssistanceMail(
$email, $logins);
623 'Could not sent username assistance emails to (reason: no user found): %s',
643 public function sendUsernameAssistanceMail(
$email, array $logins)
647 require_once
'Services/Mail/classes/class.ilMailbox.php';
648 require_once
'Services/Mail/classes/class.ilMail.php';
649 require_once
'Services/Mail/classes/class.ilMimeMail.php';
650 require_once
'include/inc.pwassist_session_handler.php';
655 'client_id' => $this->
ilias->getClientId(),
656 'lang' => $this->lng->getLangKey()
661 $senderFactory = $DIC[
"mail.mime.sender.factory"];
662 $sender = $senderFactory->system();
665 $mm->Subject($this->lng->txt(
'pwassist_mail_subject'),
true);
673 $this->lng->txt(
'pwassist_username_mail_body'),
674 join(
",\n", $logins),
678 'mailto:' . $DIC->settings()->get(
"admin_email"),
692 ilStartUpGUI::initStartUpTemplate(
'tpl.pwassist_message.html',
true);
693 $this->tpl->setVariable(
'TXT_PAGEHEADLINE', $this->lng->txt(
'password_assistance'));
696 $this->tpl->setVariable(
'TXT_TEXT', str_replace(
"\\n",
'<br />',
$text));
706 $this->tpl->setPermanentLink(
'usr', null,
$context);
static getUserIdByLogin($a_login)
getAssignPasswordForm($pwassist_id)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
getLogin()
get login / username public
db_pwassist_session_destroy($pwassist_id)
destroy session
db_pwassist_session_read($pwassist_id)
static isPasswordValidForUserContext($clear_text_password, $user, &$error_language_variable=null)
fillPermanentLink($context)
buildUrl(string $script, array $queryParameters)
static getPasswordRequirementsInfo()
infotext for ilPasswordInputGUI setInfo()
showAssignPasswordForm(ilPropertyFormGUI $form=null, $pwassist_id='')
Assign password form.
const PERMANENT_LINK_TARGET_PW
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
catch(Exception $e) $message
getEmail()
get email address public
db_pwassist_session_find($user_id)
static getUserLoginsByEmail($a_email)
get all user login names of an email address
if(isset($_POST['submit'])) $form
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.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
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)
const PERMANENT_LINK_TARGET_NAME
submitAssignPasswordForm()
Reads the submitted data from the password assistance form.
submitAssistanceForm()
Reads the submitted data from the password assistance form.
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
static getLogger($a_component_id)
Get component logger.
update()
update object in db
db_pwassist_session_write($pwassist_id, $maxlifetime, $user_id)
Writes serialized session data to the database.
getBaseUrl()
Returns the ILIAS http path without a trailing /.
showUsernameAssistanceForm(ilPropertyFormGUI $form=null)
Shows the password assistance form.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.