ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 if (isset($attributes['displayName']))
21 return $attributes['displayName'][0];
22
23 if (isset($attributes['cn'])) {
24 if (count(explode(' ', $attributes['cn'][0])) > 1)
25 return $attributes['cn'][0];
26 }
27
28 if (isset($attributes['sn']) && isset($attributes['givenName']))
29 return $attributes['givenName'][0] . ' ' . $attributes['sn'][0];
30
31 if (isset($attributes['cn']))
32 return $attributes['cn'][0];
33
34 if (isset($attributes['sn']))
35 return $attributes['sn'][0];
36
37 if (isset($attributes['givenName']))
38 return $attributes['givenName'][0];
39
40 if (isset($attributes['eduPersonPrincipalName'])) {
41 $localname = $this->getLocalUser($attributes['eduPersonPrincipalName'][0]);
42 if (isset($localname)) return $localname;
43 }
44
45 return NULL;
46 }
47
48 private function getLocalUser($userid) {
49 if (strpos($userid, '@') === FALSE) return NULL;
50 $decomposed = explode('@', $userid);
51 if(count($decomposed) === 2) {
52 return $decomposed[0];
53 }
54 return NULL;
55 }
56
64 public function process(&$request) {
65 assert('is_array($request)');
66 assert('array_key_exists("Attributes", $request)');
67
68 $attributes =& $request['Attributes'];
69
70 $fullname = $this->getFullName($attributes);
71
72 if(isset($fullname)) $request['Attributes']['smartname-fullname'] = array($fullname);
73
74 }
75
76}
An exception for terminatinating execution or to throw for unit testing.
process(&$request)
Apply filter to add or replace attributes.
Definition: SmartName.php:64
$attributes
Attributes which should be added/appended.
Definition: SmartName.php:16
if(empty($userids)) $userid