original_string: public static function request_password_reset($username = '', $email = '') {
          global $CFG, $PAGE;
          require_once($CFG->dirroot . '/login/lib.php');
  
          $warnings = array();
          $params = self::validate_parameters(
              self::request_password_reset_parameters(),
              array(
                  'username' => $username,
                  'email' => $email,
              )
          );
  
          $context = context_system::instance();
          $PAGE->set_context($context);   // Needed by format_string calls.
  
          // Check if an alternate forgotten password method is set.
          if (!empty($CFG->forgottenpasswordurl)) {
              throw new moodle_exception('cannotmailconfirm');
          }
  
          $errors = core_login_validate_forgot_password_data($params);
          if (!empty($errors)) {
              $status = 'dataerror';
              $notice = '';
  
              foreach ($errors as $itemname => $message) {
                  $warnings[] = array(
                      'item' => $itemname,
                      'itemid' => 0,
                      'warningcode' => 'fielderror',
                      'message' => s($message)
                  );
              }
          } else {
              list($status, $notice, $url) = core_login_process_password_reset($params['username'], $params['email']);
          }
  
          return array(
              'status' => $status,
              'notice' => $notice,
              'warnings' => $warnings,
          );
      }
code: public static function request_password_reset($username = '', $email = '') {
          global $CFG, $PAGE;
          require_once($CFG->dirroot . '/login/lib.php');
  
          $warnings = array();
          $params = self::validate_parameters(
              self::request_password_reset_parameters(),
              array(
                  'username' => $username,
                  'email' => $email,
              )
          );
  
          $context = context_system::instance();
          $PAGE->set_context($context);   // Needed by format_string calls.
  
          // Check if an alternate forgotten password method is set.
          if (!empty($CFG->forgottenpasswordurl)) {
              throw new moodle_exception('cannotmailconfirm');
          }
  
          $errors = core_login_validate_forgot_password_data($params);
          if (!empty($errors)) {
              $status = 'dataerror';
              $notice = '';
  
              foreach ($errors as $itemname => $message) {
                  $warnings[] = array(
                      'item' => $itemname,
                      'itemid' => 0,
                      'warningcode' => 'fielderror',
                      'message' => s($message)
                  );
              }
          } else {
              list($status, $notice, $url) = core_login_process_password_reset($params['username'], $params['email']);
          }
  
          return array(
              'status' => $status,
              'notice' => $notice,
              'warnings' => $warnings,
          );
      }
code_tokens: public static function request_password_reset ( $ username = '' , $ email = '' ) { global $ CFG , $ PAGE ; require_once ( $ CFG -> dirroot . '/login/lib.php' ) ; $ warnings = array ( ) ; $ params = self :: validate_parameters ( self :: request_password_reset_parameters ( ) , array ( 'username' => $ username , 'email' => $ email , ) ) ; $ context = context_system :: instance ( ) ; $ PAGE -> set_context ( $ context ) ; // Needed by format_string calls. // Check if an alternate forgotten password method is set. if ( ! empty ( $ CFG -> forgottenpasswordurl ) ) { throw new moodle_exception ( 'cannotmailconfirm' ) ; } $ errors = core_login_validate_forgot_password_data ( $ params ) ; if ( ! empty ( $ errors ) ) { $ status = 'dataerror' ; $ notice = '' ; foreach ( $ errors as $ itemname => $ message ) { $ warnings [ ] = array ( 'item' => $ itemname , 'itemid' => 0 , 'warningcode' => 'fielderror' , 'message' => s ( $ message ) ) ; } } else { list ( $ status , $ notice , $ url ) = core_login_process_password_reset ( $ params [ 'username' ] , $ params [ 'email' ] ) ; } return array ( 'status' => $ status , 'notice' => $ notice , 'warnings' => $ warnings , ) ; }
docstring: Requests a password reset.
  
  @param  string $username user name
  @param  string $email    user email
  @return array warnings and success status (including notices and errors while processing)
  @since Moodle 3.4
  @throws moodle_exception
docstring_tokens: Requests a password reset .