1 25 26 package net.killingar.forum.actions; 27 28 import net.killingar.forum.internal.Comic; 29 import net.killingar.forum.internal.Event; 30 import net.killingar.forum.internal.User; 31 import net.killingar.forum.internal.managers.*; 32 33 import java.util.Date ; 34 35 public class ViewContents 36 extends net.killingar.forum.actions.hotlist.ActionHotlistSupport 37 { 38 TodoManager todoMgr; 40 Timekeeper timekeeper; 41 PlanningManager planningMgr; 42 PollManager pollMgr; 43 TaskManager taskMgr; 44 45 47 49 public boolean getHasUrgentTodos() throws Exception {return todoMgr.hasUrgentStuffTodo(manager.getUserID());} 51 public boolean getTimeKeeperRunning() throws Exception {return timekeeper.hasStartedTimes();} 52 public boolean getPlanningUnread() throws Exception {return planningMgr.isUnreadPlanning();} 53 public long getPlanningTime() throws Exception {return planningMgr.getTimeOnPlanning().getTime();} 54 public boolean getTasksUnread() throws Exception {return taskMgr.isUnread();} 55 public long getTasksTime() throws Exception {return taskMgr.getTime().getTime();} 56 public long getWikiTime() throws Exception {return timemgr.getUserTime(TimeManager.systemWiki).getTime();} 57 public boolean getPollsUnread() throws Exception {return pollMgr.isUnread();} 58 59 public boolean getWikiUnread() throws Exception 60 { 61 return timemgr.getUserTime(TimeManager.systemWiki).before(timemgr.getSystemTime(TimeManager.systemWiki)); 63 80 } 81 82 public boolean getNewStrips() throws Exception 83 { 84 boolean newStrips = false; 85 86 ItemListManager itemLists = (ItemListManager)manager.getManager(ItemListManager.class.getName()); 87 88 ComicManager cmgr = (ComicManager)manager.getManager(ComicManager.class.getName()); 89 String comicHotlist[] = itemLists.getList("comics hotlist"); 90 for (int i = 0; i < comicHotlist.length; i++) 91 { 92 Comic c = cmgr.getComic(Long.parseLong(comicHotlist[i])); 93 if (c != null) 94 { 95 long pos = cmgr.getPosition(manager.getUserID(), c.ID); 96 if (pos < c.latestID) 97 { 98 newStrips = true; 99 break; 100 } 101 } 102 } 103 104 return newStrips; 105 } 106 107 public String getPlanningWarning() throws Exception 108 { 109 String warning = ""; 110 Event[] events = planningMgr.getEvents(); 111 Date now = new Date (); 112 for (int i = 0; i != events.length; i++) 113 { 114 if (planningMgr.getEventData(events[i].ID, manager.getUserID()).data != 2) 116 { 117 long diffDays = (events[i].time.getTime()-now.getTime())/86400000L; 118 if (diffDays >= 0) 119 { 120 if (diffDays == 0) 121 warning = "notice "; 122 else if (diffDays < 7) 123 warning = "notice2 "; 124 } 125 warning+=diffDays; 126 warning+=" "; 127 warning+=events[i].name; 128 warning+=" "; 129 } 130 } 131 return warning; 132 } 133 134 public String getBirthdaysWarning() 135 { 136 Date now = new Date (); 137 String birthdaysWarning = "standard"; 138 139 try 140 { 141 User users[] = manager.getCommonGroupUsers(manager.getUserID()); 142 long days = 365, diff; 143 String test = null; 144 for (int i = 0; i < users.length; i++) 145 { 146 if (users[i].birthdate != null && users[i].getId() != manager.getUserID()) 147 { 148 diff = (new Date (now.getYear(), users[i].birthdate.getMonth(), users[i].birthdate.getDate()).getTime()-now.getTime())/86400000; int year = now.getYear()-users[i].birthdate.getYear(); 150 151 long userdays = diff; if (userdays < -5) 153 { 154 userdays += 365; 155 year++; 156 if (year%4 == 0 && year%400 != 0) 157 userdays++; 158 } 159 160 if (userdays < days) 161 days = userdays; 162 } 163 } 164 165 if (days == 0) 166 birthdaysWarning = "notice"; 167 else if (days < 7 && days > 0) 168 birthdaysWarning = "notice2"; 169 } 170 catch (Exception e) 171 { 172 addErrorMessage("getting contents failed, exception thrown ("+e.toString()+")"); 173 e.printStackTrace(); 174 return ""; 175 } 176 177 return birthdaysWarning; 178 } 179 180 protected String doExecute() 182 { 183 try 185 { 186 todoMgr = (TodoManager)manager.getManager(TodoManager.class.getName()); 188 timekeeper = (Timekeeper)manager.getManager(Timekeeper.class.getName()); 189 planningMgr = (PlanningManager)manager.getManager(PlanningManager.class.getName()); 190 pollMgr = (PollManager)manager.getManager(PollManager.class.getName()); 191 taskMgr = (TaskManager)manager.getManager(TaskManager.class.getName()); 192 193 return SUCCESS; 194 } 195 catch (Exception e) 196 { 197 addErrorMessage("getting contents failed, exception thrown ("+e.toString()+")"); 198 e.printStackTrace(); 199 return ERROR; 200 } 201 } 202 } 203 | Popular Tags |