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)  

BuildingDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 //$Id$
17 
18 import('scheduler.Building');
19 
20 class BuildingDAO extends DAO {
26  function &getBuilding($buildingId) {
27  $result =& $this->retrieve(
28  'SELECT * FROM buildings WHERE building_id = ?', $buildingId
29  );
30 
31  $returner = null;
32  if ($result->RecordCount() != 0) {
33  $returner =& $this->_returnBuildingFromRow($result->GetRowAssoc(false));
34  }
35  $result->Close();
36  return $returner;
37  }
38 
44  function getBuildingSchedConfId($buildingId) {
45  $result =& $this->retrieve(
46  'SELECT sched_conf_id FROM buildings WHERE building_id = ?', $buildingId
47  );
48 
49  return isset($result->fields[0]) ? $result->fields[0] : 0;
50  }
51 
58  function buildingExistsForSchedConf($buildingId, $schedConfId) {
59  $result =& $this->retrieve(
60  'SELECT COUNT(*)
61  FROM buildings
62  WHERE building_id = ?
63  AND sched_conf_id = ?',
64  array(
65  $buildingId,
66  $schedConfId
67  )
68  );
69  $returner = isset($result->fields[0]) && $result->fields[0] != 0 ? true : false;
70 
71  $result->Close();
72  unset($result);
73 
74  return $returner;
75  }
76 
81  function getLocaleFieldNames() {
82  return array('name', 'abbrev', 'description');
83  }
84 
90  function &_returnBuildingFromRow(&$row) {
91  $building = new Building();
92  $building->setId($row['building_id']);
93  $building->setSchedConfId($row['sched_conf_id']);
94  $this->getDataObjectSettings('building_settings', 'building_id', $row['building_id'], $building);
95 
96  return $building;
97  }
98 
103  function updateLocaleFields(&$building) {
104  $this->updateDataObjectSettings('building_settings', $building, array(
105  'building_id' => $building->getId()
106  ));
107  }
108 
114  function insertBuilding(&$building) {
115  $this->update(
116  sprintf('INSERT INTO buildings
117  (sched_conf_id)
118  VALUES
119  (?)'),
120  array(
121  $building->getSchedConfId()
122  )
123  );
124  $building->setId($this->getInsertBuildingId());
125  $this->updateLocaleFields($building);
126  return $building->getId();
127  }
128 
134  function updateBuilding(&$building) {
135  $returner = $this->update(
136  sprintf('UPDATE buildings
137  SET
138  sched_conf_id = ?
139  WHERE building_id = ?'),
140  array(
141  $building->getSchedConfId(),
142  $building->getId()
143  )
144  );
145  $this->updateLocaleFields($building);
146  return $returner;
147  }
148 
154  function deleteBuilding($building) {
155  return $this->deleteBuildingById($building->getId());
156  }
157 
163  function deleteBuildingById($buildingId) {
164  // Delete dependent rooms first.
165  $roomDao =& DAORegistry::getDAO('RoomDAO');
166  $rooms =& $roomDao->deleteRoomsByBuildingId($buildingId);
167 
168  $this->update('DELETE FROM building_settings WHERE building_id = ?', $buildingId);
169  $ret = $this->update('DELETE FROM buildings WHERE building_id = ?', $buildingId);
170  return $ret;
171  }
172 
177  function deleteBuildingsBySchedConfId($schedConfId) {
178  $buildings =& $this->getBuildingsBySchedConfId($schedConfId);
179  while (($building =& $buildings->next())) {
180  $this->deleteBuilding($building);
181  unset($building);
182  }
183  }
184 
190  function &getBuildingsBySchedConfId($schedConfId, $rangeInfo = null) {
191  $result =& $this->retrieveRange(
192  'SELECT * FROM buildings WHERE sched_conf_id = ? ORDER BY sched_conf_id',
193  $schedConfId,
194  $rangeInfo
195  );
196 
197  $returner = new DAOResultFactory($result, $this, '_returnBuildingFromRow');
198  return $returner;
199  }
200 
205  function getInsertBuildingId() {
206  return $this->getInsertId('buildings', 'building_id');
207  }
208 }
209 
210 ?>
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
deleteBuildingsBySchedConfId($schedConfId)
& getBuildingsBySchedConfId($schedConfId, $rangeInfo=null)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
buildingExistsForSchedConf($buildingId, $schedConfId)
& _returnBuildingFromRow(&$row)
deleteBuilding($building)
Operations for retrieving and modifying Building objects.
insertBuilding(&$building)
getInsertId($table='', $id='', $callHooks=true)
Definition: DAO.inc.php:225
updateDataObjectSettings($tableName, &$dataObject, $idArray)
Definition: DAO.inc.php:412
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
Basic class describing a building.
updateLocaleFields(&$building)
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
updateBuilding(&$building)
deleteBuildingById($buildingId)
& getDAO($name, $dbconn=null)
getDataObjectSettings($tableName, $idFieldName, $idFieldValue, &$dataObject)
Definition: DAO.inc.php:498
& getBuilding($buildingId)
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
getBuildingSchedConfId($buildingId)