Code Duplication    Length = 21-25 lines in 3 locations

core/db_classes/EE_Event.class.php 3 locations

@@ 621-645 (lines=25) @@
618
	 * @access public
619
	 * @return boolean true yes, false no
620
	 */
621
	public function is_upcoming() {
622
		// check if event id is present and if this event is published
623
		if ( $this->is_inactive() ) {
624
			return FALSE;
625
		}
626
		// set initial value
627
		$upcoming = FALSE;
628
		//next let's get all datetimes and loop through them
629
		$datetimes = $this->datetimes_in_chronological_order();
630
		foreach ( $datetimes as $datetime ) {
631
			if ( $datetime instanceof EE_Datetime ) {
632
				//if this dtt is expired then we continue cause one of the other datetimes might be upcoming.
633
				if ( $datetime->is_expired() ) {
634
					continue;
635
				}
636
				//if this dtt is active then we return false.
637
				if ( $datetime->is_active() ) {
638
					return FALSE;
639
				}
640
				//otherwise let's check upcoming status
641
				$upcoming = $datetime->is_upcoming();
642
			}
643
		}
644
		return $upcoming;
645
	}
646
647
648
@@ 652-676 (lines=25) @@
649
	/**
650
	 * @return bool
651
	 */
652
	public function is_active() {
653
		// check if event id is present and if this event is published
654
		if ( $this->is_inactive() ) {
655
			return FALSE;
656
		}
657
		// set initial value
658
		$active = FALSE;
659
		//next let's get all datetimes and loop through them
660
		$datetimes = $this->datetimes_in_chronological_order();
661
		foreach ( $datetimes as $datetime ) {
662
			if ( $datetime instanceof EE_Datetime ) {
663
				//if this dtt is expired then we continue cause one of the other datetimes might be active.
664
				if ( $datetime->is_expired() ) {
665
					continue;
666
				}
667
				//if this dtt is upcoming then we return false.
668
				if ( $datetime->is_upcoming() ) {
669
					return FALSE;
670
				}
671
				//otherwise let's check active status
672
				$active = $datetime->is_active();
673
			}
674
		}
675
		return $active;
676
	}
677
678
679
@@ 683-703 (lines=21) @@
680
	/**
681
	 * @return bool
682
	 */
683
	public function is_expired() {
684
		// check if event id is present and if this event is published
685
		if ( $this->is_inactive() ) {
686
			return FALSE;
687
		}
688
		// set initial value
689
		$expired = FALSE;
690
		//first let's get all datetimes and loop through them
691
		$datetimes = $this->datetimes_in_chronological_order();
692
		foreach ( $datetimes as $datetime ) {
693
			if ( $datetime instanceof EE_Datetime ) {
694
				//if this dtt is upcoming or active then we return false.
695
				if ( $datetime->is_upcoming() || $datetime->is_active() ) {
696
					return FALSE;
697
				}
698
				//otherwise let's check active status
699
				$expired = $datetime->is_expired();
700
			}
701
		}
702
		return $expired;
703
	}
704
705
706