Code source wiki de MeetingManagerMacros
Modifié par Vincent Massol le 2011/08/13 09:46
Masquer les derniers auteurs
author | version | line-number | content |
---|---|---|---|
![]() |
1.1 | 1 | {{velocity output=false}} |
2 | #** | ||
3 | * Display a help message (similar to info, warning, error, etc.) | ||
4 | *# | ||
5 | #macro(help $text) | ||
6 | <div class="helpmessage">$text</div> | ||
7 | #end | ||
8 | #** | ||
9 | * User avatar 2, with image size, using the image plugin. | ||
10 | * | ||
11 | * @todo: re-write useravatar in XE's macros.vm | ||
12 | *# | ||
13 | #macro(avatar $username) | ||
14 | #if(!$picturelist) | ||
15 | #set($picturelist = $util.hashMap) | ||
16 | #end | ||
17 | #if(!$picturelist.containsKey($username)) | ||
18 | #set($picture = "<img src='") | ||
19 | #set($picture = $picture.concat($xwiki.getSkinFile("noavatar.png"))) | ||
20 | #set($picture = $picture.concat("' alt='$username' title='$username'/>")) | ||
21 | #set($profiledoc = $xwiki.getDocument($username)) | ||
22 | #if(!$profiledoc.isNew()) | ||
23 | #set($profileobj = $profiledoc.getObject("XWikiUsers", 0)) | ||
24 | #if($profiledoc.attachmentList.size() != 0) | ||
25 | #set($hasavatar = 0) | ||
26 | #if($profileobj.avatar && $profileobj.avatar != "") | ||
27 | #foreach ($attach in $profiledoc.attachmentList) | ||
28 | #if($attach.filename == $profileobj.avatar) | ||
29 | #set($hasavatar = 1) | ||
30 | #end | ||
31 | #end | ||
32 | #end | ||
33 | #if($hasavatar == 1) | ||
34 | #set($pictureurl = "${profiledoc.getAttachmentURL($profileobj.avatar)}?width=52") | ||
35 | #set($picture = "<img src='") | ||
36 | #set($picture = $picture.concat($pictureurl)) | ||
37 | #set($picture = $picture.concat("' alt='")) | ||
38 | #set($picture = $picture.concat($username)) | ||
39 | #set($picture = $picture.concat("' title='")) | ||
40 | #set($picture = $picture.concat($username)) | ||
41 | #set($picture = $picture.concat("'/>")) | ||
42 | #end | ||
43 | #end | ||
44 | #end | ||
45 | #set($ok = $!picturelist.put($username, $picture)) | ||
46 | #end | ||
47 | $picturelist.get($username) | ||
48 | #end | ||
49 | #** | ||
50 | * Display a participant in the list of participants | ||
51 | * @param p the participant object of class MMCode.MeetingParticipantClass | ||
52 | *# | ||
53 | #macro(participantitem $p $isManager $status) | ||
54 | #set($username = $p.getProperty("username").value) | ||
55 | #set($participation = $p.getProperty("participation").value) | ||
56 | #set($message = $p.getProperty("message").value) | ||
57 | <li class="xitem xunderline #if($participation!='')$participation#else undecided my#end"> | ||
58 | <span class="xitemcontainer"> | ||
59 | <span class="username">#avatar($username) | ||
60 | <span class="participation"> </span> | ||
61 | $xwiki.getUserName($username) | ||
62 | </span> | ||
63 | <span class="participationmessage">#if("$!message" != "")$message#end</span> | ||
64 | #if($isManager) | ||
65 | #set($redirect="$doc.getURL('view')#participants") | ||
66 | #set($delURL = $doc.getURL("objectremove","classname=MMCode.MeetingParticipantClass&classid=${p.number}&xredirect=$redirect")) | ||
67 | <span class="deleteparticipants"> | ||
68 | #set($confirmationmsg = $msg.get('meetings.meeting.participants.confirmremove', ["$xwiki.getUserName($username, false)"])) | ||
69 | <a href="javascript:void()" onclick="javascript:if (!confirm('$confirmationmsg')){return false;} else { XWiki.MeetingManager.removeParticipant('${p.number}')}"> | ||
70 | <img class="delete" src="$xwiki.getDocument('MMCode.MeetingManager').getAttachmentURL('cross.gif')" /> | ||
71 | </a> | ||
72 | </span> | ||
73 | #end | ||
74 | #if($context.user == $p.get("username") && $status == "prepared") | ||
75 | <span id="modifymyparticipation"> | ||
76 | <span >$msg.get('meetings.meeting.myparticipation.modify')</span> | ||
77 | </span> | ||
78 | <span class="clearfloats"></span> | ||
79 | <span id="myparticipation" #if($participation!="")class="hidden"#end> | ||
80 | <span>$msg.get('meetings.meeting.myparticipation.select')</span> | ||
81 | <span>$p.display("participation", "edit")</span> | ||
82 | <span>$msg.get('meetings.meeting.myparticipation.message')</span> | ||
83 | <span>$p.display("message", "edit")</span> | ||
84 | <span><span class="buttonwrapper"><button id="savemyparticipation">$msg.get('meetings.meeting.myparticipation.save')</button></span></span> | ||
85 | </span> | ||
86 | #end | ||
87 | </span> | ||
88 | </li> | ||
89 | #end | ||
90 | #** | ||
91 | * Determine if a given meeting is part of a meeting cycle | ||
92 | *# | ||
93 | #macro(isCyclic $meetingDoc $isCyclic) | ||
94 | #if($meetingDoc.getObject("MMCode.MeetingCycleItemClass")) | ||
95 | #set($isCyclic = true) | ||
96 | #else | ||
97 | #set($isCyclic = false) | ||
98 | #end | ||
99 | #end | ||
100 | #** | ||
101 | * Determine if a meeting date is planned already or not | ||
102 | * @param $meetingDoc the document that hold the meeting to test | ||
103 | * @return $isDateDefined a boolean that says if the date is planned or not | ||
104 | *# | ||
105 | #macro(isDateDefined $meetingDoc $isDateDefined) | ||
![]() |
2.1 | 106 | #set($ok = $meetingDoc.use("MMCode.MeetingClass")) |
![]() |
1.1 | 107 | #set($sdate = $meetingDoc.display("date")) |
![]() |
2.1 | 108 | #if($sdate.equals("") || $sdate.equals("01/01/2000") || $sdate.equals("2000/01/01")) |
109 | #set($isDateDefined = false) | ||
110 | #else | ||
![]() |
1.1 | 111 | #set($isDateDefined = true) |
112 | #end | ||
113 | #end | ||
114 | #** | ||
115 | * Determine if the context user is manager of the passed meeting | ||
116 | *# | ||
117 | #macro(isManager $meetingDoc $isManager) | ||
118 | #if(($meetingDoc.creator==$context.user || !$isWorkflowEnforced) && $meetingDoc.hasAccessLevel("edit"))#set($isManager = true)#else#set($isManager = false)#end | ||
119 | #end | ||
120 | #** | ||
121 | * Is participant | ||
122 | *# | ||
123 | #macro(isParticipant $meetingDoc $isParticipant) | ||
124 | #if($meetingDoc.getObject("MMCode.MeetingParticipantClass", "username", "$context.user")) | ||
125 | #set($isParticipant = true) | ||
126 | #else | ||
127 | #set($isParticipant = false) | ||
128 | #end | ||
129 | #end | ||
130 | #** | ||
131 | * The doodle | ||
132 | *# | ||
133 | #macro(attempttable $attempts $participants $closed) | ||
134 | #set($dispotable = $util.hashMap) | ||
135 | #foreach($p in $participants) | ||
136 | #set($ok = $dispotable.put("$p.get('username')", $util.arrayList)) | ||
137 | #end | ||
138 | #if($participants.size() > 0) | ||
139 | <table id="meetingattempts"> | ||
140 | <tr> | ||
141 | <td></td> | ||
142 | #foreach($attempt in $attempts) | ||
143 | <td class="meetingattempt"> | ||
144 | <div class="date">$attempt.get("date")</div> | ||
145 | <div class="location">$attempt.get("location")</div> | ||
146 | </td> | ||
147 | #foreach($p in $participants) | ||
148 | #if($p.get('username') == $context.user) #set($myId = $p.number) #end | ||
149 | #if($listtool.contains($p.get('available').split(','), "$attempt.number")) | ||
150 | #set($ok = $dispotable.get("$p.get('username')").add("${attempt.number}:available")) | ||
151 | #elseif($listtool.contains($p.get('unavailable').split(','), "$attempt.number")) | ||
152 | #set($ok = $dispotable.get("$p.get('username')").add("${attempt.number}:unavailable")) | ||
153 | #else | ||
154 | #set($ok = $dispotable.get("$p.get('username')").add("${attempt.number}:unknown")) | ||
155 | #end | ||
156 | #end | ||
157 | #end | ||
158 | </tr> | ||
159 | #if($dispotable.containsKey($context.user) && !$closed) | ||
160 | #set($mydispo = $dispotable.remove($context.user)) | ||
161 | #end | ||
162 | #if($mydispo) | ||
163 | <tr class="contextuser" id="mydisponibilities"> | ||
164 | <td>$xwiki.getUserName($context.user, false) <strong>($msg.get('meetings.meeting.vote.you'))</strong></td> | ||
165 | #foreach($d in $mydispo) | ||
166 | <td class="$listtool.get($d.split(':'), 1)"><div rel="${listtool.get($d.split(':'), 0)}" class="my" /></td> | ||
167 | #end | ||
168 | <td class="save"> | ||
169 | <span class="buttonwrapper"><button id="savemydisponibilities">$msg.get('meetings.meeting.vote.save')</button><span> | ||
170 | <div id="savemydisponibilitiesinfo" class="hidden"><img src=$xwiki.getDocument("MMCode.MeetingManager").getAttachmentURL('accept.gif') style="float:left;"></div> | ||
171 | <input type="hidden" id="myid" value="$myId" /> | ||
172 | </td> | ||
173 | </tr> | ||
174 | #end | ||
175 | #foreach($p in $dispotable.keySet()) | ||
176 | <tr> | ||
177 | <td class="username">$xwiki.getUserName($p, false)</td> | ||
178 | #foreach($d in $dispotable.get($p)) | ||
179 | <td class="$listtool.get($d.split(':'), 1)"> </td> | ||
180 | #end | ||
181 | <td></td> | ||
182 | </tr> | ||
183 | #end | ||
184 | </table> | ||
185 | #end | ||
186 | #end | ||
187 | {{/velocity}} |