Révision 32700c57
Ajouté par Assos Assos il y a environ 5 ans
drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.drush.inc | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* LDAP module drush integration.
|
|
5 |
* LDAP module drush integration. |
|
6 | 6 |
*/ |
7 | 7 |
|
8 | 8 |
/** |
... | ... | |
14 | 14 |
* @see drush_parse_command() |
15 | 15 |
*/ |
16 | 16 |
function ldap_servers_drush_command() { |
17 |
$items['ldap-servers-set-password'] = array(
|
|
17 |
$items['ldap-servers-set-password'] = [
|
|
18 | 18 |
'description' => 'Set the password of an otherwise already configured LDAP server.', |
19 |
'aliases' => array('lssp'),
|
|
20 |
'arguments' => array(
|
|
21 |
'ldap_sid' => 'The configured LDAP server ID.' |
|
22 |
),
|
|
23 |
'options' => array(
|
|
24 |
'password' => 'The password to set for the server.' |
|
25 |
),
|
|
26 |
'examples' => array(
|
|
19 |
'aliases' => ['lssp'],
|
|
20 |
'arguments' => [
|
|
21 |
'ldap_sid' => 'The configured LDAP server ID.',
|
|
22 |
],
|
|
23 |
'options' => [
|
|
24 |
'password' => 'The password to set for the server.',
|
|
25 |
],
|
|
26 |
'examples' => [
|
|
27 | 27 |
'drush lssp LDAP_SERVER_ID --password="PASSWORD"' => 'Sets the password for LDAP_SERVER_ID. Replace LDAP_SERVER_ID with the "Machine name for this configuration." of |
28 | 28 |
the server found at /admin/config/people/ldap/servers, and replace PASSWORD with your password.', |
29 |
),
|
|
30 |
);
|
|
29 |
],
|
|
30 |
];
|
|
31 | 31 |
return $items; |
32 | 32 |
} |
33 | 33 |
|
34 | 34 |
/** |
35 | 35 |
* Callback for the ldap-servers-set-password command. |
36 | 36 |
* |
37 |
* @param string $ldap_sid The server ID for which to set the password. |
|
37 |
* @param string $ldap_sid |
|
38 |
* The server ID for which to set the password. |
|
39 |
* |
|
38 | 40 |
* @option string --password Used to provide the password via an option in the Drush command. |
39 | 41 |
* |
40 | 42 |
* @return |
... | ... | |
52 | 54 |
// Retrieves the password from the --password option set in the drush command. |
53 | 55 |
$ldap_server->bindpw = drush_get_option('password'); |
54 | 56 |
if (!isset($ldap_server->bindpw)) { |
55 |
return drupal_set_message(dt('No password was provided for @ldap_sid. A password has not been set.', array('@ldap_sid' => $ldap_sid)));
|
|
57 |
return drupal_set_message(dt('No password was provided for @ldap_sid. A password has not been set.', ['@ldap_sid' => $ldap_sid]));
|
|
56 | 58 |
} |
57 | 59 |
// Save the server configuration with the password. |
58 | 60 |
$ldap_server->save('edit'); |
59 | 61 |
// Notify of success. |
60 |
return drupal_set_message(dt('Password for @ldap_sid has been set.', array('@ldap_sid' => $ldap_sid)));
|
|
62 |
return drupal_set_message(dt('Password for @ldap_sid has been set.', ['@ldap_sid' => $ldap_sid]));
|
|
61 | 63 |
} |
62 | 64 |
// Provided server ID does not match any of the existing server IDs. |
63 | 65 |
return drush_set_error(dt('@ldap_sid does not match the server ID of any configured servers. Use the "Machine name for this server configuration." found on the edit screen for that server.', |
64 |
array('@ldap_sid' => $ldap_sid)));
|
|
66 |
['@ldap_sid' => $ldap_sid]));
|
|
65 | 67 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules