ILIAS  eassessment Revision 61809
 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 
53  public function isActive()
54  {
55  return (bool) $this->active;
56  }
57 
63  public function setActive($a_status)
64  {
65  $this->active = $a_status;
66  }
67 
72  public function forcedProviderSelection()
73  {
75  }
76 
82  public function forceProviderSelection($a_status)
83  {
84  $this->forced_selection = $a_status;
85  }
86 
91  public function isCreationEnabled()
92  {
93  return (bool) $this->creation;
94  }
95 
101  public function enableCreation($a_status)
102  {
103  $this->creation = $a_status;
104  }
105 
110  public function isAccountMigrationEnabled()
111  {
112  return (bool) $this->account_migration;
113  }
114 
120  public function enableAccountMigration($a_status)
121  {
122  $this->account_migration = $a_status;
123  }
124 
129  public function getDefaultRole()
130  {
131  return $this->default_role;
132  }
133 
139  public function setDefaultRole($a_role)
140  {
141  $this->default_role = $a_role;
142  }
143 
148  protected function read()
149  {
150  $this->setActive($this->storage->get('active',false));
151  $this->enableCreation($this->storage->get('creation',false));
152  $this->setDefaultRole($this->storage->get('default_role',0));
153  $this->enableAccountMigration($this->storage->get('account_migration',false));
154  $this->forceProviderSelection($this->storage->get('forced_selection',false));
155  }
156 
161  public function update()
162  {
163  $this->storage->set('active', (int) $this->isActive());
164  $this->storage->set('creation',(int) $this->isCreationEnabled());
165  $this->storage->set('default_role',(int) $this->getDefaultRole());
166  $this->storage->set('account_migration',(int) $this->isAccountMigrationEnabled());
167  $this->storage->set('forced_selection',(int) $this->forcedProviderSelection());
168  }
169 
174  public function getConsumer()
175  {
176  return $this->consumer;
177  }
178 
183  public function getReturnLocation()
184  {
185  global $ilCtrl;
186 
187  $ilCtrl->setTargetScript('ilias.php');
188  $ilCtrl->setParameterByClass('ilstartupgui','oid_check_status',1);
189  $redir = ILIAS_HTTP_PATH.'/';
190  $redir .= $ilCtrl->getLinkTargetByClass('ilstartupgui','showLogin','',false,false);
191  return $redir;
192  }
193 
198  protected function initTempDir()
199  {
200  if(!file_exists(ilUtil::getDataDir().DIRECTORY_SEPARATOR.'tmp'))
201  {
202  ilUtil::makeDir(ilUtil::getDataDir().DIRECTORY_SEPARATOR.'tmp');
203  }
204  return true;
205  }
206 
207  public function initConsumer()
208  {
209  include_once "Auth/OpenID/Consumer.php";
210  include_once "Auth/OpenID/FileStore.php";
211  include_once 'Auth/OpenID/DumbStore.php';
212 
213  if(is_object($this->consumer))
214  {
215  return true;
216  }
217 
218  $this->initTempDir();
219  $store = new Auth_OpenID_FileStore(ilUtil::getDataDir().DIRECTORY_SEPARATOR.'tmp');
220  return $this->consumer = new Auth_OpenID_Consumer($store);
221  }
222 
223 }
224 ?>