Code Duplication    Length = 47-47 lines in 2 locations

admin_pages/venues/Venues_Admin_Page.core.php 1 location

@@ 955-1001 (lines=47) @@
952
	 * @param  string $venue_status
953
	 * @return void
954
	 */
955
	private function _change_venue_status( $VNU_ID = 0, $venue_status = '' ) {
956
		// grab venue id
957
		if (! $VNU_ID) {
958
			$msg = __('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
959
			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
960
			return FALSE;
961
		}
962
963
		$this->_cpt_model_obj = EEM_Venue::instance()->get_one_by_ID( $VNU_ID );
964
965
		// clean status
966
		$venue_status = sanitize_key($venue_status);
967
		// grab status
968
		if ( ! $venue_status ) {
969
			$msg = __('An error occurred. No Venue Status or an invalid Venue Status was received.', 'event_espresso');
970
			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
971
			return FALSE;
972
		}
973
974
		// was event trashed or restored ?
975
		switch ($venue_status) {
976
			case 'draft' :
977
				$action = 'restored from the trash';
978
				$hook = 'AHEE_venue_restored_from_trash';
979
				break;
980
			case 'trash' :
981
				$action = 'moved to the trash';
982
				$hook = 'AHEE_venue_moved_to_trash';
983
				break;
984
			default :
985
				$action = 'updated';
986
				$hook = FALSE;
987
		}
988
		//use class to change status
989
		$this->_cpt_model_obj->set_status( $venue_status );
990
		$success = $this->_cpt_model_obj->save();
991
992
		if ($success === FALSE) {
993
			$msg = sprintf(__('An error occurred. The venue could not be %s.', 'event_espresso'), $action);
994
			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
995
			return FALSE;
996
		}
997
		if ($hook) {
998
			do_action($hook);
999
		}
1000
		return TRUE;
1001
	}
1002
1003
1004
	/**

admin_pages/events/Events_Admin_Page.core.php 1 location

@@ 1817-1863 (lines=47) @@
1814
	 * @param  string $event_status
1815
	 * @return bool
1816
	 */
1817
	private function _change_event_status( $EVT_ID = 0, $event_status = '') {
1818
		// grab event id
1819
		if (!$EVT_ID) {
1820
			$msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso');
1821
			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1822
			return FALSE;
1823
		}
1824
1825
		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
1826
1827
		// clean status
1828
		$event_status = sanitize_key($event_status);
1829
		// grab status
1830
		if (empty($event_status)) {
1831
			$msg = __('An error occurred. No Event Status or an invalid Event Status was received.', 'event_espresso');
1832
			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1833
			return FALSE;
1834
		}
1835
1836
		// was event trashed or restored ?
1837
		switch ($event_status) {
1838
			case 'draft' :
1839
				$action = 'restored from the trash';
1840
				$hook = 'AHEE_event_restored_from_trash';
1841
				break;
1842
			case 'trash' :
1843
				$action = 'moved to the trash';
1844
				$hook = 'AHEE_event_moved_to_trash';
1845
				break;
1846
			default :
1847
				$action = 'updated';
1848
				$hook = FALSE;
1849
		}
1850
		//use class to change status
1851
		$this->_cpt_model_obj->set_status( $event_status );
1852
		$success = $this->_cpt_model_obj->save();
1853
1854
		if ($success === FALSE) {
1855
			$msg = sprintf(__('An error occurred. The event could not be %s.', 'event_espresso'), $action);
1856
			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1857
			return FALSE;
1858
		}
1859
		if ($hook) {
1860
			do_action($hook);
1861
		}
1862
		return TRUE;
1863
	}
1864
1865
1866