ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilPasswordAssistanceGUI Class Reference

Password assistance facility for users who have forgotten their password or for users for whom no password has been assigned yet. More...

+ Collaboration diagram for ilPasswordAssistanceGUI:

Public Member Functions

 executeCommand ()
 
 showAssistanceForm (ilPropertyFormGUI $form=null)
 
 submitAssistanceForm ()
 Reads the submitted data from the password assistance form. More...
 
 sendPasswordAssistanceMail (ilObjUser $userObj)
 Creates (or reuses) a password assistance session, and sends a password assistance mail to the specified user. More...
 
 showAssignPasswordForm (ilPropertyFormGUI $form=null, $pwassist_id='')
 Assign password form. More...
 
 submitAssignPasswordForm ()
 Reads the submitted data from the password assistance form. More...
 
 showUsernameAssistanceForm (ilPropertyFormGUI $form=null)
 Shows the password assistance form. More...
 
 submitUsernameAssistanceForm ()
 Reads the submitted data from the password assistance form. More...
 
 sendUsernameAssistanceMail ($email, array $logins)
 Creates (or reuses) a password assistance session, and sends a password assistance mail to the specified user. More...
 
 showMessageForm ($text)
 This form is used to show a message to the user. More...
 

Protected Member Functions

 getAssistanceForm ()
 
 getAssignPasswordForm ($pwassist_id)
 
 getUsernameAssistanceForm ()
 

Protected Attributes

 $ctrl
 
 $lng
 
 $rbacreview
 
 $tpl
 
 $settings
 
 $ilias
 
 $https
 

Detailed Description

Password assistance facility for users who have forgotten their password or for users for whom no password has been assigned yet.

Author
Werner Randelshofer wrand.nosp@m.els@.nosp@m.hsw.f.nosp@m.hz.c.nosp@m.h
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 12 of file class.ilPasswordAssistanceGUI.php.

Member Function Documentation

◆ executeCommand()

ilPasswordAssistanceGUI::executeCommand ( )
Returns
mixed

Definition at line 77 of file class.ilPasswordAssistanceGUI.php.

References $_GET, $_SESSION, $cmd, $lang, $lng, showAssignPasswordForm(), and showAssistanceForm().

78  {
79  // check hack attempts
80  if(!$this->settings->get('password_assistance')) // || AUTH_DEFAULT != AUTH_LOCAL)
81  {
82  if(empty($_SESSION['AccountId']) && $_SESSION['AccountId'] !== false)
83  {
84  $this->ilias->error_obj->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->WARNING);
85  }
86  }
87 
88  // check correct setup
89  if(!$this->settings->get('setup_ok'))
90  {
91  die('Setup is not completed. Please run setup routine again.');
92  }
93 
94  // Change the language, if necessary.
95  // And load the 'pwassist' language module
96  $lang = $_GET['lang'];
97  if($lang != null && $lang != '' && $this->lng->getLangKey() != $lang)
98  {
99  $lng = new ilLanguage($lang);
100  }
101  $this->lng->loadLanguageModule('pwassist');
102 
103  $cmd = $this->ctrl->getCmd();
104  $next_class = $this->ctrl->getNextClass($this);
105 
106  switch($next_class)
107  {
108  default:
109  if($cmd != '')
110  {
111  return $this->$cmd();
112  }
113  else
114  {
115  if(!empty($_GET['key']))
116  {
117  $this->showAssignPasswordForm();
118  }
119  else
120  {
121  $this->showAssistanceForm();
122  }
123  }
124  break;
125  }
126  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
$_GET["client_id"]
$cmd
Definition: sahs_server.php:35
showAssignPasswordForm(ilPropertyFormGUI $form=null, $pwassist_id='')
Assign password form.
redirection script todo: (a better solution should control the processing via a xml file) ...
showAssistanceForm(ilPropertyFormGUI $form=null)
language handling
+ Here is the call graph for this function:

