17 require_once SQ_INCLUDE_PATH.
'/asset_edit/asset_edit_fns.inc';
42 $this->static_screens = Array(
45 'force_unlock' => TRUE,
46 'lock_type' =>
'attributes',
48 'permissions' => Array(
49 'name' =>
'Permissions',
50 'force_unlock' => TRUE,
51 'lock_type' =>
'permissions',
55 'force_unlock' => TRUE,
56 'lock_type' =>
'links',
60 'force_unlock' => TRUE,
65 'force_unlock' => TRUE,
66 'lock_type' =>
'none',
70 'force_unlock' => TRUE,
71 'lock_type' =>
'none',
90 $conn = @$asset->connectToLdap();
91 if (is_null($conn) || is_null($conn->ptr)) {
93 echo
'<span style="color: red"><b>'.translate(
'ldap_unable_to_connect').
'</b></span>';
95 echo
'<span style="color: green"><b>'.translate(
'ldap_connected').
'</b></span>';
132 $configured_options = $asset->attr(
'ldap_options');
135 foreach ($asset->getConnectionOptions() as $option => $checked_value) {
137 if (isset($configured_options[$option])) {
141 if ($asset->writeAccess(
'attributes')) {
142 $element_name = $prefix.
'_ldap_options['.$option.
']';
144 check_box($element_name, $checked_value, $checked);
146 <label
for=
"<?php echo $element_name; ?>"><?php echo translate(
'option_'.strtolower($option)); ?></label><br />
149 $display_image =
'cross';
150 if ($checked) $display_image =
'tick';
152 $mask =
'<img src="'.sq_web_path(
'lib').
'/web/images/'.$display_image.
'.gif" />';
153 echo $mask.
' '.translate(
'option_'.strtolower($option)).
'<br />';
156 return $asset->writeAccess(
'attributes');
173 $configured_options = Array();
174 $element_name = $prefix.
'_ldap_options';
177 foreach ($asset->getConnectionOptions() as $option => $value) {
178 if (isset($_REQUEST[$element_name][$option])) {
179 $configured_options[$option] = $value;
184 $asset->setAttrValue(
'ldap_options', $configured_options);
186 return $asset->writeAccess(
'attributes');
203 $write_access = $asset->writeAccess(
'attributes');
205 $current = $asset->attr(
'attributes');
208 'uid' => translate(
'ldap_user_id'),
209 'cn' => translate(
'ldap_common_name'),
210 'fn' => translate(
'ldap_first_name'),
211 'sn' => translate(
'ldap_last_name'),
212 'email' => translate(
'ldap_email_address'),
215 'mo' => translate(
'ldap_group_membership'),
216 'gm' => translate(
'ldap_group_members_attribute'),
217 'ou' => translate(
'ldap_group_name'),
222 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
225 foreach ($required as $section => $section_data) {
226 $o->openSection(translate(
'ldap_attributes_section_'.$section));
227 foreach ($section_data as $code => $name) {
228 $o->openField($name);
229 $default = (isset($current[$code])) ? $current[$code] :
'';
231 text_box($prefix.
'_attributes['.$code.
']', $default, 20);
240 return $write_access;
257 if (isset($_POST[$prefix.
'_attributes'])) {
258 $new_attributes = Array();
259 foreach ($_POST[$prefix.
'_attributes'] as $code => $name) {
260 $name = (string)$name;
261 if (empty($name))
continue;
262 $new_attributes[(string)$code] = $name;
264 return $asset->setAttrValue(
'attributes', $new_attributes);
284 $write_access = $asset->writeAccess(
'attributes');
286 $current = $asset->attr(
'user_attributes');
287 $sort_by = (isset($current[
'sort_by'])) ? $current[
'sort_by'] :
'';
291 $user = $asset->getAsset($asset->id.
':'.$asset->attr(
'bind_dn'),
'', FALSE, FALSE, TRUE);
292 if (is_null($user)) {
293 trigger_localised_error(
'LDAP0001', E_USER_WARNING);
297 $user_type = $asset->attr(
'user_type');
298 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($user_type);
299 $ldap_asset =
new $user_type();
300 $ldap_asset_attrs = array_keys($ldap_asset->vars);
303 <table
class=
"sq-backend-table">
305 <td
class=
"sq-backend-table-header"><?php echo translate(
'ldap_attribute_name'); ?></td>
306 <td
class=
"sq-backend-table-header"><?php echo translate(
'ldap_common_name'); ?></td>
307 <td
class=
"sq-backend-table-header"><?php echo translate(
'display_question'); ?></td>
308 <td
class=
"sq-backend-table-header"><?php echo translate(
'ldap_use_for_sorting_question'); ?></td>
312 foreach ($user->vars as $field_name => $field_data) {
313 if (isset($current[
'show'][$field_name])) {
315 $display_name = $current[
'show'][$field_name];
318 $display_name = (isset($current[
'hide'][$field_name])) ? $current[
'hide'][$field_name] : $field_name;
323 <td
class=
"sq-backend-table-cell"><b><?php echo $field_name; ?></b></td>
324 <td
class=
"sq-backend-table-cell">
327 text_box($prefix.
'_user_attribute_fields['.$field_name.
'][name]', $display_name);
333 <td
class=
"sq-backend-table-cell">
336 check_box($prefix.
'_user_attribute_fields['.$field_name.
'][show]', 1, $show);
338 echo ($show) ? translate(
'yes') :
'';
342 <td
class=
"sq-backend-table-cell">
345 if (!in_array($field_name, $ldap_asset_attrs)){
346 radio_button($prefix.
'_sort_by', $field_name, ($field_name == $sort_by));
349 echo ($sort_by == $field_name) ? translate(
'yes') :
'';
359 return $write_access;
376 if (!isset($_POST[$prefix.
'_user_attribute_fields'])) {
380 $user_attributes = Array(
'show' => Array(),
'hide' => Array());
381 foreach ($_POST[$prefix.
'_user_attribute_fields'] as $field_name => $field_data) {
382 $show_hide = (isset($field_data[
'show']) && $field_data[
'show']) ?
'show' :
'hide';
383 $user_attributes[$show_hide][$field_name] = $field_data[
'name'];
385 $user_attributes[
'sort_by'] = (isset($_POST[$prefix.
'_sort_by'])) ? $_POST[$prefix.
'_sort_by'] :
'';
387 return $asset->setAttrValue(
'user_attributes', $user_attributes);
405 <p
class=
"sq-backend-warning"><strong><?php echo translate(
'ldap_not_available_line_1'); ?></strong></p>
406 <p><?php echo translate(
'ldap_not_available_line_2'); ?></p>
438 return extension_loaded(
'ldap');