ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilOpenIdSettings.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/Administration/classes/class.ilSetting.php';
5 
6 
14 {
15  private static $instance = null;
16 
17  private $storage = null;
18 
19  private $active = false;
20  private $account_migration = false;
21  private $default_role = 0;
22  private $creation = false;
23  private $forced_selection = false;
24 
25  private $consumer = null;
26 
30  private function __construct()
31  {
32  $this->storage = new ilSetting('auth_openid');
33  $this->read();
34  }
35 
40  public static function getInstance()
41  {
42  if(self::$instance != null)
43  {
44  return self::$instance;
45  }
46  return self::$instance = new ilOpenIdSettings();
47  }
48 
49 
54  public function isActive()
55  {
56  return (bool) $this->active;
57  }
58 
64  public function setActive($a_status)
65  {
66  $this->active = $a_status;
67  }
68 
73  public function forcedProviderSelection()
74  {
76  }
77 
83  public function forceProviderSelection($a_status)
84  {
85  $this->forced_selection = $a_status;
86  }
87 
92  public function isCreationEnabled()
93  {
94  return (bool) $this->creation;
95  }
96 
102  public function enableCreation($a_status)
103  {
104  $this->creation = $a_status;
105  }
106 
111  public function isAccountMigrationEnabled()
112  {
113  return (bool) $this->account_migration;
114  }
115 
121  public function enableAccountMigration($a_status)
122  {
123  $this->account_migration = $a_status;
124  }
125 
130  public function getDefaultRole()
131  {
132  return $this->default_role;
133  }
134 
140  public function setDefaultRole($a_role)
141  {
142  $this->default_role = $a_role;
143  }
144 
149  protected function read()
150  {
151  $this->setActive($this->storage->get('active',false));
152  $this->enableCreation($this->storage->get('creation',false));
153  $this->setDefaultRole($this->storage->get('default_role',0));
154  $this->enableAccountMigration($this->storage->get('account_migration',false));
155  $this->forceProviderSelection($this->storage->get('forced_selection',false));
156  }
157 
162  public function update()
163  {
164  $this->storage->set('active', (int) $this->isActive());
165  $this->storage->set('creation',(int) $this->isCreationEnabled());
166  $this->storage->set('default_role',(int) $this->getDefaultRole());
167  $this->storage->set('account_migration',(int) $this->isAccountMigrationEnabled());
168  $this->storage->set('forced_selection',(int) $this->forcedProviderSelection());
169  }
170 
175  public function getConsumer()
176  {
177  return $this->consumer;
178  }
179 
184  public function getReturnLocation()
185  {
186  global $ilCtrl;
187 
188  $ilCtrl->setTargetScript('ilias.php');
189  $ilCtrl->setParameterByClass('ilstartupgui','oid_check_status',1);
190  $redir = ILIAS_HTTP_PATH.'/';
191  $redir .= $ilCtrl->getLinkTargetByClass('ilstartupgui','showLogin','',false,false);
192  return $redir;
193  }
194 
199  protected function initTempDir()
200  {
201  if(!file_exists(ilUtil::getDataDir().DIRECTORY_SEPARATOR.'tmp'))
202  {
203  ilUtil::makeDir(ilUtil::getDataDir().DIRECTORY_SEPARATOR.'tmp');
204  }
205  return true;
206  }
207 
208  public function initConsumer()
209  {
210  include_once "Auth/OpenID/Consumer.php";
211  include_once "Auth/OpenID/FileStore.php";
212  include_once 'Auth/OpenID/DumbStore.php';
213 
214  if(is_object($this->consumer))
215  {
216  return true;
217  }
218 
219  $this->initTempDir();
220  $store = new Auth_OpenID_FileStore(ilUtil::getDataDir().DIRECTORY_SEPARATOR.'tmp');
221  return $this->consumer = new Auth_OpenID_Consumer($store);
222  }
223 
224 }
225 ?>