Projet

Général

Profil

Paste
Télécharger (4,6 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ldap / ldap_authentication / ldap_authentication.theme.inc @ 91af538d

1
<?php
2

    
3
/**
4
 * @file
5
 * Theming functions for ldap_authentication module.
6
 */
7

    
8
/**
9
 * Returns HTML for user login block links.
10
 *
11
 * @param $variables
12
 *   An associative array containing:
13
 *   - $show_reset_pwd (boolean) whether reset password link should be visible
14
 *   - auth_conf: object with ldap authentication configuration data
15
 *
16
 * @ingroup themeable
17
 *
18
 * @return string
19
 */
20
function theme_ldap_authentication_user_login_block_links($variables) {
21
  /** @var bool $show_reset_pwd */
22
  /** @var object $auth_conf */
23
  extract($variables);
24

    
25
  // The code below modified from user.module user_login_block function.
26
  $items = [];
27
  if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
28
    $items[] = l(t('Create new account'), 'user/register', ['attributes' => ['title' => t('Create a new user account.')]]);
29
  }
30
  if ($show_reset_pwd) {
31
    $items[] = l(t('Request new password'), 'user/password', ['attributes' => ['title' => t('Request new password via e-mail.')]]);
32
  }
33
  elseif ($auth_conf->ldapUserHelpLinkUrl) {
34
    $items[] = l(t($auth_conf->ldapUserHelpLinkText), $auth_conf->ldapUserHelpLinkUrl);
35
  }
36

    
37
  $output = theme('item_list', ['items' => $items]);
38
  return $output;
39
}
40

    
41
/**
42
 * Returns HTML warning text for request new password/password reset form.
43
 *
44
 * @param $variables
45
 *   An associative array containing:
46
 *   - auth_conf: object with ldap authentication configuration data
47
 *
48
 * @ingroup themeable
49
 *
50
 * @return string|null
51
 */
52
function theme_ldap_authentication_user_pass_message($variables) {
53
  /** @var object $auth_conf */
54
  extract($variables);
55
  if ($auth_conf->authenticationMode == LDAP_AUTHENTICATION_EXCLUSIVE && $auth_conf->passwordOption != LDAP_AUTHENTICATION_PASSWORD_FIELD_ALLOW) {
56
    $msg = t('This page is only useful for the site administrator.  All other users
57
      need to reset their passwords');
58
    if ($auth_conf->ldapUserHelpLinkUrl) {
59
      $msg .= ' ' . t('at') . ' ' . l(t($auth_conf->ldapUserHelpLinkText), $auth_conf->ldapUserHelpLinkUrl) . '.';
60
    }
61
    else {
62
      $msg .= ' ' . t('with one of your organizations password management sites.');
63
    }
64
  }
65
  // Mixed mode.
66
  else {
67
    // Warning will come up on validation.  we do not know if the user is ldap authenticated or not until they submit form.
68
    $msg = "";
69
  }
70

    
71
  return $msg;
72
}
73

    
74
/**
75
 * Returns HTML warning text when an ldap authenticated user tries to reset
76
 * their password.
77
 *
78
 * @param $variables
79
 *   An associative array containing:
80
 *   - auth_conf: object with ldap authentication configuration data
81
 *   - account: user object
82
 *
83
 * @ingroup themeable
84
 *
85
 * @return string|null
86
 */
87
function theme_ldap_authentication_user_pass_validate_ldap_authenticated($variables) {
88
  /** @var object $auth_conf */
89
  extract($variables);
90
  // Already know user exists and is ldap authenticated.
91
  if ($auth_conf->ldapUserHelpLinkUrl) {
92
    $msg = t('You may not reset your password here.  You must reset your password via the directions at')
93
    . ' ' . l(t($auth_conf->ldapUserHelpLinkText), $auth_conf->ldapUserHelpLinkUrl);
94
  }
95
  else {
96
    $msg = t('You may not reset your password here.  You must reset your password via one of your
97
      organization\'s password management sites.');
98
  }
99
  return $msg;
100
}
101

    
102
/**
103
 * The following three functions are theme callbacks for various messages
104
 * from NTLM/seamless login integration.
105
 *
106
 * Provides a theme callback for successful login messages. The reason for
107
 * using theme callbacks instead of a simple t() function is to provide the
108
 * ability to have more complex message handling performed; an example would
109
 * be to use the Real Name module to say "Welcome, User Name" upon successful
110
 * login.
111
 *
112
 * @param string $message
113
 *   A text string containing a translatable success message.
114
 *
115
 * @ingroup themeable
116
 *
117
 * @return mixed
118
 */
119
function theme_ldap_authentication_login_message($variables) {
120
  /** @var string $message */
121
  extract($variables);
122
  return $message;
123
}
124

    
125
/**
126
 * Provides a theme callback for user not found messages.
127
 *
128
 * @param string $message
129
 *   A text string containing a translatable "user not found" message.
130
 *
131
 * @ingroup themeable
132
 *
133
 * @return mixed
134
 */
135
function theme_ldap_authentication_message_not_found($variables) {
136
  /** @var string $message */
137
  extract($variables);
138
  return $message;
139
}
140

    
141
/**
142
 * Provides a theme callback for authentication failure messages.
143
 *
144
 * @param string $message
145
 *   A text string containing a translatable "authentication failure" message.
146
 *
147
 * @ingroup themeable
148
 *
149
 * @return string
150
 */
151
function theme_ldap_authentication_message_not_authenticated($variables) {
152
  /** @var string $message */
153
  extract($variables);
154
  return $message;
155
}