. */ /** * Event Database Access Object. This class provides functionality to * load and save countries */ require_once(FILESYSTEMROOTPATH."include/classes/IDao.php"); require_once(FILESYSTEMROOTPATH."events/include/model/Event.php"); class EventDao implements IDao { /** MySQL object */ private $mysql; /** * Default constructor */ public function __construct(MySQL $mysql) { $this->mysql = $mysql; } /** * Load an event by id * * @param string id of the event to be loaded * @return Event containing the data of the requested event, or NULL in case event does not exist */ public function load($id) { $query = "SELECT `id`, `localOrganisers`, `europeanOrganisers`, `status`, `title`, `logo`, `range`, `type`, `arrival`, `departure`, `applicationStart`, `applicationEnd`, `place`, `fee`, `accomPlace`, `accomCapacity`, `accomType`, `participants`, `disabled`, `disabledAccepted`, `omsHandlesApplications`, `applicationLink`, `contactUid`, `contactEmail`, `contactPhone`, `url`, `facebook`, `idealParticipant`, `mainFieldsOfAction`, `focusArea`, `focusOther`, `theme`, `programme`, `photos`, `shortDescription`, `description` FROM `events` WHERE id='".$id."'"; if( $this->mysql->query($query) ) { return new Event ($this->mysql->fetchArray()); }else { return array(); } } /** * Load all events for the calendar of events * @param string future of the time the events to be loaded are happening. Possibilities: future, past, all * @param string type of the event to be loaded * @param string bodyCode of the event to be loaded * @return array of Event */ public function loadAllCalendar($time, $type, $bodyCode, $status) { $query = "SELECT e.`id`, e.`localOrganisers`, e.`europeanOrganisers`, s.`name` AS status, e.`title`, r.`name` AS `range`, t.`name` AS `type`, e.`arrival`, e.`departure`, e.`applicationEnd` FROM `events` e INNER JOIN statuses s ON s.id=e.`status` INNER JOIN ranges r ON r.id=e.`range` INNER JOIN types t ON t.id=e.`type` WHERE 1=1 "; if ( $bodyCode == "AEGEE" ) $query .= " AND `europeanOrganisers` IS NOT NULL "; else if ( $bodyCode == "European" ) $query .= " AND `europeanOrganisers` IS NULL "; else if ( $bodyCode != NULL ) $query .= " AND (`localOrganisers` LIKE '%".$bodyCode."%' OR `europeanOrganisers` LIKE '%".$bodyCode."%') "; if ( $type != NULL ) $query .= " AND t.`name`='".$type."' "; if ( $time == "past" ) $query .= " AND `arrival`<=now() "; else if ( $time == "future" ) $query .= " AND `arrival`>=now() "; $query .= " ORDER BY e.`arrival`, e.`applicationEnd`, e.`id`"; if( $this->mysql->query($query) ) { $ret = array(); while( $row = $this->mysql->fetchArray() ) { $ret[ $row['id'] ] = new Event($row); } return $ret; }else { return array(); } } /** * Save or update an event * * @param Event object with the event data * @return boolean true in case of success, false otherwise */ public function saveOrUpdate(IModel $event) { } } ?>