/** * 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; }