BrightSide Workbench Full Report + Source Code
ContactsUserMenu.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2019 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.contacts.user.menu;
20 
21 import java.io.File;
22 import org.turro.action.UserSummaries;
23 import org.turro.elephant.context.Application;
24 import org.turro.elephant.context.ElephantContext;
25 import org.turro.elephant.user.menu.DefaultUserMenu;
26 import org.turro.elephant.user.menu.IUserMenu;
27 import org.turro.elephant.user.menu.UserMenu;
28 import org.turro.elephant.user.menu.UserMenus;
29 
34 @UserMenu
35 public class ContactsUserMenu extends DefaultUserMenu {
36 
37  public ContactsUserMenu() {
38  super("Social", null, 2);
39  }
40 
41  @Override
42  public void initMenu() {
43  addChild(new DefaultUserMenu("Contacts", null, "/user/mycontacts") {
44  @Override
45  public boolean isInRole() {
46  return Application.getApplication().isInRole("contact:list|contact:list-all");
47  }
48 
49  @Override
50  public Object getDetail() {
51  return null;
52  }
53  });
54  addChild(new DefaultUserMenu("Profile", null, "/user/profile") {
55  @Override
56  public boolean isInRole() {
57  return true;
58  }
59  @Override
60  public Object getDetail() {
61  return null;
62  }
63  });
64 // addChild(new DefaultUserMenu("About", null, "/user/about") {
65 // @Override
66 // public boolean isInRole() {
67 // return true;
68 // }
69 // @Override
70 // public Object getDetail() {
71 // return null;
72 // }
73 // });
74  addChild(new DefaultUserMenu("Tell someone about this site", null, "/user/tellsomeone") {
75  @Override
76  public boolean isInRole() {
77  return new File(ElephantContext.getRealPath("/user/tellsomeone")).exists();
78  }
79  @Override
80  public Object getDetail() {
81  return null;
82  }
83  });
85  session.addChild(new DefaultUserMenu("Acceptances", null, "/user/acceptances") {
86  @Override
87  public boolean isInRole() {
89  }
90  @Override
91  public Object getDetail() {
92  return null;
93  }
94  });
95  session.addChild(new DefaultUserMenu("Agreements", null, "/user/myagreements") {
96  @Override
97  public boolean isInRole() {
99  }
100  @Override
101  public Object getDetail() {
102  return UserSummaries.isNotZero("pendingSignature") ? UserSummaries.getAttribute("pendingSignature") : null;
103  }
104  });
105  session.addChild(new DefaultUserMenu("Subscriptions", null, "/user/subscriptions") {
106  @Override
107  public boolean isInRole() {
109  }
110  @Override
111  public Object getDetail() {
112  return null;
113  }
114  });
115  session.addChild(new DefaultUserMenu("Push notifications", null, "/user/push") {
116  @Override
117  public boolean isInRole() {
119  }
120  @Override
121  public Object getDetail() {
122  return null;
123  }
124  });
125  session.addChild(new DefaultUserMenu("Change password", null, "/user/changepass") {
126  @Override
127  public boolean isInRole() {
129  }
130  @Override
131  public Object getDetail() {
132  return null;
133  }
134  });
135  }
136 
137  @Override
138  public boolean isInRole() {
140  }
141 
142  @Override
143  public Object getDetail() {
144  return null;
145  }
146 
147 }
static boolean isNotZero(String attribute)
static Object getAttribute(String attribute)
IUserMenu addChild(IUserMenu menu)