ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilOpenIdProviders.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/OpenId/classes/class.ilOpenIdProvider.php';
5
14{
15 private static $instance = null;
16
17 private $providers = array();
18
23 protected function __construct()
24 {
25 $this->read();
26 }
27
32 public static function getInstance()
33 {
34 if(self::$instance)
35 {
36 return self::$instance;
37 }
38 return self::$instance = new ilOpenIdProviders();
39 }
40
45 public function getProvider()
46 {
47 return (array) $this->providers;
48 }
49
56 public function getProviderById($a_provider_id)
57 {
58 foreach($this->getProvider() as $provider)
59 {
60 if($provider->getId() == $a_provider_id)
61 {
62 return $provider;
63 }
64 }
65 throw new UnexpectedValueException();
66 }
67
72 public function getProviderSelection()
73 {
74 global $lng;
75
76 $options[0] = $lng->txt('select_one');
77 foreach($this->getProvider() as $provider)
78 {
79 $options[$provider->getId()] = $provider->getName();
80 }
81 return $options;
82 }
83
90 public function getSelectedProvider()
91 {
92 include_once './Services/OpenId/classes/class.ilOpenIdSettings.php';
93 if(count($this->getProvider()) != 1 or !ilOpenIdSettings::getInstance()->forcedProviderSelection())
94 {
95 return 0;
96 }
97
98 foreach($this->getProvider() as $pro)
99 {
100 return $pro->getId();
101 }
102 return 0;
103 }
104
109 private function read()
110 {
111 global $ilDB;
112
113 $query = "SELECT provider_id FROM openid_provider ORDER BY name ";
114 $res = $ilDB->query($query);
115 while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
116 {
117 $this->providers[] = new ilOpenIdProvider($row['provider_id']);
118 }
119 return true;
120 }
121}
122?>
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10
@classDescription OpenId provider
@classDescription OpenId provider
getProvider()
Get enabled provider.
getSelectedProvider()
Return the default provider, if there is only one.
getProviderById($a_provider_id)
Get provider by id.
__construct()
Singleton constructor.
getProviderSelection()
get html select options
static getInstance()
Get singleton instance.
static getInstance()
Get singleton instance.
global $lng
Definition: privfeed.php:40
global $ilDB
if(!is_array($argv)) $options