◆ getAssignPasswordForm()

ilPasswordAssistanceGUI::getAssignPasswordForm (   $pwassist_id)
protected
Parameters
string$pwassist_id
Returns
ilPropertyFormGUI

Definition at line 353 of file class.ilPasswordAssistanceGUI.php.

References ilFormPropertyGUI\setRequired().

Referenced by showAssignPasswordForm(), and submitAssignPasswordForm().

354  {
355  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
356  $form = new ilPropertyFormGUI();
357 
358  $form->setFormAction($this->ctrl->getFormAction($this, 'submitAssignPasswordForm'));
359  $form->setTarget('_parent');
360 
361  $username = new ilTextInputGUI($this->lng->txt('username'), 'username');
362  $username->setRequired(true);
363  $form->addItem($username);
364 
365  $password = new ilPasswordInputGUI($this->lng->txt('password'), 'password');
366  $password->setRequired(true);
367  $form->addItem($password);
368 
369  $key = new ilHiddenInputGUI('key');
370  $key->setValue($pwassist_id);
371  $form->addItem($key);
372 
373  $form->addCommandButton('submitAssignPasswordForm', $this->lng->txt('submit'));
374 
375  return $form;
376  }
This class represents a property form user interface.
This class represents a hidden form property in a property form.
This class represents a text property in a property form.
This class represents a password property in a property form.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAssistanceForm()

ilPasswordAssistanceGUI::getAssistanceForm ( )
protected
Returns
ilPropertyFormGUI

Definition at line 131 of file class.ilPasswordAssistanceGUI.php.

References ilFormPropertyGUI\setRequired().

Referenced by showAssistanceForm(), and submitAssistanceForm().

132  {
133  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
134  $form = new ilPropertyFormGUI();
135 
136  $form->setFormAction($this->ctrl->getFormAction($this, 'submitAssistanceForm'));
137  $form->setTarget('_parent');
138 
139  $username = new ilTextInputGUI($this->lng->txt('username'), 'username');
140  $username->setRequired(true);
141  $form->addItem($username);
142 
143  $email = new ilTextInputGUI($this->lng->txt('email'), 'email');
144  $email->setRequired(true);
145  $form->addItem($email);
146 
147  $form->addCommandButton('submitAssistanceForm', $this->lng->txt('submit'));
148 
149  return $form;
150  }
This class represents a property form user interface.
This class represents a text property in a property form.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUsernameAssistanceForm()

ilPasswordAssistanceGUI::getUsernameAssistanceForm ( )
protected
Returns
ilPropertyFormGUI

Definition at line 544 of file class.ilPasswordAssistanceGUI.php.

References ilFormPropertyGUI\setRequired().

Referenced by showUsernameAssistanceForm(), and submitUsernameAssistanceForm().

545  {
546  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
547  $form = new ilPropertyFormGUI();
548 
549  $form->setFormAction($this->ctrl->getFormAction($this, 'submitUsernameAssistanceForm'));
550  $form->setTarget('_parent');
551 
552  $email = new ilTextInputGUI($this->lng->txt('email'), 'email');
553  $email->setRequired(true);
554  $form->addItem($email);
555 
556  $form->addCommandButton('submitUsernameAssistanceForm', $this->lng->txt('submit'));
557 
558  return $form;
559  }
This class represents a property form user interface.
This class represents a text property in a property form.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendPasswordAssistanceMail()

ilPasswordAssistanceGUI::sendPasswordAssistanceMail ( ilObjUser  $userObj)

Creates (or reuses) a password assistance session, and sends a password assistance mail to the specified user.

Note: To prevent DOS attacks, a new session is created only, if no session exists, or if the existing session has been expired. The password assistance mail contains an URL, which points to this script and contains the following URL parameters: client_id key

Parameters
$userObjilObjUser

Definition at line 277 of file class.ilPasswordAssistanceGUI.php.

