18 require_once SQ_INCLUDE_PATH.
'/asset.inc';
19 require_once SQ_CORE_PACKAGE_PATH.
'/interfaces/bridge/bridge.inc';
20 require_once SQ_FUDGE_PATH.
'/ldap/ldap.inc';
42 var $_group_types = Array(
43 'organizationalunit' =>
'ou',
46 'groupofnames' =>
'cn',
47 'groupofuniquenames' =>
'cn',
50 'organization' =>
'o',
60 var $_user_types = Array(
61 'organizationalperson' =>
'cn',
62 'inetorgperson' =>
'cn',
71 var $ldap_shdw_link_type = SQ_LINK_TYPE_1;
82 $this->_ser_attrs = TRUE;
83 $this->
Asset($assetid);
98 protected function _getName($short_name=FALSE, $contextid=NULL)
101 if ($contextid === NULL) {
102 $contextid = $GLOBALS[
'SQ_SYSTEM']->getContextId();
106 $values = $GLOBALS[
'SQ_SYSTEM']->am->getAttributeValuesByName(
'name', $this->
type(), Array($this->
id), $contextid);
107 if (empty($values) === TRUE) {
108 return parent::_getName($short_name, $contextid);
110 return $values[$this->id];
125 if ($this->status == SQ_STATUS_ARCHIVED) {
130 $hostname = $this->
attr(
'host');
131 if (empty($hostname))
return NULL;
134 if (!$ldap->connect($this->attr(
'host'), $this->
attr(
'port'))) {
139 foreach ($this->
attr(
'ldap_options') as $option => $value) {
140 ldap_set_option($ldap->ptr, constant($option), $value);
144 ldap_set_option($ldap->ptr, LDAP_OPT_DEREF, constant($this->
attr(
'aliases')));
146 $bind_dn = $this->
attr(
'bind_dn');
150 if (empty($bind_dn)) {
153 $password = $this->
attr(
'password');
156 if (!$ldap->bind($bind_dn, $password)) {
181 'LDAP_OPT_PROTOCOL_VERSION' => 3,
182 'LDAP_OPT_REFERRALS' => 0,
205 function getAsset($assetid, $type_code=
'', $mute_errors=FALSE, $return_null=FALSE, $get_all_attr = FALSE)
208 $id_parts = explode(
':', $assetid);
210 if (isset($id_parts[1])) {
211 $shadowid = $id_parts[1];
217 if (isset($id_parts[2]) && $id_parts[2] ==
'inbox') {
218 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'inbox');
219 $inbox_asset =
new Inbox();
220 $inbox_asset->id = $this->
id.
':'.$shadowid.
':inbox';
221 $inbox_asset->name =
'Inbox';
222 $inbox_asset->status = $this->status;
227 if (is_null($ldap) || is_null($ldap->ptr))
return $return_null ? NULL : $this->
_getDummyAsset($shadowid);
228 $required_attrs = $this->
attr(
'attributes');
232 if (!$get_all_attr) {
233 $user_attrs = $this->
attr(
'user_attributes');
234 $sort_attr = (!empty($user_attrs[
'sort_by'])) ? Array($user_attrs[
'sort_by']) : Array();
235 $attr_req = array_merge(
236 array_keys(array_get_index($this->
attr(
'user_attributes'),
'show', Array())),
237 array_values($required_attrs),
242 $result = $ldap->search($shadowid,
'(objectClass=*)', NULL, FALSE, FALSE, array_values(array_unique($attr_req)));
244 $result = $ldap->search($shadowid,
'(objectClass=*)', NULL, FALSE, FALSE);
247 if (!$result)
return $return_null ? NULL : $this->
_getDummyAsset($shadowid);
248 $data = $ldap->getEntries($result);
249 if (!$data[
'count'])
return $return_null ? NULL : $this->
_getDummyAsset($shadowid);
254 if (!isset($data[
'dn']) && isset($data[
'distinguishedname'])) {
255 $data[
'dn'] = $data[
'distinguishedname'];
258 unset($data[
'objectclass'][
'count']);
260 foreach ($data[
'objectclass'] as $class) {
261 $class = strtolower($class);
262 if (isset($this->_group_types[$class])) {
264 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'ldap_user_group');
268 }
else if (isset($this->_user_types[$class])) {
270 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'ldap_backend_user');
271 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'ldap_simple_edit_user');
272 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'ldap_user');
275 $user_type = $this->
attr(
'user_type');
276 $asset =
new $user_type($this->
id, $data);
297 $data[
'objectclass'] = Array();
298 $data[
'dn'] = $shadowid;
299 $user_type = $this->
attr(
'user_type');
300 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($user_type);
301 $asset =
new $user_type($this->
id, $data);
319 if (!is_array($assetids)) {
320 $assetids = Array($assetids);
322 assert_type($type_code,
'array');
323 if (empty($assetids))
return Array();
326 $type_codes = Array();
329 $type_infos = $GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo($assetids, $type_code, $strict_type_code,
'type_code');
331 foreach ($type_infos as $assetid => $type_code) {
332 if (!isset($type_codes[$type_code])) {
333 $sql =
'SELECT inhd_type_code FROM sq_ast_typ_inhd WHERE type_code = :type_code ORDER BY inhd_type_code_lvl DESC';
337 $type_codes[$type_code] = $result;
340 $results[$assetid] = $type_codes[$type_code];
373 function getLinks($assetid, $link_types, $type_code=
'', $strict_type_code=TRUE, $side_of_link=
'major', $sort_by=NULL, $dependant=NULL, $exclusive=NULL)
377 if (!($this->ldap_shdw_link_type & $link_types)) {
381 if ($dependant || $exclusive) {
385 $id_parts = explode(
':', $assetid);
386 if (isset($id_parts[1])) $assetid = $id_parts[1];
388 if (!is_array($type_code)) {
389 if (empty($type_code)) {
390 $type_code = Array();
392 $type_code = Array($type_code);
395 $type_code_key = implode(
'-', $type_code);
398 $attrs = $this->
attr(
'attributes');
400 if (!isset($this->_tmp[
'getLinks'][$assetid][$side_of_link][$type_code_key])) {
402 if ($side_of_link ==
'minor') {
405 $minorid = substr($assetid, strpos($assetid,
',') +1);
406 if ($minorid == $this->
attr(
'root_dn')) {
410 'majorid' => $this->
id,
411 'major_type_code' => $this->
type(),
412 'minorid' => $this->
id.
':'.$assetid,
414 'link_type' => $this->ldap_shdw_link_type,
415 'is_dependant' => FALSE,
416 'is_exclusive' => FALSE,
422 $asset = $this->
getAsset($this->
id.
':'.$minorid);
424 if (!empty($type_code)) {
425 if ($asset->type() ==
'ldap_user_group') {
426 if (!((in_array(
'ldap_user_group', $type_code)) || (!$strict_type_code && in_array(
'user_group', $type_code)))) {
429 }
else if ($asset->type() ==
'ldap_backend_user') {
430 if (!((in_array(
'ldap_backend_user', $type_code)) || (!$strict_type_code && in_array(
'user', $type_code)) || (!$strict_type_code && in_array(
'ldap_user', $type_code)))) {
433 }
else if ($asset->type() ==
'ldap_backend_user') {
434 if (!((in_array(
'ldap_simple_edit_user', $type_code)) || (!$strict_type_code && in_array(
'user', $type_code)) || (!$strict_type_code && in_array(
'ldap_user', $type_code)))) {
437 }
else if ($asset->type() ==
'ldap_user') {
438 if (!((in_array(
'ldap_user', $type_code)) || (!$strict_type_code && in_array(
'user', $type_code)))) {
446 'majorid' => $asset->id,
447 'major_type_code' => $asset->type(),
448 'minorid' => $this->
id.
':'.$assetid,
450 'link_type' => $this->ldap_shdw_link_type,
451 'is_dependant' => FALSE,
452 'is_exclusive' => FALSE,
462 $attr = $this->
attr(
'attributes');
463 $user_attrs = $this->
attr(
'user_attributes');
464 $sort_by = (!empty($user_attrs[
'sort_by'])) ? $user_attrs[
'sort_by'] : NULL;
469 if (($this->
attr(
'system_type') ==
'activedirectory') && empty($attr[
'gm'])) {
470 $attr[
'gm'] =
'member';
472 if ($assetid != $this->
id) {
473 $asset = $this->
getAsset($this->
id.
':'.$assetid);
474 if ($asset->type() ==
'ldap_user_group' && !empty($attr[
'gm']) && isset($asset->vars[$attr[
'gm']])) {
475 $members = $asset->vars[$attr[
'gm']];
477 foreach ($members as $dn) {
478 $user = $this->
getAsset($this->
id.
':'.$dn,
'', FALSE, TRUE);
480 if (!is_null($user)){
481 $user->vars[
'dn'] = $dn;
482 $entries[$dn] = $user->vars;
485 if (!empty($sort_by)){
486 uasort($entries, create_function(
'$a,$b',
487 '$a = (isset($a[\''.$sort_by.
'\'][\
'value\'])) ? $a[\''.$sort_by.
'\'][\
'value\'] : "";
488 $b = (isset($b[\''.$sort_by.
'\'][\
'value\'])) ? $b[\''.$sort_by.
'\'][\
'value\'] : "";
492 return ($a < $b) ? -1 : 1;'
499 if (is_null($entries)) {
501 if (is_null($ldap) || is_null($ldap->ptr))
return Array();
503 if ($assetid == $this->
id) {
504 $base_dn = $this->
attr(
'root_dn');
510 foreach ($this->_group_types as $key => $value) {
511 if (empty($filter)) {
512 $filter =
'(objectClass='.$key.
')';
514 $filter =
'(|'.$filter.
'(objectClass='.$key.
'))';
517 foreach ($this->_user_types as $key => $value) {
518 if (empty($filter)) {
519 $filter =
'(objectClass='.$key.
')';
521 $filter =
'(|'.$filter.
'(objectClass='.$key.
'))';
528 $sort_attr = (!empty($sort_by)) ? Array($sort_by) : Array();
529 $required_attrs = array_values(array_unique(array_merge($attr, $sort_attr, Array(
'c',
'o',
'ou',
'cn',
'dc',
'objectclass'))));
530 $result = $ldap->search($base_dn, $filter, $sort_by, FALSE, TRUE, $required_attrs);
537 $entries = $ldap->getEntries($result);
538 if (!$entries[
'count']) {
542 unset($entries[
'count']);
550 foreach ($entries as $data) {
553 if (isset($data[
'objectclass'][
'count'])) {
554 unset($data[
'objectclass'][
'count']);
557 if (isset($data[
'objectclass'][
'value'])) {
558 $data[
'objectclass'] = $data[
'objectclass'][
'value'];
561 foreach ($data[
'objectclass'] as $class) {
562 $class = strtolower($class);
563 foreach ($this->_group_types as $key => $value) {
564 if ($class == $key) {
565 if (!isset($attrs[$value])) {
566 $attrs[$value] = $value;
569 if (!isset($data[$attrs[$value]][0])) {
573 $name = $data[$attrs[$value]][0];
574 $type =
'ldap_user_group';
580 foreach ($this->_user_types as $key => $value) {
581 if ($class == $key) {
582 if (!isset($attrs[$value])) {
583 $attrs[$value] = $value;
586 if ((!isset($data[$attrs[$value]][0]) && !isset($data[$attrs[$value]][
'value']))) {
590 if (isset($data[$attrs[$value]][
'value']) && isset($data[$attrs[$value]][
'value'][0])) {
591 $name = $data[$attrs[$value]][
'value'][0];
593 $name = $data[$attrs[$value]][0];
595 $type = $this->
attr(
'user_type');
599 if (!empty($type))
break;
602 if (empty($type))
continue;
603 if (!empty($type_code)) {
605 if ($type ==
'ldap_user_group') {
606 if (!in_array(
'user_group', $type_code) && !in_array(
'ldap_user_group', $type_code)) {
611 if ($this->
attr(
'user_type') ==
'ldap_backend_user') {
615 'ldap_simple_edit_user',
618 }
else if ($this->
attr(
'user_type') ==
'ldap_simple_edit_user') {
622 'ldap_simple_edit_user',
631 $found = array_intersect($all_types, $type_code);
632 if (empty($found))
continue;
639 if (!isset($data[
'dn']) && isset($data[
'distinguishedname'])) {
640 $data[
'dn'] = $data[
'distinguishedname'];
643 if (is_array($data[
'dn'])) {
644 $dn = array_shift($data[
'dn']);
651 'majorid' => $this->
id,
653 'minor_type_code' => $type,
655 'link_type' => $this->ldap_shdw_link_type,
656 'is_dependant' => FALSE,
657 'is_exclusive' => FALSE,
667 $this->_tmp[
'getLinks'][$assetid][$side_of_link][$type_code_key] = $links;
670 return $this->_tmp[
'getLinks'][$assetid][$side_of_link][$type_code_key];
690 function getParents($assetid, $type_code=
'', $strict_type_code=TRUE)
692 $id_parts = explode(
':', $assetid);
693 if (isset($id_parts[1])) $assetid = $id_parts[1];
696 if (!is_array($type_code)) {
697 $type_code = Array($type_code);
701 $valid_types = Array(
'user_group',
'ldap_user_group');
702 $found_type = array_intersect($valid_types, $type_code);
704 if (empty($found_type)) {
708 if (!isset($this->_tmp[
'getParents'][$assetid])) {
710 if (is_null($ldap) || is_null($ldap->ptr))
return Array();
713 $attrs = $this->
attr(
'attributes');
716 $result = $ldap->search($assetid,
'(objectClass=*)', NULL, FALSE, FALSE, array_merge(array_values($attrs), Array(
'objectclass')));
717 if (!$result)
return Array();
719 $data = $ldap->getEntries($result);
720 if (!$data[
'count']) {
726 $mo_groups = Array();
728 if (isset($attrs[
'mo']) && isset($data[$attrs[
'mo']])) {
730 $mo_groups = $data[$attrs[
'mo']];
731 if (!$mo_groups[
'count']) $mo_groups = Array();
732 unset($mo_groups[
'count']);
733 }
else if (isset($attrs[
'gm'])) {
735 $base_dn = $this->
attr(
'root_dn');
737 $result = $ldap->search($base_dn,
'('.$attrs[
'gm'].
'='.$ldap->escape_filter_value($assetid).
')', NULL, TRUE, TRUE, array_merge(array_values($attrs), Array(
'objectclass')));
739 $groups = $ldap->getEntries($result);
740 if (!$groups[
'count']) $mo_groups = Array();
741 unset($groups[
'count']);
742 foreach ($groups as $group_data) {
743 $mo_groups[] = $group_data[
'dn'];
749 $ou_groups = Array();
751 $reg_expression =
'|ou=([^,]+),(.*)|i';
752 $reg_string = substr($assetid, strpos($assetid,
',') + 1);
757 preg_match_all($reg_expression, $reg_string, $matches);
758 if (!empty($matches[1])) {
759 $reg_string = array_shift($matches[2]);
760 $ou_groups[array_shift($matches[1])] = $reg_string;
766 foreach ($mo_groups as $group_name) {
768 $result = $ldap->search($group_name,
'(objectClass=*)', NULL, FALSE, FALSE, array_merge(array_values($attrs), Array(
'objectclass')));
769 if (!$result)
continue;
770 $group_data = $ldap->getEntries($result);
771 if ($group_data[
'count'] > 0) {
772 $parents[$this->
id.
':'.$group_data[0][
'dn']] =
'ldap_user_group';
776 foreach ($ou_groups as $group_name => $group_dn) {
778 $ou_value = (isset($attrs[
'ou']) && $attrs[
'ou'] !=
'') ? $attrs[
'ou'] :
'ou';
779 $result = $ldap->search($ou_value.
'='.$group_name.
','.$group_dn,
'(objectClass=organizationalUnit)', NULL, FALSE, FALSE, array_merge(array_values($attrs), Array(
'objectclass')));
780 if (!$result)
continue;
781 $group_data = $ldap->getEntries($result);
783 if ($group_data[
'count'] > 0) {
784 $parents[$this->
id.
':'.$group_data[0][
'dn']] =
'ldap_user_group';
790 if (!empty($parents)) {
795 $bridge_getParents_first_level = FALSE;
796 if (!isset($this->_tmp[
'all_parents'])) {
798 $this->_tmp[
'all_parents'] = Array($this->
id.
':'.$assetid =>
'');
799 $bridge_getParents_first_level = TRUE;
804 $valid_parents = Array();
805 foreach ($parents as $parent_id => $parent_type_code) {
806 if (!isset($this->_tmp[
'all_parents'][$parent_id])) {
807 $valid_parents[$parent_id] = $parent_type_code;
812 $parents = $valid_parents;
814 if (!empty($valid_parents)) {
817 $this->_tmp[
'all_parents'] += $valid_parents;
820 $grandparents = Array();
821 foreach ($valid_parents as $parent_id => $parent_type_code) {
822 $grandparents += $GLOBALS[
'SQ_SYSTEM']->am->getParents($parent_id, $type_code, $strict_type_code);
826 $parents += $grandparents;
830 if ($bridge_getParents_first_level) {
833 unset($this->_tmp[
'all_parents']);
842 $this->_tmp[
'getParents'][$assetid] = $parents;
846 return $this->_tmp[
'getParents'][$assetid];
871 function getChildren($assetid, $type_code=
'', $strict_type_code=TRUE, $dependant=NULL, $sort_by=NULL)
873 $id_parts = explode(
':', $assetid);
874 if (isset($id_parts[1])) $assetid = $id_parts[1];
876 if ($assetid != $this->
id) {
879 if ($this->
attr(
'system_type') ==
'activedirectory') {
880 $links = $this->
getLinks($assetid, SQ_LINK_TYPE_1 | SQ_LINK_TYPE_2, $type_code, $strict_type_code,
'major', $sort_by);
883 foreach ($links as $link_data) {
884 $children[$link_data[
'minorid']][0][
'type_code'] = $link_data[
'minor_type_code'];
890 if (!is_array($type_code)) {
891 if (empty($type_code)) {
892 $type_code = Array();
894 $type_code = Array($type_code);
899 if (is_null($ldap) || is_null($ldap->ptr))
return Array();
901 if ($assetid == $this->
id) {
902 $base_dn = $this->
attr(
'root_dn');
908 $attrs = $this->
attr(
'attributes');
911 $result = $ldap->search($base_dn,
'(objectClass=*)', NULL, TRUE, TRUE, array_merge(array_values($attrs), Array(
'objectclass')));
916 $entries = $ldap->getEntries($result);
917 if (!$entries[
'count']) {
921 unset($entries[
'count']);
923 if ($sort_by ==
'name') {
925 $sorted_array = Array();
926 foreach ($entries as $data) {
930 unset($data[
'objectclass'][
'count']);
931 foreach ($data[
'objectclass'] as $class) {
932 $class = strtolower($class);
933 foreach ($this->_group_types as $key => $value) {
934 if ($class == $key) $attr = $value;
936 foreach ($this->_user_types as $key => $value) {
937 if ($class == $key) $attr = $value;
940 if (empty($attr))
continue;
942 $sorted_array[strtolower($data[$attrs[$attr]][0])] = Array(
944 'objectclass' => $data[
'objectclass'],
948 ksort($sorted_array, SORT_STRING);
949 $entries = $sorted_array;
958 if ($this->
attr(
'user_type') ==
'ldap_backend_user') {
962 'ldap_simple_edit_user',
965 }
else if ($this->
attr(
'user_type') ==
'ldap_simple_edit_user') {
969 'ldap_simple_edit_user',
978 $user_groups = Array(
'user_group',
'ldap_user_group');
979 $found = array_intersect($all_types, $type_code);
980 $found_ug = array_intersect($user_groups, $type_code);
982 foreach ($entries as $data) {
983 if ($data[
'dn'] == $assetid)
continue;
984 unset($data[
'objectclass'][
'count']);
985 foreach ($data[
'objectclass'] as $class) {
986 $class = strtolower($class);
987 if (isset($this->_group_types[$class])) {
988 if (!empty($type_code) && empty($found_ug)) {
991 $children[$this->
id.
':'.$data[
'dn']][0][
'type_code'] =
'ldap_user_group';
992 }
else if (isset($this->_user_types[$class])) {
993 if (!empty($type_code) && empty($found)) {
996 $children[$this->
id.
':'.$data[
'dn']][0][
'type_code'] = $this->
attr(
'user_type');
1001 $ldap->disconnect();
1022 $groups = explode(
',', $assetid);
1023 for (reset($groups); NULL !== ($k = key($groups));) {
1024 $dn = implode(
',', $groups);
1025 if ($dn == $this->
attr(
'root_dn'))
break;
1027 $asset = $this->
getAsset($this->
id.
':'.$dn);
1028 $url = substr($asset->getURL(), strlen(current_protocol()) +3);
1030 $lineage[] = Array (
1032 'assetid' => $this->
id.
':'.$dn,
1033 'name' => $asset->name,
1034 'short_name' => $asset->short_name,
1035 'type_code' => $asset->type(),
1036 'link_type' => SQ_LINK_TYPE_1,
1037 'protocol' => current_protocol(),
1042 return array_reverse($lineage);
1067 function getPermission($assetid, $permission, $granted=NULL, $and_greater=TRUE, $expand_groups=FALSE, $all_info=FALSE)
1070 return $GLOBALS[
'SQ_SYSTEM']->am->getPermission($this->
id, $permission, $granted, $and_greater, $expand_groups, $all_info);
1124 function getAssetInfo($assetids, $type_code=Array(), $strict_type_code=TRUE, $field=
'')
1127 foreach ($assetids as $assetid) {
1128 if (!empty($field)) {
1129 if ($field ==
'assetid') {
1130 $info[$assetid] = $assetid;
1131 }
else if ($field ==
'type_code') {
1132 $asset =& $this->
getAsset($assetid);
1133 if (is_null($asset) === FALSE) {
1134 $info[$assetid] = $asset->type();
1136 $info[$assetid] =
'';
1138 }
else if (in_array($field , Array(
'version',
'name',
'short_name',
'status'))) {
1139 $asset =& $this->
getAsset($assetid);
1140 if (is_null($asset) === FALSE) {
1141 $info[$assetid] = $asset->$field;
1143 $info[$assetid] =
'';
1146 $info[$assetid] = $this->$field;
1149 $asset =& $this->
getAsset($assetid);
1150 if (is_null($asset) === FALSE) {
1151 $info[$assetid] = Array(
1152 'assetid' => $assetid,
1153 'type_code' => $asset->type(),
1154 'version' => $asset->version,
1155 'name' => $asset->name,
1156 'short_name' => $asset->short_name,
1157 'status' => $asset->status,
1158 'languages' => $this->languages,
1159 'charset' => $this->charset,
1160 'force_secure' => $this->force_secure,
1161 'created' => $this->created,
1162 'created_userid' => $this->created_userid,
1163 'updated' => $this->updated,
1164 'updated_userid' => $this->updated_userid,
1165 'published' => $this->published,
1166 'published_userid' => $this->published_userid,
1167 'status_changed' => $this->status_changed,
1168 'status_changed_userid' => $this->status_changed_userid,
1171 $info[$assetid] = Array();
1220 function getLink($assetid, $link_type=NULL, $type_code=
'', $strict_type_code=TRUE, $value=NULL, $side_of_link=
'major', $exclusive=NULL)
1222 if ($type_code==
'inbox') {
1223 return $links = Array(
1225 'majorid' => $assetid,
1226 'minor_type_code' =>
'inbox',
1227 'minorid' => $assetid.
':inbox',
1229 'link_type' => $this->ldap_shdw_link_type,
1230 'is_dependant' => FALSE,
1231 'is_exclusive' => FALSE,
1235 }
else if ($type_code ==
'user' && $side_of_link ==
'minor') {
1236 $id_parts = explode(
':', $assetid);
1237 if (isset($id_parts[2]) && $id_parts[2] ==
'inbox') {
1238 return $links = Array(
1240 'majorid' => $id_parts[0].
':'.$id_parts[1],
1241 'major_type_code' => $this->
attr(
'user_type'),
1242 'minorid' => $assetid,
1244 'link_type' => $this->ldap_shdw_link_type,
1245 'is_dependant' => FALSE,
1246 'is_exclusive' => FALSE,
1297 function countLinks($assetid, $side_of_link=
'major', $link_types=0, $type_code=
'', $strict_type_code=TRUE, $ignore_linkid=0)
1324 function getLinkByAsset($assetid, $other_assetid, $link_types=NULL, $value=NULL, $side_of_link=
'major', $force_array=FALSE, $dependant=NULL, $exclusive=NULL)
1361 function updateLink($linkid, $link_type=NULL, $value=NULL, $sort_order=NULL)
1420 function createAssetLink(&$major, &$minor, $link_type, $value=
'', $sort_order=NULL, $dependant=
'0', $exclusive=
'0', $moving=FALSE)
1435 function delete($release_lock)
1437 if (parent::delete($release_lock)) {
1456 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
1457 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
1459 $sql =
'DELETE FROM sq_shdw_ast_lnk WHERE minorid LIKE :minorid';
1465 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
1466 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
1485 $show = $this->
attr(
'user_attributes');
1486 if (!isset($show[
'show'])) {
1489 $show = $show[
'show'];
1493 ?><table border=
"0" cellspacing=
"2" cellpadding=
"2"><?php
1497 foreach ($show as $field_name => $friendly_name) {
1498 if (!isset($info[$field_name])) {
1502 $value = $info[$field_name][
'value'];
1505 if (is_array($value)) {
1506 $count = count($value);
1507 $value = implode(
'<br />', $value);
1509 if ($count > 1) $multi =
' ('.$count.
' values)';
1512 $o->openField($friendly_name.$multi);
1514 ?><tr><td valign=
"top"><b><?php echo $friendly_name.$multi; ?></b></td><td valign=
"top"><?php
1521 if (isset($info[$field_name][
'attrid'])) {
1522 echo
'<span style="color:#666">(attrid = '.$info[$field_name][
'attrid'].
')</span> ';
1524 echo
'<span style="color:#666">(type = '.$info[$field_name][
'type'].
')</span>';
1552 $attrs = $this->
attr(
'attributes');
1553 $user->_ldapid = $this->id;
1556 $user->id = $this->
id.
':'.$this->
encodeString($data[
'dn']);
1557 foreach ($data[
'objectclass'] as $class) {
1558 $class = strtolower($class);
1559 foreach ($this->_user_types as $key => $value) {
1560 if (($class == $key) && isset($attrs[$value])) {
1561 $user->name = $data[$attrs[$value]][0];
1565 if (empty($user->name)) {
1566 $user->name = translate(
'ldap_unknown_user');
1571 $user->short_name = $user->name;
1572 $user->status = $this->status;
1573 $user->version =
'0.1';
1577 foreach ($data as $key => $value) {
1578 if (is_array($value)) {
1579 if (isset($value[
'count'])) unset($value[
'count']);
1580 if (count($value) > 1) {
1581 $user->vars[$key] = Array(
1583 'type' =>
'serialise',
1587 $user->vars[$key] = Array(
1588 'value' => array_shift($value),
1597 $user->_loadDataPaths();
1600 $user->vars[
'dn'][
'value'] = $data[
'dn'];
1601 $user->vars[
'dn'][
'type'] =
'text';
1603 if (isset($attrs[
'uid']) && isset($data[$attrs[
'uid']])) {
1604 $user->vars[
'username'][
'value'] = $data[$attrs[
'uid']][0];
1606 $user->vars[
'username'][
'value'] = $data[
'dn'];
1609 $user->vars[
'username'][
'type'] =
'text';
1611 if (isset($attrs[
'email']) && isset($data[$attrs[
'email']])) {
1612 $user->vars[
'email'][
'value'] = $data[$attrs[
'email']][0];
1614 $user->vars[
'email'][
'value'] =
'';
1617 $user->vars[
'email'][
'type'] =
'email';
1619 if (isset($attrs[
'fn']) && isset($data[$attrs[
'fn']])) {
1620 $user->vars[
'first_name'][
'value'] = $data[$attrs[
'fn']][0];
1622 $user->vars[
'first_name'][
'value'] =
'';
1625 $user->vars[
'first_name'][
'type'] =
'text';
1627 if (isset($attrs[
'sn']) && isset($data[$attrs[
'sn']])) {
1628 $user->vars[
'last_name'][
'value'] = $data[$attrs[
'sn']][0];
1630 $user->vars[
'last_name'][
'value'] =
'';
1633 $user->vars[
'last_name'][
'type'] =
'text';
1651 if (is_array($string)) {
1652 foreach ($string as $key => $value) {
1656 $string = str_replace(
'&',
'%26', $string);
1677 if (is_array($string)) {
1678 foreach ($string as $key => $value) {
1682 $string = str_replace(
'%26',
'&', $string);