function __construct(\bbdkp\views\viewPlanner $viewPlanner) { $this->viewPlanner = $viewPlanner; parent::__construct($viewPlanner, $viewPlanner->view_mode); }
/** * display raidplan add/edit form * * @param Raidplan $raidplan * @param RaidCalendar $cal */ public function showadd(Raidplan $raidplan, RaidCalendar $cal) { global $db, $auth, $user, $config, $template, $phpEx, $phpbb_root_path; include $phpbb_root_path . 'includes/functions_display.' . $phpEx; $s_action = append_sid("{$phpbb_root_path}dkp.{$phpEx}", "page=planner&view=raidplan&raidplanid=" . $raidplan->getId()); /* * fill template * */ $user->setup('posting'); $user->add_lang(array('posting', 'mods/dkp_common', 'mods/raidplanner')); if ($raidplan->getId() > 0) { $page_title = $user->lang['CALENDAR_EDIT_RAIDPLAN']; } else { $page_title = $user->lang['CALENDAR_POST_RAIDPLAN']; } //count events from bbDKP, put them in a pulldown... foreach ($this->eventlist as $eventid => $event) { $selected = ''; if ($raidplan->id == 0) { $selected = ''; } else { if ($raidplan->getEventType() == $eventid) { $selected = ' selected="selected" '; } } $template->assign_block_vars('bbdkp_events_options', array('KEY' => $eventid, 'VALUE' => $event['event_name'], 'SELECTED' => $selected)); } // populate raidplan acces level pulldowns $level_sel = array(); if ($auth->acl_get('u_raidplanner_create_public_raidplans')) { $level_sel[2] = $user->lang['EVENT_ACCESS_LEVEL_PUBLIC']; } if ($auth->acl_get('u_raidplanner_create_group_raidplans')) { $level_sel[1] = $user->lang['EVENT_ACCESS_LEVEL_GROUP']; } if ($auth->acl_get('u_raidplanner_create_private_raidplans')) { $level_sel[0] = $user->lang['EVENT_ACCESS_LEVEL_PERSONAL']; } foreach ($level_sel as $key => $value) { $template->assign_block_vars('accesslevel_options', array('KEY' => $key, 'VALUE' => $value, 'SELECTED' => $raidplan->getAccesslevel() == $key ? ' selected="selected"' : '')); } // Find what groups this user is a member of and add them to the list of groups to invite $disp_hidden_groups = $config['rp_display_hidden_groups']; if ($auth->acl_get('u_raidplanner_nonmember_groups')) { if ($disp_hidden_groups == 1) { $sql = 'SELECT g.group_id, g.group_name, g.group_type FROM ' . GROUPS_TABLE . ' g ORDER BY g.group_type, g.group_name'; } else { $sql = 'SELECT g.group_id, g.group_name, g.group_type FROM ' . GROUPS_TABLE . ' g ' . (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') ? ' WHERE g.group_type <> ' . GROUP_HIDDEN : '') . ' ORDER BY g.group_type, g.group_name'; } } else { if ($disp_hidden_groups == 1) { $sql = 'SELECT g.group_id, g.group_name, g.group_type FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug\n\t\t\t\t\t\tWHERE ug.user_id = " . $db->sql_escape($user->data['user_id']) . ' AND g.group_id = ug.group_id AND ug.user_pending = 0 ORDER BY g.group_type, g.group_name'; } else { $sql = 'SELECT g.group_id, g.group_name, g.group_type FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . " ug\n\t\t\t\t\t\tWHERE ug.user_id = " . $db->sql_escape($user->data['user_id']) . "\n\t\t\t\t\t\t\tAND g.group_id = ug.group_id" . (!$auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel') ? ' AND g.group_type <> ' . GROUP_HIDDEN : '') . ' AND ug.user_pending = 0 ORDER BY g.group_type, g.group_name'; } } $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('group_sel_options', array('KEY' => $row['group_id'], 'VALUE' => $row['group_type'] == GROUP_SPECIAL ? $user->lang['G_' . $row['group_name']] : $row['group_name'], 'SELECTED' => '')); } $db->sql_freeresult($result); /** * populate day pulldown */ if ($raidplan->getId() > 0) { $day = $user->format_date($raidplan->getStartTime(), 'd', true); $month = $user->format_date($raidplan->getStartTime(), 'm', true); $year = $user->format_date($raidplan->getStartTime(), 'Y', true); } else { $day = $cal->date['day']; $month = $cal->date['month_no']; $year = $cal->date['year']; } //day dropdown for ($i = 1; $i <= $cal->days_in_month; $i++) { $template->assign_block_vars('enddayoptions', array('KEY' => $i, 'VALUE' => $i, 'SELECTED' => (int) $day == $i ? ' selected="selected"' : '')); } // month dropdown for ($i = 1; $i <= 12; $i++) { $template->assign_block_vars('endmonthoptions', array('KEY' => $i, 'VALUE' => $user->lang['datetime'][$cal->month_names[$i]], 'SELECTED' => $month == $i ? ' selected="selected"' : '')); } //year dropdown $temp_year = gmdate('Y'); for ($i = $temp_year - 1; $i < $temp_year + 5; $i++) { $template->assign_block_vars('endyearoptions', array('KEY' => $i, 'VALUE' => $i, 'SELECTED' => (int) $year == $i ? ' selected="selected"' : '')); } /** * populate Raid invite time select */ $hour_mode = $config['rp_hour_mode']; $presetinvhour = intval(($raidplan->getInviteTime() > 0 ? $user->format_date($raidplan->getInviteTime(), 'G', true) * 60 : $config['rp_default_invite_time']) / 60); for ($i = 0; $i < 24; $i++) { $mod_12 = $i % 12; if ($mod_12 == 0) { $mod_12 = 12; } $am_pm = $user->lang['PM']; if ($i < 12) { $am_pm = $user->lang['AM']; } $template->assign_block_vars('invhouroptions', array('KEY' => $i, 'VALUE' => $hour_mode == 12 ? $mod_12 . ' ' . $am_pm : $i, 'SELECTED' => $i == $presetinvhour ? ' selected="selected"' : '')); } /** * populate Raid invite minute */ if ($raidplan->getInviteTime() > 0) { $presetinvmin = $user->format_date($raidplan->getInviteTime(), 'i', true); } else { $presetinvmin = (int) $config['rp_default_invite_time'] - $presetinvhour * 60; } for ($i = 0; $i <= 59; $i++) { $template->assign_block_vars('invminoptions', array('KEY' => $i, 'VALUE' => $i, 'SELECTED' => $i == $presetinvmin ? ' selected="selected"' : '')); } /** * populate Raid start hour pulldown */ $hour_start_selcode = ""; $presetstarthour = intval(($raidplan->getStartTime() > 0 ? $user->format_date($raidplan->getStartTime(), 'G', true) * 60 : $config['rp_default_start_time']) / 60); for ($i = 0; $i < 24; $i++) { $mod_12 = $i % 12; if ($mod_12 == 0) { $mod_12 = 12; } $am_pm = $user->lang['PM']; if ($i < 12) { $am_pm = $user->lang['AM']; } $template->assign_block_vars('starthouroptions', array('KEY' => $i, 'VALUE' => $hour_mode == 12 ? $mod_12 . ' ' . $am_pm : $i, 'SELECTED' => $i == $presetstarthour ? ' selected="selected"' : '')); } /** * populate Raid start minute pulldown */ if ($raidplan->id > 0) { $presetstartmin = $user->format_date($raidplan->getStartTime(), 'i', true); } else { $presetstartmin = (int) $config['rp_default_start_time'] - $presetstarthour * 60; } for ($i = 0; $i <= 59; $i++) { $template->assign_block_vars('startminoptions', array('KEY' => $i, 'VALUE' => $i, 'SELECTED' => $i == $presetstartmin ? ' selected="selected"' : '')); } /** * populate Raid END time pulldown */ $presetendhour = intval(($raidplan->getEndTime() > 0 ? $user->format_date($raidplan->getEndTime(), 'G', true) * 60 : $config['rp_default_end_time']) / 60); for ($i = 0; $i < 24; $i++) { $mod_12 = $i % 12; if ($mod_12 == 0) { $mod_12 = 12; } $am_pm = $user->lang['PM']; if ($i < 12) { $am_pm = $user->lang['AM']; } $template->assign_block_vars('endhouroptions', array('KEY' => $i, 'VALUE' => $hour_mode == 12 ? $mod_12 . ' ' . $am_pm : $i, 'SELECTED' => $i == $presetendhour ? ' selected="selected"' : '')); } /** * populate Raid end minute pulldown */ if ($raidplan->getEndTime() > 0) { $presetendmin = $user->format_date($raidplan->getEndTime(), 'i', true); } else { $presetendmin = (int) $config['rp_default_end_time'] - $presetendhour * 60; } for ($i = 0; $i <= 59; $i++) { $template->assign_block_vars('endminuteoptions', array('KEY' => $i, 'VALUE' => $i, 'SELECTED' => $i == $presetendmin ? ' selected="selected"' : '')); } // get team array $sql = 'SELECT * FROM ' . RP_TEAMS . ' ORDER BY teams_id'; $db->sql_query($sql); $team_id = 0; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $team_id = $row['teams_id']; $template->assign_block_vars('team_row', array('VALUE' => $row['teams_id'], 'SELECTED' => ' selected="selected"', 'OPTION' => $row['team_name'] . ': ' . $row['team_size'])); } $db->sql_freeresult($result); if ($team_id == 0) { trigger_error('NOTEAMSDEFINED'); } /* * make raid composition proposal */ if ($raidplan->getId() == 0 && $team_id > 0) { // make roles proposal $sql = 'SELECT t.game_id, t.role_id, t.role_needed, t.teams_id, r.role_color, r.role_icon, l.name as role_description FROM ' . RP_TEAMSIZE . ' t INNER JOIN ' . BB_GAMEROLE_TABLE . ' r ON r.role_id=t.role_id INNER JOIN ' . RP_TEAMS . ' e ON e.teams_id = t.teams_id INNER JOIN ' . BB_LANGUAGE . ' l ON l.game_id=t.game_id AND r.role_id = l.attribute_id WHERE t.teams_id = ' . $team_id . " AND l.attribute='role' AND l.language='" . $config['bbdkp_lang'] . "'"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('teamsize', array('ROLE_COLOR' => $row['role_color'], 'S_ROLE_ICON_EXISTS' => strlen($row['role_icon']) > 1 ? true : false, 'ROLE_ICON' => strlen($row['role_icon']) > 1 ? $phpbb_root_path . "images/bbdkp/role_icons/" . $row['role_icon'] . ".png" : '', 'ROLE_ID' => $row['role_id'], 'ROLE_NAME' => $row['role_description'], 'ROLE_NEEDED' => $row['role_needed'])); } $db->sql_freeresult($result); } else { //repopulate dropdown from object $sql = 'SELECT * FROM ' . RP_TEAMS . ' ORDER BY teams_id'; $db->sql_query($sql); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $template->assign_block_vars('team_row', array('VALUE' => $row['teams_id'], 'SELECTED' => $row['teams_id'] == $raidplan->getRaidteam() ? ' selected="selected"' : '', 'OPTION' => $row['team_name'] . ': ' . $row['team_size'])); } $db->sql_freeresult($result); unset($row); // get roles from object foreach ($raidplan->getRaidroles() as $key => $role) { $template->assign_block_vars('teamsize', array('ROLE_COLOR' => $role['role_color'], 'S_ROLE_ICON_EXISTS' => strlen($role['role_icon']) > 1 ? true : false, 'ROLE_ICON' => strlen($role['role_icon']) > 1 ? $phpbb_root_path . "images/bbdkp/role_icons/" . $role['role_icon'] . ".png" : '', 'ROLE_ID' => $key, 'ROLE_NAME' => $role['role_name'], 'ROLE_NEEDED' => $role['role_needed'])); } } $body = $raidplan->getBody(); $bbcode = $raidplan->getBbcode(); $message = generate_text_for_edit($body, isset($bbcode['uid']) ? $bbcode['uid'] : '', isset($bbcode['bitfield']) ? $bbcode['bitfield'] : '', 7); // HTML, BBCode, Smilies, Images and Flash status $bbcode_status = $config['allow_bbcode'] ? true : false; $img_status = $bbcode_status ? true : false; $flash_status = $bbcode_status && $config['allow_post_flash'] ? true : false; $url_status = $config['allow_post_links'] ? true : false; $smilies_status = $bbcode_status && $config['allow_smilies'] ? true : false; if ($smilies_status) { // Generate smiley listing $cal->generate_calendar_smilies('inline'); } $start_date = gmmktime(0, 0, 0, $month, $day, $year) - $user->timezone - $user->dst; $ajaxpath = append_sid($phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template/planner/raidplan/ajax1.' . $phpEx, "ajax=1"); if ($raidplan->id > 0) { $eventname = $this->eventlist[$raidplan->getEventType()]['event_name']; $eventcolor = $this->eventlist[$raidplan->getEventType()]['color']; 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"; } } else { $eventimg = $phpbb_root_path . "images/bbdkp/event_images/dummy.png"; $eventcolor = ''; $eventname = $user->lang['NEW_RAID']; } $template->assign_vars(array('ETYPE_DISPLAY_NAME' => $eventname, 'EVENT_COLOR' => $eventcolor, 'EVENT_IMAGE' => $eventimg, 'S_POST_ACTION' => $s_action, 'RAIDPLAN_ID' => $raidplan->id, 'S_PLANNER_EDIT' => $raidplan->id > 0 ? true : false, 'S_PLANNER_ADD' => $raidplan->getId() > 0 ? false : true, 'S_DELETE_ALLOWED' => $raidplan->getAuthCandelete(), 'S_BBCODE_ALLOWED' => $bbcode_status, 'S_SMILIES_ALLOWED' => $smilies_status, 'S_LINKS_ALLOWED' => $url_status, 'S_BBCODE_IMG' => $img_status, 'S_BBCODE_URL' => $url_status, 'S_BBCODE_FLASH' => $flash_status, 'S_BBCODE_QUOTE' => false, 'TEAM_ID' => $raidplan->getRaidteam(), 'TEAM_NAME' => $raidplan->getRaidteamname(), 'TEAM_SIZE' => $raidplan->getRaidTeamNeeded(), 'L_POST_A' => $page_title, 'SUBJECT' => $raidplan->getSubject(), 'MESSAGE' => $message['text'], 'START_DATE' => $user->format_date($start_date, $config['rp_date_format'], true), 'START_HOUR_SEL' => $hour_start_selcode, 'BBCODE_STATUS' => $bbcode_status ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . append_sid("{$phpbb_root_path}faq.{$phpEx}", 'mode=bbcode') . '">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . append_sid("{$phpbb_root_path}faq.{$phpEx}", 'mode=bbcode') . '">', '</a>'), 'IMG_STATUS' => $img_status ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => $flash_status ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], 'SMILIES_STATUS' => $smilies_status ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], 'URL_STATUS' => $bbcode_status && $url_status ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], 'LA_ALERT_OLDBROWSER' => $user->lang['ALERT_OLDBROWSER'], 'UA_AJAXHANDLER1' => $ajaxpath)); // Build custom bbcodes array display_custom_bbcodes(); }