References db_pwassist_create_id(), db_pwassist_session_find(), db_pwassist_session_write(), ilObjUser\getEmail(), ilObject\getId(), ilMail\getIliasMailerAddress(), and ilObjUser\getLogin().

Referenced by submitAssistanceForm().

278  {
279  require_once 'Services/Mail/classes/class.ilMailbox.php';
280  require_once 'Services/Mail/classes/class.ilMail.php';
281  require_once 'Services/Mail/classes/class.ilMimeMail.php';
282  require_once 'include/inc.pwassist_session_handler.php';
283 
284  // Check if we need to create a new session
285  $pwassist_session = db_pwassist_session_find($userObj->getId());
286  if(
287  count($pwassist_session) == 0 ||
288  $pwassist_session['expires'] < time() ||
289  true // comment by mjansen: wtf? :-)
290  )
291  {
292  // Create a new session id
293  // #9700 - this didn't do anything before?!
294  // db_set_save_handler();
295  session_start();
296  $pwassist_session['pwassist_id'] = db_pwassist_create_id();
297  session_destroy();
299  $pwassist_session['pwassist_id'],
300  3600,
301  $userObj->getId()
302  );
303  }
304  $protocol = $this->https->isDetected() ? 'https://' : 'http://';
305  // Compose the mail
306  $server_url = $protocol . $_SERVER['HTTP_HOST'] . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')) . '/';
307  // XXX - Werner Randelshofer - Insert code here to dynamically get the
308  // the delimiter. For URL's that are sent by e-mail to a user,
309  // it is best to use semicolons as parameter delimiter
310  $delimiter = '&';
311  $pwassist_url = $protocol . $_SERVER['HTTP_HOST']
312  . str_replace('ilias.php', 'pwassist.php', $_SERVER['PHP_SELF'])
313  . '?client_id=' . $this->ilias->getClientId()
314  . $delimiter . 'lang=' . $this->lng->getLangKey()
315  . $delimiter . 'key=' . $pwassist_session['pwassist_id'];
316  $alternative_pwassist_url = $protocol . $_SERVER['HTTP_HOST']
317  . str_replace('ilias.php', 'pwassist.php', $_SERVER['PHP_SELF'])
318  . '?client_id=' . $this->ilias->getClientId()
319  . $delimiter . 'lang=' . $this->lng->getLangKey()
320  . $delimiter . 'key=' . $pwassist_session['pwassist_id'];
321 
322  $contact_address = ilMail::getIliasMailerAddress();
323 
324  $mm = new ilMimeMail();
325  $mm->Subject($this->lng->txt('pwassist_mail_subject'));
326  $mm->From($contact_address);
327  $mm->To($userObj->getEmail());
328  $mm->Body
329  (
330  str_replace
331  (
332  array("\\n", "\\t"),
333  array("\n", "\t"),
334  sprintf
335  (
336  $this->lng->txt('pwassist_mail_body'),
337  $pwassist_url,
338  $server_url,
339  $_SERVER['REMOTE_ADDR'],
340  $userObj->getLogin(),
341  'mailto:' . $contact_address,
342  $alternative_pwassist_url
343  )
344  )
345  );
346  $mm->Send();
347  }
getLogin()
get login / username public
getEmail()
get email address public
db_pwassist_session_find($user_id)
this class encapsulates the PHP mail() function.
getId()
get object id public
redirection script todo: (a better solution should control the processing via a xml file) ...
db_pwassist_session_write($pwassist_id, $maxlifetime, $user_id)
Writes serialized session data to the database.
static getIliasMailerAddress()
Builds an email address used for system notifications.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendUsernameAssistanceMail()

ilPasswordAssistanceGUI::sendUsernameAssistanceMail (   $email,
array  $logins 
)

Creates (or reuses) a password assistance session, and sends a password assistance mail to the specified user.

