/** * Perform actions about rendez-vous (insert/edit/delete/save prefs) * * @package Rendez Vous * @subpackage Groups * * @since Rendez Vous (1.1.0) * * @uses Rendez_Vous_Group->is_rendez_vous() Checks whether we're on a rendez-vous page of a group * @uses rendez_vous() to get the plugin's instance * @uses rendez_vous_handle_actions() to insert/edit/delete/save prefs about a rendez-vous * @uses bp_get_current_group_id() to get the group id * @uses Rendez_Vous_Group::group_get_option() to get the needed group metas. * @uses groups_is_user_member() to check the organizer is still a member of the group * @uses delete_post_meta() to remove a rendez-vous from a group * @uses rendez_vous_get_single_link() to get the rendez-vous link * @uses bp_core_add_message() to give a feedback to the user * @uses do_action() call 'rendez_vous_groups_component_deactivated' or * 'rendez_vous_groups_member_removed' to perform custom actions * @uses bp_core_redirect() to safely redirect the user * @uses bp_is_current_component() to check for a BuddyPress component * @uses bp_current_item() to make sure a group item is requested * @uses bp_do_404() to set the WP Query to a 404. */ public function group_handle_screens() { if ($this->is_rendez_vous()) { $rendez_vous = rendez_vous(); $this->screen = rendez_vous_handle_actions(); $rendez_vous->screens->screen = $this->screen; $group_id = bp_get_current_group_id(); /** * Should we remove the rendez-vous from the group ? * * Although, this is already handled in Rendez_Vous_Group->group_rendez_vous_link() * an invited user can click on an email he received where the link is a group rendez-vous link. * @see rendez_vous_published_notification() * * Not checking if notifications are active, because there's also an edge case when the activity * has not been deleted yet and the user clicks on the activity link. */ if ('single' == $this->screen && !empty($rendez_vous->item->id)) { $message = $action = false; // The group doesn't support rendez-vous anymore if (!self::group_get_option($group_id, '_rendez_vous_group_activate', false)) { $message = __('The Group, the rendez-vous was attached to, does not support rendez-vous anymore', 'rendez-vous'); $action = 'rendez_vous_groups_component_deactivated'; // The organizer was removed or left the group } else { if (!groups_is_user_member($rendez_vous->item->organizer, $group_id)) { $message = sprintf(__('%s is not a member of the group, the rendez-vous was attached to, anymore. As a result, the rendez-vous was removed from the group.', 'rendez-vous'), bp_core_get_user_displayname($rendez_vous->item->organizer)); $action = 'rendez_vous_groups_member_removed'; } } // Bail if everything is ok. if (empty($message)) { return; } // Delete the rendez-vous group id meta delete_post_meta($rendez_vous->item->id, '_rendez_vous_group_id'); $redirect = rendez_vous_get_single_link($rendez_vous->item->id, $rendez_vous->item->organizer); bp_core_add_message($message, 'error'); // fire an action to deal with group activities do_action($action, $rendez_vous->item->id, $rendez_vous->item); // Redirect to organizer's rendez-vous page bp_core_redirect($redirect); } } else { if (bp_is_current_component('groups') && bp_is_current_action($this->slug) && bp_current_item()) { bp_do_404(); return; } } }
/** * Set Actions * * @package Rendez Vous * @subpackage Screens * * @since Rendez Vous (1.0.0) */ public function schedule_actions() { $this->screen = rendez_vous_handle_actions(); }