@PostMapping(value = "/delete/calendar") public static String deleteCalendar(HttpServletRequest request, HttpServletResponse response, @RequestParam Map<String, String> queryParams) { try { //TODO: Handle multiple calendars... //String calId = request.queryParams("calendar-id"); Map m = DiscordAccountHandler.getHandler().getAccount(request); WebGuild g = (WebGuild) m.get("selected"); if (g.isManageServer()) { CalendarData data = DatabaseManager.getManager().getMainCalendar(Long.valueOf(g.getId())); GuildSettings settings = DatabaseManager.getManager().getSettings(Long.valueOf(g.getId())); CalendarUtils.deleteCalendar(data, settings); g.setCalendar(new WebCalendar().fromCalendar(DatabaseManager.getManager().getMainCalendar(Long.valueOf(g.getId())), DatabaseManager.getManager().getSettings(Long.valueOf(g.getId())))); response.sendRedirect("/dashboard/guild/calendar"); return "redirect:/dashboard/guild/calendar"; } else { response.sendRedirect("/dashboard/guild/calendar"); return "redirect:/dashboard/guild/calendar"; } } catch (Exception e) { Logger.getLogger().exception(null, "[WEB] Failed to delete/remove calendar!", e, DashboardHandler.class); response.setContentType("application/json"); response.setStatus(500); return ResponseUtils.getJsonResponseMessage("Internal Server Error"); } }
calendar = new WebCalendar().fromJson(data.getJSONObject("Calendar"));
Calendar cal = CalendarAuth.getCalendarService(g.getSettings()).calendars().get(g.getCalendar().getId()).execute(); cal.setSummary(queryParams.get("cal-name")); CalendarAuth.getCalendarService(g.getSettings()).calendars().update(g.getCalendar().getId(), cal).execute(); g.getCalendar().setName(queryParams.get("cal-name")); } catch (Exception e) { Logger.getLogger().exception(null, "[WEB] Failed to update calendar name", e, DashboardHandler.class); Calendar cal = CalendarAuth.getCalendarService(g.getSettings()).calendars().get(g.getCalendar().getId()).execute(); cal.setDescription(queryParams.get("cal-desc")); CalendarAuth.getCalendarService(g.getSettings()).calendars().update(g.getCalendar().getId(), cal).execute(); g.getCalendar().setDescription(queryParams.get("cal-desc")); } catch (Exception e) { Logger.getLogger().exception(null, "[WEB] Failed to update calendar description", e, DashboardHandler.class); Calendar cal = CalendarAuth.getCalendarService(g.getSettings()).calendars().get(g.getCalendar().getId()).execute(); cal.setTimeZone(queryParams.get("cal-tz").replace("___", "/")); CalendarAuth.getCalendarService(g.getSettings()).calendars().update(g.getCalendar().getId(), cal).execute(); g.getCalendar().setTimezone(queryParams.get("cal-tz")); } catch (Exception e) { Logger.getLogger().exception(null, "[WEB] Failed to update calendar timezone", e, DashboardHandler.class);
Calendar cal = CalendarAuth.getCalendarService(g.getSettings()).calendars().get(g.getCalendar().getId()).execute(); cal.setSummary(queryParams.get("cal-name")); CalendarAuth.getCalendarService(g.getSettings()).calendars().update(g.getCalendar().getId(), cal).execute(); g.getCalendar().setName(queryParams.get("cal-name")); } catch (Exception e) { Logger.getLogger().exception(null, "[WEB] Failed to update calendar name", e, DashboardHandler.class); Calendar cal = CalendarAuth.getCalendarService(g.getSettings()).calendars().get(g.getCalendar().getId()).execute(); cal.setDescription(queryParams.get("cal-desc")); CalendarAuth.getCalendarService(g.getSettings()).calendars().update(g.getCalendar().getId(), cal).execute(); g.getCalendar().setDescription(queryParams.get("cal-desc")); } catch (Exception e) { Logger.getLogger().exception(null, "[WEB] Failed to update calendar description", e, DashboardHandler.class); Calendar cal = CalendarAuth.getCalendarService(g.getSettings()).calendars().get(g.getCalendar().getId()).execute(); cal.setTimeZone(queryParams.get("cal-tz").replace("___", "/")); CalendarAuth.getCalendarService(g.getSettings()).calendars().update(g.getCalendar().getId(), cal).execute(); g.getCalendar().setTimezone(queryParams.get("cal-tz")); } catch (Exception e) { Logger.getLogger().exception(null, "[WEB] Failed to update calendar timezone", e, DashboardHandler.class);
@PostMapping(value = "/delete/calendar") public static String deleteCalendar(HttpServletRequest request, HttpServletResponse response, @RequestParam Map<String, String> queryParams) { try { //TODO: Handle multiple calendars... //String calId = request.queryParams("calendar-id"); Map m = DiscordAccountHandler.getHandler().getAccount(request); WebGuild g = (WebGuild) m.get("selected"); if (g.isManageServer()) { CalendarData data = DatabaseManager.getManager().getMainCalendar(Long.valueOf(g.getId())); GuildSettings settings = DatabaseManager.getManager().getSettings(Long.valueOf(g.getId())); CalendarUtils.deleteCalendar(data, settings); g.setCalendar(new WebCalendar().fromCalendar(DatabaseManager.getManager().getMainCalendar(Long.valueOf(g.getId())), DatabaseManager.getManager().getSettings(Long.valueOf(g.getId())))); response.sendRedirect("/dashboard/guild/calendar"); return "redirect:/dashboard/guild/calendar"; } else { response.sendRedirect("/dashboard/guild/calendar"); return "redirect:/dashboard/guild/calendar"; } } catch (Exception e) { Logger.getLogger().exception(null, "[WEB] Failed to delete/remove calendar!", e, DashboardHandler.class); response.setContentType("application/json"); response.setStatus(500); return ResponseUtils.getJsonResponseMessage("Internal Server Error"); } }
Calendar cal = CalendarAuth.getCalendarService(g.getSettings()).calendars().get(g.getCalendar().getId()).execute(); cal.setSummary(queryParams.get("cal-name")); CalendarAuth.getCalendarService(g.getSettings()).calendars().update(g.getCalendar().getId(), cal).execute(); g.getCalendar().setName(queryParams.get("cal-name")); } catch (Exception e) { Logger.getLogger().exception(null, "[WEB] Failed to update calendar name", e, DashboardHandler.class); Calendar cal = CalendarAuth.getCalendarService(g.getSettings()).calendars().get(g.getCalendar().getId()).execute(); cal.setDescription(queryParams.get("cal-desc")); CalendarAuth.getCalendarService(g.getSettings()).calendars().update(g.getCalendar().getId(), cal).execute(); g.getCalendar().setDescription(queryParams.get("cal-desc")); } catch (Exception e) { Logger.getLogger().exception(null, "[WEB] Failed to update calendar description", e, DashboardHandler.class); Calendar cal = CalendarAuth.getCalendarService(g.getSettings()).calendars().get(g.getCalendar().getId()).execute(); cal.setTimeZone(queryParams.get("cal-tz").replace("___", "/")); CalendarAuth.getCalendarService(g.getSettings()).calendars().update(g.getCalendar().getId(), cal).execute(); g.getCalendar().setTimezone(queryParams.get("cal-tz")); } catch (Exception e) { Logger.getLogger().exception(null, "[WEB] Failed to update calendar timezone", e, DashboardHandler.class);
@PostMapping(value = "/delete/calendar") public static String deleteCalendar(HttpServletRequest request, HttpServletResponse response, @RequestParam Map<String, String> queryParams) { try { //TODO: Handle multiple calendars... //String calId = request.queryParams("calendar-id"); Map m = DiscordAccountHandler.getHandler().getAccount(request); WebGuild g = (WebGuild) m.get("selected"); if (g.isManageServer()) { CalendarData data = DatabaseManager.getManager().getMainCalendar(Long.valueOf(g.getId())); GuildSettings settings = DatabaseManager.getManager().getSettings(Long.valueOf(g.getId())); CalendarUtils.deleteCalendar(data, settings); g.setCalendar(new WebCalendar().fromCalendar(DatabaseManager.getManager().getMainCalendar(Long.valueOf(g.getId())), DatabaseManager.getManager().getSettings(Long.valueOf(g.getId())))); response.sendRedirect("/dashboard/guild/calendar"); return "redirect:/dashboard/guild/calendar"; } else { response.sendRedirect("/dashboard/guild/calendar"); return "redirect:/dashboard/guild/calendar"; } } catch (Exception e) { Logger.getLogger().exception(null, "[WEB] Failed to delete/remove calendar!", e, DashboardHandler.class); response.setContentType("application/json"); response.setStatus(500); return ResponseUtils.getJsonResponseMessage("Internal Server Error"); } }
public WebGuild fromGuild(IGuild g) { id = g.getStringID(); name = g.getName(); iconUrl = g.getIconURL(); botNick = g.getClient().getOurUser().getNicknameForGuild(g); settings = DatabaseManager.getManager().getSettings(g.getLongID()); //Handle lists and stuffs for (IRole r : g.getRoles()) { roles.add(new WebRole().fromRole(r, settings)); } WebChannel all = new WebChannel(); all.setId(0); all.setName("All Channels"); all.setDiscalChannel(settings.getDiscalChannel().equalsIgnoreCase("all")); channels.add(all); for (IChannel c : g.getChannels()) { channels.add(new WebChannel().fromChannel(c, settings)); } announcements.addAll(DatabaseManager.getManager().getAnnouncements(g.getLongID())); calendar = new WebCalendar().fromCalendar(DatabaseManager.getManager().getMainCalendar(Long.valueOf(id)), settings); return this; }
g.setCalendar(new WebCalendar().fromCalendar(calendarData, g.getSettings())); } catch (Exception ex) { Logger.getLogger().exception(null, "[WEB] Failed to confirm calendar.", ex, DashboardHandler.class);
g.setCalendar(new WebCalendar().fromCalendar(calendarData, g.getSettings())); } catch (Exception ex) { Logger.getLogger().exception(null, "[WEB] Failed to confirm calendar.", ex, DashboardHandler.class);
g.setCalendar(new WebCalendar().fromCalendar(calendarData, g.getSettings())); } catch (Exception ex) { Logger.getLogger().exception(null, "[WEB] Failed to confirm calendar.", ex, DashboardHandler.class);