ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SmartName.php
Go to the documentation of this file.
1<?php
2
10{
16 private $attributes = array();
17
18
19 private function getFullName($attributes)
20 {
21 if (isset($attributes['displayName'])) {
22 return $attributes['displayName'][0];
23 }
24
25 if (isset($attributes['cn'])) {
26 if (count(explode(' ', $attributes['cn'][0])) > 1) {
27 return $attributes['cn'][0];
28 }
29 }
30
31 if (isset($attributes['sn']) && isset($attributes['givenName'])) {
32 return $attributes['givenName'][0].' '.$attributes['sn'][0];
33 }
34
35 if (isset($attributes['cn'])) {
36 return $attributes['cn'][0];
37 }
38
39 if (isset($attributes['sn'])) {
40 return $attributes['sn'][0];
41 }
42
43 if (isset($attributes['givenName'])) {
44 return $attributes['givenName'][0];
45 }
46
47 if (isset($attributes['eduPersonPrincipalName'])) {
48 $localname = $this->getLocalUser($attributes['eduPersonPrincipalName'][0]);
49 if (isset($localname)) {
50 return $localname;
51 }
52 }
53
54 return null;
55 }
56
57 private function getLocalUser($userid)
58 {
59 if (strpos($userid, '@') === false) {
60 return null;
61 }
62 $decomposed = explode('@', $userid);
63 if (count($decomposed) === 2) {
64 return $decomposed[0];
65 }
66 return null;
67 }
68
76 public function process(&$request)
77 {
78 assert(is_array($request));
79 assert(array_key_exists('Attributes', $request));
80
81 $attributes =& $request['Attributes'];
82
83 $fullname = $this->getFullName($attributes);
84
85 if (isset($fullname)) {
86 $request['Attributes']['smartname-fullname'] = array($fullname);
87 }
88 }
89}
foreach($paths as $path) $request
Definition: asyncclient.php:32
An exception for terminatinating execution or to throw for unit testing.
process(&$request)
Apply filter to add or replace attributes.
Definition: SmartName.php:76
$attributes
Attributes which should be added/appended.
Definition: SmartName.php:16
if(empty($userids)) $userid