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