Code Duplication    Length = 29-30 lines in 2 locations

admin_pages/venues/Venues_Admin_Page.core.php 1 location

@@ 911-939 (lines=29) @@
908
909
910
911
	protected function _trash_or_restore_venues( $venue_status = 'trash' ) {
912
		// clean status
913
		$venue_status = sanitize_key($venue_status);
914
		// grab status
915
		if (!empty($venue_status)) {
916
			$success = TRUE;
917
			//determine the event id and set to array.
918
			$VNU_IDs = isset($this->_req_data['venue_id']) ? (array) $this->_req_data['venue_id'] : array();
919
			// loop thru events
920
			foreach ($VNU_IDs as $VNU_ID) {
921
				if ($VNU_ID = absint($VNU_ID)) {
922
					$results = $this->_change_venue_status($VNU_ID, $venue_status);
923
					$success = $results !== FALSE ? $success : FALSE;
924
				} else {
925
					$msg = sprintf(__('An error occurred. Venue #%d could not be moved to the trash because a valid venue ID was not not supplied.', 'event_espresso'), $VNU_ID);
926
					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
927
					$success = FALSE;
928
				}
929
			}
930
		} else {
931
			$success = FALSE;
932
			$msg = __('An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.', 'event_espresso');
933
			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
934
		}
935
		// in order to force a pluralized result message we need to send back a success status greater than 1
936
		$success = $success ? 2 : FALSE;
937
		$action = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
938
		$this->_redirect_after_action($success, 'Venues', $action, array('action' => 'default'));
939
	}
940
941
942

admin_pages/events/Events_Admin_Page.core.php 1 location

@@ 1781-1810 (lines=30) @@
1778
	 * @param  string $event_status
1779
	 * @return void
1780
	 */
1781
	protected function _trash_or_restore_events($event_status = 'trash') {
1782
		// clean status
1783
		$event_status = sanitize_key($event_status);
1784
		// grab status
1785
		if (!empty($event_status)) {
1786
			$success = TRUE;
1787
			//determine the event id and set to array.
1788
			$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
1789
			// loop thru events
1790
			foreach ($EVT_IDs as $EVT_ID) {
1791
				if ($EVT_ID = absint($EVT_ID)) {
1792
					$results = $this->_change_event_status($EVT_ID, $event_status);
1793
					$success = $results !== FALSE ? $success : FALSE;
1794
				} else {
1795
					$msg = sprintf(__('An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', 'event_espresso'), $EVT_ID);
1796
					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1797
					$success = FALSE;
1798
				}
1799
			}
1800
		} else {
1801
			$success = FALSE;
1802
			$msg = __('An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', 'event_espresso');
1803
			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1804
		}
1805
		// in order to force a pluralized result message we need to send back a success status greater than 1
1806
		$success = $success ? 2 : FALSE;
1807
		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1808
1809
		$this->_redirect_after_action($success, 'Events', $action, array('action' => 'default'));
1810
	}
1811
1812
	/**
1813
	 * _trash_or_restore_events