Fix hard-coded parameter information and add comment for newest functions

This commit is contained in:
Benjamin Renard 2016-11-17 11:37:19 +01:00
parent 7607a8f4ec
commit 71480875d4

View file

@ -189,6 +189,18 @@ LSerror :: defineError('POSIX_01',
return true; return true;
} }
/**
* Generate member attribute value from memberUid
*
* IMPORTANT : The attribute memberUid must be define in configuration
* of the same object and must use HTML type select_object.
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param[in] $ldapObject The LSldapObject
*
* @retval array|null array of member attribute values or null in case of error
*/
function generateMemberFromMemberUid($ldapObject) { function generateMemberFromMemberUid($ldapObject) {
if ( get_class($ldapObject -> attrs[ 'memberUid' ]) != 'LSattribute' ) { if ( get_class($ldapObject -> attrs[ 'memberUid' ]) != 'LSattribute' ) {
LSerror :: addErrorCode('POSIX_01',array('dependency' => 'memberUid', 'attr' => 'member')); LSerror :: addErrorCode('POSIX_01',array('dependency' => 'memberUid', 'attr' => 'member'));
@ -200,17 +212,33 @@ function generateMemberFromMemberUid($ldapObject) {
return; return;
} }
$obj_type=LSconfig::get('LSobjects.'.get_class($ldapObject).'.attrs.memberUid.html_options.selectable_object.object_type');
if (empty($obj_type))
return;
$uids = $ldapObject -> attrs[ 'memberUid' ] -> getValue(); $uids = $ldapObject -> attrs[ 'memberUid' ] -> getValue();
$member = array(); $member = array();
if (is_array($uids)) { if (is_array($uids)) {
foreach ( $uids as $uid ) { foreach ( $uids as $uid ) {
$member[]='uid='.$uid.','.LSconfig::get('LSobjets.LSehessPerson.container_dn').','.LSsession::getTopDn(); $member[]='uid='.$uid.','.LSconfig::get('LSobjects.'.$obj_type.'.container_dn').','.LSsession::getTopDn();
} }
} }
return $member; return $member;
} }
/**
* Generate memberUid attribute value from uniqueMember
*
* IMPORTANT : The attribute uniqueMember must be define in configuration
* of the same object.
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param[in] $ldapObject The LSldapObject
*
* @retval array|null array of memberUid values or null in case of error
*/
function generate_memberUidFromUniqueMember($ldapObject) { function generate_memberUidFromUniqueMember($ldapObject) {
if ( get_class($ldapObject -> attrs[ 'memberUid' ]) != 'LSattribute' ) { if ( get_class($ldapObject -> attrs[ 'memberUid' ]) != 'LSattribute' ) {
LSerror :: addErrorCode('POSIX_01',array('dependency' => 'memberUid', 'attr' => 'memberUid')); LSerror :: addErrorCode('POSIX_01',array('dependency' => 'memberUid', 'attr' => 'memberUid'));
@ -234,5 +262,3 @@ function generate_memberUidFromUniqueMember($ldapObject) {
return $uids; return $uids;
} }
?>