Note: To prevent DOS attacks, a new session is created only, if no session exists, or if the existing session has been expired. The password assistance mail contains an URL, which points to this script and contains the following URL parameters: client_id key

Parameters
$email
$logins

Definition at line 678 of file class.ilPasswordAssistanceGUI.php.

References ilMail\getIliasMailerAddress().

Referenced by submitUsernameAssistanceForm().

679  {
680  require_once 'Services/Mail/classes/class.ilMailbox.php';
681  require_once 'Services/Mail/classes/class.ilMail.php';
682  require_once 'Services/Mail/classes/class.ilMimeMail.php';
683  require_once 'include/inc.pwassist_session_handler.php';
684 
685  $protocol = $this->https->isDetected() ? 'https://' : 'http://';
686 
687  $server_url = $protocol . $_SERVER['HTTP_HOST'] . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')) . '/';
688  $login_url = $server_url . 'pwassist.php' . '?client_id=' . $this->ilias->getClientId() . '&lang=' . $this->lng->getLangKey();
689  $contact_address = ilMail::getIliasMailerAddress();
690 
691  $mm = new ilMimeMail();
692  $mm->Subject($this->lng->txt('pwassist_mail_subject'));
693  $mm->From($contact_address);
694  $mm->To($email);
695  $mm->Body
696  (
697  str_replace
698  (
699  array("\\n", "\\t"),
700  array("\n", "\t"),
701  sprintf
702  (
703  $this->lng->txt('pwassist_username_mail_body'),
704  join($logins, ",\n"),
705  $server_url,
706  $_SERVER['REMOTE_ADDR'],
707  $email,
708  'mailto:' . $contact_address,
709  $login_url
710  )
711  )
712  );
713  $mm->Send();
714  }
this class encapsulates the PHP mail() function.
redirection script todo: (a better solution should control the processing via a xml file) ...
static getIliasMailerAddress()
Builds an email address used for system notifications.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showAssignPasswordForm()

ilPasswordAssistanceGUI::showAssignPasswordForm ( ilPropertyFormGUI  $form = null,
  $pwassist_id = '' 
)

Assign password form.

This form is used to assign a password to a username. To use this form, the following data must be provided as HTTP GET parameter, or in argument pwassist_id: key The key is used to retrieve the password assistance session. If the key is missing, or if the password assistance session has expired, the password assistance form will be shown instead of this form.

Parameters
ilPropertyFormGUI$form
string$pwassist_id

Definition at line 390 of file class.ilPasswordAssistanceGUI.php.

References $_GET, db_pwassist_session_read(), getAssignPasswordForm(), ilUtil\getImagePath(), and showAssistanceForm().

Referenced by executeCommand(), and submitAssignPasswordForm().

