ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilECSUser.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
35 class ilECSUser
36 {
37  protected $source;
38 
39  public $login;
40  public $email;
41  public $firstname;
42  public $lastname;
43  public $institution;
44  public $uid_hash;
45 
52  public function __construct($a_data)
53  {
54  $this->source = $a_data;
55  if(is_object($a_data))
56  {
57  $this->loadFromObject();
58  }
59  elseif(is_array($a_data))
60  {
61  $this->loadFromGET();
62  }
63  else
64  {
65  $this->loadFromJSON();
66  }
67  }
68 
75  public function getLogin()
76  {
77  return $this->login;
78  }
79 
86  public function getFirstname()
87  {
88  return $this->firstname;
89  }
90 
96  public function getLastname()
97  {
98  return $this->lastname;
99  }
100 
106  public function getEmail()
107  {
108  return $this->email;
109  }
116  public function getInstitution()
117  {
118  return $this->institution;
119  }
120 
127  public function getImportId()
128  {
129  return $this->uid_hash;
130  }
131 
138  public function loadFromObject()
139  {
140  global $ilSetting;
141 
142  $this->login = $this->source->getLogin();
143  $this->firstname = $this->source->getFirstname();
144  $this->lastname = $this->source->getLastname();
145  $this->email = $this->source->getEmail();
146  $this->institution = $this->source->getInstitution();
147 
148  $this->uid_hash = 'il_'.$ilSetting->get('inst_id',0).'_usr_'.$this->source->getId();
149  }
150 
157  public function loadFromJSON()
158  {
159  $this->source = json_decode(urldecode($this->source));
160 
161  $this->login = $this->source->login();
162  $this->firstname = $this->source->firstname();
163  $this->lastname = $this->source->lastname();
164  $this->email = $this->source->email();
165  $this->institution = $this->source->institution();
166 
167  $this->uid_hash = $this->source->uid_hash;
168 
169  }
170 
177  public function loadFromGET()
178  {
179  $this->login = ilUtil::stripSlashes(urldecode($_GET['ecs_login']));
180  $this->firstname = ilUtil::stripSlashes(urldecode($_GET['ecs_firstname']));
181  $this->lastname = ilUtil::stripSlashes(urldecode($_GET['ecs_lastname']));
182  $this->email = ilUtil::stripSlashes(urldecode($_GET['ecs_email']));
183  $this->institution = ilUtil::stripSlashes(urldecode($_GET['ecs_institution']));
184  $this->uid_hash = ilUtil::stripSlashes(urldecode($_GET['ecs_uid_hash']));
185  }
186 
194  public function toJSON()
195  {
196  return urlencode(json_encode($this));
197  }
198 
205  public function toGET()
206  {
207  return '&ecs_login='.urlencode((string) $this->login).
208  '&ecs_firstname='.urlencode((string) $this->firstname).
209  '&ecs_lastname='.urlencode((string) $this->lastname).
210  '&ecs_email='.urlencode((string) $this->email).
211  '&ecs_institution='.urlencode((string) $this->institution).
212  '&ecs_uid_hash='.urlencode((string) $this->uid_hash);
213  }
214 
219  public function toREALM()
220  {
221  return
222  (string) $this->login.''.
223  (string) $this->firstname.''.
224  (string) $this->lastname.''.
225  (string) $this->email.''.
226  (string) $this->institution.''.
227  (string) $this->uid_hash;
228  }
229 }
230 
231 ?>