0
|
1 package nabble.view.web.template;
|
|
2
|
|
3 import fschmidt.util.java.Filter;
|
|
4 import fschmidt.util.java.HtmlUtils;
|
|
5 import nabble.model.DailyNumber;
|
|
6 import nabble.model.FilteredNodeIterator;
|
|
7 import nabble.model.ModelException;
|
|
8 import nabble.model.ModelHome;
|
|
9 import nabble.model.Node;
|
|
10 import nabble.model.NodeIterator;
|
|
11 import nabble.model.NodeSearcher;
|
|
12 import nabble.model.Person;
|
|
13 import nabble.model.Site;
|
|
14 import nabble.model.Subscription;
|
|
15 import nabble.model.User;
|
|
16 import nabble.naml.compiler.Command;
|
|
17 import nabble.naml.compiler.CommandSpec;
|
|
18 import nabble.naml.compiler.IPrintWriter;
|
|
19 import nabble.naml.compiler.Interpreter;
|
|
20 import nabble.naml.compiler.Namespace;
|
|
21 import nabble.naml.compiler.ScopedInterpreter;
|
|
22 import nabble.naml.namespaces.ListSequence;
|
|
23 import nabble.view.lib.Jtp;
|
|
24 import nabble.view.lib.Permissions;
|
|
25 import nabble.view.lib.Shared;
|
|
26
|
|
27 import javax.servlet.ServletException;
|
|
28 import java.io.IOException;
|
|
29 import java.util.ArrayList;
|
|
30 import java.util.Collections;
|
|
31 import java.util.List;
|
|
32 import java.util.Map;
|
|
33
|
|
34
|
|
35 @Namespace (
|
|
36 name = "user",
|
|
37 global = false
|
|
38 )
|
|
39 public final class UserNamespace {
|
|
40 private final Person personR;
|
|
41 private User userR;
|
|
42
|
|
43 public UserNamespace(Person person) {
|
|
44 if( person == null )
|
|
45 throw new NullPointerException("person is null");
|
|
46 this.personR = person;
|
|
47 this.userR = person instanceof User ? (User)person : null;
|
|
48 }
|
|
49
|
|
50 public void refreshUser() {
|
|
51 if( isUser() )
|
|
52 userR = userR.getGoodCopy();
|
|
53 }
|
|
54
|
|
55 public boolean isUser() {
|
|
56 return userR != null;
|
|
57 }
|
|
58
|
|
59 public User user() {
|
|
60 if( !isUser() )
|
|
61 return null;
|
|
62 return userR;
|
|
63 }
|
|
64
|
|
65 public Person person() {
|
|
66 return isUser() ? user() : personR;
|
|
67 }
|
|
68
|
|
69 private Site site() {
|
|
70 return person().getSite();
|
|
71 }
|
|
72
|
|
73 public static final CommandSpec this_user = CommandSpec.DO;
|
|
74
|
|
75 @Command public void this_user(IPrintWriter out,ScopedInterpreter<UserNamespace> interp) {
|
|
76 out.print( interp.getArg(this,"do") );
|
|
77 }
|
|
78
|
|
79 @Command public void id(IPrintWriter out,Interpreter interp) {
|
|
80 out.print( interp.encode( person().getIdString() ) );
|
|
81 }
|
|
82
|
|
83 @Command public void search_id(IPrintWriter out,Interpreter interp) {
|
|
84 out.print( person().getSearchId() );
|
|
85 }
|
|
86
|
|
87 public static final CommandSpec name = new CommandSpec.Builder()
|
|
88 .optionalParameters("truncate")
|
|
89 .build()
|
|
90 ;
|
|
91
|
|
92 @Command public void name(IPrintWriter out,Interpreter interp)
|
|
93 throws IOException
|
|
94 {
|
|
95 String truncate = interp.getArgString("truncate");
|
|
96 String name = person().getName();
|
|
97 if( name==null ) {
|
|
98 out.print((String)null);
|
|
99 return;
|
|
100 }
|
|
101 if (truncate != null) {
|
|
102 try {
|
|
103 name = Jtp.truncate(name,Integer.valueOf(truncate),"...");
|
|
104 } catch (NumberFormatException e) {
|
|
105 throw new RuntimeException("Invalid \"truncate\" attribute: " + truncate);
|
|
106 }
|
|
107 }
|
|
108 out.print( interp.encode(name) );
|
|
109 }
|
|
110
|
|
111 public static final CommandSpec avatar_url = new CommandSpec.Builder()
|
|
112 .optionalParameters("size")
|
|
113 .build()
|
|
114 ;
|
|
115
|
|
116 @Command public void avatar_url(IPrintWriter out,Interpreter interp)
|
|
117 throws IOException
|
|
118 {
|
|
119 String size = interp.getArgString("size");
|
|
120 out.print( interp.encode(Shared.getAvatarImageURL(person(), "small".equals(size))) );
|
|
121 }
|
|
122
|
|
123 public static final CommandSpec default_avatar_url = new CommandSpec.Builder()
|
|
124 .optionalParameters("size")
|
|
125 .build()
|
|
126 ;
|
|
127
|
|
128 @Command public void default_avatar_url(IPrintWriter out,Interpreter interp)
|
|
129 throws IOException
|
|
130 {
|
|
131 String size = interp.getArgString("size");
|
|
132 out.print( interp.encode(Shared.getDefaultAvatarImageURL("small".equals(size))) );
|
|
133 }
|
|
134
|
|
135 @Command public void is_registered(IPrintWriter out,Interpreter interp) {
|
|
136 out.print( isUser() && user().isRegistered() );
|
|
137 }
|
|
138
|
|
139 @Command public void has_too_many_posts(IPrintWriter out,Interpreter interp) {
|
|
140 out.print( isUser() && user().hasTooManyPosts() );
|
|
141 }
|
|
142
|
|
143 public static final CommandSpec registration_date = CommandSpec.DO;
|
|
144
|
|
145 @Command public void registration_date(IPrintWriter out,ScopedInterpreter<DateNamespace> interp) {
|
|
146 out.print( interp.getArg( new DateNamespace(user().getRegistered()), "do" ) );
|
|
147 }
|
|
148
|
|
149 @Command public void is_deactivated(IPrintWriter out,Interpreter interp) {
|
|
150 out.print( isUser() && user().isDeactivated() );
|
|
151 }
|
|
152
|
|
153 @Command public void is_anonymous(IPrintWriter out,Interpreter interp) {
|
|
154 out.print( !isUser() );
|
|
155 }
|
|
156
|
|
157 @Command public void is_authenticated(IPrintWriter out,Interpreter interp) {
|
|
158 out.print( isUser() );
|
|
159 }
|
|
160
|
|
161 @Command public void user_email(IPrintWriter out,Interpreter interp) {
|
|
162 out.print( user().getEmail() );
|
|
163 }
|
|
164
|
|
165 @Command public void resetcode(IPrintWriter out,Interpreter interp) {
|
|
166 out.print( user().getResetcode() );
|
|
167 }
|
|
168
|
|
169 @Command public void send_email_url(IPrintWriter out,Interpreter interp) {
|
|
170 out.print( interp.encode( "/user/SendEmail.jtp?type=user&user=" + user().getId() ) );
|
|
171 }
|
|
172
|
|
173
|
|
174 public static final CommandSpec is_in_group = new CommandSpec.Builder()
|
|
175 .dotParameter("group")
|
|
176 .build()
|
|
177 ;
|
|
178
|
|
179 @Command public void is_in_group(IPrintWriter out,Interpreter interp) {
|
|
180 String group = interp.getArgString("group");
|
|
181 out.print( isUser() && Permissions.isInGroup(user(),group) );
|
|
182 }
|
|
183
|
|
184 public static final CommandSpec has_permission = new CommandSpec.Builder()
|
|
185 .parameters("node","permission_node","permission")
|
|
186 .build()
|
|
187 ;
|
|
188
|
|
189 @Command public void has_permission(IPrintWriter out,Interpreter interp) {
|
|
190 NodeNamespace nodeNs = interp.getArgAsNamespace(NodeNamespace.class,"node");
|
|
191 NodeNamespace permissionNodeNs = interp.getArgAsNamespace(NodeNamespace.class,"permission_node");
|
|
192 String perm = interp.getArgString("permission");
|
|
193 out.print( Permissions.hasPermission(permissionNodeNs.node(),nodeNs.node(),person(),perm) );
|
|
194 }
|
|
195
|
|
196 public static final CommandSpec has_site_permission = new CommandSpec.Builder()
|
|
197 .parameters("permission")
|
|
198 .build()
|
|
199 ;
|
|
200
|
|
201 @Command public void has_site_permission(IPrintWriter out,Interpreter interp) {
|
|
202 String perm = interp.getArgString("permission");
|
|
203 out.print( Permissions.hasSitePermission(NabbleNamespace.current().site(),person(),perm) );
|
|
204 }
|
|
205
|
|
206 public static final CommandSpec owns = new CommandSpec.Builder()
|
|
207 .dotParameter("node")
|
|
208 .build()
|
|
209 ;
|
|
210
|
|
211 @Command public void owns(IPrintWriter out,Interpreter interp) {
|
|
212 NodeNamespace nodeNs = interp.getArgAsNamespace(NodeNamespace.class,"node");
|
|
213 out.print( nodeNs.node().getOwner().equals(person()) );
|
|
214 }
|
|
215
|
|
216 public static final CommandSpec reply_address_for = new CommandSpec.Builder()
|
|
217 .dotParameter("node")
|
|
218 .build()
|
|
219 ;
|
|
220
|
|
221 @Command public void reply_address_for(IPrintWriter out,Interpreter interp) {
|
|
222 NodeNamespace nodeNs = interp.getArgAsNamespace(NodeNamespace.class,"node");
|
|
223 out.print( ModelHome.getNodeReplyAddress(nodeNs.node(), user()) );
|
|
224 }
|
|
225
|
|
226 @Command public void bounces_address(IPrintWriter out,Interpreter interp) {
|
|
227 out.print( ModelHome.getUserBouncesAddress(user()) );
|
|
228 }
|
|
229
|
|
230 public static final CommandSpec as_user_page = CommandSpec.DO;
|
|
231
|
|
232 @Command public void as_user_page(IPrintWriter out,ScopedInterpreter<UserPageNamespace> interp) {
|
|
233 out.print( interp.getArg(new UserPageNamespace(this),"do") );
|
|
234 }
|
|
235
|
|
236
|
|
237 public static final CommandSpec groups = CommandSpec.DO;
|
|
238
|
|
239 @Command public void groups(IPrintWriter out,ScopedInterpreter<NabbleNamespace.GroupList> interp) {
|
|
240 List<String> groups = Permissions.getPersonGroups(person());
|
|
241 Object block = interp.getArg(new NabbleNamespace.GroupList(groups),"do");
|
|
242 out.print(block);
|
|
243 }
|
|
244
|
|
245 public static final CommandSpec nodes_list = CommandSpec.DO()
|
|
246 .parameters("length")
|
|
247 .optionalParameters("start","sort","filter")
|
|
248 .requiredInStack(ServletNamespace.class)
|
|
249 .build()
|
|
250 ;
|
|
251
|
|
252 @Command public void nodes_list(IPrintWriter out,ScopedInterpreter<NodeList> interp)
|
|
253 throws ServletException
|
|
254 {
|
|
255 ServletNamespace servletNamespace = interp.getFromStack(ServletNamespace.class);
|
|
256 int start = NodeNamespace.getLoopStart(interp);
|
|
257 int length = NodeNamespace.getLoopLength(interp);
|
|
258 String filter = interp.getArgString("filter");
|
|
259 NodeIterator<? extends Node> nodeIter = person().getNodesByDateDesc(filter);
|
|
260 try {
|
|
261 Filter<Node> viewFilter = Permissions.canBeViewedByPersonFilter(servletNamespace.getVisitorUser());
|
|
262 nodeIter = new FilteredNodeIterator(nodeIter,viewFilter);
|
|
263 NodeList.userNodes( out, interp, nodeIter, start, length );
|
|
264 } finally {
|
|
265 nodeIter.close();
|
|
266 }
|
|
267 }
|
|
268
|
|
269 @Command public void post_filter(IPrintWriter out,Interpreter interp) {
|
|
270 out.print( "(is_app is null or not is_app)" );
|
|
271 }
|
|
272
|
|
273 @Command public void app_filter(IPrintWriter out,Interpreter interp) {
|
|
274 out.print( "is_app" );
|
|
275 }
|
|
276
|
|
277 @Command public void topic_filter(IPrintWriter out,Interpreter interp) {
|
|
278 out.print( "(is_app is null or not is_app) and exists(select 1 from node p where node.parent_id=p.node_id and is_app)" );
|
|
279 }
|
|
280
|
|
281 @Command public void reply_filter(IPrintWriter out,Interpreter interp) {
|
|
282 out.print( "(is_app is null or not is_app) and exists(select 1 from node p where node.parent_id=p.node_id and (is_app is null or not is_app))" );
|
|
283 }
|
|
284
|
|
285 public static final CommandSpec equals = new CommandSpec.Builder()
|
|
286 .dotParameter("user")
|
|
287 .build()
|
|
288 ;
|
|
289
|
|
290 @Command public void equals(IPrintWriter out,Interpreter interp) {
|
|
291 UserNamespace userNs = interp.getArgAsNamespace(UserNamespace.class,"user");
|
|
292 out.print( userNs.person().equals(person()) );
|
|
293 }
|
|
294
|
|
295
|
|
296 @Namespace (
|
|
297 name = "user_list",
|
|
298 global = true
|
|
299 )
|
|
300 public static class UserList extends ListSequence<User> {
|
|
301
|
|
302 public UserList(List<User> nodeUsers) {
|
|
303 super(nodeUsers);
|
|
304 }
|
|
305
|
|
306 public static final CommandSpec current_user = CommandSpec.DO;
|
|
307
|
|
308 @Command public void current_user(IPrintWriter out,ScopedInterpreter<UserNamespace> interp) {
|
|
309 out.print( interp.getArg(new UserNamespace(get()),"do") );
|
|
310 }
|
|
311
|
|
312 @Command public void next_user(IPrintWriter out,Interpreter interp) {
|
|
313 next_element(out,interp);
|
|
314 }
|
|
315
|
|
316 public static final CommandSpec sort_by_node_count_desc = CommandSpec.NO_OUTPUT;
|
|
317
|
|
318 @Command public void sort_by_node_count_desc(IPrintWriter out,Interpreter interp) {
|
|
319 Collections.sort(elements,User.nodeCountComparatorDesc);
|
|
320 }
|
|
321
|
|
322 public static final CommandSpec sort_by_name = CommandSpec.NO_OUTPUT;
|
|
323
|
|
324 @Command public void sort_by_name(IPrintWriter out,Interpreter interp) {
|
|
325 Collections.sort(elements,User.BY_NAME_COMPARATOR);
|
|
326 }
|
|
327
|
|
328 public static final CommandSpec sub_list = CommandSpec.DO()
|
|
329 .parameters("length")
|
|
330 .optionalParameters("start")
|
|
331 .build()
|
|
332 ;
|
|
333
|
|
334 @Command public void sub_list(IPrintWriter out,ScopedInterpreter<UserList> interp) {
|
|
335 int start = interp.getArgAsInt("start",0);
|
|
336 int length = interp.getArgAsInt("length");
|
|
337 UserList ns ;
|
|
338 if( start==0 && length >= elements.size() ) {
|
|
339 ns = this;
|
|
340 } else {
|
|
341 ns = new UserList(elements.subList(start,Math.min(elements.size(),start+length)));
|
|
342 }
|
|
343 out.print( interp.getArg(ns,"do") );
|
|
344 }
|
|
345 }
|
|
346
|
|
347 public static final CommandSpec signature_impl = CommandSpec.DO;
|
|
348
|
|
349 @Command public void signature_impl(IPrintWriter out,ScopedInterpreter<MessageNamespace> interp) {
|
|
350 out.print( interp.getArg( new MessageNamespace(person().getSignature()), "do" ) );
|
|
351 }
|
|
352
|
|
353 @Command public void has_signature(IPrintWriter out,Interpreter interp) {
|
|
354 out.print( person().getSignature() != null );
|
|
355 }
|
|
356
|
|
357 public static final CommandSpec node_count = new CommandSpec.Builder()
|
|
358 .optionalParameters("filter")
|
|
359 .build()
|
|
360 ;
|
|
361
|
|
362 @Command public void node_count(IPrintWriter out,Interpreter interp) {
|
|
363 out.print( person().getNodeCount(interp.getArgString("filter")) );
|
|
364 }
|
|
365
|
|
366 @Command public void is_banned(IPrintWriter out, Interpreter interp) {
|
|
367 out.print( isUser() && Permissions.isBanned(user()) );
|
|
368 }
|
|
369
|
|
370 public static final CommandSpec ban = CommandSpec.NO_OUTPUT;
|
|
371
|
|
372 @Command public void ban(IPrintWriter out, Interpreter interp) {
|
|
373 Permissions.ban(user());
|
|
374 user().setNoArchive(true);
|
|
375 site().update(); // uncache
|
|
376 }
|
|
377
|
|
378 public static final CommandSpec unban = CommandSpec.NO_OUTPUT;
|
|
379
|
|
380 @Command public void unban(IPrintWriter out, Interpreter interp) {
|
|
381 Permissions.unban(user());
|
|
382 user().setNoArchive(false);
|
|
383 site().update(); // uncache
|
|
384 }
|
|
385
|
|
386 public static final CommandSpec delete_user_nodes = CommandSpec.NO_OUTPUT;
|
|
387
|
|
388 @Command public void delete_user_nodes(IPrintWriter out, Interpreter interp) {
|
|
389 person().deleteNodes();
|
|
390 }
|
|
391
|
|
392
|
|
393 @Command public void is_sysadmin(IPrintWriter out, Interpreter interp) {
|
|
394 out.print( isUser() && Permissions.isSysAdmin(user()) );
|
|
395 }
|
|
396
|
|
397 public static final CommandSpec reset_password_path = new CommandSpec.Builder()
|
|
398 .parameters("email","q")
|
|
399 .build()
|
|
400 ;
|
|
401
|
|
402 @Command public void reset_password_path(IPrintWriter out,Interpreter interp) {
|
|
403 String email = interp.getArgString("email");
|
|
404 String q = interp.getArgString("q");
|
|
405 out.print( interp.encode( "/user/ResetPassword.jtp" ) );
|
|
406 if (email!=null && q!=null)
|
|
407 out.print( interp.encode("?email=" + HtmlUtils.urlEncode(email) + "&q=" + HtmlUtils.urlEncode(q)) );
|
|
408 }
|
|
409
|
|
410 @Command public void change_email_path(IPrintWriter out,Interpreter interp) {
|
|
411 out.print( interp.encode( "/user/ChangeEmail.jtp?user=" + user().getId() ) );
|
|
412 }
|
|
413
|
|
414 @Command public void change_avatar_path(IPrintWriter out,Interpreter interp) {
|
|
415 out.print( interp.encode( "/user/ChangeAvatar.jtp" ) );
|
|
416 }
|
|
417
|
|
418 @Command public void advanced_settings_path(IPrintWriter out,Interpreter interp) {
|
|
419 out.print( interp.encode( "/user/Advanced.jtp" ) );
|
|
420 }
|
|
421
|
|
422 @Command public void remove_account_path(IPrintWriter out,Interpreter interp) {
|
|
423 out.print( interp.encode( "/user/RemoveAccount.jtp" ) );
|
|
424 }
|
|
425
|
|
426 @Command public void pending_posts_path(IPrintWriter out,Interpreter interp) {
|
|
427 out.print( interp.encode( "/user/UserPendingNodes.jtp" ) );
|
|
428 }
|
|
429
|
|
430 private Map<Long,Long> lastVisitedNodeIds = null;
|
|
431
|
|
432 private Long lastVisitedNodeId(Interpreter interp,long nodeId) {
|
|
433 if( !isUser() )
|
|
434 return null;
|
|
435 if( lastVisitedNodeIds == null ) {
|
|
436 RequestNamespace.ParameterValueList params = interp.getFromStack(RequestNamespace.ParameterValueList.class);
|
|
437 List<Long> ids = new ArrayList<Long>();
|
|
438 for( String value : params.values() ) {
|
|
439 ids.add(Long.parseLong(value));
|
|
440 }
|
|
441 lastVisitedNodeIds = user().lastVisitedNodeIds(ids);
|
|
442 }
|
|
443 return lastVisitedNodeIds.get(nodeId);
|
|
444 }
|
|
445
|
|
446 public static final CommandSpec has_visited_node = CommandSpec.DO()
|
|
447 .parameters("node_id")
|
|
448 .requiredInStack(RequestNamespace.ParameterValueList.class)
|
|
449 .build()
|
|
450 ;
|
|
451
|
|
452 @Command public void has_visited_node(IPrintWriter out, Interpreter interp) {
|
|
453 Long id = lastVisitedNodeId(interp, interp.getArgAsLong("node_id"));
|
|
454 Node node = id == null? null : site().getNode(id);
|
|
455 if (id != null && node == null)
|
|
456 lastVisitedNodeIds.remove(id);
|
|
457 out.print( node != null);
|
|
458 }
|
|
459
|
|
460 public static final CommandSpec last_visited_node = CommandSpec.DO()
|
|
461 .parameters("node_id")
|
|
462 .requiredInStack(RequestNamespace.ParameterValueList.class)
|
|
463 .build()
|
|
464 ;
|
|
465
|
|
466 @Command public void last_visited_node(IPrintWriter out, ScopedInterpreter<NodeNamespace> interp) {
|
|
467 Node lastVisitedNode = null;
|
|
468 long nodeId = interp.getArgAsLong("node_id");
|
|
469 Long id = lastVisitedNodeId(interp,nodeId);
|
|
470 if (id != null)
|
|
471 lastVisitedNode = site().getNode(id);
|
|
472 out.print( interp.getArg( new NodeNamespace(lastVisitedNode), "do" ) );
|
|
473 }
|
|
474
|
|
475 public static final CommandSpec mark_visited = CommandSpec.NO_OUTPUT()
|
|
476 .parameters("last_node_id")
|
|
477 .dotParameter("node")
|
|
478 .build()
|
|
479 ;
|
|
480
|
|
481 @Command public void mark_visited(IPrintWriter out, Interpreter interp) {
|
|
482 if (isUser()) {
|
|
483 NodeNamespace nodeNs = interp.getArgAsNamespace(NodeNamespace.class,"node");
|
|
484 long lastNodeId = interp.getArgAsLong("last_node_id");
|
|
485 user().markVisited(nodeNs.node(), lastNodeId);
|
|
486 }
|
|
487 }
|
|
488
|
|
489 public static final CommandSpec register = new CommandSpec.Builder()
|
|
490 .requiredInStack(ServletNamespace.class)
|
|
491 .build()
|
|
492 ;
|
|
493
|
|
494 @Command public void register(IPrintWriter out, Interpreter interp)
|
|
495 throws ModelException, IOException
|
|
496 {
|
|
497 user().register();
|
|
498 refreshUser();
|
|
499 ServletNamespace servletNamespace = interp.getFromStack(ServletNamespace.class);
|
|
500 Jtp.doLogin(servletNamespace.request, servletNamespace.response, user(), false);
|
|
501 DailyNumber.registrations.inc();
|
|
502 }
|
|
503
|
|
504 public static final CommandSpec NAME = new CommandSpec.Builder()
|
|
505 .dotParameter("name")
|
|
506 .build()
|
|
507 ;
|
|
508
|
|
509 public static final CommandSpec has_property = NAME;
|
|
510
|
|
511 @Command public void has_property(IPrintWriter out,Interpreter interp) {
|
|
512 String name = interp.getArgString("name");
|
|
513 out.print(user().getProperty(name) != null);
|
|
514 }
|
|
515
|
|
516 public static final CommandSpec get_property = NAME;
|
|
517
|
|
518 @Command public void get_property(IPrintWriter out,Interpreter interp) {
|
|
519 String name = interp.getArgString("name");
|
|
520 out.print(user().getProperty(name));
|
|
521 }
|
|
522
|
|
523 public static final CommandSpec delete_property = CommandSpec.NO_OUTPUT()
|
|
524 .parameters("name")
|
|
525 .build()
|
|
526 ;
|
|
527
|
|
528 @Command public void delete_property(IPrintWriter out,Interpreter interp) {
|
|
529 User user = user();
|
|
530 String name = interp.getArgString("name");
|
|
531 user.setProperty(name, null);
|
|
532 user.getSite().update();
|
|
533 }
|
|
534
|
|
535 public static final CommandSpec set_property = CommandSpec.NO_OUTPUT()
|
|
536 .parameters("name", "value")
|
|
537 .build()
|
|
538 ;
|
|
539
|
|
540 @Command public void set_property(IPrintWriter out,Interpreter interp) {
|
|
541 User user = user();
|
|
542 String name = interp.getArgString("name");
|
|
543 String value = interp.getArgString("value");
|
|
544 user.setProperty(name, value);
|
|
545 user.getSite().update();
|
|
546 }
|
|
547
|
|
548 public static final CommandSpec has_subscription_to_descentants_of = CommandSpec.NO_OUTPUT()
|
|
549 .dotParameter("node")
|
|
550 .build()
|
|
551 ;
|
|
552
|
|
553 @Command public void has_subscription_to_descentants_of(IPrintWriter out,Interpreter interp) {
|
|
554 if (userR == null) {
|
|
555 out.print(false);
|
|
556 return;
|
|
557 }
|
|
558 NodeNamespace nodeNs = interp.getArgAsNamespace(NodeNamespace.class,"node");
|
|
559 for (Node n : nodeNs.node().getAncestors() ) {
|
|
560 if (userR.isSubscribed(n)) {
|
|
561 Subscription subscription = userR.getSubscription(n);
|
|
562 if (subscription.getTo() == Subscription.To.DESCENDANTS) {
|
|
563 out.print(true);
|
|
564 return;
|
|
565 }
|
|
566 }
|
|
567 }
|
|
568 out.print(false);
|
|
569 }
|
|
570
|
|
571 }
|