lang . " AS title, " . " text_" . $this->lang . " AS text, " . " after_" . $this->lang . " AS after, " . " price, " . " inscription, " . " people, " . " max_people, " . " visible, " . " dtime, " . " album " . "FROM activity " . "WHERE " . " visible = 1 AND " . " ( " . " id = '$id' OR " . " permalink = '$id' " . " );"; $q = mysqli_query($this->db, $s); if (mysqli_num_rows($q) > 0){ $r = mysqli_fetch_array($q); $this->id = $r["id"]; $this->permalink = $r["permalink"]; $this->title = $r["title"]; $this->text = $r["text"]; $this->date = $r["date"]; $this->city = $r["city"]; if (!is_null($r["after"])){ $this->after = $r["after"]; } if ($r["inscription"] == 1){ $this->inscription = true; $this->people = $r["people"]; $this->max_people = $r["max_people"]; } else{ $this->inscription = false; } if ($r["visible"] == 1){ $this->visible = true; } else{ $this->visible = false; } $this->price = $r["price"]; $this->dtime = $r["dtime"]; // TODO //if (!is_null($r["album"])){ // $this->after = New Album($this->db, $this->lang, $r["album"]); //} } $s_image = "SELECT id " . "FROM activity_image " . "WHERE activity = " . $this->id . " " . "ORDER BY idx; "; $q_image = mysqli_query($this->db, $s_image); while($r_image = mysqli_fetch_array($q_image)){ array_push($this->image, new Activity_Image($this->db, $r_image["id"])); } $s_tag = "SELECT tag " . "FROM activity_tag " . "WHERE activity = " . $this->id . ";"; $q_tag = mysqli_query($this->db, $s_tag); while($r_tag = mysqli_fetch_array($q_tag)){ array_push($this->tag, $r_tag["tag"]); } $s_comment = "SELECT id " . "FROM activity_comment " . "WHERE " . " activity = " . $this->id . " AND " . " approved = 1;"; $q_comment = mysqli_query($this->db, $s_comment); while($r_tag = mysqli_fetch_array($q_comment)){ array_push($this->comment, new Activity_Comment($this->db, $r_comment["id"])); } $s_itinerary = "SELECT id " . "FROM activity_itinerary " . "WHERE " . " activity = " . $this->id . ";"; $q_itinerary = mysqli_query($this->db, $s_itinerary); while($r_itinerary = mysqli_fetch_array($q_itinerary)){ array_push($this->itinerary, new Activity_Itinerary($this->db, $this->lang, $r_itinerary["id"])); } } /** * Checks if an activity is in the future. * * If the activity takes place during the current day, it's still * considered in the future. * * @return true if future, false if past. */ public function is_future(){ return (time() - 60 * 60 * 24 < $this->date); } /** * Checks if an activity is in the past. * * If the activity takes place during the current day, it's still * considered in the future. * * @return true if past, false if future. */ public function is_past(){ return !$this->is_future(); } } ?>