Code Duplication    Length = 32-33 lines in 2 locations

admin_pages/venues/Venues_Admin_Page.core.php 1 location

@@ 923-955 (lines=33) @@
920
    }
921
922
923
    protected function _trash_or_restore_venue($venue_status = 'trash', $redirect_after = true)
924
    {
925
        $VNU_ID = isset($this->_req_data['VNU_ID']) ? absint($this->_req_data['VNU_ID']) : false;
926
927
        // loop thru venues
928
        if ($VNU_ID) {
929
            // clean status
930
            $venue_status = sanitize_key($venue_status);
931
            // grab status
932
            if (! empty($venue_status)) {
933
                $success = $this->_change_venue_status($VNU_ID, $venue_status);
934
            } else {
935
                $success = false;
936
                $msg = __(
937
                    'An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.',
938
                    'event_espresso'
939
                );
940
                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
941
            }
942
        } else {
943
            $success = false;
944
            $msg = __(
945
                'An error occurred. The venue could not be moved to the trash because a valid venue ID was not not supplied.',
946
                'event_espresso'
947
            );
948
            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
949
        }
950
        $action = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
951
952
        if ($redirect_after) {
953
            $this->_redirect_after_action($success, 'Venue', $action, array('action' => 'default'));
954
        }
955
    }
956
957
958
    protected function _trash_or_restore_venues($venue_status = 'trash')

admin_pages/events/Events_Admin_Page.core.php 1 location

@@ 1940-1971 (lines=32) @@
1937
     * @param  string $event_status
1938
     * @param bool    $redirect_after
1939
     */
1940
    protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)
1941
    {
1942
        // determine the event id and set to array.
1943
        $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;
1944
        // loop thru events
1945
        if ($EVT_ID) {
1946
            // clean status
1947
            $event_status = sanitize_key($event_status);
1948
            // grab status
1949
            if (! empty($event_status)) {
1950
                $success = $this->_change_event_status($EVT_ID, $event_status);
1951
            } else {
1952
                $success = false;
1953
                $msg = esc_html__(
1954
                    'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',
1955
                    'event_espresso'
1956
                );
1957
                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1958
            }
1959
        } else {
1960
            $success = false;
1961
            $msg = esc_html__(
1962
                'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',
1963
                'event_espresso'
1964
            );
1965
            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1966
        }
1967
        $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1968
        if ($redirect_after) {
1969
            $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1970
        }
1971
    }
1972
1973
1974
    /**