/** * 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 status changes * @param \phpbb\event\data $event * @param bool $is_member */ protected function process_status($event, $is_member) { $availables = $this->request->variable('available', array(0 => 0)); if (!$this->request->is_set_post('available')) { return array(); } if (!$is_member) { return array($this->user->lang('NO_HOOKUP_MEMBER')); } foreach ($availables as $date_id => $available) { //ignore HOOKUP_UNSET and other invalid values if (!is_numeric($date_id) || !isset($this->hookup->hookup_dates[$date_id]) || !in_array($available, array(hookup::HOOKUP_YES, hookup::HOOKUP_NO, hookup::HOOKUP_MAYBE))) { continue; } $this->hookup->set_user_date($this->user->data['user_id'], $date_id, $available); } $this->hookup->update_available_sums(); $this->hookup->set_user_data($this->user->data['user_id'], 0, $this->request->variable('comment', '', true)); return array(); }