$roomID)); $dbd1=$dbquery1->fetch(PDO::FETCH_ASSOC); $serverID = $dbd1['serverid']; $sroomID = $dbd1['serverroomid']; $lastUpdate = $dbd1['lastcalenderupdate']; //Check if in cache if(strtotime($lastUpdate) > strtotime("-".$this->getCacheTime()."seconds") && $this->getCacheTime()>0) { $dbquery3 = Database::simpleQuery("SELECT calendar FROM location_info WHERE locationid = :id", array('id' => $sroomID)); $dbd3=$dbquery3->fetch(PDO::FETCH_ASSOC); return $dbd3['callendar']; } //Check if we should refresh other rooms recently requested by front ends elseif ($this->getCacheTime()>0) { $dbquery4 = Database::simpleQuery("SELECT serverroomid, lastcalenderupdate FROM location_info WHERE serverid= :id", array('id' => $serverID)); $roomIDs[] = $sroomID; foreach($dbquery4->fetchAll(PDO::FETCH_COLUMN) as $row){ if($row['lastcalenderupdate']<$this->getRefreshTime()){ $roomIDs[] = $row['serverroomid']; } } $roomIDs = array_unique($roomIDs); } else { $roomIDs[] = $sroomID; } $dbquery2 = Database::simpleQuery("SELECT serverurl FROM `setting_location_info` WHERE serverid = :id", array('id' => $serverID)); $dbd2=$dbquery2->fetch(PDO::FETCH_ASSOC); $result = $this->fetchSchedulesInternal($roomIDs); if($this->getCacheTime()>0){ foreach ($result as $key => $value) { $now = strtotime('Now'); $dbquery1 = Database::simpleQuery("UPDATE location_info SET calendar = :ttable, lastcalenderupdate = :now WHERE locationid = :id ", array('id' => $key,'ttable' => $result[$key],'now'=> $now)); } } return $result[$roomID]; } }