/** * 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; } }
/** * collect data from POST after submit or update in showadd * * @param $raidplan */ public function SetRaidplan(Raidplan $raidplan, $action) { global $user, $template; $error = array(); // read subjectline $raidplan->setSubject(utf8_normalize_nfc(request_var('subject', '', true))); //read comment section $body = utf8_normalize_nfc(request_var('message', '', true)); $bitfield = $uid = $options = ''; $allow_bbcode = $allow_urls = $allow_smilies = true; generate_text_for_storage($body, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies); $raidplan->setBbcode(array('uid' => $uid, 'bitfield' => $bitfield)); $raidplan->setBody($body); $raidplan->setPoster($user->data['user_id']); // set access level $raidplan->setAccesslevel(request_var('accesslevel', 0)); // set member group id $raidplan->setGroupId(0); $raidplan->setGroupIdList(','); $group_id_array = request_var('calGroupId', array(0)); $num_group_ids = sizeof($group_id_array); if ($num_group_ids == 1) { // if only one group pass the groupid $raidplan->setGroupId($group_id_array[0]); } elseif ($num_group_ids > 1) { // if we want multiple groups then pass the array for ($group_index = 0; $group_index < $num_group_ids; $group_index++) { if ($group_id_array[$group_index] == "") { continue; } $raidplan->setGroupIdList($group_id_array[$group_index] . ","); } } //assign raid team switch ($raidplan->getAccesslevel()) { case 0: //non raid, manual event. $raidplan->setSignupsAllowed(0); $raidplan->setRaidteam(0); break; case 1: // if we selected group access but didn't actually choose a group then throw error if ($num_group_ids < 1) { $error[] = $user->lang['NO_GROUP_SELECTED']; } //no break! //no break! case 2: //everyone invited $raidplan->setRaidteam(request_var('teamselect', request_var('team_id', 0))); $raidplan->setSignupsAllowed(1); $raidplan->init_raidplan_roles(); $raidroles = request_var('role_needed', array(0 => 0)); foreach ($raidroles as $role_id => $needed) { $raidplan->setRaidroles($role_id, (int) $needed); } } //set event type $raidplan->setEventType(request_var('bbdkp_events', 0)); // invite/start date values from pulldown click $end_m = request_var('calMEnd', 0); $end_d = request_var('calDEnd', 0); $end_y = request_var('calYEnd', 0); $inv_hr = request_var('calinvHr', 0); $inv_mn = request_var('calinvMn', 0); $raidplan->setInviteTime(gmmktime($inv_hr, $inv_mn, 0, $end_m, $end_d, $end_y) - $user->timezone - $user->dst); $start_hr = request_var('calHr', 0); $start_mn = request_var('calMn', 0); $raidplan->setStartTime(gmmktime($start_hr, $start_mn, 0, $end_m, $end_d, $end_y) - $user->timezone - $user->dst); $end_hr = request_var('calEndHr', 0); $end_mn = request_var('calEndMn', 0); $raidplan->setEndTime(gmmktime($end_hr, $end_mn, 0, $end_m, $end_d, $end_y) - $user->timezone - $user->dst); if ($raidplan->getEndTime() < $raidplan->getStartTime()) { //check for enddate before begindate // if the end hour is earlier than start hour then roll over a day $temp = $raidplan->getEndTime(); $raidplan->setEndTime($temp += 3600 * 24); } //if this is not an "all day event" $raidplan->setAllDay(0); $raidplan->setday(sprintf('%2d-%2d-%4d', $end_d, $end_m, $end_y)); $raidplan->Check_auth(); if (count($error) > 0) { trigger_error(implode($error, "<br /> "), E_USER_WARNING); } $str = serialize($raidplan); $str1 = base64_encode($str); switch ($action) { case 'addraid': if (!$raidplan->getAuthCanadd()) { trigger_error('USER_CANNOT_POST_RAIDPLAN'); } $s_hidden_fields = build_hidden_fields(array('addraid' => true, 'raidobject' => $str1)); $template->assign_vars(array('S_HIDDEN_FIELDS' => $s_hidden_fields)); confirm_box(false, $user->lang['CONFIRM_ADDRAID'], $s_hidden_fields); break; case 'updateraid': if (!$raidplan->getAuthCanedit()) { trigger_error('USER_CANNOT_EDIT_RAIDPLAN'); } $s_hidden_fields = build_hidden_fields(array('updateraid' => true, 'raidobject' => $str1, 'raidplan_id' => $raidplan->getId())); $template->assign_vars(array('S_HIDDEN_FIELDS' => $s_hidden_fields)); confirm_box(false, $user->lang['CONFIRM_UPDATERAID'], $s_hidden_fields); break; } }
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); } }