391  {
392  require_once 'include/inc.pwassist_session_handler.php';
393  require_once 'Services/Language/classes/class.ilLanguage.php';
394 
395  // Retrieve form data
396  if(!$pwassist_id)
397  {
398  $pwassist_id = $_GET['key'];
399  }
400 
401  // Retrieve the session, and check if it is valid
402  $pwassist_session = db_pwassist_session_read($pwassist_id);
403  if(
404  count($pwassist_session) == 0 ||
405  $pwassist_session['expires'] < time()
406  )
407  {
408  $this->showAssistanceForm(null, $this->lng->txt('pwassist_session_expired'));
409  }
410  else
411  {
412  ilStartUpGUI::initStartUpTemplate('tpl.pwassist_assignpassword.html', true);
413  $this->tpl->setVariable('IMG_PAGEHEADLINE', ilUtil::getImagePath('icon_auth.svg'));
414  $this->tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
415 
416  $this->tpl->setVariable('TXT_ENTER_USERNAME_AND_NEW_PASSWORD', $this->lng->txt('pwassist_enter_username_and_new_password'));
417 
418  if(!$form)
419  {
420  $form = $this->getAssignPasswordForm($pwassist_id);
421  }
422  $this->tpl->setVariable('FORM', $form->getHTML());
423  $this->tpl->show();
424  }
425  }
db_pwassist_session_read($pwassist_id)
$_GET["client_id"]
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
showAssistanceForm(ilPropertyFormGUI $form=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showAssistanceForm()

ilPasswordAssistanceGUI::showAssistanceForm ( ilPropertyFormGUI  $form = null)
Parameters
ilPropertyFormGUI$form

Definition at line 155 of file class.ilPasswordAssistanceGUI.php.

References getAssistanceForm(), ilUtil\getImagePath(), and ilUtil\prepareFormOutput().

Referenced by executeCommand(), showAssignPasswordForm(), submitAssignPasswordForm(), and submitAssistanceForm().

156  {
157  ilStartUpGUI::initStartUpTemplate('tpl.pwassist_assistance.html', true);
158  $this->tpl->setVariable('IMG_PAGEHEADLINE', ilUtil::getImagePath('icon_auth.svg'));
159  $this->tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
160 
161  $this->tpl->setVariable
162  (
163  'TXT_ENTER_USERNAME_AND_EMAIL',
164  str_replace
165  (
166  "\\n", '<br />',
167  sprintf
168  (
169  $this->lng->txt('pwassist_enter_username_and_email'),
170  '<a href="mailto:' . ilUtil::prepareFormOutput($this->settings->get('admin_email')) . '">' . ilUtil::prepareFormOutput($this->settings->get('admin_email')) . '</a>'
171  )
172  )
173  );
174 
175  if(!$form)
176  {
177  $form = $this->getAssistanceForm();
178  }
179  $this->tpl->setVariable('FORM', $form->getHTML());
180  $this->tpl->show();
181  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showMessageForm()

ilPasswordAssistanceGUI::showMessageForm (   $text)

This form is used to show a message to the user.

Parameters
string$text

Definition at line 720 of file class.ilPasswordAssistanceGUI.php.

References ilUtil\getImagePath().

Referenced by submitAssignPasswordForm(), submitAssistanceForm(), and submitUsernameAssistanceForm().

721  {
722  ilStartUpGUI::initStartUpTemplate('tpl.pwassist_message.html', true);
723  $this->tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
724  $this->tpl->setVariable('IMG_PAGEHEADLINE', ilUtil::getImagePath('icon_auth.svg'));
725 
726  $this->tpl->setVariable('TXT_TEXT', str_replace("\\n", '<br />', $text));
727  $this->tpl->show();
728  }
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showUsernameAssistanceForm()

ilPasswordAssistanceGUI::showUsernameAssistanceForm ( ilPropertyFormGUI  $form = null)

Shows the password assistance form.

This form is used to request a password assistance mail from ILIAS. This form contains the following fields: username email When the user submits the form, then this script is invoked with the cmd 'submitAssistanceForm'.

Parameters
ilPropertyFormGUI$form

Definition at line 571 of file class.ilPasswordAssistanceGUI.php.

References ilUtil\getImagePath(), getUsernameAssistanceForm(), and ilUtil\prepareFormOutput().

Referenced by submitUsernameAssistanceForm().

572  {
573  ilStartUpGUI::initStartUpTemplate('tpl.pwassist_username_assistance.html', true);
574  $this->tpl->setVariable('IMG_PAGEHEADLINE', ilUtil::getImagePath('icon_auth.svg'));
575  $this->tpl->setVariable('TXT_PAGEHEADLINE', $this->lng->txt('password_assistance'));
576 
577  $this->tpl->setVariable
578  (
579  'TXT_ENTER_USERNAME_AND_EMAIL',
580  str_replace
581  (
582  "\\n", '<br />',
583  sprintf
584  (
585  $this->lng->txt('pwassist_enter_email'),
586  '<a href="mailto:' . ilUtil::prepareFormOutput($this->settings->get('admin_email')) . '">' . ilUtil::prepareFormOutput($this->settings->get('admin_email')) . '</a>'
587  )
588  )
589  );
590 
591  if(!$form)
592  {
593  $form = $this->getUsernameAssistanceForm();
594  }
595  $this->tpl->setVariable('FORM', $form->getHTML());
596  $this->tpl->show();
597  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ submitAssignPasswordForm()

ilPasswordAssistanceGUI::submitAssignPasswordForm ( )

Reads the submitted data from the password assistance form.

The following form fields are read as HTTP POST parameters: key username password1 password2 The key is used to retrieve the password assistance session. If the key is missing, or if the password assistance session has expired, the password assistance form will be shown instead of this form. If the password assistance session is valid, and if the username matches the username, for which the password assistance has been requested, and if the new password is valid, ILIAS assigns the password to the user. Note: To prevent replay attacks, the session is deleted when the password has been assigned successfully.

Definition at line 443 of file class.ilPasswordAssistanceGUI.php.

References $_POST, db_pwassist_session_destroy(), db_pwassist_session_read(), getAssignPasswordForm(), ilUtil\isPasswordValidForUserContext(), ilUtil\sendFailure(), showAssignPasswordForm(), showAssistanceForm(), showMessageForm(), and ilUtil\stripSlashes().

444  {
445 
446  require_once 'include/inc.pwassist_session_handler.php';
447 
448  // We need to fetch this before form instantiation
449  $pwassist_id = ilUtil::stripSlashes($_POST['key']);
450 
451  $form = $this->getAssignPasswordForm($pwassist_id);
452  if(!$form->checkInput())
453  {
454  $form->setValuesByPost();
455  $this->showAssistanceForm($form);
456  return;
457  }
458 
459  $username = $form->getInput('username');
460  $password = $form->getInput('password');
461  $pwassist_id = $form->getInput('key');
462 
463  // Retrieve the session
464  $pwassist_session = db_pwassist_session_read($pwassist_id);
465 
466  if(
467  count($pwassist_session) == 0 ||
468  $pwassist_session['expires'] < time()
469  )
470  {
471  ilUtil::sendFailure(str_replace("\\n", '', $this->lng->txt('pwassist_session_expired')));
472  $form->setValuesByPost();
473  $this->showAssistanceForm($form);
474  return;
475  }
476  else
477  {
478  $is_successful = true;
479  $message = '';
480 
481  $userObj = new ilObjUser($pwassist_session['user_id']);
482  if($userObj == null)
483  {
484  $message = $this->lng->txt('user_does_not_exist');
485  $is_successful = false;
486  }
487 
488  // check if the username entered by the user matches the
489  // one of the user object.
490  if($is_successful && strcasecmp($userObj->getLogin(), $username) != 0)
491  {
492  $message = $this->lng->txt('pwassist_login_not_match');
493  $is_successful = false;
494  }
495 
496  $error_lng_var = '';
497  if(!ilUtil::isPasswordValidForUserContext($password, $userObj, $error_lng_var))
498  {
499  $message = $this->lng->txt($error_lng_var);
500  $is_successful = false;
501  }
502 
503  // End of validation
504  // If the validation was successful, we change the password of the
505  // user.
506  // ------------------
507  if($is_successful)
508  {
509  $is_successful = $userObj->resetPassword($password, $password);
510  if(!$is_successful)
511  {
512  $message = $this->lng->txt('passwd_invalid');
513  }
514  }
515 
516  // If we are successful so far, we update the user object.
517  // ------------------
518  if($is_successful)
519  {
520  $userObj->update();
521  }
522 
523  // If we are successful, we destroy the password assistance
524  // session and redirect to the login page.
525  // Else we display the form again along with an error message.
526  // ------------------
527  if($is_successful)
528  {
529  db_pwassist_session_destroy($pwassist_id);
530  $this->showMessageForm(sprintf($this->lng->txt('pwassist_password_assigned'), $username));
531  }
532  else
533  {
534  ilUtil::sendFailure(str_replace("\\n", '', $message));
535  $form->setValuesByPost();
536  $this->showAssignPasswordForm($form, $pwassist_id);
537  }
538  }
539  }
$_POST['username']
Definition: cron.php:12
db_pwassist_session_destroy($pwassist_id)
destroy session
db_pwassist_session_read($pwassist_id)
static isPasswordValidForUserContext($clear_text_password, $user, &$error_language_variable=null)
showAssignPasswordForm(ilPropertyFormGUI $form=null, $pwassist_id='')
Assign password form.
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 sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
showAssistanceForm(ilPropertyFormGUI $form=null)
+ Here is the call graph for this function:

◆ submitAssistanceForm()

ilPasswordAssistanceGUI::submitAssistanceForm ( )

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().

Definition at line 194 of file class.ilPasswordAssistanceGUI.php.

References AUTH_LOCAL, getAssistanceForm(), ilObjUser\getUserIdByLogin(), ilUtil\sendFailure(), sendPasswordAssistanceMail(), showAssistanceForm(), and showMessageForm().

195  {
196  $form = $this->getAssistanceForm();
197  if(!$form->checkInput())
198  {
199  $form->setValuesByPost();
200  $this->showAssistanceForm($form);
201  return;
202  }
203 
204  $username = $form->getInput('username');
205  $email = $form->getInput('email');
206 
207  $userObj = null;
208  $userid = ilObjUser::getUserIdByLogin($username);
209  $txt_key = 'pwassist_invalid_username_or_email';
210  if($userid != 0)
211  {
212  $userObj = new ilObjUser($userid);
213  if(strcasecmp($userObj->getEmail(), $email) != 0)
214  {
215  $userObj = null;
216  }
217  elseif(!strlen($email))
218  {
219  $userObj = null;
220  $txt_key = 'pwassist_no_email_found';
221  }
222  else if(
223  $userObj->getAuthMode(true) != AUTH_LOCAL ||
224  ($userObj->getAuthMode(true) == AUTH_DEFAULT && AUTH_DEFAULT != AUTH_LOCAL)
225  )
226  {
227  $userObj = null;
228  $txt_key = 'pwassist_invalid_auth_mode';
229  }
230  }
231 
232  // No matching user object found?
233  // Show the password assistance form again, and display an error message.
234  if($userObj == null)
235  {
236  ilUtil::sendFailure(str_replace("\\n", '', $this->lng->txt($txt_key)));
237  $form->setValuesByPost();
238  $this->showAssistanceForm($form);
239  }
240  else
241  {
242  // Matching user object found?
243  // Check if the user is permitted to use the password assistance function,
244  // and then send a password assistance mail to the email address.
245  // FIXME: Extend this if-statement to check whether the user
246  // has the permission to use the password assistance function.
247  // The anonymous user and users who are system administrators are
248  // not allowed to use this feature
249  if(
250  $this->rbacreview->isAssigned($userObj->getId(), ANONYMOUS_ROLE_ID) ||
251  $this->rbacreview->isAssigned($userObj->getId(), SYSTEM_ROLE_ID)
252  )
253  {
254  ilUtil::sendFailure(str_replace("\\n", '', $this->lng->txt('pwassist_not_permitted')));
255  $form->setValuesByPost();
256  $this->showAssistanceForm($form);
257  }
258  else
259  {
260  $this->sendPasswordAssistanceMail($userObj);
261  $this->showMessageForm(sprintf($this->lng->txt('pwassist_mail_sent'), $email));
262  }
263  }
264  }
sendPasswordAssistanceMail(ilObjUser $userObj)
Creates (or reuses) a password assistance session, and sends a password assistance mail to the specif...
getUserIdByLogin($a_login)
const AUTH_LOCAL
showMessageForm($text)
This form is used to show a message to the user.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
showAssistanceForm(ilPropertyFormGUI $form=null)
+ Here is the call graph for this function:

◆ submitUsernameAssistanceForm()

ilPasswordAssistanceGUI::submitUsernameAssistanceForm ( )

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().

Definition at line 610 of file class.ilPasswordAssistanceGUI.php.

References ilObjUser\_getUserIdsByEmail(), getUsernameAssistanceForm(), ilUtil\sendFailure(), sendUsernameAssistanceMail(), showMessageForm(), and showUsernameAssistanceForm().

611  {
612  require_once 'Services/User/classes/class.ilObjUser.php';
613  require_once 'Services/Utilities/classes/class.ilUtil.php';
614 
615  $form = $this->getUsernameAssistanceForm();
616  if(!$form->checkInput())
617  {
618  $form->setValuesByPost();
619  $this->showUsernameAssistanceForm($form);
620  return;
621  }
622 
623  // Retrieve form data
624  $email = $form->getInput('email');
625 
626  // Retrieve a user object with matching user name and email address.
627  $logins = ilObjUser::_getUserIdsByEmail($email);
628 
629  // No matching user object found?
630  // Show the password assistance form again, and display an error message.
631  if(!is_array($logins) || count($logins) < 1)
632  {
633  ilUtil::sendFailure(str_replace("\\n", '', $this->lng->txt('pwassist_invalid_email')));
634  $form->setValuesByPost();
635  $this->showUsernameAssistanceForm($form);
636  }
637  else
638  {
639  // Matching user object found?
640  // Check if the user is permitted to use the password assistance function,
641  // and then send a password assistance mail to the email address.
642 
643  // FIXME: Extend this if-statement to check whether the user
644  // has the permission to use the password assistance function.
645  // The anonymous user and users who are system administrators are
646  // not allowed to use this feature
647  /* if ($rbacreview->isAssigned($userObj->getID, ANONYMOUS_ROLE_ID)
648  || $rbacreview->isAssigned($userObj->getID, SYSTEM_ROLE_ID)
649  )
650  {
651  $this->showAssistanceForm
652  (
653  $lng->txt("pwassist_not_permitted"),
654  $username,
655  $email
656  );
657  }
658  else */
659  {
660  $this->sendUsernameAssistanceMail($email, $logins);
661  $this->showMessageForm(sprintf($this->lng->txt('pwassist_mail_sent'), $email));
662  }
663  }
664  }
showMessageForm($text)
This form is used to show a message to the user.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
sendUsernameAssistanceMail($email, array $logins)
Creates (or reuses) a password assistance session, and sends a password assistance mail to the specif...
showUsernameAssistanceForm(ilPropertyFormGUI $form=null)
Shows the password assistance form.
_getUserIdsByEmail($a_email)
STATIC METHOD get all user_ids of an email address.
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilPasswordAssistanceGUI::$ctrl
protected

Definition at line 17 of file class.ilPasswordAssistanceGUI.php.

◆ $https

ilPasswordAssistanceGUI::$https
protected

Definition at line 47 of file class.ilPasswordAssistanceGUI.php.

◆ $ilias

ilPasswordAssistanceGUI::$ilias
protected

Definition at line 42 of file class.ilPasswordAssistanceGUI.php.

◆ $lng

ilPasswordAssistanceGUI::$lng
protected

Definition at line 22 of file class.ilPasswordAssistanceGUI.php.

Referenced by executeCommand().

◆ $rbacreview

ilPasswordAssistanceGUI::$rbacreview
protected

Definition at line 27 of file class.ilPasswordAssistanceGUI.php.

◆ $settings

ilPasswordAssistanceGUI::$settings
protected

Definition at line 37 of file class.ilPasswordAssistanceGUI.php.

◆ $tpl

ilPasswordAssistanceGUI::$tpl
protected

Definition at line 32 of file class.ilPasswordAssistanceGUI.php.


The documentation for this class was generated from the following file: