original_string: function password_expire($username) {
          $result = 0;
  
          $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding);
  
          $ldapconnection = $this->ldap_connect();
          $user_dn = $this->ldap_find_userdn($ldapconnection, $extusername);
          $search_attribs = array($this->config->expireattr);
          $sr = ldap_read($ldapconnection, $user_dn, '(objectClass=*)', $search_attribs);
          if ($sr)  {
              $info = ldap_get_entries_moodle($ldapconnection, $sr);
              if (!empty ($info)) {
                  $info = $info[0];
                  if (isset($info[$this->config->expireattr][0])) {
                      $expiretime = $this->ldap_expirationtime2unix($info[$this->config->expireattr][0], $ldapconnection, $user_dn);
                      if ($expiretime != 0) {
                          $now = time();
                          if ($expiretime > $now) {
                              $result = ceil(($expiretime - $now) / DAYSECS);
                          } else {
                              $result = floor(($expiretime - $now) / DAYSECS);
                          }
                      }
                  }
              }
          } else {
              error_log($this->errorlogtag.get_string('didtfindexpiretime', 'auth_ldap'));
          }
  
          return $result;
      }
code: function password_expire($username) {
          $result = 0;
  
          $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding);
  
          $ldapconnection = $this->ldap_connect();
          $user_dn = $this->ldap_find_userdn($ldapconnection, $extusername);
          $search_attribs = array($this->config->expireattr);
          $sr = ldap_read($ldapconnection, $user_dn, '(objectClass=*)', $search_attribs);
          if ($sr)  {
              $info = ldap_get_entries_moodle($ldapconnection, $sr);
              if (!empty ($info)) {
                  $info = $info[0];
                  if (isset($info[$this->config->expireattr][0])) {
                      $expiretime = $this->ldap_expirationtime2unix($info[$this->config->expireattr][0], $ldapconnection, $user_dn);
                      if ($expiretime != 0) {
                          $now = time();
                          if ($expiretime > $now) {
                              $result = ceil(($expiretime - $now) / DAYSECS);
                          } else {
                              $result = floor(($expiretime - $now) / DAYSECS);
                          }
                      }
                  }
              }
          } else {
              error_log($this->errorlogtag.get_string('didtfindexpiretime', 'auth_ldap'));
          }
  
          return $result;
      }
code_tokens: function password_expire ( $ username ) { $ result = 0 ; $ extusername = core_text :: convert ( $ username , 'utf-8' , $ this -> config -> ldapencoding ) ; $ ldapconnection = $ this -> ldap_connect ( ) ; $ user_dn = $ this -> ldap_find_userdn ( $ ldapconnection , $ extusername ) ; $ search_attribs = array ( $ this -> config -> expireattr ) ; $ sr = ldap_read ( $ ldapconnection , $ user_dn , '(objectClass=*)' , $ search_attribs ) ; if ( $ sr ) { $ info = ldap_get_entries_moodle ( $ ldapconnection , $ sr ) ; if ( ! empty ( $ info ) ) { $ info = $ info [ 0 ] ; if ( isset ( $ info [ $ this -> config -> expireattr ] [ 0 ] ) ) { $ expiretime = $ this -> ldap_expirationtime2unix ( $ info [ $ this -> config -> expireattr ] [ 0 ] , $ ldapconnection , $ user_dn ) ; if ( $ expiretime != 0 ) { $ now = time ( ) ; if ( $ expiretime > $ now ) { $ result = ceil ( ( $ expiretime - $ now ) / DAYSECS ) ; } else { $ result = floor ( ( $ expiretime - $ now ) / DAYSECS ) ; } } } } } else { error_log ( $ this -> errorlogtag . get_string ( 'didtfindexpiretime' , 'auth_ldap' ) ) ; } return $ result ; }
docstring: Return number of days to user password expires
  
  If userpassword does not expire it should return 0. If password is already expired
  it should return negative value.
  
  @param mixed $username username
  @return integer
docstring_tokens: Return number of days to user password expires