/** * 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); }
public function activedate_set($event) { $topic_data = $event['topic_data']; $first_post = intval($topic_data['topic_first_post_id']); if (0 == $event['active_date']) { // Reset $sql = 'SELECT event_id FROM ' . $this->cal_table . ' WHERE post_id = ' . $first_post; $result = $this->db->sql_query_limit($sql, 1); $event_id = $this->db->sql_fetchfield('event_id'); $this->db->sql_freeresult($result); if (!$event_id) { // No event entered, simply skip return; } $sql = 'DELETE FROM ' . $this->cal_table . ' WHERE event_id = ' . $event_id; $this->db->sql_query($sql); $sql = 'DELETE FROM ' . $this->cal_event_table . ' WHERE id = ' . $event_id; $this->db->sql_query($sql); $sql = 'DELETE FROM ' . $this->cal_participants_table . ' WHERE post_id = ' . $first_post; $this->db->sql_query($sql); } else { // Copy Date & entries if ($this->hookup->topic_id != $event['topic_id']) { if ($this->hookup->topic_id != 0) { $this->hookup = new hookup(); } $this->hookup->load_hookup($event['topic_id']); } //TODO Fortsetzen } }
public function find_users_for_notification($notification_data, $options = array()) { $options = array_merge(array('ignore_users' => array()), $options); // We usually wish to notify the users who are listed in a hookup: if (!$this->hookup->topic_id == $notification_data['topic_id']) { if ($this->hookup->topic_id) { // If we are actually using the hookup for some other topic, this will ensure we don't break its use - stupid bugs $this->hookup = clone $this->hookup; } $this->hookup->load_hookup($notification_data['topic_id']); } $users = array_keys($this->hookup->hookup_users); if (empty($users)) { // Maybe the data was entered by someone else? return array(); } $users = array_unique($users); return $this->check_user_notification_options($users, $options); }
/** * Displays hookup data in posting.php * * @param unknown $event */ public function posting_display_template($event) { // Check permissions if (!$this->auth->acl_get('f_hookup', $event['forum_id']) && !$this->auth->acl_get('m_edit', $event['forum_id'])) { return; } // Check for first post if (isset($event['post_data']['topic_first_post_id']) && (!isset($event['post_data']['post_id']) || $event['post_data']['topic_first_post_id'] != $event['post_data']['post_id'])) { return; } $this->user->add_lang_ext('gn36/hookup', 'hookup'); if (isset($event['topic_id']) && $event['topic_id']) { $this->hookup->load_hookup($event['topic_id']); } $is_inactive = !empty($this->hookup->hookup_users) || !empty($this->hookup->hookup_dates); $is_inactive = $is_inactive && $this->hookup->hookup_enabled == false; $this->template->assign_vars(array('S_HOOKUP_ALLOWED' => true, 'S_TOPIC_HAS_HOOKUP' => $this->hookup->hookup_enabled, 'S_TOPIC_HAS_INACTIVE_HOOKUP' => $is_inactive, 'S_HOOKUP_CHECKED' => $this->hookup->hookup_enabled ? "checked='checked'" : '', 'S_HOOKUP_SELF_INVITE_CHECKED' => $this->hookup->hookup_self_invite ? "checked='checked'" : '', 'S_HOOKUP_AUTORESET_CHECKED' => $this->hookup->hookup_autoreset ? "checked='checked'" : '')); }
/** * Process all hookup stuff in viewtopic * * @param \phpbb\event\data $event */ public function show_hookup_viewtopic($event) { // Check auth if (!$this->auth->acl_get('f_hookup', $event['forum_id']) && !$this->auth->acl_get('m_edit', $event['forum_id'])) { return; } if (!$this->hookup->load_hookup($event['topic_id'])) { // No hookup for this topic return; } // Load Language file $this->user->add_lang_ext('gn36/hookup', 'hookup'); // Now process all submits, if any $hookup_errors = $this->process_submit($event); // If the hookup is disabled, then return now (also if we just disabled it) if (!$this->hookup->hookup_enabled) { return; } // Set the hookup as "viewed" for the current user: $this->hookup->set_user_data($this->user->data['user_id'], 0); // This will submit all changes to the db, including the ones processed in $this->process_submit(); $this->hookup->submit(); // Some frequently used data: $forum_id = $event['forum_id']; $topic_id = $event['topic_id']; $is_owner = $event['topic_data']['topic_poster'] == $this->user->data['user_id'] || $this->auth->acl_get('m_edit', $event['forum_id']); $is_member = isset($this->hookup->hookup_users[$this->user->data['user_id']]); $viewtopic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->phpEx}?f={$forum_id}&t={$topic_id}"); // TODO: populate lists for adding groups, deleting dates and users if ($is_owner) { // Populate group list $sql = 'SELECT group_id, group_name, group_type FROM ' . GROUPS_TABLE . ' WHERE group_type <> ' . GROUP_HIDDEN . ' AND ' . $this->db->sql_in_set('group_name', array('GUESTS', 'BOTS'), true); $result = $this->db->sql_query($sql); $s_group_list = ''; while ($row = $this->db->sql_fetchrow($result)) { $s_group_list .= '<option value="' . $row['group_id'] . '"' . ($row['group_type'] == GROUP_SPECIAL ? ' class="sep"' : '') . '>'; $s_group_list .= $row['group_type'] == GROUP_SPECIAL ? $this->user->lang['G_' . $row['group_name']] : $row['group_name']; $s_group_list .= '</option>'; } $this->db->sql_freeresult($result); $this->template->assign_var('S_GROUP_LIST', $s_group_list); } if (count($this->hookup->hookup_dates) == 0) { $hookup_errors[] = $this->user->lang['HOOKUP_NO_DATES']; } if (count($this->hookup->hookup_users) == 0) { $hookup_errors[] = $this->user->lang['HOOKUP_NO_USERS']; } $this->template->assign_vars(array('S_HAS_HOOKUP' => true, 'S_IS_HOOKUP_OWNER' => $is_owner, 'S_IS_HOOKUP_MEMBER' => $is_member, 'S_HAS_DATES' => empty($this->hookup->hookup_dates) ? false : true, 'S_HAS_USERS' => empty($this->hookup->hookup_users) ? false : true, 'S_IS_SELF_INVITE' => $this->hookup->hookup_self_invite, 'S_HOOKUP_ACTION' => $viewtopic_url, 'S_ACTIVE_DATE' => $this->hookup->hookup_active_date, 'ACTIVE_DATE_DATE' => isset($this->hookup->hookup_dates[$this->hookup->hookup_active_date]) ? $this->user->format_date($this->hookup->hookup_dates[$this->hookup->hookup_active_date]['date_time']) : '-', 'S_NUM_DATES' => count($this->hookup->hookup_dates), 'S_NUM_DATES_PLUS_1' => count($this->hookup->hookup_dates) + 1, 'U_UNSET_ACTIVE' => $viewtopic_url . '&set_active=0', 'U_FIND_USERNAME' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=searchuser&form=ucp&field=usernames'), 'UA_FIND_USERNAME' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=searchuser&form=ucp&field=usernames', false), 'USER_COMMENT' => isset($this->hookup->hookup_users[$this->user->data['user_id']]) ? $this->hookup->hookup_users[$this->user->data['user_id']]['comment'] : '', 'HOOKUP_ERRORS' => count($hookup_errors) > 0 ? implode('<br />', $hookup_errors) : false, 'HOOKUP_YES' => hookup::HOOKUP_YES, 'HOOKUP_MAYBE' => hookup::HOOKUP_MAYBE, 'HOOKUP_NO' => hookup::HOOKUP_NO, 'HOOKUP_UNSET' => hookup::HOOKUP_UNSET, 'L_HOOKUP_YES' => $this->user->lang['HOOKUP_STATUS'][hookup::HOOKUP_YES], 'L_HOOKUP_NO' => $this->user->lang['HOOKUP_STATUS'][hookup::HOOKUP_NO], 'L_HOOKUP_MAYBE' => $this->user->lang['HOOKUP_STATUS'][hookup::HOOKUP_MAYBE], 'L_HOOKUP_UNSET' => $this->user->lang['HOOKUP_STATUS'][hookup::HOOKUP_UNSET], 'L_HOOKUP_Y' => $this->user->lang['HOOKUP_STATUS'][hookup::HOOKUP_YES][0], 'L_HOOKUP_N' => $this->user->lang['HOOKUP_STATUS'][hookup::HOOKUP_NO][0], 'L_HOOKUP_M' => $this->user->lang['HOOKUP_STATUS'][hookup::HOOKUP_MAYBE][0], 'S_EXT_PATH' => $this->hookup_path, 'S_LANG_NAME' => $this->user->lang_name)); // Output dates foreach ($this->hookup->hookup_dates as $hookup_date) { $yes_count = $this->hookup->hookup_available_sums[$hookup_date['date_id']][hookup::HOOKUP_YES]; $maybe_count = $this->hookup->hookup_available_sums[$hookup_date['date_id']][hookup::HOOKUP_MAYBE]; $no_count = $this->hookup->hookup_available_sums[$hookup_date['date_id']][hookup::HOOKUP_NO]; //$total_count = $yes_count + $maybe_count + $no_count; //unset_count? $total_count = count($this->hookup->hookup_users); $unset_count = $total_count - ($yes_count + $maybe_count + $no_count); $yes_percent = $total_count > 0 ? round($yes_count / $total_count * 100) : 0; $maybe_percent = $total_count > 0 ? round($maybe_count / $total_count * 100) : 0; $no_percent = $total_count > 0 ? round($no_count / $total_count * 100) : 0; $unset_percent = 100 - ($yes_percent + $maybe_percent + $no_percent); // More than 100% if ($unset_percent < 0) { if ($maybe_percent > 0) { $maybe_percent--; } else { $no_percent--; } } $this->template->assign_block_vars('date', array('ID' => $hookup_date['date_id'], 'DATE' => $this->user->format_date($hookup_date['date_time'], $this->user->lang['HOOKUP_DATEFORMAT']), 'FULL_DATE' => $this->user->format_date($hookup_date['date_time']), 'YES_COUNT' => $yes_count, 'YES_PERCENT' => $yes_percent, 'MAYBE_COUNT' => $maybe_count, 'MAYBE_PERCENT' => $maybe_percent, 'NO_COUNT' => $no_count, 'NO_PERCENT' => $no_percent, 'UNSET_COUNT' => $unset_count, 'UNSET_PERCENT' => $unset_percent, 'S_IS_ACTIVE' => $hookup_date['date_id'] == $this->hookup->hookup_active_date, 'U_SET_ACTIVE' => $viewtopic_url . '&set_active=' . $hookup_date['date_id'])); } // Output details if (!empty($this->hookup->hookup_users)) { // Fetch User details $sql = 'SELECT user_id, username, user_colour FROM ' . USERS_TABLE . ' WHERE ' . $this->db->sql_in_set('user_id', array_keys($this->hookup->hookup_users)); $result = $this->db->sql_query($sql); $user_details = array(); while ($row = $this->db->sql_fetchrow($result)) { $user_details[$row['user_id']] = $row; } } foreach ($this->hookup->hookup_users as $hookup_user) { $is_self = $hookup_user['user_id'] == $this->user->data['user_id']; $this->template->assign_block_vars('user', array('ID' => $hookup_user['user_id'], 'NAME' => $user_details[$hookup_user['user_id']]['username'], 'COMMENT' => isset($hookup_user['comment']) ? $hookup_user['comment'] : '', 'USERNAME_FULL' => get_username_string('full', $hookup_user['user_id'], $user_details[$hookup_user['user_id']]['username'], $user_details[$hookup_user['user_id']]['user_colour']), 'IS_SELF' => $is_self)); foreach ($this->hookup->hookup_dates as $hookup_date) { $available = isset($this->hookup->hookup_availables[$hookup_user['user_id']][$hookup_date['date_id']]) ? $this->hookup->hookup_availables[$hookup_user['user_id']][$hookup_date['date_id']] : hookup::HOOKUP_UNSET; $this->template->assign_block_vars('user.date', array('ID' => $hookup_date['date_id'], 'AVAILABLE' => $this->user->lang['HOOKUP_STATUS'][$available], 'STATUS_YES' => $available == hookup::HOOKUP_YES, 'STATUS_NO' => $available == hookup::HOOKUP_NO, 'STATUS_MAYBE' => $available == hookup::HOOKUP_MAYBE, 'STATUS_UNSET' => $available == hookup::HOOKUP_UNSET, 'S_SELECT_NAME' => 'available[' . $hookup_date['date_id'] . ']', 'S_IS_ACTIVE' => $hookup_date['date_id'] == $this->hookup->hookup_active_date)); } } }