Skip to content

Commit

Permalink
searchUser: handle "name-gender" in supannActivite-all
Browse files Browse the repository at this point in the history
  • Loading branch information
prigaux committed Jan 18, 2022
1 parent 1d435eb commit caa1c13
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
4 changes: 3 additions & 1 deletion config/config-groups.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
'displayName;x-gender-m;x-short' => "name-gender-m-short", 'displayName;x-gender-f;x-short' => "name-gender-f-short",
"up1Flags" => "weight");
$ETABLISSEMENT_TABLE_ATTRS = array("up1TableKey" => "key", "displayName" => "name");
$ACTIVITE_TABLE_ATTRS = array("up1TableKey" => "key", "displayName" => "name");
$ACTIVITE_TABLE_ATTRS = array("up1TableKey" => "key", "displayName" => "name",
'displayName;x-gender-m' => "name-gender-m", 'displayName;x-gender-f' => "name-gender-f",
);

$AFFILIATION2TEXT = array("faculty" => "enseignants-chercheurs",
"teacher" => "enseignants et chargés d'enseignement",
Expand Down
2 changes: 1 addition & 1 deletion gen/genTables
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ $fh = fopen($output_file, "w");
if (!$fh) exit("failed to open output file $output_file");
gen($fh,
array('structureKeyToAll' => $structures,
'activiteKeyToAll' => $activites,
'roleGeneriqueKeyToAll' => $roles),
array('roleGeneriqueKeyToShortname' => $roles,
'activiteKeyToShortname' => $activites,
'etablissementKeyToShortname' => $etablissements,
'supannCodePopulationToShortname' => $supannCodesPopulation),
array('descriptionToActivityKey' => $activitesUP1)
Expand Down
16 changes: 10 additions & 6 deletions lib/supannPerson.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,17 @@ function activiteUP1All($descriptions) {
return $r;
}

function supannActiviteAll($keys) {
global $activiteKeyToShortname;
function supannActiviteAll($user, $keys) {
global $activiteKeyToAll;
$r = array();
foreach ($keys as $key) {
$e = array('key' => $key);
$name = @$activiteKeyToShortname[$key];
if ($name) $e['name'] = $name;
$all = @$activiteKeyToAll[$key];
if ($all) {
$e['name'] = $all['name'];
$gender = all_to_name_with_gender_no_fallback($all, $user);
if ($gender) $e['name-gender'] = $gender;
}
$r[] = $e;
}
return empty($r) ? NULL : $r;
Expand All @@ -477,7 +481,7 @@ function toShortnames($all) {
}

function supannActiviteShortnames($keys) {
return toShortnames(supannActiviteAll($keys));
return toShortnames(supannActiviteAll([], $keys));
}

function parse_composite_value($s) {
Expand Down Expand Up @@ -825,7 +829,7 @@ function userAttributesKeyToText(&$user, $wanted_attrs) {
}
if (isset($user['supannActivite'])) {
if (isset($wanted_attrs['supannActivite-all']))
$user['supannActivite-all'] = supannActiviteAll($user['supannActivite']);
$user['supannActivite-all'] = supannActiviteAll($user, $user['supannActivite']);
if (isset($wanted_attrs['supannActivite']))
$user['supannActivite'] = supannActiviteShortnames($user['supannActivite']);
else
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 de projet ou expert 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 de projet ou expert en d\u00e9veloppement et d\u00e9ploiement d'applications"],"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 de projet ou expert en d\u00e9veloppement et d\u00e9ploiement d'applications"}]},{"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 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"}]},{"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
13 changes: 10 additions & 3 deletions test/tables.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@
),
);

global $activiteKeyToShortname; $activiteKeyToShortname = array (
'{REFERENS}E1B22' => 'Chef de projet ou expert en développement et déploiement d\'applications',
'{REFERENS}E1C23' => 'Chef de projet ou expert systèmes informatiques, réseaux et télécommunications',
global $activiteKeyToAll; $activiteKeyToAll = array (
'{REFERENS}E1B22' => [
'name' => 'Chef-fe de projet ou expert-e en Ingéniérie logicielle',
'name-gender-f' => 'Cheffe de projet ou experte en Ingéniérie logicielle',
'name-gender-m' => 'Chef de projet ou expert en Ingéniérie logicielle',
],
'{REFERENS}E1C23' => [ 'name' => 'Chef-fe de projet ou expert-e systèmes informatiques, réseaux et télécommunications',
'name-gender-f' => 'Cheffe de projet ou experte systèmes informatiques, réseaux et télécommunications',
'name-gender-m' => 'Chef de projet ou expert systèmes informatiques, réseaux et télécommunications',
],
);


Expand Down

0 comments on commit caa1c13

Please sign in to comment.