| @@ 1011-1057 (lines=47) @@ | ||
| 1008 | * @param string $venue_status |
|
| 1009 | * @return void |
|
| 1010 | */ |
|
| 1011 | private function _change_venue_status($VNU_ID = 0, $venue_status = '') |
|
| 1012 | { |
|
| 1013 | // grab venue id |
|
| 1014 | if (! $VNU_ID) { |
|
| 1015 | $msg = __('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso'); |
|
| 1016 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1017 | return false; |
|
| 1018 | } |
|
| 1019 | ||
| 1020 | $this->_cpt_model_obj = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
| 1021 | ||
| 1022 | // clean status |
|
| 1023 | $venue_status = sanitize_key($venue_status); |
|
| 1024 | // grab status |
|
| 1025 | if (! $venue_status) { |
|
| 1026 | $msg = __('An error occurred. No Venue Status or an invalid Venue Status was received.', 'event_espresso'); |
|
| 1027 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1028 | return false; |
|
| 1029 | } |
|
| 1030 | ||
| 1031 | // was event trashed or restored ? |
|
| 1032 | switch ($venue_status) { |
|
| 1033 | case 'draft': |
|
| 1034 | $action = 'restored from the trash'; |
|
| 1035 | $hook = 'AHEE_venue_restored_from_trash'; |
|
| 1036 | break; |
|
| 1037 | case 'trash': |
|
| 1038 | $action = 'moved to the trash'; |
|
| 1039 | $hook = 'AHEE_venue_moved_to_trash'; |
|
| 1040 | break; |
|
| 1041 | default: |
|
| 1042 | $action = 'updated'; |
|
| 1043 | $hook = false; |
|
| 1044 | } |
|
| 1045 | // use class to change status |
|
| 1046 | $this->_cpt_model_obj->set_status($venue_status); |
|
| 1047 | $success = $this->_cpt_model_obj->save(); |
|
| 1048 | ||
| 1049 | if ($success === false) { |
|
| 1050 | $msg = sprintf(__('An error occurred. The venue could not be %s.', 'event_espresso'), $action); |
|
| 1051 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1052 | return false; |
|
| 1053 | } |
|
| 1054 | if ($hook) { |
|
| 1055 | do_action($hook); |
|
| 1056 | } |
|
| 1057 | return true; |
|
| 1058 | } |
|
| 1059 | ||
| 1060 | ||
| @@ 2044-2090 (lines=47) @@ | ||
| 2041 | * @param string $event_status |
|
| 2042 | * @return bool |
|
| 2043 | */ |
|
| 2044 | private function _change_event_status($EVT_ID = 0, $event_status = '') |
|
| 2045 | { |
|
| 2046 | // grab event id |
|
| 2047 | if (! $EVT_ID) { |
|
| 2048 | $msg = esc_html__( |
|
| 2049 | 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
| 2050 | 'event_espresso' |
|
| 2051 | ); |
|
| 2052 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2053 | return false; |
|
| 2054 | } |
|
| 2055 | $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2056 | // clean status |
|
| 2057 | $event_status = sanitize_key($event_status); |
|
| 2058 | // grab status |
|
| 2059 | if (empty($event_status)) { |
|
| 2060 | $msg = esc_html__( |
|
| 2061 | 'An error occurred. No Event Status or an invalid Event Status was received.', |
|
| 2062 | 'event_espresso' |
|
| 2063 | ); |
|
| 2064 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2065 | return false; |
|
| 2066 | } |
|
| 2067 | // was event trashed or restored ? |
|
| 2068 | switch ($event_status) { |
|
| 2069 | case 'draft': |
|
| 2070 | $action = 'restored from the trash'; |
|
| 2071 | $hook = 'AHEE_event_restored_from_trash'; |
|
| 2072 | break; |
|
| 2073 | case 'trash': |
|
| 2074 | $action = 'moved to the trash'; |
|
| 2075 | $hook = 'AHEE_event_moved_to_trash'; |
|
| 2076 | break; |
|
| 2077 | default: |
|
| 2078 | $action = 'updated'; |
|
| 2079 | $hook = false; |
|
| 2080 | } |
|
| 2081 | // use class to change status |
|
| 2082 | $this->_cpt_model_obj->set_status($event_status); |
|
| 2083 | $success = $this->_cpt_model_obj->save(); |
|
| 2084 | if ($success === false) { |
|
| 2085 | $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
| 2086 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2087 | return false; |
|
| 2088 | } |
|
| 2089 | if ($hook) { |
|
| 2090 | do_action($hook); |
|
| 2091 | } |
|
| 2092 | return true; |
|
| 2093 | } |
|