/** * Synchronizes new participant entries from calendar to hookup * * @param \Symfony\Component\EventDispatcher\Event $event * @throws \Exception */ public function sync_participant_calendar(\Symfony\Component\EventDispatcher\Event $event) { $sql_data = $event['sql_ary']; $post_id = (int) $sql_data['POST_ID']; // Retrieve Hookup for that post: $sql = 'SELECT p.topic_id, t.forum_id, t.topic_first_post_id FROM ' . POSTS_TABLE . ' p LEFT JOIN ' . TOPICS_TABLE . ' t ON p.topic_id = t.topic_id WHERE post_id = ' . $post_id; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); if (!$row || !$this->hookup->load_hookup($row['topic_id'])) { throw new \Exception('Loading topic or hookup failed. Post ID: ' . $post_id); } if (!$this->hookup->hookup_enabled || $post_id != $row['topic_first_post_id']) { // Don't sync if the hookup is disabled or the event is not linked to the first post of the topic return; } // Do not enter, if the user is not permitted to use the hookup // Ignore permissions, if called for user_id different from current user if ($event['user_id'] == $this->user->data['user_id'] && !$this->auth->acl_get('f_hookup', $row['forum_id'])) { return; } // Don't sync if no activedate is set if (!$this->hookup->hookup_active_date) { return; } $this->hookup->add_user($sql_data['USER_ID'], $sql_data['COMMENTS']); $this->hookup->set_user_date($sql_data['USER_ID'], $this->hookup->hookup_active_date, $this->part_ary_inv[$sql_data['PARTICIPANTS']]); $this->hookup->submit(false); }
/** * Process enable/disable * * @param \phpbb\event\data $event * @param bool $is_owner */ protected function process_disable($event, $is_owner) { $action = $this->request->variable('delete_hookup', 'no'); if ($action != 'disable' && $action != 'delete') { return array(); } if (!$is_owner) { return array($this->user->lang('NOT_AUTH_HOOKUP')); } if (confirm_box(true)) { if ($action == 'disable') { $this->hookup->hookup_enabled = false; $this->hookup->submit(false); } else { if ($action == 'delete') { $this->hookup->delete(); $this->hookup->submit(false); } } } else { $s_hidden_fields = build_hidden_fields(array('t' => $event['topic_id'], 'delete_hookup' => $action)); confirm_box(false, $this->user->lang['DELETE_HOOKUP_' . strtoupper($action) . '_CONFIRM'], $s_hidden_fields); } return array(); }
/** * Process enable/disable * * @param \phpbb\event\data $event * @param bool $is_owner */ protected function process_disable($event, $is_owner) { $action = $this->request->variable('delete_hookup', 'no'); if ($action != 'disable' && $action != 'delete') { return array(); } if (!$is_owner) { return array($this->user->lang('NOT_AUTH_HOOKUP')); } if (confirm_box(true)) { if ($action == 'disable') { $this->hookup->hookup_enabled = false; $this->hookup->submit(false); // TODO: is there a way to hide notifications? $this->notification_manager->delete_notifications(array('gn36.hookup.notification.type.invited', 'gn36.hookup.notification.type.user_added', 'gn36.hookup.notification.type.date_added', 'gn36.hookup.notification.type.active_date_set', 'gn36.hookup.notification.type.active_date_reset'), $event['topic_id']); } else { if ($action == 'delete') { $this->hookup->delete(); $this->hookup->submit(false); $this->notification_manager->delete_notifications(array('gn36.hookup.notification.type.invited', 'gn36.hookup.notification.type.user_added', 'gn36.hookup.notification.type.date_added', 'gn36.hookup.notification.type.active_date_set', 'gn36.hookup.notification.type.active_date_reset'), $event['topic_id']); } } } else { $s_hidden_fields = build_hidden_fields(array('t' => $event['topic_id'], 'delete_hookup' => $action)); confirm_box(false, $this->user->lang['DELETE_HOOKUP_' . strtoupper($action) . '_CONFIRM'], $s_hidden_fields); } return array(); }