Code Duplication    Length = 29-30 lines in 2 locations

admin_pages/venues/Venues_Admin_Page.core.php 1 location

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

admin_pages/events/Events_Admin_Page.core.php 1 location

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