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)  

SessionDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 // $Id$
17 
18 
19 import('session.Session');
20 
21 class SessionDAO extends DAO {
27  function &getSession($sessionId) {
28  $result =& $this->retrieve(
29  'SELECT * FROM sessions WHERE session_id = ?',
30  array($sessionId)
31  );
32 
33  $session = null;
34  if ($result->RecordCount() != 0) {
35  $row =& $result->GetRowAssoc(false);
36 
37  $session = new Session();
38  $session->setId($row['session_id']);
39  $session->setUserId($row['user_id']);
40  $session->setIpAddress($row['ip_address']);
41  $session->setUserAgent($row['user_agent']);
42  $session->setSecondsCreated($row['created']);
43  $session->setSecondsLastUsed($row['last_used']);
44  $session->setRemember($row['remember']);
45  $session->setSessionData($row['data']);
46 
47  }
48 
49  $result->Close();
50  unset($result);
51 
52  return $session;
53  }
54 
59  function insertSession(&$session) {
60  return $this->update(
61  'INSERT INTO sessions
62  (session_id, ip_address, user_agent, created, last_used, remember, data)
63  VALUES
64  (?, ?, ?, ?, ?, ?, ?)',
65  array(
66  $session->getId(),
67  $session->getIpAddress(),
68  substr($session->getUserAgent(), 0, 255),
69  (int) $session->getSecondsCreated(),
70  (int) $session->getSecondsLastUsed(),
71  $session->getRemember() ? 1 : 0,
72  $session->getSessionData()
73  )
74  );
75  }
76 
81  function updateObject(&$session) {
82  return $this->update(
83  'UPDATE sessions
84  SET
85  user_id = ?,
86  ip_address = ?,
87  user_agent = ?,
88  created = ?,
89  last_used = ?,
90  remember = ?,
91  data = ?
92  WHERE session_id = ?',
93  array(
94  $session->getUserId()==''?null:(int) $session->getUserId(),
95  $session->getIpAddress(),
96  substr($session->getUserAgent(), 0, 255),
97  (int) $session->getSecondsCreated(),
98  (int) $session->getSecondsLastUsed(),
99  $session->getRemember() ? 1 : 0,
100  $session->getSessionData(),
101  $session->getId()
102  )
103  );
104  }
105 
106  function updateSession(&$session) {
107  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
108  return $this->updateObject($session);
109  }
110 
115  function deleteObject(&$session) {
116  return $this->deleteSessionById($session->getId());
117  }
118 
119  function deleteSession(&$session) {
120  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
121  return $this->deleteObject($session);
122  }
123 
128  function deleteSessionById($sessionId) {
129  return $this->update(
130  'DELETE FROM sessions WHERE session_id = ?',
131  array($sessionId)
132  );
133  }
134 
139  function deleteSessionsByUserId($userId) {
140  return $this->update(
141  'DELETE FROM sessions WHERE user_id = ?',
142  array((int) $userId)
143  );
144  }
145 
151  function deleteSessionByLastUsed($lastUsed, $lastUsedRemember = 0) {
152  if ($lastUsedRemember == 0) {
153  return $this->update(
154  'DELETE FROM sessions WHERE (last_used < ? AND remember = 0)',
155  array((int) $lastUsed)
156  );
157  } else {
158  return $this->update(
159  'DELETE FROM sessions WHERE (last_used < ? AND remember = 0) OR (last_used < ? AND remember = 1)',
160  array((int) $lastUsed, (int) $lastUsedRemember)
161  );
162  }
163  }
164 
168  function deleteAllSessions() {
169  return $this->update('DELETE FROM sessions');
170  }
171 
177  function sessionExistsById($sessionId) {
178  $result =& $this->retrieve(
179  'SELECT COUNT(*) FROM sessions WHERE session_id = ?',
180  array($sessionId)
181  );
182  $returner = isset($result->fields[0]) && $result->fields[0] == 1 ? true : false;
183 
184  $result->Close();
185  unset($result);
186 
187  return $returner;
188  }
189 }
190 
191 ?>
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
sessionExistsById($sessionId)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
deleteSessionByLastUsed($lastUsed, $lastUsedRemember=0)
getVar($section, $key, $default=null)
Definition: Config.inc.php:35
& getSession($sessionId)
updateObject(&$session)
Operations for retrieving and modifying Session objects.
Maintains user state information from one request to the next.
Definition: Session.inc.php:23
insertSession(&$session)
deleteObject(&$session)
deleteSessionById($sessionId)
deleteSession(&$session)
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
deleteSessionsByUserId($userId)
updateSession(&$session)