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

@@ 1730-1759 (lines=30) @@
1727
	 * @param  string $event_status
1728
	 * @return void
1729
	 */
1730
	protected function _trash_or_restore_events($event_status = 'trash') {
1731
		// clean status
1732
		$event_status = sanitize_key($event_status);
1733
		// grab status
1734
		if (!empty($event_status)) {
1735
			$success = TRUE;
1736
			//determine the event id and set to array.
1737
			$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
1738
			// loop thru events
1739
			foreach ($EVT_IDs as $EVT_ID) {
1740
				if ($EVT_ID = absint($EVT_ID)) {
1741
					$results = $this->_change_event_status($EVT_ID, $event_status);
1742
					$success = $results !== FALSE ? $success : FALSE;
1743
				} else {
1744
					$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);
1745
					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1746
					$success = FALSE;
1747
				}
1748
			}
1749
		} else {
1750
			$success = FALSE;
1751
			$msg = __('An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', 'event_espresso');
1752
			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1753
		}
1754
		// in order to force a pluralized result message we need to send back a success status greater than 1
1755
		$success = $success ? 2 : FALSE;
1756
		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1757
1758
		$this->_redirect_after_action($success, 'Events', $action, array('action' => 'default'));
1759
	}
1760
1761
	/**
1762
	 * _trash_or_restore_events