Code Duplication    Length = 25-26 lines in 2 locations

admin_pages/venues/Venues_Admin_Page.core.php 1 location

@@ 880-905 (lines=26) @@
877
878
879
880
	protected function _trash_or_restore_venue( $venue_status = 'trash', $redirect_after = TRUE ) {
881
		$VNU_ID = isset( $this->_req_data['VNU_ID'] ) ? absint( $this->_req_data['VNU_ID'] ) : FALSE;
882
883
		//loop thru venues
884
		if ( $VNU_ID ) {
885
			//clean status
886
			$venue_status = sanitize_key( $venue_status );
887
			// grab status
888
			if (!empty($venue_status)) {
889
				$success = $this->_change_venue_status($VNU_ID, $venue_status);
890
			} else {
891
				$success = FALSE;
892
				$msg = __('An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.', 'event_espresso');
893
				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
894
			}
895
		} else {
896
			$success = FALSE;
897
			$msg = __('An error occurred. The venue could not be moved to the trash because a valid venue ID was not not supplied.', 'event_espresso');
898
			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
899
		}
900
		$action = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
901
902
		if ( $redirect_after )
903
			$this->_redirect_after_action($success, 'Venue', $action, array('action' => 'default'));
904
905
	}
906
907
908

admin_pages/events/Events_Admin_Page.core.php 1 location

@@ 1745-1769 (lines=25) @@
1742
	 * @param  string $event_status
1743
	 * @return void
1744
	 */
1745
	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE ) {
1746
		//determine the event id and set to array.
1747
		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : FALSE;
1748
		// loop thru events
1749
		if ($EVT_ID) {
1750
			// clean status
1751
			$event_status = sanitize_key($event_status);
1752
			// grab status
1753
			if (!empty($event_status)) {
1754
				$success = $this->_change_event_status($EVT_ID, $event_status);
1755
			} else {
1756
				$success = FALSE;
1757
				$msg = __('An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', 'event_espresso');
1758
				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1759
			}
1760
		} else {
1761
			$success = FALSE;
1762
			$msg = __('An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', 'event_espresso');
1763
			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1764
		}
1765
		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1766
1767
		if ( $redirect_after )
1768
			$this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1769
	}
1770
1771
	/**
1772
	 * _trash_or_restore_events