/** * displays the next x number of upcoming raidplans * */ private function _display_next_raidplans() { global $config, $user, $db, $template, $phpEx, $phpbb_root_path; // build sql $sql_array = array('SELECT' => 'r.raidplan_id ', 'FROM' => array(RP_RAIDS_TABLE => 'r'), 'WHERE' => '(raidplan_access_level = 2 OR (r.poster_id = ' . $db->sql_escape($user->data['user_id']) . ' ) OR (r.raidplan_access_level = 1 AND (' . $this->group_options . ')) ) AND (r.raidplan_start_time >= ' . $db->sql_escape(time()) . " )", 'ORDER_BY' => 'r.raidplan_start_time ASC'); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query_limit($sql, $config['rp_display_next_raidplans'], 0, 3600); while ($row = $db->sql_fetchrow($result)) { unset($raidplan); $raidplan = new Raidplan($this->game_id, $this->guild_id, $this->eventlist, $row['raidplan_id']); if (!isset($this->eventlist[$raidplan->getEventType()])) { //this event is closed, so fetch the whole eventlist including closed ones. $this->eventlist = new \bbdkp\controller\raidplanner\rpevents(0); $this->eventlist = $this->eventlist->events; } if (strlen($this->eventlist[$raidplan->getEventType()]['imagename']) > 1) { $eventimg = $phpbb_root_path . "images/bbdkp/event_images/" . $this->eventlist[$raidplan->getEventType()]['imagename'] . ".png"; } else { $eventimg = $phpbb_root_path . "images/bbdkp/event_images/dummy.png"; } $template->assign_block_vars('upcoming', array('RAID_ID' => $raidplan->id, 'EVENTNAME' => $this->eventlist[$raidplan->getEventType()]['event_name'], 'EVENT_URL' => append_sid("{$phpbb_root_path}dkp.{$phpEx}", "page=planner&view=raidplan&raidplanid=" . $raidplan->id), 'EVENT_ID' => $raidplan->id, 'COLOR' => $this->eventlist[$raidplan->getEventType()]['color'], 'SUBJECT' => censor_text($raidplan->getSubject()), 'IMAGE' => $eventimg, 'START_TIME' => $user->format_date($raidplan->getStartTime(), $config['rp_date_format'], true), 'END_TIME' => $user->format_date($raidplan->getEndTime(), $config['rp_time_format'], true), 'DISPLAY_BOLD' => $user->data['user_id'] == $raidplan->getPoster() ? true : false)); } $db->sql_freeresult($result); $template->assign_vars(array('S_PLANNER_UPCOMING' => true)); }
function main($id, $mode) { global $db, $user, $auth, $template, $config, $phpbb_root_path, $phpEx; $Navigation = new \bbdkp\views\viewNavigation('ucp'); $user->add_lang(array('mods/raidplanner', 'mods/dkp_common')); if (!function_exists('group_memberships')) { include_once $phpbb_root_path . 'includes/functions_user.' . $phpEx; } $this->eventlist = new \bbdkp\controller\raidplanner\rpevents($Navigation->getDkpsysId()); // get the groups of which this user is part of. $groups = group_memberships(false, $user->data['user_id']); $group_options = ""; // build the sql to get access foreach ($groups as $grouprec) { if ($group_options != "") { $group_options .= " OR "; } $group_options .= "group_id = " . $grouprec['group_id'] . " OR group_id_list LIKE '%," . $grouprec['group_id'] . ",%'"; } // build template $daycount = request_var('daycount', 7); $disp_date_format = $config['rp_date_format']; $disp_date_time_format = $config['rp_date_time_format']; // show all in coming year $start_temp_date = time() - 86400; $sort_timestamp_cutoff = $start_temp_date + 86400 * 365; // get $sql_array = array('SELECT' => ' r.raidplan_id ', 'FROM' => array(RP_RAIDS_TABLE => 'r'), 'WHERE' => ' (r.raidplan_access_level = 2) OR (r.poster_id = ' . $db->sql_escape($user->data['user_id']) . ' ) OR (r.raidplan_access_level = 1 AND (' . $group_options . ') ) AND r.raidplan_start_time >= ' . (int) $start_temp_date . ' AND r.raidplan_start_time <= ' . (int) $sort_timestamp_cutoff, 'ORDER_BY' => 'r.raidplan_start_time ASC '); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query_limit($sql, $config['rp_display_next_raidplans'], 0); while ($row = $db->sql_fetchrow($result)) { unset($raidplan); $raidplan = new Raidplan($Navigation->getGameId(), $Navigation->getGuildId(), $this->eventlist->events, $row['raidplan_id']); if (!isset($this->eventlist->events[$raidplan->getEventType()])) { //this event is closed, so fetch the whole eventlist including closed ones. $this->eventlist = new \bbdkp\controller\raidplanner\rpevents(0); } if (strlen($this->eventlist->events[$raidplan->getEventType()]['imagename']) > 1) { $eventimg = $phpbb_root_path . "images/bbdkp/event_images/" . $this->eventlist->events[$raidplan->getEventType()]['imagename'] . ".png"; } else { $eventimg = $phpbb_root_path . "images/bbdkp/event_images/dummy.png"; } $subj = $raidplan->getSubject(); if ($config['rp_display_truncated_name'] > 0) { if (utf8_strlen($raidplan->getSubject()) > $config['rp_display_truncated_name']) { $subj = truncate_string(utf8_strlen($raidplan->getSubject()), $config['rp_display_truncated_name']) . '…'; } } $delete_url = ""; $edit_url = ""; if ($user->data['is_registered']) { // can user edit ? if ($auth->acl_get('u_raidplanner_edit_raidplans') && ($user->data['user_id'] == $raidplan->getPoster() || $auth->acl_get('m_raidplanner_edit_other_users_raidplans'))) { $edit_url = append_sid("{$phpbb_root_path}dkp.{$phpEx}", "page=planner&view=raidplan&action=showadd&raidplanid=" . $raidplan->id); } //can user delete ? if ($auth->acl_get('u_raidplanner_delete_raidplans') && ($user->data['user_id'] == $raidplan->getPoster() || $auth->acl_get('m_raidplanner_delete_other_users_raidplans'))) { $delete_url = append_sid("{$phpbb_root_path}dkp.{$phpEx}", "page=planner&view=raidplan&action=delete&raidplanid=" . $raidplan->id); } } $template->assign_block_vars('raids', array('RAID_ID' => $raidplan->id, 'IMAGE' => $eventimg, 'EVENTNAME' => $this->eventlist->events[$raidplan->getEventType()]['event_name'], 'EVENT_URL' => append_sid("{$phpbb_root_path}dkp.{$phpEx}", "page=planner&view=raidplan&raidplanid=" . $raidplan->id), 'EVENT_ID' => $raidplan->id, 'COLOR' => $this->eventlist->events[$raidplan->getEventType()]['color'], 'SUBJECT' => $subj, 'U_DELETE' => $delete_url, 'U_EDIT' => $edit_url, 'POSTER' => $raidplan->getPosterUrl(), 'START_TIME' => $user->format_date($raidplan->getStartTime(), $disp_date_time_format, true), 'START_TIME' => $user->format_date($raidplan->getStartTime(), $config['rp_date_format'], true), 'END_TIME' => $user->format_date($raidplan->getEndTime(), $config['rp_time_format'], true), 'DISPLAY_BOLD' => $user->data['user_id'] == $raidplan->getPoster() ? true : false)); // get signups foreach ($raidplan->getRaidroles() as $key => $role) { foreach ($role['role_signups'] as $signup) { if (is_object($signup) && $signup instanceof RaidplanSignup) { switch ($signup->getSignupVal()) { case 0: $signupcolor = '#00FF00'; $signuptext = $user->lang['YES']; break; case 1: $signupcolor = '#FF0000'; $signuptext = $user->lang['NO']; break; case 2: $signupcolor = '#FFCC33'; $signuptext = $user->lang['MAYBE']; break; } $template->assign_block_vars('raids.signups', array('COLOR' => $signupcolor, 'CHARNAME' => $signup->getDkpmembername(), 'COLORCODE' => $signup->getColorcode() == '' ? '#123456' : $signup->getColorcode(), 'CLASS_IMAGE' => strlen($signup->getImagename()) > 1 ? $phpbb_root_path . "images/bbdkp/class_images/" . $signup->getImagename() . ".png" : '', 'S_CLASS_IMAGE_EXISTS' => strlen($signup->getImagename()) > 1 ? true : false, 'VALUE_TXT' => " : " . $signuptext)); } } } } $db->sql_freeresult($result); switch ($mode) { case 'raidplanner_registration': $this->tpl_name = 'planner/ucp_planner'; $template->assign_vars(array('U_COUNT_ACTION' => $this->u_action, 'DAYCOUNT' => $daycount)); break; } }
/** * return raid plan info array to send to template for tooltips in day/week/month/upcoming calendar * * @param int $month this month * @param int $day today * @param int $year this year * @param string $group_options * @param string $mode * @return array */ public function DisplayCalendarRaidTooltip($month, $day, $year, $group_options, $mode) { global $db, $user, $config, $phpbb_root_path, $phpEx; $raidplan_output = array(); $x = 0; $raidplan_counter = 0; // build sql to find raids on this day $day = $day < 10 ? ' ' . $day : $day; $month = $month < 10 ? ' ' . $month : $month; $sql_array = array('SELECT' => 'r.raidplan_id ', 'FROM' => array(RP_RAIDS_TABLE => 'r'), 'WHERE' => "(raidplan_access_level = 2\n\t\t\t\t\t OR (r.poster_id = " . $db->sql_escape($user->data['user_id']) . " )\n\t\t\t\t\t OR (r.raidplan_access_level = 1 AND (" . $group_options . ")) )\n\t\t\t\t\t AND (r.raidplan_day = '" . $db->sql_escape($day . '-' . $month . '-' . $year) . "' ) ", 'ORDER_BY' => 'r.raidplan_start_time ASC'); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query_limit($sql, $x, 0, 86400); // we need to find out the time zone to display on tooltip if ($user->data['user_id'] == ANONYMOUS) { //grab board default $tz = $config['board_timezone']; } else { // get user setting $tz = (int) $user->data['user_timezone']; } $timezone = $user->lang['tz'][$tz]; $rpcounter = 0; $raidplan = new Raidplan($this->game_id, $this->guild_id, $this->eventlist); while ($row = $db->sql_fetchrow($result)) { $raidplan->id = $row['raidplan_id']; $raidplan->Get_Raidplan(); $raidplan->Check_auth(); $fsubj = $subj = censor_text($raidplan->getSubject()); if ($config['rp_display_truncated_name'] > 0) { if (utf8_strlen($subj) > $config['rp_display_truncated_name']) { $subj = truncate_string($subj, $config['rp_display_truncated_name']) . '...'; } } $correct_format = $config['rp_time_format']; if ($raidplan->getEndTime() - $raidplan->getStartTime() > 86400) { $correct_format = $config['rp_date_time_format']; } $pre_padding = 0; $padding = 0; $post_padding = 0; /* if in dayview we need to shift the raid to its time */ if ($mode == "day") { // find padding values $pre_padding = 4 * $user->format_date($raidplan->getStartTime(), "H", true); $padding = 4 * $user->format_date($raidplan->getEndTime(), "H", true) - $pre_padding; $post_padding = 96 - $padding - $pre_padding; } $rolesinfo = array(); $userchars = array(); // only show signup tooltip if user can actually sign up if ($raidplan->getSignupsAllowed() == true && $raidplan->getLocked() == false && $raidplan->getFrozen() == false && $raidplan->getNochar() == false && $raidplan->getSignedUp() == false && $raidplan->getSignedOff() == false && $raidplan->getAccesslevel() != 0 && !$user->data['is_bot'] && $user->data['user_id'] != ANONYMOUS) { foreach ($raidplan->getMychars() as $key => $mychar) { if ($mychar['role_id'] == '') { $userchars[] = array('MEMBER_ID' => $mychar['id'], 'MEMBER_NAME' => $mychar['name']); } } foreach ($raidplan->getRoles() as $key => $role) { $rolesinfo[] = array('ROLE_ID' => $key, 'ROLE_NAME' => $role['role_name']); } } $evtype = $raidplan->getEventType(); if (!isset($this->eventlist[$evtype])) { $this->eventlist = new \bbdkp\controller\raidplanner\rpevents(0); $this->eventlist = $this->eventlist->events; } if (strlen($this->eventlist[$evtype]['imagename']) > 1) { $eventimg = $phpbb_root_path . "images/bbdkp/event_images/" . $this->eventlist[$raidplan->getEventType()]['imagename'] . ".png"; } else { $eventimg = $phpbb_root_path . "images/bbdkp/event_images/dummy.png"; } $signuplist = $raidplan->getSignups(); $raidinfo = array('TZ' => $timezone, 'RAID_ID' => $raidplan->id, 'PRE_PADDING' => $pre_padding, 'POST_PADDING' => $post_padding, 'PADDING' => $padding, 'ETYPE_DISPLAY_NAME' => $this->eventlist[$raidplan->getEventType()]['event_name'], 'FULL_SUBJECT' => $fsubj, 'EVENT_SUBJECT' => $subj, 'COLOR' => $this->eventlist[$raidplan->getEventType()]['color'], 'IMAGE' => $eventimg, 'EVENT_URL' => append_sid("{$phpbb_root_path}dkp.{$phpEx}", "page=planner&view=raidplan&raidplanid=" . $raidplan->id), 'EVENT_ID' => $raidplan->id, 'S_ANON' => $user->data['user_id'] == ANONYMOUS ? true : false, 'S_LOCKED' => $raidplan->getLocked(), 'S_FROZEN' => $raidplan->getFrozen(), 'S_NOCHAR' => $raidplan->getNochar(), 'S_SIGNED_UP' => $raidplan->getSignedUp(), 'S_SIGNED_OFF' => $raidplan->getSignedOff(), 'S_CONFIRMED' => $raidplan->getConfirmed(), 'S_SIGNUPMAYBE' => $raidplan->getSignedUpMaybe(), 'S_CANSIGNUP' => $raidplan->getSignupsAllowed(), 'S_LEGITUSER' => $user->data['is_bot'] || $user->data['user_id'] == ANONYMOUS ? false : true, 'S_SIGNUP_MODE_ACTION' => append_sid("{$phpbb_root_path}dkp.{$phpEx}", "page=planner&view=raidplan&raidplanid=" . $raidplan->id . "&action=signup"), 'INVITE_TIME' => $user->format_date($raidplan->getInviteTime(), $correct_format, true), 'START_TIME' => $user->format_date($raidplan->getStartTime(), $correct_format, true), 'END_TIME' => $user->format_date($raidplan->getEndTime(), $correct_format, true), 'DISPLAY_BOLD' => $user->data['user_id'] == $raidplan->getPoster() ? true : false, 'ALL_DAY' => $raidplan->getAllDay() == 1 ? true : false, 'SHOW_TIME' => $mode == "day" || $mode == "week" ? true : false, 'COUNTER' => $raidplan_counter++, 'RAID_TOTAL' => $raidplan->getRaidTeamNeeded(), 'CURR_CONFIRMED_COUNT' => $signuplist['confirmed'], 'S_CURR_CONFIRMED_COUNT' => $signuplist['confirmed'] > 0 ? true : false, 'CURR_CONFIRMEDPCT' => sprintf("%.0f%%", $raidplan->getRaidTeamNeeded() > 0 ? round($signuplist['confirmed'] / $raidplan->getRaidTeamNeeded(), 2) * 100 : 0), 'CURR_YES_COUNT' => $signuplist['yes'], 'S_CURR_YES_COUNT' => $signuplist['yes'] + $signuplist['maybe'] > 0 ? true : false, 'CURR_YESPCT' => sprintf("%.0f%%", $raidplan->getRaidTeamNeeded() > 0 ? round($signuplist['yes'] / $raidplan->getRaidTeamNeeded(), 2) * 100 : 0), 'CURR_MAYBE_COUNT' => $signuplist['maybe'], 'S_CURR_MAYBE_COUNT' => $signuplist['maybe'] > 0 ? true : false, 'CURR_MAYBEPCT' => sprintf("%.0f%%", $raidplan->getRaidTeamNeeded() > 0 ? round($signuplist['maybe'] / $raidplan->getRaidTeamNeeded(), 2) * 100 : 0), 'CURR_NO_COUNT' => $signuplist['no'], 'S_CURR_NO_COUNT' => $signuplist['no'] > 0 ? true : false, 'CURR_NOPCT' => sprintf("%.0f%%", $raidplan->getRaidTeamNeeded() > 0 ? round($signuplist['no'] / $raidplan->getRaidTeamNeeded(), 2) * 100 : 0), 'CURR_TOTAL_COUNT' => $signuplist['yes'] + $signuplist['maybe']); $rpcounter += 1; $hourslot = $user->format_date($raidplan->getInviteTime(), 'Hi', true); $raidplan_output[$hourslot . '_' . $rpcounter] = array('raidinfo' => $raidinfo, 'userchars' => $userchars, 'raidroles' => $rolesinfo); } $db->sql_freeresult($result); return $raidplan_output; }
function signupmessenger($trigger, Raidplan $raidplan, $eventlist) { global $user, $config; global $phpEx, $phpbb_root_path; include_once $phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx; include_once $phpbb_root_path . 'includes/functions.' . $phpEx; include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx; include_once $phpbb_root_path . 'includes/functions_user.' . $phpEx; // get recipient data (email, etc) if (!class_exists('\\bbdkp\\controller\\raidplanner\\Raidmessenger')) { require "{$phpbb_root_path}includes/bbdkp/controller/raidplanner/raidmessenger.{$phpEx}"; } $rpm = new Raidmessenger(); $rpm->get_notifiable_users($trigger, $this->raidplan_id, $this->signup_id); $emailrecipients = array(); $messenger = new \messenger(); if (!isset($eventlist[$raidplan->getEventType()])) { //this event is closed, so fetch the whole eventlist including closed ones. $eventlist = new \bbdkp\controller\raidplanner\rpevents(0); $eventlist = $eventlist->events; } foreach ($rpm->send_user_data as $id => $row) { $data = array(); // get template switch ($trigger) { case 4: // send signup to RL $messenger->template('signup_new', $row['user_lang']); $subject = '[' . $user->lang['RAIDPLANNER'] . '] ' . $user->lang['NEWSIGN'] . ': ' . $eventlist->events[$raidplan->getEventType()]['event_name'] . ' ' . $user->format_date($raidplan->getStartTime(), $config['rp_date_time_format'], true); $data['address_list'] = array('u' => array($raidplan->getPoster() => 'to')); break; case 5: // send confirmation to RL and raider $messenger->template('signup_confirm', $row['user_lang']); $subject = '[' . $user->lang['RAIDPLANNER'] . '] ' . $user->lang['CONFIRMSIGN'] . ': ' . $eventlist->events[$raidplan->getEventType()]['event_name'] . ' ' . $user->format_date($raidplan->getStartTime(), $config['rp_date_time_format'], true); $data['address_list'] = array('u' => array($row['user_id'] => 'to')); break; case 6: // send cancellation to RL and raider $messenger->template('signup_unsign', $row['user_lang']); $subject = '[' . $user->lang['RAIDPLANNER'] . '] ' . $user->lang['UNSIGNED'] . ': ' . $eventlist->events[$raidplan->getEventType()]['event_name'] . ' ' . $user->format_date($raidplan->getStartTime(), $config['rp_date_time_format'], true); $data['address_list'] = array('u' => array($row['user_id'] => 'to')); break; } $userids = array($raidplan->getPoster()); $rlname = array(); user_get_id_name($userids, $rlname); $messenger->assign_vars(array('RAIDLEADER' => $rlname[$raidplan->getPoster()], 'EVENT_SUBJECT' => $subject, 'SIGNUP_TIME' => $user->format_date($this->signup_time, $config['rp_date_time_format'], true), 'USERNAME' => htmlspecialchars_decode($user->data['username']), 'RAIDER' => $this->dkpmembername, 'EVENT' => $eventlist->events[$raidplan->getEventType()]['event_name'], 'ROLE' => $this->role_name, 'INVITE_TIME' => $user->format_date($raidplan->getInviteTime(), $config['rp_date_time_format'], true), 'START_TIME' => $user->format_date($raidplan->getStartTime(), $config['rp_date_time_format'], true), 'END_TIME' => $user->format_date($raidplan->getEndTime(), $config['rp_date_time_format'], true), 'TZ' => $user->lang['tz'][(int) $user->data['user_timezone']], 'U_RAIDPLAN' => generate_board_url() . "/dkp.{$phpEx}?page=planner&view=raidplan&raidplanid=" . $raidplan->id)); $messenger->msg = trim($messenger->tpl_obj->assign_display('body')); $messenger->msg = str_replace("\r\n", "\n", $messenger->msg); $messenger->msg = utf8_normalize_nfc($messenger->msg); $uid = $bitfield = $options = ''; // will be modified by generate_text_for_storage $allow_bbcode = $allow_smilies = $allow_urls = true; generate_text_for_storage($messenger->msg, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies); $messenger->msg = generate_text_for_display($messenger->msg, $uid, $bitfield, $options); $data['from_user_id'] = $user->data['user_id']; $data['from_username'] = $user->data['username']; $data['icon_id'] = 0; $data['from_user_ip'] = $user->data['user_ip']; $data['enable_bbcode'] = true; $data['enable_smilies'] = true; $data['enable_urls'] = true; $data['enable_sig'] = true; $data['message'] = $messenger->msg; $data['bbcode_bitfield'] = $this->bbcode['bitfield']; $data['bbcode_uid'] = $this->bbcode['uid']; if ($config['rp_pm_signup'] == 1 && (int) $row['user_allow_pm'] == 1) { // send a PM submit_pm('post', $subject, $data, false); } if ($config['rp_email_signup'] == 1 && $row['user_email'] != '') { //send email, reuse messenger object $email = $messenger; $emailrecipients[] = $row['username']; $email->to($row['user_email'], $row['username']); $email->anti_abuse_headers($config, $user); $email->send(0); } } if ($config['rp_email_signup'] == 1 && isset($email)) { $email->save_queue(); $emailrecipients = implode(', ', $emailrecipients); add_log('admin', 'LOG_MASS_EMAIL', $emailrecipients); } }