| @@ 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 | /** |
|
| @@ 1769-1815 (lines=47) @@ | ||
| 1766 | * @param string $event_status |
|
| 1767 | * @return bool |
|
| 1768 | */ |
|
| 1769 | private function _change_event_status( $EVT_ID = 0, $event_status = '') { |
|
| 1770 | // grab event id |
|
| 1771 | if (!$EVT_ID) { |
|
| 1772 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
|
| 1773 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1774 | return FALSE; |
|
| 1775 | } |
|
| 1776 | ||
| 1777 | $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
| 1778 | ||
| 1779 | // clean status |
|
| 1780 | $event_status = sanitize_key($event_status); |
|
| 1781 | // grab status |
|
| 1782 | if (empty($event_status)) { |
|
| 1783 | $msg = __('An error occurred. No Event Status or an invalid Event Status was received.', 'event_espresso'); |
|
| 1784 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1785 | return FALSE; |
|
| 1786 | } |
|
| 1787 | ||
| 1788 | // was event trashed or restored ? |
|
| 1789 | switch ($event_status) { |
|
| 1790 | case 'draft' : |
|
| 1791 | $action = 'restored from the trash'; |
|
| 1792 | $hook = 'AHEE_event_restored_from_trash'; |
|
| 1793 | break; |
|
| 1794 | case 'trash' : |
|
| 1795 | $action = 'moved to the trash'; |
|
| 1796 | $hook = 'AHEE_event_moved_to_trash'; |
|
| 1797 | break; |
|
| 1798 | default : |
|
| 1799 | $action = 'updated'; |
|
| 1800 | $hook = FALSE; |
|
| 1801 | } |
|
| 1802 | //use class to change status |
|
| 1803 | $this->_cpt_model_obj->set_status( $event_status ); |
|
| 1804 | $success = $this->_cpt_model_obj->save(); |
|
| 1805 | ||
| 1806 | if ($success === FALSE) { |
|
| 1807 | $msg = sprintf(__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
| 1808 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1809 | return FALSE; |
|
| 1810 | } |
|
| 1811 | if ($hook) { |
|
| 1812 | do_action($hook); |
|
| 1813 | } |
|
| 1814 | return TRUE; |
|
| 1815 | } |
|
| 1816 | ||
| 1817 | ||
| 1818 | ||