<commit_before><?php
	/**
	 * Events management class
	 * @since Version 3.8.7
	 * @package Railpage
	 * @author <NAME>
	 */
	
	namespace Railpage\Events;
	
	use Railpage\AppCore;
	use Railpage\Module;
	use DateTime;
	use DateTimeZone;
	use Railpage\Organisations\Organisation;
	
	/**
	 * Events
	 * 
	 * The Events master class
	 * @since Version 3.8.7
	 */
	
	class Events extends AppCore {
		
		/**
		 * Status: approved
		 * @const STATUS_APPROVED
		 * @since Version 3.9
		 */
		
		const STATUS_APPROVED = 1;
		
		/**
		 * Status: unapproved
		 * @const STATUS_UNAPPROVED
		 * @since Version 3.9
		 */
		
		const STATUS_UNAPPROVED = 0;
		
		/**
		 * Constructor
		 * @since Version 3.8.7
		 */
		
		public function __construct() {
			parent::__construct(); 
			
			$this->Module = new Module("events");
			$this->namespace = $this->Module->namespace;
		}
		
		/**
		 * Find an event based on name
		 * @param string $name The name of the event to search for
		 * @return array
		 */
		
		public function findEvent($name = NULL) {
			if (!is_string($name) || is_null($name)) {
				return false;
			}
			
			return $this->db->fetchAll("SELECT * FROM event WHERE title = ?", $name);
		}
		
		/**
		 * Get events for a given DateTime object
		 * @param \DateTime $Date An optional DateTime instance to search for. Will default to today if not provided
		 * @return array
		 */
		
		public function getEventsForDate(DateTime $Date = NULL) {
			if (!$Date instanceof DateTime) {
				$Date = new DateTime;
			}
			
			return $this->db->fetchAll("SELECT ed.*, e.title, CONCAT('/events/', e.slug) AS url FROM event_dates AS ed LEFT JOIN event AS e ON e.id = ed.event_id WHERE ed.date = ? AND e.status = ?", array($Date->format("Y-m-d"), self::STATUS_APPROVED));<commit_msg>Bugfix for cancelled events showing up<commit_after><?php
	/**
	 * Events management class
	 * @since Version 3.8.7
	 * @package Railpage
	 * @author <NAME>
	 */
	
	namespace Railpage\Events;
	
	use Railpage\AppCore;
	use Railpage\Module;
	use DateTime;
	use DateTimeZone;
	use Railpage\Organisations\Organisation;
	
	/**
	 * Events
	 * 
	 * The Events master class
	 * @since Version 3.8.7
	 */
	
	class Events extends AppCore {
		
		/**
		 * Status: approved
		 * @const STATUS_APPROVED
		 * @since Version 3.9
		 */
		
		const STATUS_APPROVED = 1;
		
		/**
		 * Status: unapproved
		 * @const STATUS_UNAPPROVED
		 * @since Version 3.9
		 */
		
		const STATUS_UNAPPROVED = 0;
		
		/**
		 * Constructor
		 * @since Version 3.8.7
		 */
		
		public function __construct() {
			parent::__construct(); 
			
			$this->Module = new Module("events");
			$this->namespace = $this->Module->namespace;
		}
		
		/**
		 * Find an event based on name
		 * @param string $name The name of the event to search for
		 * @return array
		 */
		
		public function findEvent($name = NULL) {
			if (!is_string($name) || is_null($name)) {
				return false;
			}
			
			return $this->db->fetchAll("SELECT * FROM event WHERE title = ?", $name);
		}
		
		/**
		 * Get events for a given DateTime object
		 * @param \DateTime $Date An optional DateTime instance to search for. Will default to today if not provided
		 * @return array
		 */
		
		public function getEventsForDate(DateTime $Date = NULL) {
			if (!$Date instanceof DateTime) {
				$Date = new DateTime;
			}
			
			$args = array(
				$Date->format("Y-m-d"), 
				self::STATUS_APPROVED, 
				EventDate::STATUS_RUNNING
			);
			
			return $this->db->fetchAll("SELECT ed.*, e.title, CONCAT('/events/', e.slug) AS url FROM event_dates AS ed LEFT JOIN event AS e ON e.id = ed.event_id WHERE ed.date = ? AND e.status = ? AND ed.status = ?", $args);
{'fraction_non_alphanumeric': 0.12935050698821596, 'fraction_numerical': 0.00822143052891203, 'mean_word_length': 2.6905965621840244, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5356589', 'n_tokens_mistral': 1414, 'n_tokens_neox': 1123, 'n_words': 344}