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 85ad3d82 Assos Assos
<?php
2
3
/**
4
 * @file
5 32700c57 Assos Assos
 * Theming functions for ldap_authentication module.
6 85ad3d82 Assos Assos
 */
7
8
/**
9
 * Returns HTML for user login block links.
10 32700c57 Assos Assos
 *
11 85ad3d82 Assos Assos
 * @param $variables
12
 *   An associative array containing:
13 32700c57 Assos Assos
 *   - $show_reset_pwd (boolean) whether reset password link should be visible
14 85ad3d82 Assos Assos
 *   - auth_conf: object with ldap authentication configuration data
15
 *
16
 * @ingroup themeable
17 32700c57 Assos Assos
 *
18
 * @return string
19 85ad3d82 Assos Assos
 */
20
function theme_ldap_authentication_user_login_block_links($variables) {
21 32700c57 Assos Assos
  /** @var bool $show_reset_pwd */
22
  /** @var object $auth_conf */
23 85ad3d82 Assos Assos
  extract($variables);
24
25 32700c57 Assos Assos
  // The code below modified from user.module user_login_block function.
26
  $items = [];
27 85ad3d82 Assos Assos
  if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
28 32700c57 Assos Assos
    $items[] = l(t('Create new account'), 'user/register', ['attributes' => ['title' => t('Create a new user account.')]]);
29 85ad3d82 Assos Assos
  }
30
  if ($show_reset_pwd) {
31 32700c57 Assos Assos
    $items[] = l(t('Request new password'), 'user/password', ['attributes' => ['title' => t('Request new password via e-mail.')]]);
32 85ad3d82 Assos Assos
  }
33
  elseif ($auth_conf->ldapUserHelpLinkUrl) {
34
    $items[] = l(t($auth_conf->ldapUserHelpLinkText), $auth_conf->ldapUserHelpLinkUrl);
35
  }
36
37 32700c57 Assos Assos
  $output = theme('item_list', ['items' => $items]);
38 85ad3d82 Assos Assos
  return $output;
39
}
40
41
/**
42
 * Returns HTML warning text for request new password/password reset form.
43 32700c57 Assos Assos
 *
44 85ad3d82 Assos Assos
 * @param $variables
45
 *   An associative array containing:
46
 *   - auth_conf: object with ldap authentication configuration data
47
 *
48
 * @ingroup themeable
49 32700c57 Assos Assos
 *
50
 * @return string|null
51 85ad3d82 Assos Assos
 */
52
function theme_ldap_authentication_user_pass_message($variables) {
53 32700c57 Assos Assos
  /** @var object $auth_conf */
54 85ad3d82 Assos Assos
  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 bc175c27 Assos Assos
      $msg .= ' ' . t('at') . ' ' . l(t($auth_conf->ldapUserHelpLinkText), $auth_conf->ldapUserHelpLinkUrl) . '.';
60 85ad3d82 Assos Assos
    }
61
    else {
62 bc175c27 Assos Assos
      $msg .= ' ' . t('with one of your organizations password management sites.');
63 85ad3d82 Assos Assos
    }
64
  }
65 32700c57 Assos Assos
  // 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 85ad3d82 Assos Assos
  }
70
71
  return $msg;
72
}
73
74
/**
75 32700c57 Assos Assos
 * Returns HTML warning text when an ldap authenticated user tries to reset
76
 * their password.
77
 *
78 85ad3d82 Assos Assos
 * @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 32700c57 Assos Assos
 *
85
 * @return string|null
86 85ad3d82 Assos Assos
 */
87
function theme_ldap_authentication_user_pass_validate_ldap_authenticated($variables) {
88 32700c57 Assos Assos
  /** @var object $auth_conf */
89 85ad3d82 Assos Assos
  extract($variables);
90 32700c57 Assos Assos
  // Already know user exists and is ldap authenticated.
91 85ad3d82 Assos Assos
  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 32700c57 Assos Assos
 *
112
 * @param string $message
113
 *   A text string containing a translatable success message.
114 85ad3d82 Assos Assos
 *
115
 * @ingroup themeable
116 32700c57 Assos Assos
 *
117
 * @return mixed
118 85ad3d82 Assos Assos
 */
119
function theme_ldap_authentication_login_message($variables) {
120 32700c57 Assos Assos
  /** @var string $message */
121 85ad3d82 Assos Assos
  extract($variables);
122
  return $message;
123
}
124
125
/**
126
 * Provides a theme callback for user not found messages.
127 32700c57 Assos Assos
 *
128
 * @param string $message
129
 *   A text string containing a translatable "user not found" message.
130 85ad3d82 Assos Assos
 *
131
 * @ingroup themeable
132 32700c57 Assos Assos
 *
133
 * @return mixed
134 85ad3d82 Assos Assos
 */
135
function theme_ldap_authentication_message_not_found($variables) {
136 32700c57 Assos Assos
  /** @var string $message */
137 85ad3d82 Assos Assos
  extract($variables);
138
  return $message;
139
}
140
141
/**
142
 * Provides a theme callback for authentication failure messages.
143 32700c57 Assos Assos
 *
144
 * @param string $message
145
 *   A text string containing a translatable "authentication failure" message.
146 85ad3d82 Assos Assos
 *
147
 * @ingroup themeable
148 32700c57 Assos Assos
 *
149
 * @return string
150 85ad3d82 Assos Assos
 */
151
function theme_ldap_authentication_message_not_authenticated($variables) {
152 32700c57 Assos Assos
  /** @var string $message */
153 85ad3d82 Assos Assos
  extract($variables);
154
  return $message;
155
}