ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilOpenIdProvider.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12{
13 private $provider_id = 0;
14 private $name = '';
15 private $url = 'http://';
16 private $enabled = true;
17 private $image = 0;
18
22 public function __construct($a_provider_id = 0)
23 {
24 if($a_provider_id)
25 {
26 $this->setId($a_provider_id);
27 $this->read();
28 }
29 }
30
36 public function setId($a_id)
37 {
38 $this->provider_id = $a_id;
39 }
40
45 public function getId()
46 {
47 return $this->provider_id;
48 }
49
55 public function enable($a_status)
56 {
57 $this->enabled = (bool) $a_status;
58 }
59
64 public function isEnabled()
65 {
66 return (bool) $this->enabled;
67 }
68
74 public function setName($a_name)
75 {
76 $this->name = $a_name;
77 }
78
83 public function getName()
84 {
85 return $this->name;
86 }
87
93 public function setURL($a_url)
94 {
95 $this->url = $a_url;
96 }
97
102 public function getURL()
103 {
104 return $this->url;
105 }
106
111 public function delete()
112 {
113 global $ilDB;
114
115 $query = "DELETE FROM openid_provider ".
116 "WHERE provider_id = ".$ilDB->quote($this->getId(),'integer');
117 $ilDB->query($query);
118 return true;
119 }
120
125 public function add()
126 {
127 global $ilDB;
128
129 $this->setId($ilDB->nextId('openid_provider'));
130 $query = "INSERT INTO openid_provider ".
131 "(provider_id, enabled, name, url) ".
132 "VALUES ( ".
133 $ilDB->quote($this->getId(),'integer').', '.
134 $ilDB->quote($this->isEnabled(),'integer').', '.
135 $ilDB->quote($this->getName(),'text').', '.
136 $ilDB->quote($this->getURL(),'text').
137 ')';
138 $ilDB->query($query);
139 return true;
140 }
141
146 public function update()
147 {
148 global $ilDB;
149
150 $query = 'UPDATE openid_provider SET '.
151 "enabled = ".$ilDB->quote($this->isEnabled(),'integer').', '.
152 "name = ".$ilDB->quote($this->getName(),'text').', '.
153 "url = ".$ilDB->quote($this->getURL(),'text')." ".
154 "WHERE provider_id = ".$ilDB->quote($this->getId(),'integer');
155 $ilDB->query($query);
156 return true;
157 }
158
159
164 protected function read()
165 {
166 global $ilDB;
167
168 $query = "SELECT * FROM openid_provider ".
169 "WHERE provider_id = ".$ilDB->quote($this->getId(),'integer');
170 $res = $ilDB->query($query);
171 while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
172 {
173 $this->setName($row['name']);
174 $this->enable($row['enabled']);
175 $this->setURL($row['url']);
176 return true;
177 }
178 return false;
179 }
180}
181?>
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10
@classDescription OpenId provider
enable($a_status)
Set en/disabled.
isEnabled()
Check if provider is en/disabled.
read()
Read provider data.
__construct($a_provider_id=0)
Constructor.
update()
Update provider.
add()
Add openid provider.
setName($a_name)
Set name.
global $ilDB