@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | |
24 | 24 | style('settings', 'settings'); |
25 | -script('settings', [ 'settings', 'admin', 'log', 'certificates']); |
|
25 | +script('settings', ['settings', 'admin', 'log', 'certificates']); |
|
26 | 26 | script('core', 'setupchecks'); |
27 | 27 | script('files', 'jquery.fileupload'); |
28 | 28 | |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | |
31 | 31 | <div id="app-navigation"> |
32 | 32 | <ul> |
33 | - <?php if(!empty($_['forms']['admin'])) { ?> |
|
33 | + <?php if (!empty($_['forms']['admin'])) { ?> |
|
34 | 34 | <li class="app-navigation-caption"><?php p($l->t('Personal')); ?></li> |
35 | 35 | <?php |
36 | 36 | } |
37 | - foreach($_['forms']['personal'] as $form) { |
|
37 | + foreach ($_['forms']['personal'] as $form) { |
|
38 | 38 | if (isset($form['anchor'])) { |
39 | 39 | $anchor = \OC::$server->getURLGenerator()->linkToRoute('settings.PersonalSettings.index', ['section' => $form['anchor']]); |
40 | - $class = 'nav-icon-' . $form['anchor']; |
|
40 | + $class = 'nav-icon-'.$form['anchor']; |
|
41 | 41 | $sectionName = $form['section-name']; |
42 | 42 | $active = $form['active'] ? ' class="active"' : ''; |
43 | 43 | ?> |
@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | ?> |
58 | 58 | |
59 | 59 | <?php |
60 | - if(!empty($_['forms']['admin'])) { |
|
60 | + if (!empty($_['forms']['admin'])) { |
|
61 | 61 | ?> |
62 | 62 | <li class="app-navigation-caption"><?php p($l->t('Administration')); ?></li> |
63 | 63 | <?php |
64 | 64 | } |
65 | - foreach($_['forms']['admin'] as $form) { |
|
65 | + foreach ($_['forms']['admin'] as $form) { |
|
66 | 66 | if (isset($form['anchor'])) { |
67 | 67 | |
68 | 68 | $anchor = \OC::$server->getURLGenerator()->linkToRoute('settings.AdminSettings.index', ['section' => $form['anchor']]); |
69 | - $class = 'nav-icon-' . $form['anchor']; |
|
69 | + $class = 'nav-icon-'.$form['anchor']; |
|
70 | 70 | $sectionName = $form['section-name']; |
71 | 71 | $active = $form['active'] ? ' class="active"' : ''; |
72 | 72 | ?> |
@@ -9,7 +9,7 @@ |
||
9 | 9 | <?php p($l->t('User documentation')); ?> |
10 | 10 | </a> |
11 | 11 | </li> |
12 | - <?php if($_['admin']) { ?> |
|
12 | + <?php if ($_['admin']) { ?> |
|
13 | 13 | <li> |
14 | 14 | <a class="icon-user-admin <?php if ($_['mode'] === 'admin') { p('active'); } ?>" |
15 | 15 | href="<?php print_unescaped($_['urlAdminDocs']); ?>"> |
@@ -59,71 +59,71 @@ |
||
59 | 59 | |
60 | 60 | <div id="ldapSettings"> |
61 | 61 | <ul> |
62 | - <li id="#ldapWizard1"><a href="#ldapWizard1"><?php p($l->t('Server'));?></a></li> |
|
63 | - <li id="#ldapWizard2"><a href="#ldapWizard2"><?php p($l->t('Users'));?></a></li> |
|
64 | - <li id="#ldapWizard3"><a href="#ldapWizard3"><?php p($l->t('Login Attributes'));?></a></li> |
|
65 | - <li id="#ldapWizard4"><a href="#ldapWizard4"><?php p($l->t('Groups'));?></a></li> |
|
66 | - <li class="ldapSettingsTabs"><a href="#ldapSettings-2"><?php p($l->t('Expert'));?></a></li> |
|
67 | - <li class="ldapSettingsTabs"><a href="#ldapSettings-1"><?php p($l->t('Advanced'));?></a></li> |
|
62 | + <li id="#ldapWizard1"><a href="#ldapWizard1"><?php p($l->t('Server')); ?></a></li> |
|
63 | + <li id="#ldapWizard2"><a href="#ldapWizard2"><?php p($l->t('Users')); ?></a></li> |
|
64 | + <li id="#ldapWizard3"><a href="#ldapWizard3"><?php p($l->t('Login Attributes')); ?></a></li> |
|
65 | + <li id="#ldapWizard4"><a href="#ldapWizard4"><?php p($l->t('Groups')); ?></a></li> |
|
66 | + <li class="ldapSettingsTabs"><a href="#ldapSettings-2"><?php p($l->t('Expert')); ?></a></li> |
|
67 | + <li class="ldapSettingsTabs"><a href="#ldapSettings-1"><?php p($l->t('Advanced')); ?></a></li> |
|
68 | 68 | </ul> |
69 | 69 | <?php |
70 | - if(!function_exists('ldap_connect')) { |
|
70 | + if (!function_exists('ldap_connect')) { |
|
71 | 71 | print_unescaped('<p class="ldapwarning">'.$l->t('<b>Warning:</b> The PHP LDAP module is not installed, the backend will not work. Please ask your system administrator to install it.').'</p>'); |
72 | 72 | } |
73 | 73 | ?> |
74 | - <?php require_once __DIR__ . '/part.wizard-server.php'; ?> |
|
75 | - <?php require_once __DIR__ . '/part.wizard-userfilter.php'; ?> |
|
76 | - <?php require_once __DIR__ . '/part.wizard-loginfilter.php'; ?> |
|
77 | - <?php require_once __DIR__ . '/part.wizard-groupfilter.php'; ?> |
|
74 | + <?php require_once __DIR__.'/part.wizard-server.php'; ?> |
|
75 | + <?php require_once __DIR__.'/part.wizard-userfilter.php'; ?> |
|
76 | + <?php require_once __DIR__.'/part.wizard-loginfilter.php'; ?> |
|
77 | + <?php require_once __DIR__.'/part.wizard-groupfilter.php'; ?> |
|
78 | 78 | <fieldset id="ldapSettings-1"> |
79 | 79 | <div id="ldapAdvancedAccordion"> |
80 | - <h3><?php p($l->t('Connection Settings'));?></h3> |
|
80 | + <h3><?php p($l->t('Connection Settings')); ?></h3> |
|
81 | 81 | <div> |
82 | - <p><label for="ldap_configuration_active"><?php p($l->t('Configuration Active'));?></label><input type="checkbox" id="ldap_configuration_active" name="ldap_configuration_active" value="1" data-default="<?php p($_['ldap_configuration_active_default']); ?>" title="<?php p($l->t('When unchecked, this configuration will be skipped.'));?>" /></p> |
|
83 | - <p><label for="ldap_backup_host"><?php p($l->t('Backup (Replica) Host'));?></label><input type="text" id="ldap_backup_host" name="ldap_backup_host" data-default="<?php p($_['ldap_backup_host_default']); ?>" title="<?php p($l->t('Give an optional backup host. It must be a replica of the main LDAP/AD server.'));?>"></p> |
|
84 | - <p><label for="ldap_backup_port"><?php p($l->t('Backup (Replica) Port'));?></label><input type="number" id="ldap_backup_port" name="ldap_backup_port" data-default="<?php p($_['ldap_backup_port_default']); ?>" /></p> |
|
85 | - <p><label for="ldap_override_main_server"><?php p($l->t('Disable Main Server'));?></label><input type="checkbox" id="ldap_override_main_server" name="ldap_override_main_server" value="1" data-default="<?php p($_['ldap_override_main_server_default']); ?>" title="<?php p($l->t('Only connect to the replica server.'));?>" /></p> |
|
86 | - <p><label for="ldap_turn_off_cert_check"><?php p($l->t('Turn off SSL certificate validation.'));?></label><input type="checkbox" id="ldap_turn_off_cert_check" name="ldap_turn_off_cert_check" title="<?php p($l->t('Not recommended, use it for testing only! If connection only works with this option, import the LDAP server\'s SSL certificate in your %s server.', [$theme->getName()]));?>" data-default="<?php p($_['ldap_turn_off_cert_check_default']); ?>" value="1"><br/></p> |
|
87 | - <p><label for="ldap_cache_ttl"><?php p($l->t('Cache Time-To-Live'));?></label><input type="number" id="ldap_cache_ttl" name="ldap_cache_ttl" title="<?php p($l->t('in seconds. A change empties the cache.'));?>" data-default="<?php p($_['ldap_cache_ttl_default']); ?>" /></p> |
|
82 | + <p><label for="ldap_configuration_active"><?php p($l->t('Configuration Active')); ?></label><input type="checkbox" id="ldap_configuration_active" name="ldap_configuration_active" value="1" data-default="<?php p($_['ldap_configuration_active_default']); ?>" title="<?php p($l->t('When unchecked, this configuration will be skipped.')); ?>" /></p> |
|
83 | + <p><label for="ldap_backup_host"><?php p($l->t('Backup (Replica) Host')); ?></label><input type="text" id="ldap_backup_host" name="ldap_backup_host" data-default="<?php p($_['ldap_backup_host_default']); ?>" title="<?php p($l->t('Give an optional backup host. It must be a replica of the main LDAP/AD server.')); ?>"></p> |
|
84 | + <p><label for="ldap_backup_port"><?php p($l->t('Backup (Replica) Port')); ?></label><input type="number" id="ldap_backup_port" name="ldap_backup_port" data-default="<?php p($_['ldap_backup_port_default']); ?>" /></p> |
|
85 | + <p><label for="ldap_override_main_server"><?php p($l->t('Disable Main Server')); ?></label><input type="checkbox" id="ldap_override_main_server" name="ldap_override_main_server" value="1" data-default="<?php p($_['ldap_override_main_server_default']); ?>" title="<?php p($l->t('Only connect to the replica server.')); ?>" /></p> |
|
86 | + <p><label for="ldap_turn_off_cert_check"><?php p($l->t('Turn off SSL certificate validation.')); ?></label><input type="checkbox" id="ldap_turn_off_cert_check" name="ldap_turn_off_cert_check" title="<?php p($l->t('Not recommended, use it for testing only! If connection only works with this option, import the LDAP server\'s SSL certificate in your %s server.', [$theme->getName()])); ?>" data-default="<?php p($_['ldap_turn_off_cert_check_default']); ?>" value="1"><br/></p> |
|
87 | + <p><label for="ldap_cache_ttl"><?php p($l->t('Cache Time-To-Live')); ?></label><input type="number" id="ldap_cache_ttl" name="ldap_cache_ttl" title="<?php p($l->t('in seconds. A change empties the cache.')); ?>" data-default="<?php p($_['ldap_cache_ttl_default']); ?>" /></p> |
|
88 | 88 | </div> |
89 | - <h3><?php p($l->t('Directory Settings'));?></h3> |
|
89 | + <h3><?php p($l->t('Directory Settings')); ?></h3> |
|
90 | 90 | <div> |
91 | - <p><label for="ldap_display_name"><?php p($l->t('User Display Name Field'));?></label><input type="text" id="ldap_display_name" name="ldap_display_name" data-default="<?php p($_['ldap_display_name_default']); ?>" title="<?php p($l->t('The LDAP attribute to use to generate the user\'s display name.'));?>" /></p> |
|
92 | - <p><label for="ldap_user_display_name_2"><?php p($l->t('2nd User Display Name Field'));?></label><input type="text" id="ldap_user_display_name_2" name="ldap_user_display_name_2" data-default="<?php p($_['ldap_user_display_name_2_default']); ?>" title="<?php p($l->t('Optional. An LDAP attribute to be added to the display name in brackets. Results in e.g. »John Doe ([email protected])«.'));?>" /></p> |
|
93 | - <p><label for="ldap_base_users"><?php p($l->t('Base User Tree'));?></label><textarea id="ldap_base_users" name="ldap_base_users" placeholder="<?php p($l->t('One User Base DN per line'));?>" data-default="<?php p($_['ldap_base_users_default']); ?>" title="<?php p($l->t('Base User Tree'));?>"></textarea></p> |
|
94 | - <p><label for="ldap_attributes_for_user_search"><?php p($l->t('User Search Attributes'));?></label><textarea id="ldap_attributes_for_user_search" name="ldap_attributes_for_user_search" placeholder="<?php p($l->t('Optional; one attribute per line'));?>" data-default="<?php p($_['ldap_attributes_for_user_search_default']); ?>" title="<?php p($l->t('User Search Attributes'));?>"></textarea></p> |
|
95 | - <p><label for="ldap_group_display_name"><?php p($l->t('Group Display Name Field'));?></label><input type="text" id="ldap_group_display_name" name="ldap_group_display_name" data-default="<?php p($_['ldap_group_display_name_default']); ?>" title="<?php p($l->t('The LDAP attribute to use to generate the groups\'s display name.'));?>" /></p> |
|
96 | - <p><label for="ldap_base_groups"><?php p($l->t('Base Group Tree'));?></label><textarea id="ldap_base_groups" name="ldap_base_groups" placeholder="<?php p($l->t('One Group Base DN per line'));?>" data-default="<?php p($_['ldap_base_groups_default']); ?>" title="<?php p($l->t('Base Group Tree'));?>"></textarea></p> |
|
97 | - <p><label for="ldap_attributes_for_group_search"><?php p($l->t('Group Search Attributes'));?></label><textarea id="ldap_attributes_for_group_search" name="ldap_attributes_for_group_search" placeholder="<?php p($l->t('Optional; one attribute per line'));?>" data-default="<?php p($_['ldap_attributes_for_group_search_default']); ?>" title="<?php p($l->t('Group Search Attributes'));?>"></textarea></p> |
|
98 | - <p><label for="ldap_group_member_assoc_attribute"><?php p($l->t('Group-Member association'));?></label><select id="ldap_group_member_assoc_attribute" name="ldap_group_member_assoc_attribute" data-default="<?php p($_['ldap_group_member_assoc_attribute_default']); ?>" ><option value="uniqueMember"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'uniqueMember')) p(' selected'); ?>>uniqueMember</option><option value="memberUid"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'memberUid')) p(' selected'); ?>>memberUid</option><option value="member"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'member')) p(' selected'); ?>>member (AD)</option><option value="gidNumber"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'gidNumber')) p(' selected'); ?>>gidNumber</option></select></p> <p><label for="ldap_dynamic_group_member_url"><?php p($l->t('Dynamic Group Member URL'));?></label><input type="text" id="ldap_dynamic_group_member_url" name="ldap_dynamic_group_member_url" title="<?php p($l->t('The LDAP attribute that on group objects contains an LDAP search URL that determines what objects belong to the group. (An empty setting disables dynamic group membership functionality.)'));?>" data-default="<?php p($_['ldap_dynamic_group_member_url_default']); ?>" /></p> |
|
99 | - <p><label for="ldap_nested_groups"><?php p($l->t('Nested Groups'));?></label><input type="checkbox" id="ldap_nested_groups" name="ldap_nested_groups" value="1" data-default="<?php p($_['ldap_nested_groups_default']); ?>" title="<?php p($l->t('When switched on, groups that contain groups are supported. (Only works if the group member attribute contains DNs.)'));?>" /></p> |
|
100 | - <p><label for="ldap_paging_size"><?php p($l->t('Paging chunksize'));?></label><input type="number" id="ldap_paging_size" name="ldap_paging_size" title="<?php p($l->t('Chunksize used for paged LDAP searches that may return bulky results like user or group enumeration. (Setting it 0 disables paged LDAP searches in those situations.)'));?>" data-default="<?php p($_['ldap_paging_size_default']); ?>" /></p> |
|
101 | - <p><label for="ldap_turn_on_pwd_change"><?php p($l->t('Enable LDAP password changes per user'));?></label><span class="inlinetable"><span class="tablerow left"><input type="checkbox" id="ldap_turn_on_pwd_change" name="ldap_turn_on_pwd_change" value="1" data-default="<?php p($_['ldap_turn_on_pwd_change_default']); ?>" title="<?php p($l->t('Allow LDAP users to change their password and allow Super Administrators and Group Administrators to change the password of their LDAP users. Only works when access control policies are configured accordingly on the LDAP server. As passwords are sent in plaintext to the LDAP server, transport encryption must be used and password hashing should be configured on the LDAP server.'));?>" /><span class="tablecell"><?php p($l->t('(New password is sent as plain text to LDAP)'));?></span></span> |
|
91 | + <p><label for="ldap_display_name"><?php p($l->t('User Display Name Field')); ?></label><input type="text" id="ldap_display_name" name="ldap_display_name" data-default="<?php p($_['ldap_display_name_default']); ?>" title="<?php p($l->t('The LDAP attribute to use to generate the user\'s display name.')); ?>" /></p> |
|
92 | + <p><label for="ldap_user_display_name_2"><?php p($l->t('2nd User Display Name Field')); ?></label><input type="text" id="ldap_user_display_name_2" name="ldap_user_display_name_2" data-default="<?php p($_['ldap_user_display_name_2_default']); ?>" title="<?php p($l->t('Optional. An LDAP attribute to be added to the display name in brackets. Results in e.g. »John Doe ([email protected])«.')); ?>" /></p> |
|
93 | + <p><label for="ldap_base_users"><?php p($l->t('Base User Tree')); ?></label><textarea id="ldap_base_users" name="ldap_base_users" placeholder="<?php p($l->t('One User Base DN per line')); ?>" data-default="<?php p($_['ldap_base_users_default']); ?>" title="<?php p($l->t('Base User Tree')); ?>"></textarea></p> |
|
94 | + <p><label for="ldap_attributes_for_user_search"><?php p($l->t('User Search Attributes')); ?></label><textarea id="ldap_attributes_for_user_search" name="ldap_attributes_for_user_search" placeholder="<?php p($l->t('Optional; one attribute per line')); ?>" data-default="<?php p($_['ldap_attributes_for_user_search_default']); ?>" title="<?php p($l->t('User Search Attributes')); ?>"></textarea></p> |
|
95 | + <p><label for="ldap_group_display_name"><?php p($l->t('Group Display Name Field')); ?></label><input type="text" id="ldap_group_display_name" name="ldap_group_display_name" data-default="<?php p($_['ldap_group_display_name_default']); ?>" title="<?php p($l->t('The LDAP attribute to use to generate the groups\'s display name.')); ?>" /></p> |
|
96 | + <p><label for="ldap_base_groups"><?php p($l->t('Base Group Tree')); ?></label><textarea id="ldap_base_groups" name="ldap_base_groups" placeholder="<?php p($l->t('One Group Base DN per line')); ?>" data-default="<?php p($_['ldap_base_groups_default']); ?>" title="<?php p($l->t('Base Group Tree')); ?>"></textarea></p> |
|
97 | + <p><label for="ldap_attributes_for_group_search"><?php p($l->t('Group Search Attributes')); ?></label><textarea id="ldap_attributes_for_group_search" name="ldap_attributes_for_group_search" placeholder="<?php p($l->t('Optional; one attribute per line')); ?>" data-default="<?php p($_['ldap_attributes_for_group_search_default']); ?>" title="<?php p($l->t('Group Search Attributes')); ?>"></textarea></p> |
|
98 | + <p><label for="ldap_group_member_assoc_attribute"><?php p($l->t('Group-Member association')); ?></label><select id="ldap_group_member_assoc_attribute" name="ldap_group_member_assoc_attribute" data-default="<?php p($_['ldap_group_member_assoc_attribute_default']); ?>" ><option value="uniqueMember"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'uniqueMember')) p(' selected'); ?>>uniqueMember</option><option value="memberUid"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'memberUid')) p(' selected'); ?>>memberUid</option><option value="member"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'member')) p(' selected'); ?>>member (AD)</option><option value="gidNumber"<?php if (isset($_['ldap_group_member_assoc_attribute']) && ($_['ldap_group_member_assoc_attribute'] === 'gidNumber')) p(' selected'); ?>>gidNumber</option></select></p> <p><label for="ldap_dynamic_group_member_url"><?php p($l->t('Dynamic Group Member URL')); ?></label><input type="text" id="ldap_dynamic_group_member_url" name="ldap_dynamic_group_member_url" title="<?php p($l->t('The LDAP attribute that on group objects contains an LDAP search URL that determines what objects belong to the group. (An empty setting disables dynamic group membership functionality.)')); ?>" data-default="<?php p($_['ldap_dynamic_group_member_url_default']); ?>" /></p> |
|
99 | + <p><label for="ldap_nested_groups"><?php p($l->t('Nested Groups')); ?></label><input type="checkbox" id="ldap_nested_groups" name="ldap_nested_groups" value="1" data-default="<?php p($_['ldap_nested_groups_default']); ?>" title="<?php p($l->t('When switched on, groups that contain groups are supported. (Only works if the group member attribute contains DNs.)')); ?>" /></p> |
|
100 | + <p><label for="ldap_paging_size"><?php p($l->t('Paging chunksize')); ?></label><input type="number" id="ldap_paging_size" name="ldap_paging_size" title="<?php p($l->t('Chunksize used for paged LDAP searches that may return bulky results like user or group enumeration. (Setting it 0 disables paged LDAP searches in those situations.)')); ?>" data-default="<?php p($_['ldap_paging_size_default']); ?>" /></p> |
|
101 | + <p><label for="ldap_turn_on_pwd_change"><?php p($l->t('Enable LDAP password changes per user')); ?></label><span class="inlinetable"><span class="tablerow left"><input type="checkbox" id="ldap_turn_on_pwd_change" name="ldap_turn_on_pwd_change" value="1" data-default="<?php p($_['ldap_turn_on_pwd_change_default']); ?>" title="<?php p($l->t('Allow LDAP users to change their password and allow Super Administrators and Group Administrators to change the password of their LDAP users. Only works when access control policies are configured accordingly on the LDAP server. As passwords are sent in plaintext to the LDAP server, transport encryption must be used and password hashing should be configured on the LDAP server.')); ?>" /><span class="tablecell"><?php p($l->t('(New password is sent as plain text to LDAP)')); ?></span></span> |
|
102 | 102 | </span><br/></p> |
103 | - <p><label for="ldap_default_ppolicy_dn"><?php p($l->t('Default password policy DN'));?></label><input type="text" id="ldap_default_ppolicy_dn" name="ldap_default_ppolicy_dn" title="<?php p($l->t('The DN of a default password policy that will be used for password expiry handling. Works only when LDAP password changes per user are enabled and is only supported by OpenLDAP. Leave empty to disable password expiry handling.'));?>" data-default="<?php p($_['ldap_default_ppolicy_dn_default']); ?>" /></p> |
|
103 | + <p><label for="ldap_default_ppolicy_dn"><?php p($l->t('Default password policy DN')); ?></label><input type="text" id="ldap_default_ppolicy_dn" name="ldap_default_ppolicy_dn" title="<?php p($l->t('The DN of a default password policy that will be used for password expiry handling. Works only when LDAP password changes per user are enabled and is only supported by OpenLDAP. Leave empty to disable password expiry handling.')); ?>" data-default="<?php p($_['ldap_default_ppolicy_dn_default']); ?>" /></p> |
|
104 | 104 | </div> |
105 | - <h3><?php p($l->t('Special Attributes'));?></h3> |
|
105 | + <h3><?php p($l->t('Special Attributes')); ?></h3> |
|
106 | 106 | <div> |
107 | - <p><label for="ldap_quota_attr"><?php p($l->t('Quota Field'));?></label><input type="text" id="ldap_quota_attr" name="ldap_quota_attr" data-default="<?php p($_['ldap_quota_attr_default']); ?>" title="<?php p($l->t('Leave empty for user\'s default quota. Otherwise, specify an LDAP/AD attribute.'));?>" /></p> |
|
108 | - <p><label for="ldap_quota_def"><?php p($l->t('Quota Default'));?></label><input type="text" id="ldap_quota_def" name="ldap_quota_def" data-default="<?php p($_['ldap_quota_def_default']); ?>" title="<?php p($l->t('Override default quota for LDAP users who do not have a quota set in the Quota Field.'));?>" /></p> |
|
109 | - <p><label for="ldap_email_attr"><?php p($l->t('Email Field'));?></label><input type="text" id="ldap_email_attr" name="ldap_email_attr" data-default="<?php p($_['ldap_email_attr_default']); ?>" title="<?php p($l->t('Set the user\'s email from their LDAP attribute. Leave it empty for default behaviour.'));?>" /></p> |
|
110 | - <p><label for="home_folder_naming_rule"><?php p($l->t('User Home Folder Naming Rule'));?></label><input type="text" id="home_folder_naming_rule" name="home_folder_naming_rule" title="<?php p($l->t('Leave empty for username (default). Otherwise, specify an LDAP/AD attribute.'));?>" data-default="<?php p($_['home_folder_naming_rule_default']); ?>" /></p> |
|
107 | + <p><label for="ldap_quota_attr"><?php p($l->t('Quota Field')); ?></label><input type="text" id="ldap_quota_attr" name="ldap_quota_attr" data-default="<?php p($_['ldap_quota_attr_default']); ?>" title="<?php p($l->t('Leave empty for user\'s default quota. Otherwise, specify an LDAP/AD attribute.')); ?>" /></p> |
|
108 | + <p><label for="ldap_quota_def"><?php p($l->t('Quota Default')); ?></label><input type="text" id="ldap_quota_def" name="ldap_quota_def" data-default="<?php p($_['ldap_quota_def_default']); ?>" title="<?php p($l->t('Override default quota for LDAP users who do not have a quota set in the Quota Field.')); ?>" /></p> |
|
109 | + <p><label for="ldap_email_attr"><?php p($l->t('Email Field')); ?></label><input type="text" id="ldap_email_attr" name="ldap_email_attr" data-default="<?php p($_['ldap_email_attr_default']); ?>" title="<?php p($l->t('Set the user\'s email from their LDAP attribute. Leave it empty for default behaviour.')); ?>" /></p> |
|
110 | + <p><label for="home_folder_naming_rule"><?php p($l->t('User Home Folder Naming Rule')); ?></label><input type="text" id="home_folder_naming_rule" name="home_folder_naming_rule" title="<?php p($l->t('Leave empty for username (default). Otherwise, specify an LDAP/AD attribute.')); ?>" data-default="<?php p($_['home_folder_naming_rule_default']); ?>" /></p> |
|
111 | 111 | <p><label for="ldap_ext_storage_home_attribute"> <?php p($l->t('"$home" Placeholder Field')); ?></label><input type="text" id="ldap_ext_storage_home_attribute" name="ldap_ext_storage_home_attribute" title="<?php p($l->t('$home in an external storage configuration will be replaced with the value of the specified attribute')); ?>" data-default="<?php p($_['ldap_ext_storage_home_attribute_default']); ?>"></p> |
112 | 112 | </div> |
113 | 113 | </div> |
114 | 114 | <?php print_unescaped($_['settingControls']); ?> |
115 | 115 | </fieldset> |
116 | 116 | <fieldset id="ldapSettings-2"> |
117 | - <p><strong><?php p($l->t('Internal Username'));?></strong></p> |
|
118 | - <p class="ldapIndent"><?php p($l->t('By default the internal username will be created from the UUID attribute. It makes sure that the username is unique and characters do not need to be converted. The internal username has the restriction that only these characters are allowed: [ a-zA-Z0-9_.@- ]. Other characters are replaced with their ASCII correspondence or simply omitted. On collisions a number will be added/increased. The internal username is used to identify a user internally. It is also the default name for the user home folder. It is also a part of remote URLs, for instance for all *DAV services. With this setting, the default behavior can be overridden. Leave it empty for default behavior. Changes will have effect only on newly mapped (added) LDAP users.'));?></p> |
|
119 | - <p class="ldapIndent"><label for="ldap_expert_username_attr"><?php p($l->t('Internal Username Attribute:'));?></label><input type="text" id="ldap_expert_username_attr" name="ldap_expert_username_attr" data-default="<?php p($_['ldap_expert_username_attr_default']); ?>" /></p> |
|
120 | - <p><strong><?php p($l->t('Override UUID detection'));?></strong></p> |
|
121 | - <p class="ldapIndent"><?php p($l->t('By default, the UUID attribute is automatically detected. The UUID attribute is used to doubtlessly identify LDAP users and groups. Also, the internal username will be created based on the UUID, if not specified otherwise above. You can override the setting and pass an attribute of your choice. You must make sure that the attribute of your choice can be fetched for both users and groups and it is unique. Leave it empty for default behavior. Changes will have effect only on newly mapped (added) LDAP users and groups.'));?></p> |
|
122 | - <p class="ldapIndent"><label for="ldap_expert_uuid_user_attr"><?php p($l->t('UUID Attribute for Users:'));?></label><input type="text" id="ldap_expert_uuid_user_attr" name="ldap_expert_uuid_user_attr" data-default="<?php p($_['ldap_expert_uuid_user_attr_default']); ?>" /></p> |
|
123 | - <p class="ldapIndent"><label for="ldap_expert_uuid_group_attr"><?php p($l->t('UUID Attribute for Groups:'));?></label><input type="text" id="ldap_expert_uuid_group_attr" name="ldap_expert_uuid_group_attr" data-default="<?php p($_['ldap_expert_uuid_group_attr_default']); ?>" /></p> |
|
124 | - <p><strong><?php p($l->t('Username-LDAP User Mapping'));?></strong></p> |
|
125 | - <p class="ldapIndent"><?php p($l->t('Usernames are used to store and assign metadata. In order to precisely identify and recognize users, each LDAP user will have an internal username. This requires a mapping from username to LDAP user. The created username is mapped to the UUID of the LDAP user. Additionally the DN is cached as well to reduce LDAP interaction, but it is not used for identification. If the DN changes, the changes will be found. The internal username is used all over. Clearing the mappings will have leftovers everywhere. Clearing the mappings is not configuration sensitive, it affects all LDAP configurations! Never clear the mappings in a production environment, only in a testing or experimental stage.'));?></p> |
|
126 | - <p class="ldapIndent"><button type="button" id="ldap_action_clear_user_mappings" name="ldap_action_clear_user_mappings"><?php p($l->t('Clear Username-LDAP User Mapping'));?></button><br/><button type="button" id="ldap_action_clear_group_mappings" name="ldap_action_clear_group_mappings"><?php p($l->t('Clear Groupname-LDAP Group Mapping'));?></button></p> |
|
117 | + <p><strong><?php p($l->t('Internal Username')); ?></strong></p> |
|
118 | + <p class="ldapIndent"><?php p($l->t('By default the internal username will be created from the UUID attribute. It makes sure that the username is unique and characters do not need to be converted. The internal username has the restriction that only these characters are allowed: [ a-zA-Z0-9_.@- ]. Other characters are replaced with their ASCII correspondence or simply omitted. On collisions a number will be added/increased. The internal username is used to identify a user internally. It is also the default name for the user home folder. It is also a part of remote URLs, for instance for all *DAV services. With this setting, the default behavior can be overridden. Leave it empty for default behavior. Changes will have effect only on newly mapped (added) LDAP users.')); ?></p> |
|
119 | + <p class="ldapIndent"><label for="ldap_expert_username_attr"><?php p($l->t('Internal Username Attribute:')); ?></label><input type="text" id="ldap_expert_username_attr" name="ldap_expert_username_attr" data-default="<?php p($_['ldap_expert_username_attr_default']); ?>" /></p> |
|
120 | + <p><strong><?php p($l->t('Override UUID detection')); ?></strong></p> |
|
121 | + <p class="ldapIndent"><?php p($l->t('By default, the UUID attribute is automatically detected. The UUID attribute is used to doubtlessly identify LDAP users and groups. Also, the internal username will be created based on the UUID, if not specified otherwise above. You can override the setting and pass an attribute of your choice. You must make sure that the attribute of your choice can be fetched for both users and groups and it is unique. Leave it empty for default behavior. Changes will have effect only on newly mapped (added) LDAP users and groups.')); ?></p> |
|
122 | + <p class="ldapIndent"><label for="ldap_expert_uuid_user_attr"><?php p($l->t('UUID Attribute for Users:')); ?></label><input type="text" id="ldap_expert_uuid_user_attr" name="ldap_expert_uuid_user_attr" data-default="<?php p($_['ldap_expert_uuid_user_attr_default']); ?>" /></p> |
|
123 | + <p class="ldapIndent"><label for="ldap_expert_uuid_group_attr"><?php p($l->t('UUID Attribute for Groups:')); ?></label><input type="text" id="ldap_expert_uuid_group_attr" name="ldap_expert_uuid_group_attr" data-default="<?php p($_['ldap_expert_uuid_group_attr_default']); ?>" /></p> |
|
124 | + <p><strong><?php p($l->t('Username-LDAP User Mapping')); ?></strong></p> |
|
125 | + <p class="ldapIndent"><?php p($l->t('Usernames are used to store and assign metadata. In order to precisely identify and recognize users, each LDAP user will have an internal username. This requires a mapping from username to LDAP user. The created username is mapped to the UUID of the LDAP user. Additionally the DN is cached as well to reduce LDAP interaction, but it is not used for identification. If the DN changes, the changes will be found. The internal username is used all over. Clearing the mappings will have leftovers everywhere. Clearing the mappings is not configuration sensitive, it affects all LDAP configurations! Never clear the mappings in a production environment, only in a testing or experimental stage.')); ?></p> |
|
126 | + <p class="ldapIndent"><button type="button" id="ldap_action_clear_user_mappings" name="ldap_action_clear_user_mappings"><?php p($l->t('Clear Username-LDAP User Mapping')); ?></button><br/><button type="button" id="ldap_action_clear_group_mappings" name="ldap_action_clear_group_mappings"><?php p($l->t('Clear Groupname-LDAP Group Mapping')); ?></button></p> |
|
127 | 127 | <?php print_unescaped($_['settingControls']); ?> |
128 | 128 | </fieldset> |
129 | 129 | </div> |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param $uid |
143 | 143 | */ |
144 | 144 | public function invalidate($uid) { |
145 | - if(!isset($this->usersByUid[$uid])) { |
|
145 | + if (!isset($this->usersByUid[$uid])) { |
|
146 | 146 | return; |
147 | 147 | } |
148 | 148 | $dn = $this->usersByUid[$uid]->getDN(); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * @return null |
157 | 157 | */ |
158 | 158 | private function checkAccess() { |
159 | - if(is_null($this->access)) { |
|
159 | + if (is_null($this->access)) { |
|
160 | 160 | throw new \Exception('LDAP Access instance must be set first'); |
161 | 161 | } |
162 | 162 | } |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | ]; |
182 | 182 | |
183 | 183 | $homeRule = $this->access->getConnection()->homeFolderNamingRule; |
184 | - if(strpos($homeRule, 'attr:') === 0) { |
|
184 | + if (strpos($homeRule, 'attr:') === 0) { |
|
185 | 185 | $attributes[] = substr($homeRule, strlen('attr:')); |
186 | 186 | } |
187 | 187 | |
188 | - if(!$minimal) { |
|
188 | + if (!$minimal) { |
|
189 | 189 | // attributes that are not really important but may come with big |
190 | 190 | // payload. |
191 | 191 | $attributes = array_merge( |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | } |
196 | 196 | |
197 | 197 | $attributes = array_reduce($attributes, |
198 | - function ($list, $attribute) { |
|
199 | - $attribute = strtolower(trim((string)$attribute)); |
|
200 | - if(!empty($attribute) && !in_array($attribute, $list)) { |
|
198 | + function($list, $attribute) { |
|
199 | + $attribute = strtolower(trim((string) $attribute)); |
|
200 | + if (!empty($attribute) && !in_array($attribute, $list)) { |
|
201 | 201 | $list[] = $attribute; |
202 | 202 | } |
203 | 203 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | public function isDeletedUser($id) { |
218 | 218 | $isDeleted = $this->ocConfig->getUserValue( |
219 | 219 | $id, 'user_ldap', 'isDeleted', 0); |
220 | - return (int)$isDeleted === 1; |
|
220 | + return (int) $isDeleted === 1; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -240,11 +240,11 @@ discard block |
||
240 | 240 | */ |
241 | 241 | protected function createInstancyByUserName($id) { |
242 | 242 | //most likely a uid. Check whether it is a deleted user |
243 | - if($this->isDeletedUser($id)) { |
|
243 | + if ($this->isDeletedUser($id)) { |
|
244 | 244 | return $this->getDeletedUser($id); |
245 | 245 | } |
246 | 246 | $dn = $this->access->username2dn($id); |
247 | - if($dn !== false) { |
|
247 | + if ($dn !== false) { |
|
248 | 248 | return $this->createAndCache($dn, $id); |
249 | 249 | } |
250 | 250 | return null; |
@@ -258,15 +258,15 @@ discard block |
||
258 | 258 | */ |
259 | 259 | public function get($id) { |
260 | 260 | $this->checkAccess(); |
261 | - if(isset($this->usersByDN[$id])) { |
|
261 | + if (isset($this->usersByDN[$id])) { |
|
262 | 262 | return $this->usersByDN[$id]; |
263 | - } else if(isset($this->usersByUid[$id])) { |
|
263 | + } else if (isset($this->usersByUid[$id])) { |
|
264 | 264 | return $this->usersByUid[$id]; |
265 | 265 | } |
266 | 266 | |
267 | - if($this->access->stringResemblesDN($id)) { |
|
267 | + if ($this->access->stringResemblesDN($id)) { |
|
268 | 268 | $uid = $this->access->dn2username($id); |
269 | - if($uid !== false) { |
|
269 | + if ($uid !== false) { |
|
270 | 270 | return $this->createAndCache($id, $uid); |
271 | 271 | } |
272 | 272 | } |
@@ -156,17 +156,17 @@ discard block |
||
156 | 156 | * @return null |
157 | 157 | */ |
158 | 158 | public function update() { |
159 | - if(is_null($this->dn)) { |
|
159 | + if (is_null($this->dn)) { |
|
160 | 160 | return null; |
161 | 161 | } |
162 | 162 | |
163 | 163 | $hasLoggedIn = $this->config->getUserValue($this->uid, 'user_ldap', |
164 | 164 | self::USER_PREFKEY_FIRSTLOGIN, 0); |
165 | 165 | |
166 | - if($this->needsRefresh()) { |
|
166 | + if ($this->needsRefresh()) { |
|
167 | 167 | $this->updateEmail(); |
168 | 168 | $this->updateQuota(); |
169 | - if($hasLoggedIn !== 0) { |
|
169 | + if ($hasLoggedIn !== 0) { |
|
170 | 170 | //we do not need to try it, when the user has not been logged in |
171 | 171 | //before, because the file system will not be ready. |
172 | 172 | $this->updateAvatar(); |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function markUser() { |
186 | 186 | $curValue = $this->config->getUserValue($this->getUsername(), 'user_ldap', 'isDeleted', '0'); |
187 | - if($curValue === '1') { |
|
187 | + if ($curValue === '1') { |
|
188 | 188 | // the user is already marked, do not write to DB again |
189 | 189 | return; |
190 | 190 | } |
191 | 191 | $this->config->setUserValue($this->getUsername(), 'user_ldap', 'isDeleted', '1'); |
192 | - $this->config->setUserValue($this->getUsername(), 'user_ldap', 'foundDeleted', (string)time()); |
|
192 | + $this->config->setUserValue($this->getUsername(), 'user_ldap', 'foundDeleted', (string) time()); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $this->markRefreshTime(); |
201 | 201 | //Quota |
202 | 202 | $attr = strtolower($this->connection->ldapQuotaAttribute); |
203 | - if(isset($ldapEntry[$attr])) { |
|
203 | + if (isset($ldapEntry[$attr])) { |
|
204 | 204 | $this->updateQuota($ldapEntry[$attr][0]); |
205 | 205 | } else { |
206 | 206 | if ($this->connection->ldapQuotaDefault !== '') { |
@@ -212,12 +212,12 @@ discard block |
||
212 | 212 | //displayName |
213 | 213 | $displayName = $displayName2 = ''; |
214 | 214 | $attr = strtolower($this->connection->ldapUserDisplayName); |
215 | - if(isset($ldapEntry[$attr])) { |
|
216 | - $displayName = (string)$ldapEntry[$attr][0]; |
|
215 | + if (isset($ldapEntry[$attr])) { |
|
216 | + $displayName = (string) $ldapEntry[$attr][0]; |
|
217 | 217 | } |
218 | 218 | $attr = strtolower($this->connection->ldapUserDisplayName2); |
219 | - if(isset($ldapEntry[$attr])) { |
|
220 | - $displayName2 = (string)$ldapEntry[$attr][0]; |
|
219 | + if (isset($ldapEntry[$attr])) { |
|
220 | + $displayName2 = (string) $ldapEntry[$attr][0]; |
|
221 | 221 | } |
222 | 222 | if ($displayName !== '') { |
223 | 223 | $this->composeAndStoreDisplayName($displayName, $displayName2); |
@@ -233,22 +233,22 @@ discard block |
||
233 | 233 | //email must be stored after displayname, because it would cause a user |
234 | 234 | //change event that will trigger fetching the display name again |
235 | 235 | $attr = strtolower($this->connection->ldapEmailAttribute); |
236 | - if(isset($ldapEntry[$attr])) { |
|
236 | + if (isset($ldapEntry[$attr])) { |
|
237 | 237 | $this->updateEmail($ldapEntry[$attr][0]); |
238 | 238 | } |
239 | 239 | unset($attr); |
240 | 240 | |
241 | 241 | // LDAP Username, needed for s2s sharing |
242 | - if(isset($ldapEntry['uid'])) { |
|
242 | + if (isset($ldapEntry['uid'])) { |
|
243 | 243 | $this->storeLDAPUserName($ldapEntry['uid'][0]); |
244 | - } else if(isset($ldapEntry['samaccountname'])) { |
|
244 | + } else if (isset($ldapEntry['samaccountname'])) { |
|
245 | 245 | $this->storeLDAPUserName($ldapEntry['samaccountname'][0]); |
246 | 246 | } |
247 | 247 | |
248 | 248 | //homePath |
249 | - if(strpos($this->connection->homeFolderNamingRule, 'attr:') === 0) { |
|
249 | + if (strpos($this->connection->homeFolderNamingRule, 'attr:') === 0) { |
|
250 | 250 | $attr = strtolower(substr($this->connection->homeFolderNamingRule, strlen('attr:'))); |
251 | - if(isset($ldapEntry[$attr])) { |
|
251 | + if (isset($ldapEntry[$attr])) { |
|
252 | 252 | $this->access->cacheUserHome( |
253 | 253 | $this->getUsername(), $this->getHomePath($ldapEntry[$attr][0])); |
254 | 254 | } |
@@ -257,14 +257,14 @@ discard block |
||
257 | 257 | //memberOf groups |
258 | 258 | $cacheKey = 'getMemberOf'.$this->getUsername(); |
259 | 259 | $groups = false; |
260 | - if(isset($ldapEntry['memberof'])) { |
|
260 | + if (isset($ldapEntry['memberof'])) { |
|
261 | 261 | $groups = $ldapEntry['memberof']; |
262 | 262 | } |
263 | 263 | $this->connection->writeToCache($cacheKey, $groups); |
264 | 264 | |
265 | 265 | //external storage var |
266 | 266 | $attr = strtolower($this->connection->ldapExtStorageHomeAttribute); |
267 | - if(isset($ldapEntry[$attr])) { |
|
267 | + if (isset($ldapEntry[$attr])) { |
|
268 | 268 | $this->updateExtStorageHome($ldapEntry[$attr][0]); |
269 | 269 | } |
270 | 270 | unset($attr); |
@@ -273,8 +273,8 @@ discard block |
||
273 | 273 | /** @var Connection $connection */ |
274 | 274 | $connection = $this->access->getConnection(); |
275 | 275 | $attributes = $connection->resolveRule('avatar'); |
276 | - foreach ($attributes as $attribute) { |
|
277 | - if(isset($ldapEntry[$attribute])) { |
|
276 | + foreach ($attributes as $attribute) { |
|
277 | + if (isset($ldapEntry[$attribute])) { |
|
278 | 278 | $this->avatarImage = $ldapEntry[$attribute][0]; |
279 | 279 | // the call to the method that saves the avatar in the file |
280 | 280 | // system must be postponed after the login. It is to ensure |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @throws \Exception |
310 | 310 | */ |
311 | 311 | public function getHomePath($valueFromLDAP = null) { |
312 | - $path = (string)$valueFromLDAP; |
|
312 | + $path = (string) $valueFromLDAP; |
|
313 | 313 | $attr = null; |
314 | 314 | |
315 | 315 | if (is_null($valueFromLDAP) |
@@ -327,12 +327,12 @@ discard block |
||
327 | 327 | if ($path !== '') { |
328 | 328 | //if attribute's value is an absolute path take this, otherwise append it to data dir |
329 | 329 | //check for / at the beginning or pattern c:\ resp. c:/ |
330 | - if('/' !== $path[0] |
|
330 | + if ('/' !== $path[0] |
|
331 | 331 | && !(3 < strlen($path) && ctype_alpha($path[0]) |
332 | 332 | && $path[1] === ':' && ('\\' === $path[2] || '/' === $path[2])) |
333 | 333 | ) { |
334 | 334 | $path = $this->config->getSystemValue('datadirectory', |
335 | - \OC::$SERVERROOT.'/data') . '/' . $path; |
|
335 | + \OC::$SERVERROOT.'/data').'/'.$path; |
|
336 | 336 | } |
337 | 337 | //we need it to store it in the DB as well in case a user gets |
338 | 338 | //deleted so we can clean up afterwards |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | return $path; |
343 | 343 | } |
344 | 344 | |
345 | - if(!is_null($attr) |
|
345 | + if (!is_null($attr) |
|
346 | 346 | && $this->config->getAppValue('user_ldap', 'enforce_home_folder_naming_rule', true) |
347 | 347 | ) { |
348 | 348 | // a naming rule attribute is defined, but it doesn't exist for that LDAP user |
349 | - throw new \Exception('Home dir attribute can\'t be read from LDAP for uid: ' . $this->getUsername()); |
|
349 | + throw new \Exception('Home dir attribute can\'t be read from LDAP for uid: '.$this->getUsername()); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | //false will apply default behaviour as defined and done by OC_User |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | public function getMemberOfGroups() { |
358 | 358 | $cacheKey = 'getMemberOf'.$this->getUsername(); |
359 | 359 | $memberOfGroups = $this->connection->getFromCache($cacheKey); |
360 | - if(!is_null($memberOfGroups)) { |
|
360 | + if (!is_null($memberOfGroups)) { |
|
361 | 361 | return $memberOfGroups; |
362 | 362 | } |
363 | 363 | $groupDNs = $this->access->readAttribute($this->getDN(), 'memberOf'); |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | * @return string data (provided by LDAP) | false |
371 | 371 | */ |
372 | 372 | public function getAvatarImage() { |
373 | - if(!is_null($this->avatarImage)) { |
|
373 | + if (!is_null($this->avatarImage)) { |
|
374 | 374 | return $this->avatarImage; |
375 | 375 | } |
376 | 376 | |
@@ -378,9 +378,9 @@ discard block |
||
378 | 378 | /** @var Connection $connection */ |
379 | 379 | $connection = $this->access->getConnection(); |
380 | 380 | $attributes = $connection->resolveRule('avatar'); |
381 | - foreach($attributes as $attribute) { |
|
381 | + foreach ($attributes as $attribute) { |
|
382 | 382 | $result = $this->access->readAttribute($this->dn, $attribute); |
383 | - if($result !== false && is_array($result) && isset($result[0])) { |
|
383 | + if ($result !== false && is_array($result) && isset($result[0])) { |
|
384 | 384 | $this->avatarImage = $result[0]; |
385 | 385 | break; |
386 | 386 | } |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | $lastChecked = $this->config->getUserValue($this->uid, 'user_ldap', |
418 | 418 | self::USER_PREFKEY_LASTREFRESH, 0); |
419 | 419 | |
420 | - if((time() - (int)$lastChecked) < (int)$this->config->getAppValue('user_ldap', 'updateAttributesInterval', 86400)) { |
|
420 | + if ((time() - (int) $lastChecked) < (int) $this->config->getAppValue('user_ldap', 'updateAttributesInterval', 86400)) { |
|
421 | 421 | return false; |
422 | 422 | } |
423 | 423 | return true; |
@@ -442,12 +442,12 @@ discard block |
||
442 | 442 | * @return string the effective display name |
443 | 443 | */ |
444 | 444 | public function composeAndStoreDisplayName($displayName, $displayName2 = '') { |
445 | - $displayName2 = (string)$displayName2; |
|
446 | - if($displayName2 !== '') { |
|
447 | - $displayName .= ' (' . $displayName2 . ')'; |
|
445 | + $displayName2 = (string) $displayName2; |
|
446 | + if ($displayName2 !== '') { |
|
447 | + $displayName .= ' ('.$displayName2.')'; |
|
448 | 448 | } |
449 | 449 | $oldName = $this->config->getUserValue($this->uid, 'user_ldap', 'displayName', null); |
450 | - if ($oldName !== $displayName) { |
|
450 | + if ($oldName !== $displayName) { |
|
451 | 451 | $this->store('displayName', $displayName); |
452 | 452 | $user = $this->userManager->get($this->getUsername()); |
453 | 453 | if (!empty($oldName) && $user instanceof \OC\User\User) { |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | * @return bool |
476 | 476 | */ |
477 | 477 | private function wasRefreshed($feature) { |
478 | - if(isset($this->refreshedFeatures[$feature])) { |
|
478 | + if (isset($this->refreshedFeatures[$feature])) { |
|
479 | 479 | return true; |
480 | 480 | } |
481 | 481 | $this->refreshedFeatures[$feature] = 1; |
@@ -488,23 +488,23 @@ discard block |
||
488 | 488 | * @return null |
489 | 489 | */ |
490 | 490 | public function updateEmail($valueFromLDAP = null) { |
491 | - if($this->wasRefreshed('email')) { |
|
491 | + if ($this->wasRefreshed('email')) { |
|
492 | 492 | return; |
493 | 493 | } |
494 | - $email = (string)$valueFromLDAP; |
|
495 | - if(is_null($valueFromLDAP)) { |
|
494 | + $email = (string) $valueFromLDAP; |
|
495 | + if (is_null($valueFromLDAP)) { |
|
496 | 496 | $emailAttribute = $this->connection->ldapEmailAttribute; |
497 | 497 | if ($emailAttribute !== '') { |
498 | 498 | $aEmail = $this->access->readAttribute($this->dn, $emailAttribute); |
499 | - if(is_array($aEmail) && (count($aEmail) > 0)) { |
|
500 | - $email = (string)$aEmail[0]; |
|
499 | + if (is_array($aEmail) && (count($aEmail) > 0)) { |
|
500 | + $email = (string) $aEmail[0]; |
|
501 | 501 | } |
502 | 502 | } |
503 | 503 | } |
504 | 504 | if ($email !== '') { |
505 | 505 | $user = $this->userManager->get($this->uid); |
506 | 506 | if (!is_null($user)) { |
507 | - $currentEmail = (string)$user->getEMailAddress(); |
|
507 | + $currentEmail = (string) $user->getEMailAddress(); |
|
508 | 508 | if ($currentEmail !== $email) { |
509 | 509 | $user->setEMailAddress($email); |
510 | 510 | } |
@@ -533,35 +533,35 @@ discard block |
||
533 | 533 | * @return null |
534 | 534 | */ |
535 | 535 | public function updateQuota($valueFromLDAP = null) { |
536 | - if($this->wasRefreshed('quota')) { |
|
536 | + if ($this->wasRefreshed('quota')) { |
|
537 | 537 | return; |
538 | 538 | } |
539 | 539 | |
540 | 540 | $quotaAttribute = $this->connection->ldapQuotaAttribute; |
541 | 541 | $defaultQuota = $this->connection->ldapQuotaDefault; |
542 | - if($quotaAttribute === '' && $defaultQuota === '') { |
|
542 | + if ($quotaAttribute === '' && $defaultQuota === '') { |
|
543 | 543 | return; |
544 | 544 | } |
545 | 545 | |
546 | 546 | $quota = false; |
547 | - if(is_null($valueFromLDAP) && $quotaAttribute !== '') { |
|
547 | + if (is_null($valueFromLDAP) && $quotaAttribute !== '') { |
|
548 | 548 | $aQuota = $this->access->readAttribute($this->dn, $quotaAttribute); |
549 | - if($aQuota && (count($aQuota) > 0) && $this->verifyQuotaValue($aQuota[0])) { |
|
549 | + if ($aQuota && (count($aQuota) > 0) && $this->verifyQuotaValue($aQuota[0])) { |
|
550 | 550 | $quota = $aQuota[0]; |
551 | - } else if(is_array($aQuota) && isset($aQuota[0])) { |
|
552 | - $this->log->log('no suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', ILogger::DEBUG); |
|
551 | + } else if (is_array($aQuota) && isset($aQuota[0])) { |
|
552 | + $this->log->log('no suitable LDAP quota found for user '.$this->uid.': ['.$aQuota[0].']', ILogger::DEBUG); |
|
553 | 553 | } |
554 | 554 | } else if ($this->verifyQuotaValue($valueFromLDAP)) { |
555 | 555 | $quota = $valueFromLDAP; |
556 | 556 | } else { |
557 | - $this->log->log('no suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', ILogger::DEBUG); |
|
557 | + $this->log->log('no suitable LDAP quota found for user '.$this->uid.': ['.$valueFromLDAP.']', ILogger::DEBUG); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | if ($quota === false && $this->verifyQuotaValue($defaultQuota)) { |
561 | 561 | // quota not found using the LDAP attribute (or not parseable). Try the default quota |
562 | 562 | $quota = $defaultQuota; |
563 | - } else if($quota === false) { |
|
564 | - $this->log->log('no suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', ILogger::DEBUG); |
|
563 | + } else if ($quota === false) { |
|
564 | + $this->log->log('no suitable default quota found for user '.$this->uid.': ['.$defaultQuota.']', ILogger::DEBUG); |
|
565 | 565 | return; |
566 | 566 | } |
567 | 567 | |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | if ($targetUser instanceof IUser) { |
570 | 570 | $targetUser->setQuota($quota); |
571 | 571 | } else { |
572 | - $this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', ILogger::INFO); |
|
572 | + $this->log->log('trying to set a quota for user '.$this->uid.' but the user is missing', ILogger::INFO); |
|
573 | 573 | } |
574 | 574 | } |
575 | 575 | |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | * @param array $params |
584 | 584 | */ |
585 | 585 | public function updateAvatarPostLogin($params) { |
586 | - if(isset($params['uid']) && $params['uid'] === $this->getUsername()) { |
|
586 | + if (isset($params['uid']) && $params['uid'] === $this->getUsername()) { |
|
587 | 587 | $this->updateAvatar(); |
588 | 588 | } |
589 | 589 | } |
@@ -593,29 +593,29 @@ discard block |
||
593 | 593 | * @return bool |
594 | 594 | */ |
595 | 595 | public function updateAvatar($force = false) { |
596 | - if(!$force && $this->wasRefreshed('avatar')) { |
|
596 | + if (!$force && $this->wasRefreshed('avatar')) { |
|
597 | 597 | return false; |
598 | 598 | } |
599 | 599 | $avatarImage = $this->getAvatarImage(); |
600 | - if($avatarImage === false) { |
|
600 | + if ($avatarImage === false) { |
|
601 | 601 | //not set, nothing left to do; |
602 | 602 | return false; |
603 | 603 | } |
604 | 604 | |
605 | - if(!$this->image->loadFromBase64(base64_encode($avatarImage))) { |
|
605 | + if (!$this->image->loadFromBase64(base64_encode($avatarImage))) { |
|
606 | 606 | return false; |
607 | 607 | } |
608 | 608 | |
609 | 609 | // use the checksum before modifications |
610 | 610 | $checksum = md5($this->image->data()); |
611 | 611 | |
612 | - if($checksum === $this->config->getUserValue($this->uid, 'user_ldap', 'lastAvatarChecksum', '')) { |
|
612 | + if ($checksum === $this->config->getUserValue($this->uid, 'user_ldap', 'lastAvatarChecksum', '')) { |
|
613 | 613 | return true; |
614 | 614 | } |
615 | 615 | |
616 | 616 | $isSet = $this->setOwnCloudAvatar(); |
617 | 617 | |
618 | - if($isSet) { |
|
618 | + if ($isSet) { |
|
619 | 619 | // save checksum only after successful setting |
620 | 620 | $this->config->setUserValue($this->uid, 'user_ldap', 'lastAvatarChecksum', $checksum); |
621 | 621 | } |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | * @return bool |
629 | 629 | */ |
630 | 630 | private function setOwnCloudAvatar() { |
631 | - if(!$this->image->valid()) { |
|
631 | + if (!$this->image->valid()) { |
|
632 | 632 | $this->log->log('avatar image data from LDAP invalid for '.$this->dn, ILogger::ERROR); |
633 | 633 | return false; |
634 | 634 | } |
@@ -636,12 +636,12 @@ discard block |
||
636 | 636 | |
637 | 637 | //make sure it is a square and not bigger than 128x128 |
638 | 638 | $size = min([$this->image->width(), $this->image->height(), 128]); |
639 | - if(!$this->image->centerCrop($size)) { |
|
639 | + if (!$this->image->centerCrop($size)) { |
|
640 | 640 | $this->log->log('croping image for avatar failed for '.$this->dn, ILogger::ERROR); |
641 | 641 | return false; |
642 | 642 | } |
643 | 643 | |
644 | - if(!$this->fs->isLoaded()) { |
|
644 | + if (!$this->fs->isLoaded()) { |
|
645 | 645 | $this->fs->setup($this->uid); |
646 | 646 | } |
647 | 647 | |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | return true; |
652 | 652 | } catch (\Exception $e) { |
653 | 653 | \OC::$server->getLogger()->logException($e, [ |
654 | - 'message' => 'Could not set avatar for ' . $this->dn, |
|
654 | + 'message' => 'Could not set avatar for '.$this->dn, |
|
655 | 655 | 'level' => ILogger::INFO, |
656 | 656 | 'app' => 'user_ldap', |
657 | 657 | ]); |
@@ -707,8 +707,8 @@ discard block |
||
707 | 707 | */ |
708 | 708 | public function handlePasswordExpiry($params) { |
709 | 709 | $ppolicyDN = $this->connection->ldapDefaultPPolicyDN; |
710 | - if (empty($ppolicyDN) || ((int)$this->connection->turnOnPasswordChange !== 1)) { |
|
711 | - return;//password expiry handling disabled |
|
710 | + if (empty($ppolicyDN) || ((int) $this->connection->turnOnPasswordChange !== 1)) { |
|
711 | + return; //password expiry handling disabled |
|
712 | 712 | } |
713 | 713 | $uid = $params['uid']; |
714 | 714 | if (isset($uid) && $uid === $this->getUsername()) { |
@@ -717,8 +717,8 @@ discard block |
||
717 | 717 | |
718 | 718 | if (array_key_exists('pwdpolicysubentry', $result[0])) { |
719 | 719 | $pwdPolicySubentry = $result[0]['pwdpolicysubentry']; |
720 | - if ($pwdPolicySubentry && (count($pwdPolicySubentry) > 0)){ |
|
721 | - $ppolicyDN = $pwdPolicySubentry[0];//custom ppolicy DN |
|
720 | + if ($pwdPolicySubentry && (count($pwdPolicySubentry) > 0)) { |
|
721 | + $ppolicyDN = $pwdPolicySubentry[0]; //custom ppolicy DN |
|
722 | 722 | } |
723 | 723 | } |
724 | 724 | |
@@ -727,9 +727,9 @@ discard block |
||
727 | 727 | $pwdChangedTime = array_key_exists('pwdchangedtime', $result[0]) ? $result[0]['pwdchangedtime'] : []; |
728 | 728 | |
729 | 729 | //retrieve relevant password policy attributes |
730 | - $cacheKey = 'ppolicyAttributes' . $ppolicyDN; |
|
730 | + $cacheKey = 'ppolicyAttributes'.$ppolicyDN; |
|
731 | 731 | $result = $this->connection->getFromCache($cacheKey); |
732 | - if(is_null($result)) { |
|
732 | + if (is_null($result)) { |
|
733 | 733 | $result = $this->access->search('objectclass=*', [$ppolicyDN], ['pwdgraceauthnlimit', 'pwdmaxage', 'pwdexpirewarning']); |
734 | 734 | $this->connection->writeToCache($cacheKey, $result); |
735 | 735 | } |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | //handle grace login |
742 | 742 | if (!empty($pwdGraceUseTime)) { //was this a grace login? |
743 | 743 | if (!empty($pwdGraceAuthNLimit) |
744 | - && count($pwdGraceUseTime) < (int)$pwdGraceAuthNLimit[0]) { //at least one more grace login available? |
|
744 | + && count($pwdGraceUseTime) < (int) $pwdGraceAuthNLimit[0]) { //at least one more grace login available? |
|
745 | 745 | $this->config->setUserValue($uid, 'user_ldap', 'needsPasswordReset', 'true'); |
746 | 746 | header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute( |
747 | 747 | 'user_ldap.renewPassword.showRenewPasswordForm', ['user' => $uid])); |
@@ -762,9 +762,9 @@ discard block |
||
762 | 762 | if (!empty($pwdChangedTime)) { |
763 | 763 | if (!empty($pwdMaxAge) |
764 | 764 | && !empty($pwdExpireWarning)) { |
765 | - $pwdMaxAgeInt = (int)$pwdMaxAge[0]; |
|
766 | - $pwdExpireWarningInt = (int)$pwdExpireWarning[0]; |
|
767 | - if ($pwdMaxAgeInt > 0 && $pwdExpireWarningInt > 0){ |
|
765 | + $pwdMaxAgeInt = (int) $pwdMaxAge[0]; |
|
766 | + $pwdExpireWarningInt = (int) $pwdExpireWarning[0]; |
|
767 | + if ($pwdMaxAgeInt > 0 && $pwdExpireWarningInt > 0) { |
|
768 | 768 | $pwdChangedTimeDt = \DateTime::createFromFormat('YmdHisZ', $pwdChangedTime[0]); |
769 | 769 | $pwdChangedTimeDt->add(new \DateInterval('PT'.$pwdMaxAgeInt.'S')); |
770 | 770 | $currentDateTime = new \DateTime(); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $keys = $this->getServersConfig($referenceConfigkey); |
102 | 102 | |
103 | 103 | $result = []; |
104 | - foreach($keys as $key) { |
|
104 | + foreach ($keys as $key) { |
|
105 | 105 | $len = strlen($key) - strlen($referenceConfigkey); |
106 | 106 | $prefix = substr($key, 0, $len); |
107 | 107 | $result[$prefix] = $this->config->getAppValue('user_ldap', $key); |
@@ -118,18 +118,18 @@ discard block |
||
118 | 118 | public function getNextServerConfigurationPrefix() { |
119 | 119 | $serverConnections = $this->getServerConfigurationPrefixes(); |
120 | 120 | |
121 | - if(count($serverConnections) === 0) { |
|
121 | + if (count($serverConnections) === 0) { |
|
122 | 122 | return 's01'; |
123 | 123 | } |
124 | 124 | |
125 | 125 | sort($serverConnections); |
126 | 126 | $lastKey = array_pop($serverConnections); |
127 | - $lastNumber = (int)str_replace('s', '', $lastKey); |
|
128 | - return 's' . str_pad($lastNumber + 1, 2, '0', STR_PAD_LEFT); |
|
127 | + $lastNumber = (int) str_replace('s', '', $lastKey); |
|
128 | + return 's'.str_pad($lastNumber + 1, 2, '0', STR_PAD_LEFT); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | private function getServersConfig($value) { |
132 | - $regex = '/' . $value . '$/S'; |
|
132 | + $regex = '/'.$value.'$/S'; |
|
133 | 133 | |
134 | 134 | $keys = $this->config->getAppKeys('user_ldap'); |
135 | 135 | $result = []; |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | * @return bool true on success, false otherwise |
149 | 149 | */ |
150 | 150 | public function deleteServerConfiguration($prefix) { |
151 | - if(!in_array($prefix, self::getServerConfigurationPrefixes())) { |
|
151 | + if (!in_array($prefix, self::getServerConfigurationPrefixes())) { |
|
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | |
155 | 155 | $saveOtherConfigurations = ''; |
156 | - if(empty($prefix)) { |
|
156 | + if (empty($prefix)) { |
|
157 | 157 | $saveOtherConfigurations = 'AND `configkey` NOT LIKE \'s%\''; |
158 | 158 | } |
159 | 159 | |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | '); |
168 | 168 | $delRows = $query->execute([$prefix.'%']); |
169 | 169 | |
170 | - if($delRows === null) { |
|
170 | + if ($delRows === null) { |
|
171 | 171 | return false; |
172 | 172 | } |
173 | 173 | |
174 | - if($delRows === 0) { |
|
174 | + if ($delRows === 0) { |
|
175 | 175 | return false; |
176 | 176 | } |
177 | 177 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $all = $this->getServerConfigurationPrefixes(false); |
188 | 188 | $active = $this->getServerConfigurationPrefixes(true); |
189 | 189 | |
190 | - if(!is_array($all) || !is_array($active)) { |
|
190 | + if (!is_array($all) || !is_array($active)) { |
|
191 | 191 | throw new \Exception('Unexpected Return Value'); |
192 | 192 | } |
193 | 193 | |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function getDomainFromURL($url) { |
203 | 203 | $uinfo = parse_url($url); |
204 | - if(!is_array($uinfo)) { |
|
204 | + if (!is_array($uinfo)) { |
|
205 | 205 | return false; |
206 | 206 | } |
207 | 207 | |
208 | 208 | $domain = false; |
209 | - if(isset($uinfo['host'])) { |
|
209 | + if (isset($uinfo['host'])) { |
|
210 | 210 | $domain = $uinfo['host']; |
211 | - } else if(isset($uinfo['path'])) { |
|
211 | + } else if (isset($uinfo['path'])) { |
|
212 | 212 | $domain = $uinfo['path']; |
213 | 213 | } |
214 | 214 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function setLDAPProvider() { |
224 | 224 | $current = \OC::$server->getConfig()->getSystemValue('ldapProviderFactory', null); |
225 | - if(is_null($current)) { |
|
225 | + if (is_null($current)) { |
|
226 | 226 | \OC::$server->getConfig()->setSystemValue('ldapProviderFactory', LDAPProviderFactory::class); |
227 | 227 | } |
228 | 228 | } |
@@ -234,9 +234,9 @@ discard block |
||
234 | 234 | */ |
235 | 235 | public function sanitizeDN($dn) { |
236 | 236 | //treating multiple base DNs |
237 | - if(is_array($dn)) { |
|
237 | + if (is_array($dn)) { |
|
238 | 238 | $result = []; |
239 | - foreach($dn as $singleDN) { |
|
239 | + foreach ($dn as $singleDN) { |
|
240 | 240 | $result[] = $this->sanitizeDN($singleDN); |
241 | 241 | } |
242 | 242 | return $result; |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @throws \Exception |
288 | 288 | */ |
289 | 289 | public static function loginName2UserName($param) { |
290 | - if(!isset($param['uid'])) { |
|
290 | + if (!isset($param['uid'])) { |
|
291 | 291 | throw new \Exception('key uid is expected to be set in $param'); |
292 | 292 | } |
293 | 293 | |
@@ -302,11 +302,11 @@ discard block |
||
302 | 302 | $userSession = \OC::$server->getUserSession(); |
303 | 303 | $userPluginManager = \OC::$server->query('LDAPUserPluginManager'); |
304 | 304 | |
305 | - $userBackend = new User_Proxy( |
|
305 | + $userBackend = new User_Proxy( |
|
306 | 306 | $configPrefixes, $ldapWrapper, $ocConfig, $notificationManager, $userSession, $userPluginManager |
307 | 307 | ); |
308 | 308 | $uid = $userBackend->loginName2UserName($param['uid']); |
309 | - if($uid !== false) { |
|
309 | + if ($uid !== false) { |
|
310 | 310 | $param['uid'] = $uid; |
311 | 311 | } |
312 | 312 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $this->deletedUsersIndex = $deletedUsersIndex; |
58 | 58 | $userBackendFound = false; |
59 | 59 | $groupBackendFound = false; |
60 | - foreach ($serverContainer->getUserManager()->getBackends() as $backend){ |
|
60 | + foreach ($serverContainer->getUserManager()->getBackends() as $backend) { |
|
61 | 61 | $this->logger->debug('instance '.get_class($backend).' user backend.', ['app' => 'user_ldap']); |
62 | 62 | if ($backend instanceof IUserLDAP) { |
63 | 63 | $this->userBackend = $backend; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | break; |
66 | 66 | } |
67 | 67 | } |
68 | - foreach ($serverContainer->getGroupManager()->getBackends() as $backend){ |
|
68 | + foreach ($serverContainer->getGroupManager()->getBackends() as $backend) { |
|
69 | 69 | $this->logger->debug('instance '.get_class($backend).' group backend.', ['app' => 'user_ldap']); |
70 | 70 | if ($backend instanceof IGroupLDAP) { |
71 | 71 | $this->groupBackend = $backend; |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | * @throws \Exception if translation was unsuccessful |
87 | 87 | */ |
88 | 88 | public function getUserDN($uid) { |
89 | - if(!$this->userBackend->userExists($uid)){ |
|
89 | + if (!$this->userBackend->userExists($uid)) { |
|
90 | 90 | throw new \Exception('User id not found in LDAP'); |
91 | 91 | } |
92 | 92 | $result = $this->userBackend->getLDAPAccess($uid)->username2dn($uid); |
93 | - if(!$result){ |
|
93 | + if (!$result) { |
|
94 | 94 | throw new \Exception('Translation to LDAP DN unsuccessful'); |
95 | 95 | } |
96 | 96 | return $result; |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | * @throws \Exception |
104 | 104 | */ |
105 | 105 | public function getGroupDN($gid) { |
106 | - if(!$this->groupBackend->groupExists($gid)){ |
|
106 | + if (!$this->groupBackend->groupExists($gid)) { |
|
107 | 107 | throw new \Exception('Group id not found in LDAP'); |
108 | 108 | } |
109 | 109 | $result = $this->groupBackend->getLDAPAccess($gid)->groupname2dn($gid); |
110 | - if(!$result){ |
|
110 | + if (!$result) { |
|
111 | 111 | throw new \Exception('Translation to LDAP DN unsuccessful'); |
112 | 112 | } |
113 | 113 | return $result; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function getUserName($dn) { |
124 | 124 | $result = $this->userBackend->dn2UserName($dn); |
125 | - if(!$result){ |
|
125 | + if (!$result) { |
|
126 | 126 | throw new \Exception('Translation to internal user name unsuccessful'); |
127 | 127 | } |
128 | 128 | return $result; |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @throws \Exception if user id was not found in LDAP |
155 | 155 | */ |
156 | 156 | public function getLDAPConnection($uid) { |
157 | - if(!$this->userBackend->userExists($uid)){ |
|
157 | + if (!$this->userBackend->userExists($uid)) { |
|
158 | 158 | throw new \Exception('User id not found in LDAP'); |
159 | 159 | } |
160 | 160 | return $this->userBackend->getNewLDAPConnection($uid); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @throws \Exception if group id was not found in LDAP |
169 | 169 | */ |
170 | 170 | public function getGroupLDAPConnection($gid) { |
171 | - if(!$this->groupBackend->groupExists($gid)){ |
|
171 | + if (!$this->groupBackend->groupExists($gid)) { |
|
172 | 172 | throw new \Exception('Group id not found in LDAP'); |
173 | 173 | } |
174 | 174 | return $this->groupBackend->getNewLDAPConnection($gid); |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | * @throws \Exception if user id was not found in LDAP |
182 | 182 | */ |
183 | 183 | public function getLDAPBaseUsers($uid) { |
184 | - if(!$this->userBackend->userExists($uid)){ |
|
184 | + if (!$this->userBackend->userExists($uid)) { |
|
185 | 185 | throw new \Exception('User id not found in LDAP'); |
186 | 186 | } |
187 | 187 | $access = $this->userBackend->getLDAPAccess($uid); |
188 | 188 | $bases = $access->getConnection()->ldapBaseUsers; |
189 | 189 | $dn = $this->getUserDN($uid); |
190 | 190 | foreach ($bases as $base) { |
191 | - if($access->isDNPartOfBase($dn, [$base])) { |
|
191 | + if ($access->isDNPartOfBase($dn, [$base])) { |
|
192 | 192 | return $base; |
193 | 193 | } |
194 | 194 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @throws \Exception if user id was not found in LDAP |
212 | 212 | */ |
213 | 213 | public function getLDAPBaseGroups($uid) { |
214 | - if(!$this->userBackend->userExists($uid)){ |
|
214 | + if (!$this->userBackend->userExists($uid)) { |
|
215 | 215 | throw new \Exception('User id not found in LDAP'); |
216 | 216 | } |
217 | 217 | $bases = $this->userBackend->getLDAPAccess($uid)->getConnection()->ldapBaseGroups; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @throws \Exception if user id was not found in LDAP |
225 | 225 | */ |
226 | 226 | public function clearCache($uid) { |
227 | - if(!$this->userBackend->userExists($uid)){ |
|
227 | + if (!$this->userBackend->userExists($uid)) { |
|
228 | 228 | throw new \Exception('User id not found in LDAP'); |
229 | 229 | } |
230 | 230 | $this->userBackend->getLDAPAccess($uid)->getConnection()->clearCache(); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @throws \Exception if user id was not found in LDAP |
238 | 238 | */ |
239 | 239 | public function clearGroupCache($gid) { |
240 | - if(!$this->groupBackend->groupExists($gid)){ |
|
240 | + if (!$this->groupBackend->groupExists($gid)) { |
|
241 | 241 | throw new \Exception('Group id not found in LDAP'); |
242 | 242 | } |
243 | 243 | $this->groupBackend->getLDAPAccess($gid)->getConnection()->clearCache(); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * @throws \Exception if user id was not found in LDAP |
277 | 277 | */ |
278 | 278 | public function getLDAPDisplayNameField($uid) { |
279 | - if(!$this->userBackend->userExists($uid)){ |
|
279 | + if (!$this->userBackend->userExists($uid)) { |
|
280 | 280 | throw new \Exception('User id not found in LDAP'); |
281 | 281 | } |
282 | 282 | return $this->userBackend->getLDAPAccess($uid)->getConnection()->getConfiguration()['ldap_display_name']; |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @throws \Exception if user id was not found in LDAP |
290 | 290 | */ |
291 | 291 | public function getLDAPEmailField($uid) { |
292 | - if(!$this->userBackend->userExists($uid)){ |
|
292 | + if (!$this->userBackend->userExists($uid)) { |
|
293 | 293 | throw new \Exception('User id not found in LDAP'); |
294 | 294 | } |
295 | 295 | return $this->userBackend->getLDAPAccess($uid)->getConnection()->getConfiguration()['ldap_email_attr']; |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @throws \Exception if group id was not found in LDAP |
303 | 303 | */ |
304 | 304 | public function getLDAPGroupMemberAssoc($gid) { |
305 | - if(!$this->groupBackend->groupExists($gid)){ |
|
305 | + if (!$this->groupBackend->groupExists($gid)) { |
|
306 | 306 | throw new \Exception('Group id not found in LDAP'); |
307 | 307 | } |
308 | 308 | return $this->groupBackend->getLDAPAccess($gid)->getConnection()->getConfiguration()['ldap_group_member_assoc_attribute']; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @return AbstractMapping |
135 | 135 | */ |
136 | 136 | public function getUserMapper() { |
137 | - if(is_null($this->userMapper)) { |
|
137 | + if (is_null($this->userMapper)) { |
|
138 | 138 | throw new \Exception('UserMapper was not assigned to this Access instance.'); |
139 | 139 | } |
140 | 140 | return $this->userMapper; |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @return AbstractMapping |
155 | 155 | */ |
156 | 156 | public function getGroupMapper() { |
157 | - if(is_null($this->groupMapper)) { |
|
157 | + if (is_null($this->groupMapper)) { |
|
158 | 158 | throw new \Exception('GroupMapper was not assigned to this Access instance.'); |
159 | 159 | } |
160 | 160 | return $this->groupMapper; |
@@ -187,14 +187,14 @@ discard block |
||
187 | 187 | * @throws ServerNotAvailableException |
188 | 188 | */ |
189 | 189 | public function readAttribute($dn, $attr, $filter = 'objectClass=*') { |
190 | - if(!$this->checkConnection()) { |
|
190 | + if (!$this->checkConnection()) { |
|
191 | 191 | \OCP\Util::writeLog('user_ldap', |
192 | 192 | 'No LDAP Connector assigned, access impossible for readAttribute.', |
193 | 193 | ILogger::WARN); |
194 | 194 | return false; |
195 | 195 | } |
196 | 196 | $cr = $this->connection->getConnectionResource(); |
197 | - if(!$this->ldap->isResource($cr)) { |
|
197 | + if (!$this->ldap->isResource($cr)) { |
|
198 | 198 | //LDAP not available |
199 | 199 | \OCP\Util::writeLog('user_ldap', 'LDAP resource not available.', ILogger::DEBUG); |
200 | 200 | return false; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $this->abandonPagedSearch(); |
205 | 205 | // openLDAP requires that we init a new Paged Search. Not needed by AD, |
206 | 206 | // but does not hurt either. |
207 | - $pagingSize = (int)$this->connection->ldapPagingSize; |
|
207 | + $pagingSize = (int) $this->connection->ldapPagingSize; |
|
208 | 208 | // 0 won't result in replies, small numbers may leave out groups |
209 | 209 | // (cf. #12306), 500 is default for paging and should work everywhere. |
210 | 210 | $maxResults = $pagingSize > 20 ? $pagingSize : 500; |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $isRangeRequest = false; |
218 | 218 | do { |
219 | 219 | $result = $this->executeRead($cr, $dn, $attrToRead, $filter, $maxResults); |
220 | - if(is_bool($result)) { |
|
220 | + if (is_bool($result)) { |
|
221 | 221 | // when an exists request was run and it was successful, an empty |
222 | 222 | // array must be returned |
223 | 223 | return $result ? [] : false; |
@@ -234,22 +234,22 @@ discard block |
||
234 | 234 | $result = $this->extractRangeData($result, $attr); |
235 | 235 | if (!empty($result)) { |
236 | 236 | $normalizedResult = $this->extractAttributeValuesFromResult( |
237 | - [ $attr => $result['values'] ], |
|
237 | + [$attr => $result['values']], |
|
238 | 238 | $attr |
239 | 239 | ); |
240 | 240 | $values = array_merge($values, $normalizedResult); |
241 | 241 | |
242 | - if($result['rangeHigh'] === '*') { |
|
242 | + if ($result['rangeHigh'] === '*') { |
|
243 | 243 | // when server replies with * as high range value, there are |
244 | 244 | // no more results left |
245 | 245 | return $values; |
246 | 246 | } else { |
247 | - $low = $result['rangeHigh'] + 1; |
|
248 | - $attrToRead = $result['attributeName'] . ';range=' . $low . '-*'; |
|
247 | + $low = $result['rangeHigh'] + 1; |
|
248 | + $attrToRead = $result['attributeName'].';range='.$low.'-*'; |
|
249 | 249 | $isRangeRequest = true; |
250 | 250 | } |
251 | 251 | } |
252 | - } while($isRangeRequest); |
|
252 | + } while ($isRangeRequest); |
|
253 | 253 | |
254 | 254 | \OCP\Util::writeLog('user_ldap', 'Requested attribute '.$attr.' not found for '.$dn, ILogger::DEBUG); |
255 | 255 | return false; |
@@ -275,13 +275,13 @@ discard block |
||
275 | 275 | if (!$this->ldap->isResource($rr)) { |
276 | 276 | if ($attribute !== '') { |
277 | 277 | //do not throw this message on userExists check, irritates |
278 | - \OCP\Util::writeLog('user_ldap', 'readAttribute failed for DN ' . $dn, ILogger::DEBUG); |
|
278 | + \OCP\Util::writeLog('user_ldap', 'readAttribute failed for DN '.$dn, ILogger::DEBUG); |
|
279 | 279 | } |
280 | 280 | //in case an error occurs , e.g. object does not exist |
281 | 281 | return false; |
282 | 282 | } |
283 | 283 | if ($attribute === '' && ($filter === 'objectclass=*' || $this->invokeLDAPMethod('countEntries', $cr, $rr) === 1)) { |
284 | - \OCP\Util::writeLog('user_ldap', 'readAttribute: ' . $dn . ' found', ILogger::DEBUG); |
|
284 | + \OCP\Util::writeLog('user_ldap', 'readAttribute: '.$dn.' found', ILogger::DEBUG); |
|
285 | 285 | return true; |
286 | 286 | } |
287 | 287 | $er = $this->invokeLDAPMethod('firstEntry', $cr, $rr); |
@@ -306,12 +306,12 @@ discard block |
||
306 | 306 | */ |
307 | 307 | public function extractAttributeValuesFromResult($result, $attribute) { |
308 | 308 | $values = []; |
309 | - if(isset($result[$attribute]) && $result[$attribute]['count'] > 0) { |
|
309 | + if (isset($result[$attribute]) && $result[$attribute]['count'] > 0) { |
|
310 | 310 | $lowercaseAttribute = strtolower($attribute); |
311 | - for($i=0;$i<$result[$attribute]['count'];$i++) { |
|
312 | - if($this->resemblesDN($attribute)) { |
|
311 | + for ($i = 0; $i < $result[$attribute]['count']; $i++) { |
|
312 | + if ($this->resemblesDN($attribute)) { |
|
313 | 313 | $values[] = $this->helper->sanitizeDN($result[$attribute][$i]); |
314 | - } elseif($lowercaseAttribute === 'objectguid' || $lowercaseAttribute === 'guid') { |
|
314 | + } elseif ($lowercaseAttribute === 'objectguid' || $lowercaseAttribute === 'guid') { |
|
315 | 315 | $values[] = $this->convertObjectGUID2Str($result[$attribute][$i]); |
316 | 316 | } else { |
317 | 317 | $values[] = $result[$attribute][$i]; |
@@ -333,10 +333,10 @@ discard block |
||
333 | 333 | */ |
334 | 334 | public function extractRangeData($result, $attribute) { |
335 | 335 | $keys = array_keys($result); |
336 | - foreach($keys as $key) { |
|
337 | - if($key !== $attribute && strpos($key, $attribute) === 0) { |
|
336 | + foreach ($keys as $key) { |
|
337 | + if ($key !== $attribute && strpos($key, $attribute) === 0) { |
|
338 | 338 | $queryData = explode(';', $key); |
339 | - if(strpos($queryData[1], 'range=') === 0) { |
|
339 | + if (strpos($queryData[1], 'range=') === 0) { |
|
340 | 340 | $high = substr($queryData[1], 1 + strpos($queryData[1], '-')); |
341 | 341 | $data = [ |
342 | 342 | 'values' => $result[$key], |
@@ -361,11 +361,11 @@ discard block |
||
361 | 361 | * @throws \Exception |
362 | 362 | */ |
363 | 363 | public function setPassword($userDN, $password) { |
364 | - if((int)$this->connection->turnOnPasswordChange !== 1) { |
|
364 | + if ((int) $this->connection->turnOnPasswordChange !== 1) { |
|
365 | 365 | throw new \Exception('LDAP password changes are disabled.'); |
366 | 366 | } |
367 | 367 | $cr = $this->connection->getConnectionResource(); |
368 | - if(!$this->ldap->isResource($cr)) { |
|
368 | + if (!$this->ldap->isResource($cr)) { |
|
369 | 369 | //LDAP not available |
370 | 370 | \OCP\Util::writeLog('user_ldap', 'LDAP resource not available.', ILogger::DEBUG); |
371 | 371 | return false; |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | // try PASSWD extended operation first |
375 | 375 | return @$this->invokeLDAPMethod('exopPasswd', $cr, $userDN, '', $password) || |
376 | 376 | @$this->invokeLDAPMethod('modReplace', $cr, $userDN, $password); |
377 | - } catch(ConstraintViolationException $e) { |
|
377 | + } catch (ConstraintViolationException $e) { |
|
378 | 378 | throw new HintException('Password change rejected.', \OC::$server->getL10N('user_ldap')->t('Password change rejected. Hint: ').$e->getMessage(), $e->getCode()); |
379 | 379 | } |
380 | 380 | } |
@@ -416,17 +416,17 @@ discard block |
||
416 | 416 | */ |
417 | 417 | public function getDomainDNFromDN($dn) { |
418 | 418 | $allParts = $this->ldap->explodeDN($dn, 0); |
419 | - if($allParts === false) { |
|
419 | + if ($allParts === false) { |
|
420 | 420 | //not a valid DN |
421 | 421 | return ''; |
422 | 422 | } |
423 | 423 | $domainParts = []; |
424 | 424 | $dcFound = false; |
425 | - foreach($allParts as $part) { |
|
426 | - if(!$dcFound && strpos($part, 'dc=') === 0) { |
|
425 | + foreach ($allParts as $part) { |
|
426 | + if (!$dcFound && strpos($part, 'dc=') === 0) { |
|
427 | 427 | $dcFound = true; |
428 | 428 | } |
429 | - if($dcFound) { |
|
429 | + if ($dcFound) { |
|
430 | 430 | $domainParts[] = $part; |
431 | 431 | } |
432 | 432 | } |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | |
453 | 453 | //Check whether the DN belongs to the Base, to avoid issues on multi- |
454 | 454 | //server setups |
455 | - if(is_string($fdn) && $this->isDNPartOfBase($fdn, $this->connection->ldapBaseUsers)) { |
|
455 | + if (is_string($fdn) && $this->isDNPartOfBase($fdn, $this->connection->ldapBaseUsers)) { |
|
456 | 456 | return $fdn; |
457 | 457 | } |
458 | 458 | |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | //To avoid bypassing the base DN settings under certain circumstances |
472 | 472 | //with the group support, check whether the provided DN matches one of |
473 | 473 | //the given Bases |
474 | - if(!$this->isDNPartOfBase($fdn, $this->connection->ldapBaseGroups)) { |
|
474 | + if (!$this->isDNPartOfBase($fdn, $this->connection->ldapBaseGroups)) { |
|
475 | 475 | return false; |
476 | 476 | } |
477 | 477 | |
@@ -489,11 +489,11 @@ discard block |
||
489 | 489 | */ |
490 | 490 | public function groupsMatchFilter($groupDNs) { |
491 | 491 | $validGroupDNs = []; |
492 | - foreach($groupDNs as $dn) { |
|
492 | + foreach ($groupDNs as $dn) { |
|
493 | 493 | $cacheKey = 'groupsMatchFilter-'.$dn; |
494 | 494 | $groupMatchFilter = $this->connection->getFromCache($cacheKey); |
495 | - if(!is_null($groupMatchFilter)) { |
|
496 | - if($groupMatchFilter) { |
|
495 | + if (!is_null($groupMatchFilter)) { |
|
496 | + if ($groupMatchFilter) { |
|
497 | 497 | $validGroupDNs[] = $dn; |
498 | 498 | } |
499 | 499 | continue; |
@@ -501,13 +501,13 @@ discard block |
||
501 | 501 | |
502 | 502 | // Check the base DN first. If this is not met already, we don't |
503 | 503 | // need to ask the server at all. |
504 | - if(!$this->isDNPartOfBase($dn, $this->connection->ldapBaseGroups)) { |
|
504 | + if (!$this->isDNPartOfBase($dn, $this->connection->ldapBaseGroups)) { |
|
505 | 505 | $this->connection->writeToCache($cacheKey, false); |
506 | 506 | continue; |
507 | 507 | } |
508 | 508 | |
509 | 509 | $result = $this->readAttribute($dn, '', $this->connection->ldapGroupFilter); |
510 | - if(is_array($result)) { |
|
510 | + if (is_array($result)) { |
|
511 | 511 | $this->connection->writeToCache($cacheKey, true); |
512 | 512 | $validGroupDNs[] = $dn; |
513 | 513 | } else { |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | //To avoid bypassing the base DN settings under certain circumstances |
531 | 531 | //with the group support, check whether the provided DN matches one of |
532 | 532 | //the given Bases |
533 | - if(!$this->isDNPartOfBase($fdn, $this->connection->ldapBaseUsers)) { |
|
533 | + if (!$this->isDNPartOfBase($fdn, $this->connection->ldapBaseUsers)) { |
|
534 | 534 | return false; |
535 | 535 | } |
536 | 536 | |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | */ |
551 | 551 | public function dn2ocname($fdn, $ldapName = null, $isUser = true, &$newlyMapped = null, array $record = null) { |
552 | 552 | $newlyMapped = false; |
553 | - if($isUser) { |
|
553 | + if ($isUser) { |
|
554 | 554 | $mapper = $this->getUserMapper(); |
555 | 555 | $nameAttribute = $this->connection->ldapUserDisplayName; |
556 | 556 | $filter = $this->connection->ldapUserFilter; |
@@ -562,15 +562,15 @@ discard block |
||
562 | 562 | |
563 | 563 | //let's try to retrieve the Nextcloud name from the mappings table |
564 | 564 | $ncName = $mapper->getNameByDN($fdn); |
565 | - if(is_string($ncName)) { |
|
565 | + if (is_string($ncName)) { |
|
566 | 566 | return $ncName; |
567 | 567 | } |
568 | 568 | |
569 | 569 | //second try: get the UUID and check if it is known. Then, update the DN and return the name. |
570 | 570 | $uuid = $this->getUUID($fdn, $isUser, $record); |
571 | - if(is_string($uuid)) { |
|
571 | + if (is_string($uuid)) { |
|
572 | 572 | $ncName = $mapper->getNameByUUID($uuid); |
573 | - if(is_string($ncName)) { |
|
573 | + if (is_string($ncName)) { |
|
574 | 574 | $mapper->setDNbyUUID($fdn, $uuid); |
575 | 575 | return $ncName; |
576 | 576 | } |
@@ -580,17 +580,17 @@ discard block |
||
580 | 580 | return false; |
581 | 581 | } |
582 | 582 | |
583 | - if(is_null($ldapName)) { |
|
583 | + if (is_null($ldapName)) { |
|
584 | 584 | $ldapName = $this->readAttribute($fdn, $nameAttribute, $filter); |
585 | - if(!isset($ldapName[0]) && empty($ldapName[0])) { |
|
585 | + if (!isset($ldapName[0]) && empty($ldapName[0])) { |
|
586 | 586 | \OCP\Util::writeLog('user_ldap', 'No or empty name for '.$fdn.' with filter '.$filter.'.', ILogger::INFO); |
587 | 587 | return false; |
588 | 588 | } |
589 | 589 | $ldapName = $ldapName[0]; |
590 | 590 | } |
591 | 591 | |
592 | - if($isUser) { |
|
593 | - $usernameAttribute = (string)$this->connection->ldapExpertUsernameAttr; |
|
592 | + if ($isUser) { |
|
593 | + $usernameAttribute = (string) $this->connection->ldapExpertUsernameAttr; |
|
594 | 594 | if ($usernameAttribute !== '') { |
595 | 595 | $username = $this->readAttribute($fdn, $usernameAttribute); |
596 | 596 | $username = $username[0]; |
@@ -620,14 +620,14 @@ discard block |
||
620 | 620 | // outside of core user management will still cache the user as non-existing. |
621 | 621 | $originalTTL = $this->connection->ldapCacheTTL; |
622 | 622 | $this->connection->setConfiguration(['ldapCacheTTL' => 0]); |
623 | - if($intName !== '' |
|
623 | + if ($intName !== '' |
|
624 | 624 | && (($isUser && !$this->ncUserManager->userExists($intName)) |
625 | 625 | || (!$isUser && !\OC::$server->getGroupManager()->groupExists($intName)) |
626 | 626 | ) |
627 | 627 | ) { |
628 | 628 | $this->connection->setConfiguration(['ldapCacheTTL' => $originalTTL]); |
629 | 629 | $newlyMapped = $this->mapAndAnnounceIfApplicable($mapper, $fdn, $intName, $uuid, $isUser); |
630 | - if($newlyMapped) { |
|
630 | + if ($newlyMapped) { |
|
631 | 631 | return $intName; |
632 | 632 | } |
633 | 633 | } |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | $this->connection->setConfiguration(['ldapCacheTTL' => $originalTTL]); |
636 | 636 | $altName = $this->createAltInternalOwnCloudName($intName, $isUser); |
637 | 637 | if (is_string($altName)) { |
638 | - if($this->mapAndAnnounceIfApplicable($mapper, $fdn, $altName, $uuid, $isUser)) { |
|
638 | + if ($this->mapAndAnnounceIfApplicable($mapper, $fdn, $altName, $uuid, $isUser)) { |
|
639 | 639 | $newlyMapped = true; |
640 | 640 | return $altName; |
641 | 641 | } |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | string $uuid, |
654 | 654 | bool $isUser |
655 | 655 | ) :bool { |
656 | - if($mapper->map($fdn, $name, $uuid)) { |
|
656 | + if ($mapper->map($fdn, $name, $uuid)) { |
|
657 | 657 | if ($this->ncUserManager instanceof PublicEmitter && $isUser) { |
658 | 658 | $this->cacheUserExists($name); |
659 | 659 | $this->ncUserManager->emit('\OC\User', 'assignedUserId', [$name]); |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | * @throws \Exception |
699 | 699 | */ |
700 | 700 | private function ldap2NextcloudNames($ldapObjects, $isUsers) { |
701 | - if($isUsers) { |
|
701 | + if ($isUsers) { |
|
702 | 702 | $nameAttribute = $this->connection->ldapUserDisplayName; |
703 | 703 | $sndAttribute = $this->connection->ldapUserDisplayName2; |
704 | 704 | } else { |
@@ -706,9 +706,9 @@ discard block |
||
706 | 706 | } |
707 | 707 | $nextcloudNames = []; |
708 | 708 | |
709 | - foreach($ldapObjects as $ldapObject) { |
|
709 | + foreach ($ldapObjects as $ldapObject) { |
|
710 | 710 | $nameByLDAP = null; |
711 | - if(isset($ldapObject[$nameAttribute]) |
|
711 | + if (isset($ldapObject[$nameAttribute]) |
|
712 | 712 | && is_array($ldapObject[$nameAttribute]) |
713 | 713 | && isset($ldapObject[$nameAttribute][0]) |
714 | 714 | ) { |
@@ -717,19 +717,19 @@ discard block |
||
717 | 717 | } |
718 | 718 | |
719 | 719 | $ncName = $this->dn2ocname($ldapObject['dn'][0], $nameByLDAP, $isUsers); |
720 | - if($ncName) { |
|
720 | + if ($ncName) { |
|
721 | 721 | $nextcloudNames[] = $ncName; |
722 | - if($isUsers) { |
|
722 | + if ($isUsers) { |
|
723 | 723 | $this->updateUserState($ncName); |
724 | 724 | //cache the user names so it does not need to be retrieved |
725 | 725 | //again later (e.g. sharing dialogue). |
726 | - if(is_null($nameByLDAP)) { |
|
726 | + if (is_null($nameByLDAP)) { |
|
727 | 727 | continue; |
728 | 728 | } |
729 | 729 | $sndName = isset($ldapObject[$sndAttribute][0]) |
730 | 730 | ? $ldapObject[$sndAttribute][0] : ''; |
731 | 731 | $this->cacheUserDisplayName($ncName, $nameByLDAP, $sndName); |
732 | - } else if($nameByLDAP !== null) { |
|
732 | + } else if ($nameByLDAP !== null) { |
|
733 | 733 | $this->cacheGroupDisplayName($ncName, $nameByLDAP); |
734 | 734 | } |
735 | 735 | } |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | */ |
746 | 746 | public function updateUserState($ncname) { |
747 | 747 | $user = $this->userManager->get($ncname); |
748 | - if($user instanceof OfflineUser) { |
|
748 | + if ($user instanceof OfflineUser) { |
|
749 | 749 | $user->unmark(); |
750 | 750 | } |
751 | 751 | } |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | */ |
786 | 786 | public function cacheUserDisplayName($ocName, $displayName, $displayName2 = '') { |
787 | 787 | $user = $this->userManager->get($ocName); |
788 | - if($user === null) { |
|
788 | + if ($user === null) { |
|
789 | 789 | return; |
790 | 790 | } |
791 | 791 | $displayName = $user->composeAndStoreDisplayName($displayName, $displayName2); |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | } |
795 | 795 | |
796 | 796 | public function cacheGroupDisplayName(string $ncName, string $displayName): void { |
797 | - $cacheKey = 'group_getDisplayName' . $ncName; |
|
797 | + $cacheKey = 'group_getDisplayName'.$ncName; |
|
798 | 798 | $this->connection->writeToCache($cacheKey, $displayName); |
799 | 799 | } |
800 | 800 | |
@@ -810,9 +810,9 @@ discard block |
||
810 | 810 | $attempts = 0; |
811 | 811 | //while loop is just a precaution. If a name is not generated within |
812 | 812 | //20 attempts, something else is very wrong. Avoids infinite loop. |
813 | - while($attempts < 20){ |
|
814 | - $altName = $name . '_' . rand(1000,9999); |
|
815 | - if(!$this->ncUserManager->userExists($altName)) { |
|
813 | + while ($attempts < 20) { |
|
814 | + $altName = $name.'_'.rand(1000, 9999); |
|
815 | + if (!$this->ncUserManager->userExists($altName)) { |
|
816 | 816 | return $altName; |
817 | 817 | } |
818 | 818 | $attempts++; |
@@ -834,25 +834,25 @@ discard block |
||
834 | 834 | */ |
835 | 835 | private function _createAltInternalOwnCloudNameForGroups($name) { |
836 | 836 | $usedNames = $this->groupMapper->getNamesBySearch($name, "", '_%'); |
837 | - if(!$usedNames || count($usedNames) === 0) { |
|
837 | + if (!$usedNames || count($usedNames) === 0) { |
|
838 | 838 | $lastNo = 1; //will become name_2 |
839 | 839 | } else { |
840 | 840 | natsort($usedNames); |
841 | 841 | $lastName = array_pop($usedNames); |
842 | - $lastNo = (int)substr($lastName, strrpos($lastName, '_') + 1); |
|
842 | + $lastNo = (int) substr($lastName, strrpos($lastName, '_') + 1); |
|
843 | 843 | } |
844 | - $altName = $name.'_'. (string)($lastNo+1); |
|
844 | + $altName = $name.'_'.(string) ($lastNo + 1); |
|
845 | 845 | unset($usedNames); |
846 | 846 | |
847 | 847 | $attempts = 1; |
848 | - while($attempts < 21){ |
|
848 | + while ($attempts < 21) { |
|
849 | 849 | // Check to be really sure it is unique |
850 | 850 | // while loop is just a precaution. If a name is not generated within |
851 | 851 | // 20 attempts, something else is very wrong. Avoids infinite loop. |
852 | - if(!\OC::$server->getGroupManager()->groupExists($altName)) { |
|
852 | + if (!\OC::$server->getGroupManager()->groupExists($altName)) { |
|
853 | 853 | return $altName; |
854 | 854 | } |
855 | - $altName = $name . '_' . ($lastNo + $attempts); |
|
855 | + $altName = $name.'_'.($lastNo + $attempts); |
|
856 | 856 | $attempts++; |
857 | 857 | } |
858 | 858 | return false; |
@@ -867,7 +867,7 @@ discard block |
||
867 | 867 | private function createAltInternalOwnCloudName($name, $isUser) { |
868 | 868 | $originalTTL = $this->connection->ldapCacheTTL; |
869 | 869 | $this->connection->setConfiguration(['ldapCacheTTL' => 0]); |
870 | - if($isUser) { |
|
870 | + if ($isUser) { |
|
871 | 871 | $altName = $this->_createAltInternalOwnCloudNameForUsers($name); |
872 | 872 | } else { |
873 | 873 | $altName = $this->_createAltInternalOwnCloudNameForGroups($name); |
@@ -916,13 +916,13 @@ discard block |
||
916 | 916 | public function fetchListOfUsers($filter, $attr, $limit = null, $offset = null, $forceApplyAttributes = false) { |
917 | 917 | $ldapRecords = $this->searchUsers($filter, $attr, $limit, $offset); |
918 | 918 | $recordsToUpdate = $ldapRecords; |
919 | - if(!$forceApplyAttributes) { |
|
919 | + if (!$forceApplyAttributes) { |
|
920 | 920 | $isBackgroundJobModeAjax = $this->config |
921 | 921 | ->getAppValue('core', 'backgroundjobs_mode', 'ajax') === 'ajax'; |
922 | - $recordsToUpdate = array_filter($ldapRecords, function ($record) use ($isBackgroundJobModeAjax) { |
|
922 | + $recordsToUpdate = array_filter($ldapRecords, function($record) use ($isBackgroundJobModeAjax) { |
|
923 | 923 | $newlyMapped = false; |
924 | 924 | $uid = $this->dn2ocname($record['dn'][0], null, true, $newlyMapped, $record); |
925 | - if(is_string($uid)) { |
|
925 | + if (is_string($uid)) { |
|
926 | 926 | $this->cacheUserExists($uid); |
927 | 927 | } |
928 | 928 | return ($uid !== false) && ($newlyMapped || $isBackgroundJobModeAjax); |
@@ -942,13 +942,13 @@ discard block |
||
942 | 942 | */ |
943 | 943 | public function batchApplyUserAttributes(array $ldapRecords) { |
944 | 944 | $displayNameAttribute = strtolower($this->connection->ldapUserDisplayName); |
945 | - foreach($ldapRecords as $userRecord) { |
|
946 | - if(!isset($userRecord[$displayNameAttribute])) { |
|
945 | + foreach ($ldapRecords as $userRecord) { |
|
946 | + if (!isset($userRecord[$displayNameAttribute])) { |
|
947 | 947 | // displayName is obligatory |
948 | 948 | continue; |
949 | 949 | } |
950 | - $ocName = $this->dn2ocname($userRecord['dn'][0], null, true); |
|
951 | - if($ocName === false) { |
|
950 | + $ocName = $this->dn2ocname($userRecord['dn'][0], null, true); |
|
951 | + if ($ocName === false) { |
|
952 | 952 | continue; |
953 | 953 | } |
954 | 954 | $this->updateUserState($ocName); |
@@ -973,10 +973,10 @@ discard block |
||
973 | 973 | */ |
974 | 974 | public function fetchListOfGroups($filter, $attr, $limit = null, $offset = null) { |
975 | 975 | $groupRecords = $this->searchGroups($filter, $attr, $limit, $offset); |
976 | - array_walk($groupRecords, function ($record) { |
|
976 | + array_walk($groupRecords, function($record) { |
|
977 | 977 | $newlyMapped = false; |
978 | 978 | $gid = $this->dn2ocname($record['dn'][0], null, false, $newlyMapped, $record); |
979 | - if(!$newlyMapped && is_string($gid)) { |
|
979 | + if (!$newlyMapped && is_string($gid)) { |
|
980 | 980 | $this->cacheGroupExists($gid); |
981 | 981 | } |
982 | 982 | }); |
@@ -989,11 +989,11 @@ discard block |
||
989 | 989 | * @return array |
990 | 990 | */ |
991 | 991 | private function fetchList($list, $manyAttributes) { |
992 | - if(is_array($list)) { |
|
993 | - if($manyAttributes) { |
|
992 | + if (is_array($list)) { |
|
993 | + if ($manyAttributes) { |
|
994 | 994 | return $list; |
995 | 995 | } else { |
996 | - $list = array_reduce($list, function ($carry, $item) { |
|
996 | + $list = array_reduce($list, function($carry, $item) { |
|
997 | 997 | $attribute = array_keys($item)[0]; |
998 | 998 | $carry[] = $item[$attribute][0]; |
999 | 999 | return $carry; |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | */ |
1021 | 1021 | public function searchUsers($filter, $attr = null, $limit = null, $offset = null) { |
1022 | 1022 | $result = []; |
1023 | - foreach($this->connection->ldapBaseUsers as $base) { |
|
1023 | + foreach ($this->connection->ldapBaseUsers as $base) { |
|
1024 | 1024 | $result = array_merge($result, $this->search($filter, [$base], $attr, $limit, $offset)); |
1025 | 1025 | } |
1026 | 1026 | return $result; |
@@ -1036,9 +1036,9 @@ discard block |
||
1036 | 1036 | */ |
1037 | 1037 | public function countUsers($filter, $attr = ['dn'], $limit = null, $offset = null) { |
1038 | 1038 | $result = false; |
1039 | - foreach($this->connection->ldapBaseUsers as $base) { |
|
1039 | + foreach ($this->connection->ldapBaseUsers as $base) { |
|
1040 | 1040 | $count = $this->count($filter, [$base], $attr, $limit, $offset); |
1041 | - $result = is_int($count) ? (int)$result + $count : $result; |
|
1041 | + $result = is_int($count) ? (int) $result + $count : $result; |
|
1042 | 1042 | } |
1043 | 1043 | return $result; |
1044 | 1044 | } |
@@ -1057,7 +1057,7 @@ discard block |
||
1057 | 1057 | */ |
1058 | 1058 | public function searchGroups($filter, $attr = null, $limit = null, $offset = null) { |
1059 | 1059 | $result = []; |
1060 | - foreach($this->connection->ldapBaseGroups as $base) { |
|
1060 | + foreach ($this->connection->ldapBaseGroups as $base) { |
|
1061 | 1061 | $result = array_merge($result, $this->search($filter, [$base], $attr, $limit, $offset)); |
1062 | 1062 | } |
1063 | 1063 | return $result; |
@@ -1075,9 +1075,9 @@ discard block |
||
1075 | 1075 | */ |
1076 | 1076 | public function countGroups($filter, $attr = ['dn'], $limit = null, $offset = null) { |
1077 | 1077 | $result = false; |
1078 | - foreach($this->connection->ldapBaseGroups as $base) { |
|
1078 | + foreach ($this->connection->ldapBaseGroups as $base) { |
|
1079 | 1079 | $count = $this->count($filter, [$base], $attr, $limit, $offset); |
1080 | - $result = is_int($count) ? (int)$result + $count : $result; |
|
1080 | + $result = is_int($count) ? (int) $result + $count : $result; |
|
1081 | 1081 | } |
1082 | 1082 | return $result; |
1083 | 1083 | } |
@@ -1092,9 +1092,9 @@ discard block |
||
1092 | 1092 | */ |
1093 | 1093 | public function countObjects($limit = null, $offset = null) { |
1094 | 1094 | $result = false; |
1095 | - foreach($this->connection->ldapBase as $base) { |
|
1095 | + foreach ($this->connection->ldapBase as $base) { |
|
1096 | 1096 | $count = $this->count('objectclass=*', [$base], ['dn'], $limit, $offset); |
1097 | - $result = is_int($count) ? (int)$result + $count : $result; |
|
1097 | + $result = is_int($count) ? (int) $result + $count : $result; |
|
1098 | 1098 | } |
1099 | 1099 | return $result; |
1100 | 1100 | } |
@@ -1119,7 +1119,7 @@ discard block |
||
1119 | 1119 | // php no longer supports call-time pass-by-reference |
1120 | 1120 | // thus cannot support controlPagedResultResponse as the third argument |
1121 | 1121 | // is a reference |
1122 | - $doMethod = function () use ($command, &$arguments) { |
|
1122 | + $doMethod = function() use ($command, &$arguments) { |
|
1123 | 1123 | if ($command == 'controlPagedResultResponse') { |
1124 | 1124 | throw new \InvalidArgumentException('Invoker does not support controlPagedResultResponse, call LDAP Wrapper directly instead.'); |
1125 | 1125 | } else { |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | $this->connection->resetConnectionResource(); |
1138 | 1138 | $cr = $this->connection->getConnectionResource(); |
1139 | 1139 | |
1140 | - if(!$this->ldap->isResource($cr)) { |
|
1140 | + if (!$this->ldap->isResource($cr)) { |
|
1141 | 1141 | // Seems like we didn't find any resource. |
1142 | 1142 | \OCP\Util::writeLog('user_ldap', "Could not $command, because resource is missing.", ILogger::DEBUG); |
1143 | 1143 | throw $e; |
@@ -1162,13 +1162,13 @@ discard block |
||
1162 | 1162 | * @throws ServerNotAvailableException |
1163 | 1163 | */ |
1164 | 1164 | private function executeSearch($filter, $base, &$attr = null, $limit = null, $offset = null) { |
1165 | - if(!is_null($attr) && !is_array($attr)) { |
|
1165 | + if (!is_null($attr) && !is_array($attr)) { |
|
1166 | 1166 | $attr = [mb_strtolower($attr, 'UTF-8')]; |
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | // See if we have a resource, in case not cancel with message |
1170 | 1170 | $cr = $this->connection->getConnectionResource(); |
1171 | - if(!$this->ldap->isResource($cr)) { |
|
1171 | + if (!$this->ldap->isResource($cr)) { |
|
1172 | 1172 | // Seems like we didn't find any resource. |
1173 | 1173 | // Return an empty array just like before. |
1174 | 1174 | \OCP\Util::writeLog('user_ldap', 'Could not search, because resource is missing.', ILogger::DEBUG); |
@@ -1176,13 +1176,13 @@ discard block |
||
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | //check whether paged search should be attempted |
1179 | - $pagedSearchOK = $this->initPagedSearch($filter, $base, $attr, (int)$limit, $offset); |
|
1179 | + $pagedSearchOK = $this->initPagedSearch($filter, $base, $attr, (int) $limit, $offset); |
|
1180 | 1180 | |
1181 | 1181 | $linkResources = array_pad([], count($base), $cr); |
1182 | 1182 | $sr = $this->invokeLDAPMethod('search', $linkResources, $base, $filter, $attr); |
1183 | 1183 | // cannot use $cr anymore, might have changed in the previous call! |
1184 | 1184 | $error = $this->ldap->errno($this->connection->getConnectionResource()); |
1185 | - if(!is_array($sr) || $error !== 0) { |
|
1185 | + if (!is_array($sr) || $error !== 0) { |
|
1186 | 1186 | \OCP\Util::writeLog('user_ldap', 'Attempt for Paging? '.print_r($pagedSearchOK, true), ILogger::ERROR); |
1187 | 1187 | return false; |
1188 | 1188 | } |
@@ -1207,29 +1207,29 @@ discard block |
||
1207 | 1207 | */ |
1208 | 1208 | private function processPagedSearchStatus($sr, $filter, $base, $iFoundItems, $limit, $offset, $pagedSearchOK, $skipHandling) { |
1209 | 1209 | $cookie = null; |
1210 | - if($pagedSearchOK) { |
|
1210 | + if ($pagedSearchOK) { |
|
1211 | 1211 | $cr = $this->connection->getConnectionResource(); |
1212 | - foreach($sr as $key => $res) { |
|
1213 | - if($this->ldap->controlPagedResultResponse($cr, $res, $cookie)) { |
|
1212 | + foreach ($sr as $key => $res) { |
|
1213 | + if ($this->ldap->controlPagedResultResponse($cr, $res, $cookie)) { |
|
1214 | 1214 | $this->setPagedResultCookie($base[$key], $filter, $limit, $offset, $cookie); |
1215 | 1215 | } |
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | //browsing through prior pages to get the cookie for the new one |
1219 | - if($skipHandling) { |
|
1219 | + if ($skipHandling) { |
|
1220 | 1220 | return false; |
1221 | 1221 | } |
1222 | 1222 | // if count is bigger, then the server does not support |
1223 | 1223 | // paged search. Instead, he did a normal search. We set a |
1224 | 1224 | // flag here, so the callee knows how to deal with it. |
1225 | - if($iFoundItems <= $limit) { |
|
1225 | + if ($iFoundItems <= $limit) { |
|
1226 | 1226 | $this->pagedSearchedSuccessful = true; |
1227 | 1227 | } |
1228 | 1228 | } else { |
1229 | - if(!is_null($limit) && (int)$this->connection->ldapPagingSize !== 0) { |
|
1229 | + if (!is_null($limit) && (int) $this->connection->ldapPagingSize !== 0) { |
|
1230 | 1230 | \OC::$server->getLogger()->debug( |
1231 | 1231 | 'Paged search was not available', |
1232 | - [ 'app' => 'user_ldap' ] |
|
1232 | + ['app' => 'user_ldap'] |
|
1233 | 1233 | ); |
1234 | 1234 | } |
1235 | 1235 | } |
@@ -1258,8 +1258,8 @@ discard block |
||
1258 | 1258 | private function count($filter, $base, $attr = null, $limit = null, $offset = null, $skipHandling = false) { |
1259 | 1259 | \OCP\Util::writeLog('user_ldap', 'Count filter: '.print_r($filter, true), ILogger::DEBUG); |
1260 | 1260 | |
1261 | - $limitPerPage = (int)$this->connection->ldapPagingSize; |
|
1262 | - if(!is_null($limit) && $limit < $limitPerPage && $limit > 0) { |
|
1261 | + $limitPerPage = (int) $this->connection->ldapPagingSize; |
|
1262 | + if (!is_null($limit) && $limit < $limitPerPage && $limit > 0) { |
|
1263 | 1263 | $limitPerPage = $limit; |
1264 | 1264 | } |
1265 | 1265 | |
@@ -1269,7 +1269,7 @@ discard block |
||
1269 | 1269 | |
1270 | 1270 | do { |
1271 | 1271 | $search = $this->executeSearch($filter, $base, $attr, $limitPerPage, $offset); |
1272 | - if($search === false) { |
|
1272 | + if ($search === false) { |
|
1273 | 1273 | return $counter > 0 ? $counter : false; |
1274 | 1274 | } |
1275 | 1275 | list($sr, $pagedSearchOK) = $search; |
@@ -1288,7 +1288,7 @@ discard block |
||
1288 | 1288 | * Continue now depends on $hasMorePages value |
1289 | 1289 | */ |
1290 | 1290 | $continue = $pagedSearchOK && $hasMorePages; |
1291 | - } while($continue && (is_null($limit) || $limit <= 0 || $limit > $counter)); |
|
1291 | + } while ($continue && (is_null($limit) || $limit <= 0 || $limit > $counter)); |
|
1292 | 1292 | |
1293 | 1293 | return $counter; |
1294 | 1294 | } |
@@ -1301,8 +1301,8 @@ discard block |
||
1301 | 1301 | private function countEntriesInSearchResults($searchResults) { |
1302 | 1302 | $counter = 0; |
1303 | 1303 | |
1304 | - foreach($searchResults as $res) { |
|
1305 | - $count = (int)$this->invokeLDAPMethod('countEntries', $this->connection->getConnectionResource(), $res); |
|
1304 | + foreach ($searchResults as $res) { |
|
1305 | + $count = (int) $this->invokeLDAPMethod('countEntries', $this->connection->getConnectionResource(), $res); |
|
1306 | 1306 | $counter += $count; |
1307 | 1307 | } |
1308 | 1308 | |
@@ -1322,8 +1322,8 @@ discard block |
||
1322 | 1322 | * @throws ServerNotAvailableException |
1323 | 1323 | */ |
1324 | 1324 | public function search($filter, $base, $attr = null, $limit = null, $offset = null, $skipHandling = false) { |
1325 | - $limitPerPage = (int)$this->connection->ldapPagingSize; |
|
1326 | - if(!is_null($limit) && $limit < $limitPerPage && $limit > 0) { |
|
1325 | + $limitPerPage = (int) $this->connection->ldapPagingSize; |
|
1326 | + if (!is_null($limit) && $limit < $limitPerPage && $limit > 0) { |
|
1327 | 1327 | $limitPerPage = $limit; |
1328 | 1328 | } |
1329 | 1329 | |
@@ -1337,13 +1337,13 @@ discard block |
||
1337 | 1337 | $savedoffset = $offset; |
1338 | 1338 | do { |
1339 | 1339 | $search = $this->executeSearch($filter, $base, $attr, $limitPerPage, $offset); |
1340 | - if($search === false) { |
|
1340 | + if ($search === false) { |
|
1341 | 1341 | return []; |
1342 | 1342 | } |
1343 | 1343 | list($sr, $pagedSearchOK) = $search; |
1344 | 1344 | $cr = $this->connection->getConnectionResource(); |
1345 | 1345 | |
1346 | - if($skipHandling) { |
|
1346 | + if ($skipHandling) { |
|
1347 | 1347 | //i.e. result do not need to be fetched, we just need the cookie |
1348 | 1348 | //thus pass 1 or any other value as $iFoundItems because it is not |
1349 | 1349 | //used |
@@ -1354,7 +1354,7 @@ discard block |
||
1354 | 1354 | } |
1355 | 1355 | |
1356 | 1356 | $iFoundItems = 0; |
1357 | - foreach($sr as $res) { |
|
1357 | + foreach ($sr as $res) { |
|
1358 | 1358 | $findings = array_merge($findings, $this->invokeLDAPMethod('getEntries', $cr, $res)); |
1359 | 1359 | $iFoundItems = max($iFoundItems, $findings['count']); |
1360 | 1360 | unset($findings['count']); |
@@ -1370,27 +1370,27 @@ discard block |
||
1370 | 1370 | |
1371 | 1371 | // if we're here, probably no connection resource is returned. |
1372 | 1372 | // to make Nextcloud behave nicely, we simply give back an empty array. |
1373 | - if(is_null($findings)) { |
|
1373 | + if (is_null($findings)) { |
|
1374 | 1374 | return []; |
1375 | 1375 | } |
1376 | 1376 | |
1377 | - if(!is_null($attr)) { |
|
1377 | + if (!is_null($attr)) { |
|
1378 | 1378 | $selection = []; |
1379 | 1379 | $i = 0; |
1380 | - foreach($findings as $item) { |
|
1381 | - if(!is_array($item)) { |
|
1380 | + foreach ($findings as $item) { |
|
1381 | + if (!is_array($item)) { |
|
1382 | 1382 | continue; |
1383 | 1383 | } |
1384 | 1384 | $item = \OCP\Util::mb_array_change_key_case($item, MB_CASE_LOWER, 'UTF-8'); |
1385 | - foreach($attr as $key) { |
|
1386 | - if(isset($item[$key])) { |
|
1387 | - if(is_array($item[$key]) && isset($item[$key]['count'])) { |
|
1385 | + foreach ($attr as $key) { |
|
1386 | + if (isset($item[$key])) { |
|
1387 | + if (is_array($item[$key]) && isset($item[$key]['count'])) { |
|
1388 | 1388 | unset($item[$key]['count']); |
1389 | 1389 | } |
1390 | - if($key !== 'dn') { |
|
1391 | - if($this->resemblesDN($key)) { |
|
1390 | + if ($key !== 'dn') { |
|
1391 | + if ($this->resemblesDN($key)) { |
|
1392 | 1392 | $selection[$i][$key] = $this->helper->sanitizeDN($item[$key]); |
1393 | - } else if($key === 'objectguid' || $key === 'guid') { |
|
1393 | + } else if ($key === 'objectguid' || $key === 'guid') { |
|
1394 | 1394 | $selection[$i][$key] = [$this->convertObjectGUID2Str($item[$key][0])]; |
1395 | 1395 | } else { |
1396 | 1396 | $selection[$i][$key] = $item[$key]; |
@@ -1408,14 +1408,14 @@ discard block |
||
1408 | 1408 | //we slice the findings, when |
1409 | 1409 | //a) paged search unsuccessful, though attempted |
1410 | 1410 | //b) no paged search, but limit set |
1411 | - if((!$this->getPagedSearchResultState() |
|
1411 | + if ((!$this->getPagedSearchResultState() |
|
1412 | 1412 | && $pagedSearchOK) |
1413 | 1413 | || ( |
1414 | 1414 | !$pagedSearchOK |
1415 | 1415 | && !is_null($limit) |
1416 | 1416 | ) |
1417 | 1417 | ) { |
1418 | - $findings = array_slice($findings, (int)$offset, $limit); |
|
1418 | + $findings = array_slice($findings, (int) $offset, $limit); |
|
1419 | 1419 | } |
1420 | 1420 | return $findings; |
1421 | 1421 | } |
@@ -1428,13 +1428,13 @@ discard block |
||
1428 | 1428 | public function sanitizeUsername($name) { |
1429 | 1429 | $name = trim($name); |
1430 | 1430 | |
1431 | - if($this->connection->ldapIgnoreNamingRules) { |
|
1431 | + if ($this->connection->ldapIgnoreNamingRules) { |
|
1432 | 1432 | return $name; |
1433 | 1433 | } |
1434 | 1434 | |
1435 | 1435 | // Transliteration to ASCII |
1436 | 1436 | $transliterated = @iconv('UTF-8', 'ASCII//TRANSLIT', $name); |
1437 | - if($transliterated !== false) { |
|
1437 | + if ($transliterated !== false) { |
|
1438 | 1438 | // depending on system config iconv can work or not |
1439 | 1439 | $name = $transliterated; |
1440 | 1440 | } |
@@ -1445,7 +1445,7 @@ discard block |
||
1445 | 1445 | // Every remaining disallowed characters will be removed |
1446 | 1446 | $name = preg_replace('/[^a-zA-Z0-9_.@-]/u', '', $name); |
1447 | 1447 | |
1448 | - if($name === '') { |
|
1448 | + if ($name === '') { |
|
1449 | 1449 | throw new \InvalidArgumentException('provided name template for username does not contain any allowed characters'); |
1450 | 1450 | } |
1451 | 1451 | |
@@ -1460,13 +1460,13 @@ discard block |
||
1460 | 1460 | */ |
1461 | 1461 | public function escapeFilterPart($input, $allowAsterisk = false) { |
1462 | 1462 | $asterisk = ''; |
1463 | - if($allowAsterisk && strlen($input) > 0 && $input[0] === '*') { |
|
1463 | + if ($allowAsterisk && strlen($input) > 0 && $input[0] === '*') { |
|
1464 | 1464 | $asterisk = '*'; |
1465 | 1465 | $input = mb_substr($input, 1, null, 'UTF-8'); |
1466 | 1466 | } |
1467 | 1467 | $search = ['*', '\\', '(', ')']; |
1468 | 1468 | $replace = ['\\*', '\\\\', '\\(', '\\)']; |
1469 | - return $asterisk . str_replace($search, $replace, $input); |
|
1469 | + return $asterisk.str_replace($search, $replace, $input); |
|
1470 | 1470 | } |
1471 | 1471 | |
1472 | 1472 | /** |
@@ -1496,13 +1496,13 @@ discard block |
||
1496 | 1496 | */ |
1497 | 1497 | private function combineFilter($filters, $operator) { |
1498 | 1498 | $combinedFilter = '('.$operator; |
1499 | - foreach($filters as $filter) { |
|
1499 | + foreach ($filters as $filter) { |
|
1500 | 1500 | if ($filter !== '' && $filter[0] !== '(') { |
1501 | 1501 | $filter = '('.$filter.')'; |
1502 | 1502 | } |
1503 | - $combinedFilter.=$filter; |
|
1503 | + $combinedFilter .= $filter; |
|
1504 | 1504 | } |
1505 | - $combinedFilter.=')'; |
|
1505 | + $combinedFilter .= ')'; |
|
1506 | 1506 | return $combinedFilter; |
1507 | 1507 | } |
1508 | 1508 | |
@@ -1538,17 +1538,17 @@ discard block |
||
1538 | 1538 | * @throws \Exception |
1539 | 1539 | */ |
1540 | 1540 | private function getAdvancedFilterPartForSearch($search, $searchAttributes) { |
1541 | - if(!is_array($searchAttributes) || count($searchAttributes) < 2) { |
|
1541 | + if (!is_array($searchAttributes) || count($searchAttributes) < 2) { |
|
1542 | 1542 | throw new \Exception('searchAttributes must be an array with at least two string'); |
1543 | 1543 | } |
1544 | 1544 | $searchWords = explode(' ', trim($search)); |
1545 | 1545 | $wordFilters = []; |
1546 | - foreach($searchWords as $word) { |
|
1546 | + foreach ($searchWords as $word) { |
|
1547 | 1547 | $word = $this->prepareSearchTerm($word); |
1548 | 1548 | //every word needs to appear at least once |
1549 | 1549 | $wordMatchOneAttrFilters = []; |
1550 | - foreach($searchAttributes as $attr) { |
|
1551 | - $wordMatchOneAttrFilters[] = $attr . '=' . $word; |
|
1550 | + foreach ($searchAttributes as $attr) { |
|
1551 | + $wordMatchOneAttrFilters[] = $attr.'='.$word; |
|
1552 | 1552 | } |
1553 | 1553 | $wordFilters[] = $this->combineFilterWithOr($wordMatchOneAttrFilters); |
1554 | 1554 | } |
@@ -1566,10 +1566,10 @@ discard block |
||
1566 | 1566 | private function getFilterPartForSearch($search, $searchAttributes, $fallbackAttribute) { |
1567 | 1567 | $filter = []; |
1568 | 1568 | $haveMultiSearchAttributes = (is_array($searchAttributes) && count($searchAttributes) > 0); |
1569 | - if($haveMultiSearchAttributes && strpos(trim($search), ' ') !== false) { |
|
1569 | + if ($haveMultiSearchAttributes && strpos(trim($search), ' ') !== false) { |
|
1570 | 1570 | try { |
1571 | 1571 | return $this->getAdvancedFilterPartForSearch($search, $searchAttributes); |
1572 | - } catch(\Exception $e) { |
|
1572 | + } catch (\Exception $e) { |
|
1573 | 1573 | \OCP\Util::writeLog( |
1574 | 1574 | 'user_ldap', |
1575 | 1575 | 'Creating advanced filter for search failed, falling back to simple method.', |
@@ -1579,17 +1579,17 @@ discard block |
||
1579 | 1579 | } |
1580 | 1580 | |
1581 | 1581 | $search = $this->prepareSearchTerm($search); |
1582 | - if(!is_array($searchAttributes) || count($searchAttributes) === 0) { |
|
1582 | + if (!is_array($searchAttributes) || count($searchAttributes) === 0) { |
|
1583 | 1583 | if ($fallbackAttribute === '') { |
1584 | 1584 | return ''; |
1585 | 1585 | } |
1586 | - $filter[] = $fallbackAttribute . '=' . $search; |
|
1586 | + $filter[] = $fallbackAttribute.'='.$search; |
|
1587 | 1587 | } else { |
1588 | - foreach($searchAttributes as $attribute) { |
|
1589 | - $filter[] = $attribute . '=' . $search; |
|
1588 | + foreach ($searchAttributes as $attribute) { |
|
1589 | + $filter[] = $attribute.'='.$search; |
|
1590 | 1590 | } |
1591 | 1591 | } |
1592 | - if(count($filter) === 1) { |
|
1592 | + if (count($filter) === 1) { |
|
1593 | 1593 | return '('.$filter[0].')'; |
1594 | 1594 | } |
1595 | 1595 | return $this->combineFilterWithOr($filter); |
@@ -1610,7 +1610,7 @@ discard block |
||
1610 | 1610 | if ($term === '') { |
1611 | 1611 | $result = '*'; |
1612 | 1612 | } else if ($allowEnum !== 'no') { |
1613 | - $result = $term . '*'; |
|
1613 | + $result = $term.'*'; |
|
1614 | 1614 | } |
1615 | 1615 | return $result; |
1616 | 1616 | } |
@@ -1622,7 +1622,7 @@ discard block |
||
1622 | 1622 | public function getFilterForUserCount() { |
1623 | 1623 | $filter = $this->combineFilterWithAnd([ |
1624 | 1624 | $this->connection->ldapUserFilter, |
1625 | - $this->connection->ldapUserDisplayName . '=*' |
|
1625 | + $this->connection->ldapUserDisplayName.'=*' |
|
1626 | 1626 | ]); |
1627 | 1627 | |
1628 | 1628 | return $filter; |
@@ -1640,7 +1640,7 @@ discard block |
||
1640 | 1640 | 'ldapAgentName' => $name, |
1641 | 1641 | 'ldapAgentPassword' => $password |
1642 | 1642 | ]; |
1643 | - if(!$testConnection->setConfiguration($credentials)) { |
|
1643 | + if (!$testConnection->setConfiguration($credentials)) { |
|
1644 | 1644 | return false; |
1645 | 1645 | } |
1646 | 1646 | return $testConnection->bind(); |
@@ -1662,30 +1662,30 @@ discard block |
||
1662 | 1662 | // Sacrebleu! The UUID attribute is unknown :( We need first an |
1663 | 1663 | // existing DN to be able to reliably detect it. |
1664 | 1664 | $result = $this->search($filter, $base, ['dn'], 1); |
1665 | - if(!isset($result[0]) || !isset($result[0]['dn'])) { |
|
1665 | + if (!isset($result[0]) || !isset($result[0]['dn'])) { |
|
1666 | 1666 | throw new \Exception('Cannot determine UUID attribute'); |
1667 | 1667 | } |
1668 | 1668 | $dn = $result[0]['dn'][0]; |
1669 | - if(!$this->detectUuidAttribute($dn, true)) { |
|
1669 | + if (!$this->detectUuidAttribute($dn, true)) { |
|
1670 | 1670 | throw new \Exception('Cannot determine UUID attribute'); |
1671 | 1671 | } |
1672 | 1672 | } else { |
1673 | 1673 | // The UUID attribute is either known or an override is given. |
1674 | 1674 | // By calling this method we ensure that $this->connection->$uuidAttr |
1675 | 1675 | // is definitely set |
1676 | - if(!$this->detectUuidAttribute('', true)) { |
|
1676 | + if (!$this->detectUuidAttribute('', true)) { |
|
1677 | 1677 | throw new \Exception('Cannot determine UUID attribute'); |
1678 | 1678 | } |
1679 | 1679 | } |
1680 | 1680 | |
1681 | 1681 | $uuidAttr = $this->connection->ldapUuidUserAttribute; |
1682 | - if($uuidAttr === 'guid' || $uuidAttr === 'objectguid') { |
|
1682 | + if ($uuidAttr === 'guid' || $uuidAttr === 'objectguid') { |
|
1683 | 1683 | $uuid = $this->formatGuid2ForFilterUser($uuid); |
1684 | 1684 | } |
1685 | 1685 | |
1686 | - $filter = $uuidAttr . '=' . $uuid; |
|
1686 | + $filter = $uuidAttr.'='.$uuid; |
|
1687 | 1687 | $result = $this->searchUsers($filter, ['dn'], 2); |
1688 | - if(is_array($result) && isset($result[0]) && isset($result[0]['dn']) && count($result) === 1) { |
|
1688 | + if (is_array($result) && isset($result[0]) && isset($result[0]['dn']) && count($result) === 1) { |
|
1689 | 1689 | // we put the count into account to make sure that this is |
1690 | 1690 | // really unique |
1691 | 1691 | return $result[0]['dn'][0]; |
@@ -1705,7 +1705,7 @@ discard block |
||
1705 | 1705 | * @throws ServerNotAvailableException |
1706 | 1706 | */ |
1707 | 1707 | private function detectUuidAttribute($dn, $isUser = true, $force = false, array $ldapRecord = null) { |
1708 | - if($isUser) { |
|
1708 | + if ($isUser) { |
|
1709 | 1709 | $uuidAttr = 'ldapUuidUserAttribute'; |
1710 | 1710 | $uuidOverride = $this->connection->ldapExpertUUIDUserAttr; |
1711 | 1711 | } else { |
@@ -1713,8 +1713,8 @@ discard block |
||
1713 | 1713 | $uuidOverride = $this->connection->ldapExpertUUIDGroupAttr; |
1714 | 1714 | } |
1715 | 1715 | |
1716 | - if(!$force) { |
|
1717 | - if($this->connection->$uuidAttr !== 'auto') { |
|
1716 | + if (!$force) { |
|
1717 | + if ($this->connection->$uuidAttr !== 'auto') { |
|
1718 | 1718 | return true; |
1719 | 1719 | } else if (is_string($uuidOverride) && trim($uuidOverride) !== '') { |
1720 | 1720 | $this->connection->$uuidAttr = $uuidOverride; |
@@ -1722,23 +1722,23 @@ discard block |
||
1722 | 1722 | } |
1723 | 1723 | |
1724 | 1724 | $attribute = $this->connection->getFromCache($uuidAttr); |
1725 | - if(!$attribute === null) { |
|
1725 | + if (!$attribute === null) { |
|
1726 | 1726 | $this->connection->$uuidAttr = $attribute; |
1727 | 1727 | return true; |
1728 | 1728 | } |
1729 | 1729 | } |
1730 | 1730 | |
1731 | - foreach(self::UUID_ATTRIBUTES as $attribute) { |
|
1732 | - if($ldapRecord !== null) { |
|
1731 | + foreach (self::UUID_ATTRIBUTES as $attribute) { |
|
1732 | + if ($ldapRecord !== null) { |
|
1733 | 1733 | // we have the info from LDAP already, we don't need to talk to the server again |
1734 | - if(isset($ldapRecord[$attribute])) { |
|
1734 | + if (isset($ldapRecord[$attribute])) { |
|
1735 | 1735 | $this->connection->$uuidAttr = $attribute; |
1736 | 1736 | return true; |
1737 | 1737 | } |
1738 | 1738 | } |
1739 | 1739 | |
1740 | 1740 | $value = $this->readAttribute($dn, $attribute); |
1741 | - if(is_array($value) && isset($value[0]) && !empty($value[0])) { |
|
1741 | + if (is_array($value) && isset($value[0]) && !empty($value[0])) { |
|
1742 | 1742 | \OC::$server->getLogger()->debug( |
1743 | 1743 | 'Setting {attribute} as {subject}', |
1744 | 1744 | [ |
@@ -1765,7 +1765,7 @@ discard block |
||
1765 | 1765 | * @throws ServerNotAvailableException |
1766 | 1766 | */ |
1767 | 1767 | public function getUUID($dn, $isUser = true, $ldapRecord = null) { |
1768 | - if($isUser) { |
|
1768 | + if ($isUser) { |
|
1769 | 1769 | $uuidAttr = 'ldapUuidUserAttribute'; |
1770 | 1770 | $uuidOverride = $this->connection->ldapExpertUUIDUserAttr; |
1771 | 1771 | } else { |
@@ -1774,10 +1774,10 @@ discard block |
||
1774 | 1774 | } |
1775 | 1775 | |
1776 | 1776 | $uuid = false; |
1777 | - if($this->detectUuidAttribute($dn, $isUser, false, $ldapRecord)) { |
|
1777 | + if ($this->detectUuidAttribute($dn, $isUser, false, $ldapRecord)) { |
|
1778 | 1778 | $attr = $this->connection->$uuidAttr; |
1779 | 1779 | $uuid = isset($ldapRecord[$attr]) ? $ldapRecord[$attr] : $this->readAttribute($dn, $attr); |
1780 | - if(!is_array($uuid) |
|
1780 | + if (!is_array($uuid) |
|
1781 | 1781 | && $uuidOverride !== '' |
1782 | 1782 | && $this->detectUuidAttribute($dn, $isUser, true, $ldapRecord)) |
1783 | 1783 | { |
@@ -1785,7 +1785,7 @@ discard block |
||
1785 | 1785 | ? $ldapRecord[$this->connection->$uuidAttr] |
1786 | 1786 | : $this->readAttribute($dn, $this->connection->$uuidAttr); |
1787 | 1787 | } |
1788 | - if(is_array($uuid) && isset($uuid[0]) && !empty($uuid[0])) { |
|
1788 | + if (is_array($uuid) && isset($uuid[0]) && !empty($uuid[0])) { |
|
1789 | 1789 | $uuid = $uuid[0]; |
1790 | 1790 | } |
1791 | 1791 | } |
@@ -1802,19 +1802,19 @@ discard block |
||
1802 | 1802 | private function convertObjectGUID2Str($oguid) { |
1803 | 1803 | $hex_guid = bin2hex($oguid); |
1804 | 1804 | $hex_guid_to_guid_str = ''; |
1805 | - for($k = 1; $k <= 4; ++$k) { |
|
1805 | + for ($k = 1; $k <= 4; ++$k) { |
|
1806 | 1806 | $hex_guid_to_guid_str .= substr($hex_guid, 8 - 2 * $k, 2); |
1807 | 1807 | } |
1808 | 1808 | $hex_guid_to_guid_str .= '-'; |
1809 | - for($k = 1; $k <= 2; ++$k) { |
|
1809 | + for ($k = 1; $k <= 2; ++$k) { |
|
1810 | 1810 | $hex_guid_to_guid_str .= substr($hex_guid, 12 - 2 * $k, 2); |
1811 | 1811 | } |
1812 | 1812 | $hex_guid_to_guid_str .= '-'; |
1813 | - for($k = 1; $k <= 2; ++$k) { |
|
1813 | + for ($k = 1; $k <= 2; ++$k) { |
|
1814 | 1814 | $hex_guid_to_guid_str .= substr($hex_guid, 16 - 2 * $k, 2); |
1815 | 1815 | } |
1816 | - $hex_guid_to_guid_str .= '-' . substr($hex_guid, 16, 4); |
|
1817 | - $hex_guid_to_guid_str .= '-' . substr($hex_guid, 20); |
|
1816 | + $hex_guid_to_guid_str .= '-'.substr($hex_guid, 16, 4); |
|
1817 | + $hex_guid_to_guid_str .= '-'.substr($hex_guid, 20); |
|
1818 | 1818 | |
1819 | 1819 | return strtoupper($hex_guid_to_guid_str); |
1820 | 1820 | } |
@@ -1831,11 +1831,11 @@ discard block |
||
1831 | 1831 | * @return string |
1832 | 1832 | */ |
1833 | 1833 | public function formatGuid2ForFilterUser($guid) { |
1834 | - if(!is_string($guid)) { |
|
1834 | + if (!is_string($guid)) { |
|
1835 | 1835 | throw new \InvalidArgumentException('String expected'); |
1836 | 1836 | } |
1837 | 1837 | $blocks = explode('-', $guid); |
1838 | - if(count($blocks) !== 5) { |
|
1838 | + if (count($blocks) !== 5) { |
|
1839 | 1839 | /* |
1840 | 1840 | * Why not throw an Exception instead? This method is a utility |
1841 | 1841 | * called only when trying to figure out whether a "missing" known |
@@ -1848,20 +1848,20 @@ discard block |
||
1848 | 1848 | * user. Instead we write a log message. |
1849 | 1849 | */ |
1850 | 1850 | \OC::$server->getLogger()->info( |
1851 | - 'Passed string does not resemble a valid GUID. Known UUID ' . |
|
1851 | + 'Passed string does not resemble a valid GUID. Known UUID '. |
|
1852 | 1852 | '({uuid}) probably does not match UUID configuration.', |
1853 | - [ 'app' => 'user_ldap', 'uuid' => $guid ] |
|
1853 | + ['app' => 'user_ldap', 'uuid' => $guid] |
|
1854 | 1854 | ); |
1855 | 1855 | return $guid; |
1856 | 1856 | } |
1857 | - for($i=0; $i < 3; $i++) { |
|
1857 | + for ($i = 0; $i < 3; $i++) { |
|
1858 | 1858 | $pairs = str_split($blocks[$i], 2); |
1859 | 1859 | $pairs = array_reverse($pairs); |
1860 | 1860 | $blocks[$i] = implode('', $pairs); |
1861 | 1861 | } |
1862 | - for($i=0; $i < 5; $i++) { |
|
1862 | + for ($i = 0; $i < 5; $i++) { |
|
1863 | 1863 | $pairs = str_split($blocks[$i], 2); |
1864 | - $blocks[$i] = '\\' . implode('\\', $pairs); |
|
1864 | + $blocks[$i] = '\\'.implode('\\', $pairs); |
|
1865 | 1865 | } |
1866 | 1866 | return implode('', $blocks); |
1867 | 1867 | } |
@@ -1877,12 +1877,12 @@ discard block |
||
1877 | 1877 | $domainDN = $this->getDomainDNFromDN($dn); |
1878 | 1878 | $cacheKey = 'getSID-'.$domainDN; |
1879 | 1879 | $sid = $this->connection->getFromCache($cacheKey); |
1880 | - if(!is_null($sid)) { |
|
1880 | + if (!is_null($sid)) { |
|
1881 | 1881 | return $sid; |
1882 | 1882 | } |
1883 | 1883 | |
1884 | 1884 | $objectSid = $this->readAttribute($domainDN, 'objectsid'); |
1885 | - if(!is_array($objectSid) || empty($objectSid)) { |
|
1885 | + if (!is_array($objectSid) || empty($objectSid)) { |
|
1886 | 1886 | $this->connection->writeToCache($cacheKey, false); |
1887 | 1887 | return false; |
1888 | 1888 | } |
@@ -1940,12 +1940,12 @@ discard block |
||
1940 | 1940 | $belongsToBase = false; |
1941 | 1941 | $bases = $this->helper->sanitizeDN($bases); |
1942 | 1942 | |
1943 | - foreach($bases as $base) { |
|
1943 | + foreach ($bases as $base) { |
|
1944 | 1944 | $belongsToBase = true; |
1945 | - if(mb_strripos($dn, $base, 0, 'UTF-8') !== (mb_strlen($dn, 'UTF-8')-mb_strlen($base, 'UTF-8'))) { |
|
1945 | + if (mb_strripos($dn, $base, 0, 'UTF-8') !== (mb_strlen($dn, 'UTF-8') - mb_strlen($base, 'UTF-8'))) { |
|
1946 | 1946 | $belongsToBase = false; |
1947 | 1947 | } |
1948 | - if($belongsToBase) { |
|
1948 | + if ($belongsToBase) { |
|
1949 | 1949 | break; |
1950 | 1950 | } |
1951 | 1951 | } |
@@ -1974,16 +1974,16 @@ discard block |
||
1974 | 1974 | * @return string containing the key or empty if none is cached |
1975 | 1975 | */ |
1976 | 1976 | private function getPagedResultCookie($base, $filter, $limit, $offset) { |
1977 | - if($offset === 0) { |
|
1977 | + if ($offset === 0) { |
|
1978 | 1978 | return ''; |
1979 | 1979 | } |
1980 | 1980 | $offset -= $limit; |
1981 | 1981 | //we work with cache here |
1982 | - $cacheKey = 'lc' . crc32($base) . '-' . crc32($filter) . '-' . (int)$limit . '-' . (int)$offset; |
|
1982 | + $cacheKey = 'lc'.crc32($base).'-'.crc32($filter).'-'.(int) $limit.'-'.(int) $offset; |
|
1983 | 1983 | $cookie = ''; |
1984 | - if(isset($this->cookies[$cacheKey])) { |
|
1984 | + if (isset($this->cookies[$cacheKey])) { |
|
1985 | 1985 | $cookie = $this->cookies[$cacheKey]; |
1986 | - if(is_null($cookie)) { |
|
1986 | + if (is_null($cookie)) { |
|
1987 | 1987 | $cookie = ''; |
1988 | 1988 | } |
1989 | 1989 | } |
@@ -2001,7 +2001,7 @@ discard block |
||
2001 | 2001 | * @return bool |
2002 | 2002 | */ |
2003 | 2003 | public function hasMoreResults() { |
2004 | - if(empty($this->lastCookie) && $this->lastCookie !== '0') { |
|
2004 | + if (empty($this->lastCookie) && $this->lastCookie !== '0') { |
|
2005 | 2005 | // as in RFC 2696, when all results are returned, the cookie will |
2006 | 2006 | // be empty. |
2007 | 2007 | return false; |
@@ -2021,8 +2021,8 @@ discard block |
||
2021 | 2021 | */ |
2022 | 2022 | private function setPagedResultCookie($base, $filter, $limit, $offset, $cookie) { |
2023 | 2023 | // allow '0' for 389ds |
2024 | - if(!empty($cookie) || $cookie === '0') { |
|
2025 | - $cacheKey = 'lc' . crc32($base) . '-' . crc32($filter) . '-' . (int)$limit . '-' . (int)$offset; |
|
2024 | + if (!empty($cookie) || $cookie === '0') { |
|
2025 | + $cacheKey = 'lc'.crc32($base).'-'.crc32($filter).'-'.(int) $limit.'-'.(int) $offset; |
|
2026 | 2026 | $this->cookies[$cacheKey] = $cookie; |
2027 | 2027 | $this->lastCookie = $cookie; |
2028 | 2028 | } |
@@ -2052,16 +2052,16 @@ discard block |
||
2052 | 2052 | private function initPagedSearch($filter, $bases, $attr, $limit, $offset) { |
2053 | 2053 | $pagedSearchOK = false; |
2054 | 2054 | if ($limit !== 0) { |
2055 | - $offset = (int)$offset; //can be null |
|
2055 | + $offset = (int) $offset; //can be null |
|
2056 | 2056 | \OCP\Util::writeLog('user_ldap', |
2057 | 2057 | 'initializing paged search for Filter '.$filter.' base '.print_r($bases, true) |
2058 | - .' attr '.print_r($attr, true). ' limit ' .$limit.' offset '.$offset, |
|
2058 | + .' attr '.print_r($attr, true).' limit '.$limit.' offset '.$offset, |
|
2059 | 2059 | ILogger::DEBUG); |
2060 | 2060 | //get the cookie from the search for the previous search, required by LDAP |
2061 | - foreach($bases as $base) { |
|
2061 | + foreach ($bases as $base) { |
|
2062 | 2062 | |
2063 | 2063 | $cookie = $this->getPagedResultCookie($base, $filter, $limit, $offset); |
2064 | - if(empty($cookie) && $cookie !== "0" && ($offset > 0)) { |
|
2064 | + if (empty($cookie) && $cookie !== "0" && ($offset > 0)) { |
|
2065 | 2065 | // no cookie known from a potential previous search. We need |
2066 | 2066 | // to start from 0 to come to the desired page. cookie value |
2067 | 2067 | // of '0' is valid, because 389ds |
@@ -2071,17 +2071,17 @@ discard block |
||
2071 | 2071 | //still no cookie? obviously, the server does not like us. Let's skip paging efforts. |
2072 | 2072 | // '0' is valid, because 389ds |
2073 | 2073 | //TODO: remember this, probably does not change in the next request... |
2074 | - if(empty($cookie) && $cookie !== '0') { |
|
2074 | + if (empty($cookie) && $cookie !== '0') { |
|
2075 | 2075 | $cookie = null; |
2076 | 2076 | } |
2077 | 2077 | } |
2078 | - if(!is_null($cookie)) { |
|
2078 | + if (!is_null($cookie)) { |
|
2079 | 2079 | //since offset = 0, this is a new search. We abandon other searches that might be ongoing. |
2080 | 2080 | $this->abandonPagedSearch(); |
2081 | 2081 | $pagedSearchOK = $this->invokeLDAPMethod('controlPagedResult', |
2082 | 2082 | $this->connection->getConnectionResource(), $limit, |
2083 | 2083 | false, $cookie); |
2084 | - if(!$pagedSearchOK) { |
|
2084 | + if (!$pagedSearchOK) { |
|
2085 | 2085 | return false; |
2086 | 2086 | } |
2087 | 2087 | \OCP\Util::writeLog('user_ldap', 'Ready for a paged search', ILogger::DEBUG); |
@@ -2104,7 +2104,7 @@ discard block |
||
2104 | 2104 | $this->abandonPagedSearch(); |
2105 | 2105 | // in case someone set it to 0 … use 500, otherwise no results will |
2106 | 2106 | // be returned. |
2107 | - $pageSize = (int)$this->connection->ldapPagingSize > 0 ? (int)$this->connection->ldapPagingSize : 500; |
|
2107 | + $pageSize = (int) $this->connection->ldapPagingSize > 0 ? (int) $this->connection->ldapPagingSize : 500; |
|
2108 | 2108 | $pagedSearchOK = $this->invokeLDAPMethod('controlPagedResult', |
2109 | 2109 | $this->connection->getConnectionResource(), |
2110 | 2110 | $pageSize, false, ''); |
@@ -42,7 +42,7 @@ |
||
42 | 42 | <span class="msg"></span> |
43 | 43 | </p> |
44 | 44 | |
45 | - <?php elseif ($_["recoveryEnabled"] && $_["privateKeySet"] && $_["initialized"] === \OCA\Encryption\Session::INIT_SUCCESSFUL): ?> |
|
45 | + <?php elseif ($_["recoveryEnabled"] && $_["privateKeySet"] && $_["initialized"] === \OCA\Encryption\Session::INIT_SUCCESSFUL): ?> |
|
46 | 46 | <br /> |
47 | 47 | <p id="userEnableRecovery"> |
48 | 48 | <label for="userEnableRecovery"><?php p($l->t("Enable password recovery:")); ?></label> |