| @@ 953-999 (lines=47) @@ | ||
| 950 | * @param string $venue_status |
|
| 951 | * @return void |
|
| 952 | */ |
|
| 953 | private function _change_venue_status( $VNU_ID = 0, $venue_status = '' ) { |
|
| 954 | // grab venue id |
|
| 955 | if (! $VNU_ID) { |
|
| 956 | $msg = __('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso'); |
|
| 957 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 958 | return FALSE; |
|
| 959 | } |
|
| 960 | ||
| 961 | $this->_cpt_model_obj = EEM_Venue::instance()->get_one_by_ID( $VNU_ID ); |
|
| 962 | ||
| 963 | // clean status |
|
| 964 | $venue_status = sanitize_key($venue_status); |
|
| 965 | // grab status |
|
| 966 | if ( ! $venue_status ) { |
|
| 967 | $msg = __('An error occurred. No Venue Status or an invalid Venue Status was received.', 'event_espresso'); |
|
| 968 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 969 | return FALSE; |
|
| 970 | } |
|
| 971 | ||
| 972 | // was event trashed or restored ? |
|
| 973 | switch ($venue_status) { |
|
| 974 | case 'draft' : |
|
| 975 | $action = 'restored from the trash'; |
|
| 976 | $hook = 'AHEE_venue_restored_from_trash'; |
|
| 977 | break; |
|
| 978 | case 'trash' : |
|
| 979 | $action = 'moved to the trash'; |
|
| 980 | $hook = 'AHEE_venue_moved_to_trash'; |
|
| 981 | break; |
|
| 982 | default : |
|
| 983 | $action = 'updated'; |
|
| 984 | $hook = FALSE; |
|
| 985 | } |
|
| 986 | //use class to change status |
|
| 987 | $this->_cpt_model_obj->set_status( $venue_status ); |
|
| 988 | $success = $this->_cpt_model_obj->save(); |
|
| 989 | ||
| 990 | if ($success === FALSE) { |
|
| 991 | $msg = sprintf(__('An error occurred. The venue could not be %s.', 'event_espresso'), $action); |
|
| 992 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 993 | return FALSE; |
|
| 994 | } |
|
| 995 | if ($hook) { |
|
| 996 | do_action($hook); |
|
| 997 | } |
|
| 998 | return TRUE; |
|
| 999 | } |
|
| 1000 | ||
| 1001 | ||
| 1002 | /** |
|
| @@ 1763-1809 (lines=47) @@ | ||
| 1760 | * @param string $event_status |
|
| 1761 | * @return bool |
|
| 1762 | */ |
|
| 1763 | private function _change_event_status( $EVT_ID = 0, $event_status = '') { |
|
| 1764 | // grab event id |
|
| 1765 | if (!$EVT_ID) { |
|
| 1766 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
|
| 1767 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1768 | return FALSE; |
|
| 1769 | } |
|
| 1770 | ||
| 1771 | $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
| 1772 | ||
| 1773 | // clean status |
|
| 1774 | $event_status = sanitize_key($event_status); |
|
| 1775 | // grab status |
|
| 1776 | if (empty($event_status)) { |
|
| 1777 | $msg = __('An error occurred. No Event Status or an invalid Event Status was received.', 'event_espresso'); |
|
| 1778 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1779 | return FALSE; |
|
| 1780 | } |
|
| 1781 | ||
| 1782 | // was event trashed or restored ? |
|
| 1783 | switch ($event_status) { |
|
| 1784 | case 'draft' : |
|
| 1785 | $action = 'restored from the trash'; |
|
| 1786 | $hook = 'AHEE_event_restored_from_trash'; |
|
| 1787 | break; |
|
| 1788 | case 'trash' : |
|
| 1789 | $action = 'moved to the trash'; |
|
| 1790 | $hook = 'AHEE_event_moved_to_trash'; |
|
| 1791 | break; |
|
| 1792 | default : |
|
| 1793 | $action = 'updated'; |
|
| 1794 | $hook = FALSE; |
|
| 1795 | } |
|
| 1796 | //use class to change status |
|
| 1797 | $this->_cpt_model_obj->set_status( $event_status ); |
|
| 1798 | $success = $this->_cpt_model_obj->save(); |
|
| 1799 | ||
| 1800 | if ($success === FALSE) { |
|
| 1801 | $msg = sprintf(__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
| 1802 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1803 | return FALSE; |
|
| 1804 | } |
|
| 1805 | if ($hook) { |
|
| 1806 | do_action($hook); |
|
| 1807 | } |
|
| 1808 | return TRUE; |
|
| 1809 | } |
|
| 1810 | ||
| 1811 | ||
| 1812 | ||