Skip to content

Commit

Permalink
searchUser: handle "name-gender" in supannActivite-all in up1Profile …
Browse files Browse the repository at this point in the history
…/ forceProfile
  • Loading branch information
prigaux committed Jan 18, 2022
1 parent 8afd665 commit b9ac106
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions lib/supannPerson.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ function searchPeople($filter, $attrRestrictions, $wanted_attrs, $KEY_FIELD, $ma
forceProfile($user, $attrRestrictions['forceProfile'], $attrRestrictions['allowExtendedInfo'], $wanted_attrs);
unset($user['up1Profile']);
} else {
$user['up1Profile'] = parse_up1Profile($user['up1Profile'], $attrRestrictions['allowExtendedInfo'], $wanted_attrs);
$user['up1Profile'] = parse_up1Profile($user['up1Profile'], $attrRestrictions['allowExtendedInfo'], $wanted_attrs, $user);
}
}
userHandleSpecialAttributePrivacy($user, $attrRestrictions['allowExtendedInfo']);
Expand Down Expand Up @@ -503,7 +503,7 @@ function unescape_sharpFF($attr_value) {
return preg_replace_callback('/#([0-9A-F]{2})/', function ($xx) { return chr(hexdec($xx)); }, $attr_value);
}

function parse_up1Profile_one($up1Profile, $allowExtendedInfo, $wanted_attrs) {
function parse_up1Profile_one($up1Profile, $allowExtendedInfo, $wanted_attrs, $global_user) {
global $USER_ALLOWED_ATTRS;
$r = [];
while (preg_match('/^\[([^\[\]=]+)=((?:[^\[\]]|\[[^\[\]]*\])*)\](.*)/', $up1Profile, $m)) {
Expand All @@ -523,14 +523,14 @@ function parse_up1Profile_one($up1Profile, $allowExtendedInfo, $wanted_attrs) {
}

if ($up1Profile !== '') error_log("bad up1Profile, remaining $up1Profile");
userAttributesKeyToText($r, $wanted_attrs, @$r['supannCivilite']);
userAttributesKeyToText($r, $wanted_attrs, isset($r['supannCivilite']) ? $r['supannCivilite'] : $global_user['supannCivilite']);
return $r;
}

function parse_up1Profile($up1Profile_s, $allowExtendedInfo, $wanted_attrs) {
function parse_up1Profile($up1Profile_s, $allowExtendedInfo, $wanted_attrs, $global_user) {
$r = [];
foreach ($up1Profile_s as $profile) {
$r[] = parse_up1Profile_one($profile, $allowExtendedInfo, $wanted_attrs);
$r[] = parse_up1Profile_one($profile, $allowExtendedInfo, $wanted_attrs, $global_user);
}
return $r;
}
Expand All @@ -544,7 +544,7 @@ function array_replace_keys(&$array, $to_set) {
function forceProfile(&$user, $forceProfile, $allowExtendedInfo, $wanted_attrs) {
foreach ($user['up1Profile'] as $profile) {
if (contains($profile, $forceProfile)) {
array_replace_keys($user, parse_up1Profile_one($profile, $allowExtendedInfo, $wanted_attrs));
array_replace_keys($user, parse_up1Profile_one($profile, $allowExtendedInfo, $wanted_attrs, $user));
}
}
unset($user['up1Profile']);
Expand Down
2 changes: 1 addition & 1 deletion test/run.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function checkUserAttr($attr, $expected, $params = []) {
test_js_attr('use prefered profile', 'searchUser', 'employeeType', ['token' => 'fbar', 'profile_supannEntiteAffectation' => 'DS'], '["Charg\u00e9 d\'enseignement"]');

$full_fbar = <<<'EOS'
[{"uid":"fbar","mail":"[email protected]","displayName":"Fooo Bar","cn":"Bar Fooo","eduPersonPrimaryAffiliation":"staff","postalAddress":"90 rue de Tolbiac\n75634 PARIS CEDEX 13\nFRANCE","eduPersonPrincipalName":"[email protected]","sn":"Bar","givenName":"Fooo","supannEntiteAffectationPrincipale":"DGHA","supannCivilite":"M.","supannListeRouge":"FALSE","supannAliasLogin":"fbar","accountStatus":"active","supannEmpId":"99007","up1BirthName":"Bar","up1BirthDay":"20150101010000Z","homePhone":"+33 1 02 03 04 05","homePostalAddress":"6 rue Zoo$75018 PARIS$FRANCE","pager":"0607070707","supannEntiteAffectation":["DSIUN-PAS"],"eduPersonAffiliation":["employee","member","staff"],"supannActivite":["Chef-fe de projet ou expert-e syst\u00e8mes informatiques, r\u00e9seaux et t\u00e9l\u00e9communications"],"supannParrainDN":["ou=DGEP,ou=structures,o=Paris1,dc=univ-paris1,dc=fr"],"roomNumber":["B 407"],"up1FloorNumber":["4e"],"telephoneNumber":["+33 1 44 07 86 59"],"objectClass":["eduPerson","inetOrgPerson","organizationalPerson","person","posixAccount","shadowAccount","supannPerson"],"up1Profile":[{"supannParrainDN":["ou=DGEP,ou=structures,o=Paris1,dc=univ-paris1,dc=fr"],"eduPersonAffiliation":["member","employee","staff"],"supannEntiteAffectation":["DSIUN-PAS"],"buildingName":["Centre Pierre Mend\u00e8s France"],"supannEntiteAffectationPrincipale":"DGHA","postalAddress":"90 RUE DE TOLBIAC$75634 PARIS CEDEX 13$FRANCE","supannActivite":["Chef-fe de projet ou expert-e en Ing\u00e9ni\u00e9rie logicielle"],"eduPersonPrimaryAffiliation":"staff","supannEntiteAffectation-all":[{"key":"DGHA","name":"DSIUN-PAS","description":"DSIUN-PAS : P\u00f4le applications et services num\u00e9riques","businessCategory":"administration","labeledURI":"http:\/\/dsiun.univ-paris1.fr"}],"supannEntiteAffectation-ou":["DSIUN-PAS"],"supannEntiteAffectationPrincipale-all":{"key":"DGHA","name":"DSIUN-PAS","description":"DSIUN-PAS : P\u00f4le applications et services num\u00e9riques","businessCategory":"administration","labeledURI":"http:\/\/dsiun.univ-paris1.fr"},"supannParrainDN-all":[{"key":"supannCodeEntite=DGEP,ou=structures,dc=univ-paris1,dc=fr","name":"DRH-SP BIATSS","description":"DRH-SP BIATSS : service des personnels des biblioth\u00e8ques, ing\u00e9nieurs, administratifs, techniques, sociaux et de sant\u00e9"}],"supannActivite-all":[{"key":"{REFERENS}E1B22","name":"Chef-fe de projet ou expert-e en Ing\u00e9ni\u00e9rie logicielle"}]},{"employeeType":["Charg\u00e9 d'enseignement"],"supannParrainDN":["ou=DGEB,ou=structures,o=Paris1,dc=univ-paris1,dc=fr"],"eduPersonAffiliation":["member","teacher","employee"],"supannEntiteAffectation":["EDS"],"buildingName":["Centre Pierre Mend\u00e8s France"],"supannEntiteAffectationPrincipale":"DS","postalAddress":"90 RUE DE TOLBIAC$75634 PARIS CEDEX 13$FRANCE","eduPersonPrimaryAffiliation":"teacher","supannEntiteAffectation-all":[{"key":"DS","name":"EDS","description":"EDS : \u00c9cole de droit de la Sorbonne","businessCategory":"pedagogy","labeledURI":"http:\/\/eds.univ-paris1.fr"}],"supannEntiteAffectation-ou":["EDS"],"supannEntiteAffectationPrincipale-all":{"key":"DS","name":"EDS","description":"EDS : \u00c9cole de droit de la Sorbonne","businessCategory":"pedagogy","labeledURI":"http:\/\/eds.univ-paris1.fr"},"supannParrainDN-all":[null],"employeeType-all":[{"name":"Charg\u00e9 d'enseignement","weight":"10"}]},{"eduPersonAffiliation":["employee","member","staff"],"eduPersonEntitlement":["urn:mace:univ-paris1.fr:entitlement:SC4:registered-reader"],"eduPersonPrimaryAffiliation":"staff","givenName":"Pascal","sn":"Rigaux","supannCivilite":"M.","supannEtablissement":["SERV COM DOC UNIV"],"supannParrainDN":["supannCodeEntite=SC4,ou=structures,dc=univ-paris1,dc=fr"],"supannParrainDN-all":[null]}],"supannEntiteAffectation-all":[{"key":"DGHA","name":"DSIUN-PAS","description":"DSIUN-PAS : P\u00f4le applications et services num\u00e9riques","businessCategory":"administration","labeledURI":"http:\/\/dsiun.univ-paris1.fr"}],"supannEntiteAffectation-ou":["DSIUN-PAS"],"supannEntiteAffectationPrincipale-all":{"key":"DGHA","name":"DSIUN-PAS","description":"DSIUN-PAS : P\u00f4le applications et services num\u00e9riques","businessCategory":"administration","labeledURI":"http:\/\/dsiun.univ-paris1.fr"},"supannParrainDN-all":[{"key":"supannCodeEntite=DGEP,ou=structures,dc=univ-paris1,dc=fr","name":"DRH-SP BIATSS","description":"DRH-SP BIATSS : service des personnels des biblioth\u00e8ques, ing\u00e9nieurs, administratifs, techniques, sociaux et de sant\u00e9"}],"supannActivite-all":[{"key":"{REFERENS}E1C23","name":"Chef-fe de projet ou expert-e syst\u00e8mes informatiques, r\u00e9seaux et t\u00e9l\u00e9communications","name-gender":"Chef de projet ou expert syst\u00e8mes informatiques, r\u00e9seaux et t\u00e9l\u00e9communications"}]}]
[{"uid":"fbar","mail":"[email protected]","displayName":"Fooo Bar","cn":"Bar Fooo","eduPersonPrimaryAffiliation":"staff","postalAddress":"90 rue de Tolbiac\n75634 PARIS CEDEX 13\nFRANCE","eduPersonPrincipalName":"[email protected]","sn":"Bar","givenName":"Fooo","supannEntiteAffectationPrincipale":"DGHA","supannCivilite":"M.","supannListeRouge":"FALSE","supannAliasLogin":"fbar","accountStatus":"active","supannEmpId":"99007","up1BirthName":"Bar","up1BirthDay":"20150101010000Z","homePhone":"+33 1 02 03 04 05","homePostalAddress":"6 rue Zoo$75018 PARIS$FRANCE","pager":"0607070707","supannEntiteAffectation":["DSIUN-PAS"],"eduPersonAffiliation":["employee","member","staff"],"supannActivite":["Chef-fe de projet ou expert-e syst\u00e8mes informatiques, r\u00e9seaux et t\u00e9l\u00e9communications"],"supannParrainDN":["ou=DGEP,ou=structures,o=Paris1,dc=univ-paris1,dc=fr"],"roomNumber":["B 407"],"up1FloorNumber":["4e"],"telephoneNumber":["+33 1 44 07 86 59"],"objectClass":["eduPerson","inetOrgPerson","organizationalPerson","person","posixAccount","shadowAccount","supannPerson"],"up1Profile":[{"supannParrainDN":["ou=DGEP,ou=structures,o=Paris1,dc=univ-paris1,dc=fr"],"eduPersonAffiliation":["member","employee","staff"],"supannEntiteAffectation":["DSIUN-PAS"],"buildingName":["Centre Pierre Mend\u00e8s France"],"supannEntiteAffectationPrincipale":"DGHA","postalAddress":"90 RUE DE TOLBIAC$75634 PARIS CEDEX 13$FRANCE","supannActivite":["Chef-fe de projet ou expert-e en Ing\u00e9ni\u00e9rie logicielle"],"eduPersonPrimaryAffiliation":"staff","supannEntiteAffectation-all":[{"key":"DGHA","name":"DSIUN-PAS","description":"DSIUN-PAS : P\u00f4le applications et services num\u00e9riques","businessCategory":"administration","labeledURI":"http:\/\/dsiun.univ-paris1.fr"}],"supannEntiteAffectation-ou":["DSIUN-PAS"],"supannEntiteAffectationPrincipale-all":{"key":"DGHA","name":"DSIUN-PAS","description":"DSIUN-PAS : P\u00f4le applications et services num\u00e9riques","businessCategory":"administration","labeledURI":"http:\/\/dsiun.univ-paris1.fr"},"supannParrainDN-all":[{"key":"supannCodeEntite=DGEP,ou=structures,dc=univ-paris1,dc=fr","name":"DRH-SP BIATSS","description":"DRH-SP BIATSS : service des personnels des biblioth\u00e8ques, ing\u00e9nieurs, administratifs, techniques, sociaux et de sant\u00e9"}],"supannActivite-all":[{"key":"{REFERENS}E1B22","name":"Chef-fe de projet ou expert-e en Ing\u00e9ni\u00e9rie logicielle","name-gender":"Chef de projet ou expert en Ing\u00e9ni\u00e9rie logicielle"}]},{"employeeType":["Charg\u00e9 d'enseignement"],"supannParrainDN":["ou=DGEB,ou=structures,o=Paris1,dc=univ-paris1,dc=fr"],"eduPersonAffiliation":["member","teacher","employee"],"supannEntiteAffectation":["EDS"],"buildingName":["Centre Pierre Mend\u00e8s France"],"supannEntiteAffectationPrincipale":"DS","postalAddress":"90 RUE DE TOLBIAC$75634 PARIS CEDEX 13$FRANCE","eduPersonPrimaryAffiliation":"teacher","supannEntiteAffectation-all":[{"key":"DS","name":"EDS","description":"EDS : \u00c9cole de droit de la Sorbonne","businessCategory":"pedagogy","labeledURI":"http:\/\/eds.univ-paris1.fr"}],"supannEntiteAffectation-ou":["EDS"],"supannEntiteAffectationPrincipale-all":{"key":"DS","name":"EDS","description":"EDS : \u00c9cole de droit de la Sorbonne","businessCategory":"pedagogy","labeledURI":"http:\/\/eds.univ-paris1.fr"},"supannParrainDN-all":[null],"employeeType-all":[{"name":"Charg\u00e9 d'enseignement","weight":"10"}]},{"eduPersonAffiliation":["employee","member","staff"],"eduPersonEntitlement":["urn:mace:univ-paris1.fr:entitlement:SC4:registered-reader"],"eduPersonPrimaryAffiliation":"staff","givenName":"Pascal","sn":"Rigaux","supannCivilite":"M.","supannEtablissement":["SERV COM DOC UNIV"],"supannParrainDN":["supannCodeEntite=SC4,ou=structures,dc=univ-paris1,dc=fr"],"supannParrainDN-all":[null]}],"supannEntiteAffectation-all":[{"key":"DGHA","name":"DSIUN-PAS","description":"DSIUN-PAS : P\u00f4le applications et services num\u00e9riques","businessCategory":"administration","labeledURI":"http:\/\/dsiun.univ-paris1.fr"}],"supannEntiteAffectation-ou":["DSIUN-PAS"],"supannEntiteAffectationPrincipale-all":{"key":"DGHA","name":"DSIUN-PAS","description":"DSIUN-PAS : P\u00f4le applications et services num\u00e9riques","businessCategory":"administration","labeledURI":"http:\/\/dsiun.univ-paris1.fr"},"supannParrainDN-all":[{"key":"supannCodeEntite=DGEP,ou=structures,dc=univ-paris1,dc=fr","name":"DRH-SP BIATSS","description":"DRH-SP BIATSS : service des personnels des biblioth\u00e8ques, ing\u00e9nieurs, administratifs, techniques, sociaux et de sant\u00e9"}],"supannActivite-all":[{"key":"{REFERENS}E1C23","name":"Chef-fe de projet ou expert-e syst\u00e8mes informatiques, r\u00e9seaux et t\u00e9l\u00e9communications","name-gender":"Chef de projet ou expert syst\u00e8mes informatiques, r\u00e9seaux et t\u00e9l\u00e9communications"}]}]
EOS;

expect_json('simple searchUser all attrs', 'searchUser', ['token' => 'fbar'], $full_fbar);
Expand Down

0 comments on commit b9ac106

Please sign in to comment.