ocs  2.3.6
About: OCS (Open Conference System) is a Web publishing tool that will create a complete Web presence for your scholarly conference.
  Fossies Dox: ocs-2.3.6.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

AuthSourceDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 // $Id$
17 
18 
19 import('security.AuthSource');
20 
21 class AuthSourceDAO extends DAO {
22  var $plugins;
23 
27  function AuthSourceDAO() {
28  parent::DAO();
30  }
31 
37  function &getPlugin($authId) {
38  $plugin = null;
39  $auth =& $this->getSource($authId);
40  if ($auth != null) {
41  $plugin =& $auth->getPluginClass();
42  if ($plugin != null) {
43  $plugin =& $plugin->getInstance($auth->getSettings(), $auth->getAuthId());
44  }
45  }
46  return $plugin;
47  }
48 
53  function &getDefaultPlugin() {
54  $plugin = null;
55  $auth =& $this->getDefaultSource();
56  if ($auth != null) {
57  $plugin =& $auth->getPluginClass();
58  if ($plugin != null) {
59  $plugin =& $plugin->getInstance($auth->getSettings(), $auth->getAuthId());
60  }
61  }
62  return $plugin;
63  }
64 
70  function &getSource($authId) {
71  $result =& $this->retrieve(
72  'SELECT * FROM auth_sources WHERE auth_id = ?',
73  array((int) $authId)
74  );
75 
76  $returner = null;
77  if ($result->RecordCount() != 0) {
78  $returner =& $this->_returnAuthSourceFromRow($result->GetRowAssoc(false));
79  }
80 
81  $result->Close();
82  unset($result);
83 
84  return $returner;
85  }
86 
91  function &getDefaultSource() {
92  $result =& $this->retrieve(
93  'SELECT * FROM auth_sources WHERE auth_default = 1'
94  );
95 
96  $returner = null;
97  if ($result->RecordCount() != 0) {
98  $returner =& $this->_returnAuthSourceFromRow($result->GetRowAssoc(false));
99  }
100 
101  $result->Close();
102  unset($result);
103 
104  return $returner;
105  }
106 
112  function &_returnAuthSourceFromRow(&$row) {
113  $auth = new AuthSource();
114  $auth->setAuthId($row['auth_id']);
115  $auth->setTitle($row['title']);
116  $auth->setPlugin($row['plugin']);
117  $auth->setPluginClass(@$this->plugins[$row['plugin']]);
118  $auth->setDefault($row['auth_default']);
119  $auth->setSettings(unserialize($row['settings']));
120  return $auth;
121  }
122 
127  function insertSource(&$auth) {
128  if (!isset($this->plugins[$auth->getPlugin()])) return false;
129  if (!$auth->getTitle()) $auth->setTitle($this->plugins[$auth->getPlugin()]->getDisplayName());
130  $this->update(
131  'INSERT INTO auth_sources
132  (title, plugin, settings)
133  VALUES
134  (?, ?, ?)',
135  array(
136  $auth->getTitle(),
137  $auth->getPlugin(),
138  serialize($auth->getSettings() ? $auth->getSettings() : array())
139  )
140  );
141 
142  $auth->setAuthId($this->getInsertId('auth_sources', 'auth_id'));
143  return $auth->getAuthId();
144  }
145 
150  function updateObject(&$auth) {
151  return $this->update(
152  'UPDATE auth_sources SET
153  title = ?,
154  settings = ?
155  WHERE auth_id = ?',
156  array(
157  $auth->getTitle(),
158  serialize($auth->getSettings() ? $auth->getSettings() : array()),
159  (int) $auth->getAuthId()
160  )
161  );
162  }
163 
164  function updateSource(&$auth) {
165  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
166  return $this->updateObject($auth);
167  }
168 
173  function deleteObject($authId) {
174  return $this->update(
175  'DELETE FROM auth_sources WHERE auth_id = ?', $authId
176  );
177  }
178 
179  function deleteSource(&$auth) {
180  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
181  return $this->deleteObject($auth);
182  }
183 
188  function setDefault($authId) {
189  $this->update(
190  'UPDATE auth_sources SET auth_default = 0'
191  );
192  $this->update(
193  'UPDATE auth_sources SET auth_default = 1 WHERE auth_id = ?',
194  array((int) $authId)
195  );
196  }
197 
202  function &getSources($rangeInfo = null) {
203  $result =& $this->retrieveRange(
204  'SELECT * FROM auth_sources ORDER BY auth_id',
205  false,
206  $rangeInfo
207  );
208 
209  $returner = new DAOResultFactory($result, $this, '_returnAuthSourceFromRow');
210  return $returner;
211  }
212 }
213 
214 ?>
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
& getSources($rangeInfo=null)
Operations for retrieving and modifying AuthSource objects.
getInsertId($table='', $id='', $callHooks=true)
Definition: DAO.inc.php:225
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
const AUTH_PLUGIN_CATEGORY
& loadCategory($category, $forceLoad=false)
& getSource($authId)
& _returnAuthSourceFromRow(&$row)
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
getVar($section, $key, $default=null)
Definition: Config.inc.php:35
Describes an authentication source.
& getPlugin($authId)
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186