Author: solomax
Date: Tue Apr  5 04:04:39 2016
New Revision: 1737761

URL: http://svn.apache.org/viewvc?rev=1737761&view=rev
Log:
[OPENMEETINGS-853] admin widget is added

Added:
    
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidget.java
    
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetDescriptor.java
    
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.html
    
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.java
    
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidget.java
    
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetDescriptor.java
    
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.html
    
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.java
Modified:
    
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
    
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.properties.xml
    
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
    
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/util/UserDashboard.java
    
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
    
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.properties.xml
    
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
    
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/util/UserDashboard.java

Modified: 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java?rev=1737761&r1=1737760&r2=1737761&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
 (original)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
 Tue Apr  5 04:04:39 2016
@@ -61,6 +61,7 @@ import org.apache.openmeetings.web.pages
 import org.apache.openmeetings.web.pages.SwfPage;
 import org.apache.openmeetings.web.pages.auth.SignInPage;
 import org.apache.openmeetings.web.pages.install.InstallWizardPage;
+import org.apache.openmeetings.web.user.dashboard.AdminWidgetDescriptor;
 import org.apache.openmeetings.web.user.dashboard.MyRoomsWidgetDescriptor;
 import org.apache.openmeetings.web.user.dashboard.RssWidgetDescriptor;
 import org.apache.openmeetings.web.user.dashboard.StartWidgetDescriptor;
@@ -137,6 +138,7 @@ public class Application extends Authent
                widgetRegistry.registerWidget(new WelcomeWidgetDescriptor());
                widgetRegistry.registerWidget(new StartWidgetDescriptor());
                widgetRegistry.registerWidget(new RssWidgetDescriptor());
+               widgetRegistry.registerWidget(new AdminWidgetDescriptor());
                // add dashboard context injector
                getComponentInstantiationListeners().add(new 
DashboardContextInjector(dashboardContext));
                DashboardSettings dashboardSettings = DashboardSettings.get();

Modified: 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.properties.xml
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.properties.xml?rev=1737761&r1=1737760&r2=1737761&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.properties.xml
 (original)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.properties.xml
 Tue Apr  5 04:04:39 2016
@@ -1890,4 +1890,6 @@
        <entry key="admin.email.errorCount">Error Count</entry>
        <entry key="admin.email.lastError">Last Error</entry>
        <entry key="admin.email.reset.status">Reset Status</entry>
+       <entry key="dashboard.widget.admin.title">Admin functions</entry>
+       <entry key="dashboard.widget.admin.desc">General Admin functions</entry>
 </properties>

Modified: 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java?rev=1737761&r1=1737760&r2=1737761&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
 (original)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
 Tue Apr  5 04:04:39 2016
@@ -61,6 +61,8 @@ import org.apache.openmeetings.db.entity
 import org.apache.openmeetings.db.util.TimezoneUtil;
 import org.apache.openmeetings.util.OmException;
 import org.apache.openmeetings.web.pages.SwfPage;
+import org.apache.openmeetings.web.user.dashboard.AdminWidget;
+import org.apache.openmeetings.web.user.dashboard.AdminWidgetDescriptor;
 import org.apache.openmeetings.web.user.dashboard.MyRoomsWidget;
 import org.apache.openmeetings.web.user.dashboard.MyRoomsWidgetDescriptor;
 import org.apache.openmeetings.web.user.dashboard.RssWidget;
@@ -243,7 +245,7 @@ public class WebSession extends Abstract
                externalType = u.getExternalType();
                tz = getBean(TimezoneUtil.class).getTimeZone(u);
                ISO8601FORMAT.setTimeZone(tz);
-               setLocale(languageId == 3 ? Locale.GERMANY : 
LabelDao.languages.get(languageId)); //FIXME hack
+               setLocale(languageId == 3 ? Locale.GERMANY : 
LabelDao.languages.get(languageId));
                //FIXMW locale need to be set by User language first
                sdf = DateFormat.getDateTimeInstance(SHORT, SHORT, getLocale());
                if (null == getId()) {
@@ -440,10 +442,11 @@ public class WebSession extends Abstract
        private void initDashboard() {
                DashboardContext dashboardContext = getDashboardContext();
                dashboard = 
(UserDashboard)dashboardContext.getDashboardPersister().load();
-               boolean existMyRoomWidget = false, existRssWidget = false;
+               boolean existMyRoomWidget = false, existRssWidget = false, 
existAdminWidget = false;
                ConfigurationDao cfgDao = getBean(ConfigurationDao.class);
                boolean showMyRoomConfValue = 1 == 
cfgDao.getConfValue(CONFIG_DASHBOARD_SHOW_MYROOMS_KEY, Integer.class, "0");
                boolean showRssConfValue = 1 == 
cfgDao.getConfValue(CONFIG_DASHBOARD_SHOW_RSS_KEY, Integer.class, "0");
+               boolean showAdminWidget = 
getRights().contains(User.Right.Admin);
                boolean save = false;
 
                WidgetFactory widgetFactory = 
dashboardContext.getWidgetFactory();
@@ -459,6 +462,9 @@ public class WebSession extends Abstract
                        if (showRssConfValue) {
                                
dashboard.addWidget(widgetFactory.createWidget(new RssWidgetDescriptor()));
                        }
+                       if (showAdminWidget) {
+                               
dashboard.addWidget(widgetFactory.createWidget(new AdminWidgetDescriptor()));
+                       }
                        save = true;
                } else {
                        for (Iterator<Widget> iter = 
dashboard.getWidgets().iterator(); iter.hasNext();) {
@@ -475,6 +481,12 @@ public class WebSession extends Abstract
                                        if (!showRssConfValue) {
                                                iter.remove();
                                        }
+                               } else if 
((w.getClass().equals(AdminWidget.class))) {
+                                       // AdminWidget is stored in the profile 
of user. check if user is admin.
+                                       existAdminWidget = true;
+                                       if (!showAdminWidget) {
+                                               iter.remove();
+                                       }
                                } else {
                                        w.init();
                                }
@@ -489,6 +501,11 @@ public class WebSession extends Abstract
                                
dashboard.addWidget(widgetFactory.createWidget(new RssWidgetDescriptor()));
                                save = true;
                        }
+                       // user had no admin rights, now he/she has.
+                       if (!existAdminWidget && showAdminWidget && 
!dashboard.isWidgetAdminDeleted()) {
+                               
dashboard.addWidget(widgetFactory.createWidget(new AdminWidgetDescriptor()));
+                               save = true;
+                       }
                }
                if (save) {
                        
dashboardContext.getDashboardPersister().save(dashboard);

Added: 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidget.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidget.java?rev=1737761&view=auto
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidget.java
 (added)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidget.java
 Tue Apr  5 04:04:39 2016
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.web.user.dashboard;
+
+import org.apache.openmeetings.web.app.Application;
+import org.apache.wicket.model.Model;
+
+import ro.fortsoft.wicket.dashboard.AbstractWidget;
+import ro.fortsoft.wicket.dashboard.Widget;
+import ro.fortsoft.wicket.dashboard.WidgetLocation;
+import ro.fortsoft.wicket.dashboard.web.WidgetView;
+
+public class AdminWidget extends AbstractWidget {
+       private static final long serialVersionUID = 1L;
+       public static final String WIDGET_ID_ADMIN = "AdminWidget";
+
+       public AdminWidget() {
+               super();
+               location = new WidgetLocation(0, 2);
+               init();
+       }
+       
+       @Override
+       public void init() {
+               super.init();
+               title = Application.getString("dashboard.widget.admin.title");
+               id = WIDGET_ID_ADMIN;
+       }
+       
+       @Override
+       public WidgetView createView(String viewId) {
+               return new AdminWidgetView(viewId, new Model<Widget>(this));
+       }
+}

Added: 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetDescriptor.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetDescriptor.java?rev=1737761&view=auto
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetDescriptor.java
 (added)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetDescriptor.java
 Tue Apr  5 04:04:39 2016
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.web.user.dashboard;
+
+import org.apache.openmeetings.web.app.Application;
+
+import ro.fortsoft.wicket.dashboard.WidgetDescriptor;
+
+public class AdminWidgetDescriptor implements WidgetDescriptor {
+       private static final long serialVersionUID = 1L;
+
+       @Override
+       public String getName() {
+               return Application.getString("dashboard.widget.admin.title");
+       }
+
+       @Override
+       public String getProvider() {
+               return "Apache Openmeetings";
+       }
+
+       @Override
+       public String getDescription() {
+               return Application.getString("dashboard.widget.admin.desc");
+       }
+
+       @Override
+       public String getWidgetClassName() {
+               return AdminWidget.class.getName();
+       }
+
+       @Override
+       public String getTypeName() {
+               return "om.widget.admin";
+       }
+}

Added: 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.html
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.html?rev=1737761&view=auto
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.html
 (added)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.html
 Tue Apr  5 04:04:39 2016
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+      http://www.apache.org/licenses/LICENSE-2.0
+         
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  
+-->
+<html xmlns:wicket="http://wicket.apache.org";>
+<wicket:panel>
+       <h3><wicket:message key="dashboard.widget.admin.title"/></h3>
+</wicket:panel>
+</html>

Added: 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.java?rev=1737761&view=auto
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.java
 (added)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.java
 Tue Apr  5 04:04:39 2016
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.web.user.dashboard;
+
+import org.apache.wicket.model.Model;
+
+import ro.fortsoft.wicket.dashboard.Widget;
+import ro.fortsoft.wicket.dashboard.web.WidgetView;
+
+public class AdminWidgetView extends WidgetView {
+       private static final long serialVersionUID = 1L;
+
+       public AdminWidgetView(String id, Model<Widget> model) {
+               super(id, model);
+       }
+}

Modified: 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/util/UserDashboard.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/util/UserDashboard.java?rev=1737761&r1=1737760&r2=1737761&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/util/UserDashboard.java
 (original)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/util/UserDashboard.java
 Tue Apr  5 04:04:39 2016
@@ -20,6 +20,7 @@ package org.apache.openmeetings.web.util
 
 import static 
org.apache.openmeetings.web.user.dashboard.MyRoomsWidget.WIDGET_ID_MY_ROOMS;
 import static 
org.apache.openmeetings.web.user.dashboard.RssWidget.WIDGET_ID_RSS;
+import static 
org.apache.openmeetings.web.user.dashboard.AdminWidget.WIDGET_ID_ADMIN;
 import ro.fortsoft.wicket.dashboard.DefaultDashboard;
 import ro.fortsoft.wicket.dashboard.Widget;
 
@@ -27,6 +28,7 @@ public class UserDashboard extends Defau
        private static final long serialVersionUID = 1L;
        private boolean widgetRssDeleted = false;
        private boolean widgetMyRoomsDeleted = false;
+       private boolean widgetAdminDeleted = false;
        
        public UserDashboard(String id, String title) {
                super(id, title);
@@ -47,6 +49,14 @@ public class UserDashboard extends Defau
        public void setWidgetMyRoomsDeleted(boolean widgetMyRoomsDeleted) {
                this.widgetMyRoomsDeleted = widgetMyRoomsDeleted;
        }
+
+       public boolean isWidgetAdminDeleted() {
+               return widgetAdminDeleted;
+       }
+
+       public void setWidgetAdminDeleted(boolean widgetAdminDeleted) {
+               this.widgetAdminDeleted = widgetAdminDeleted;
+       }
        
        @Override
        public void deleteWidget(String widgetId) {
@@ -57,6 +67,9 @@ public class UserDashboard extends Defau
                        case WIDGET_ID_MY_ROOMS:
                                widgetMyRoomsDeleted = true;
                                break;
+                       case WIDGET_ID_ADMIN:
+                               widgetAdminDeleted = true;
+                               break;
                        default:
                                break;
                }
@@ -72,6 +85,9 @@ public class UserDashboard extends Defau
                        case WIDGET_ID_MY_ROOMS:
                                widgetMyRoomsDeleted = false;
                                break;
+                       case WIDGET_ID_ADMIN:
+                               widgetAdminDeleted = false;
+                               break;
                        default:
                                break;
                }

Modified: 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java?rev=1737761&r1=1737760&r2=1737761&view=diff
==============================================================================
--- 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
 (original)
+++ 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
 Tue Apr  5 04:04:39 2016
@@ -61,6 +61,7 @@ import org.apache.openmeetings.web.pages
 import org.apache.openmeetings.web.pages.SwfPage;
 import org.apache.openmeetings.web.pages.auth.SignInPage;
 import org.apache.openmeetings.web.pages.install.InstallWizardPage;
+import org.apache.openmeetings.web.user.dashboard.AdminWidgetDescriptor;
 import org.apache.openmeetings.web.user.dashboard.MyRoomsWidgetDescriptor;
 import org.apache.openmeetings.web.user.dashboard.RssWidgetDescriptor;
 import org.apache.openmeetings.web.user.dashboard.StartWidgetDescriptor;
@@ -137,6 +138,7 @@ public class Application extends Authent
                widgetRegistry.registerWidget(new WelcomeWidgetDescriptor());
                widgetRegistry.registerWidget(new StartWidgetDescriptor());
                widgetRegistry.registerWidget(new RssWidgetDescriptor());
+               widgetRegistry.registerWidget(new AdminWidgetDescriptor());
                // add dashboard context injector
                getComponentInstantiationListeners().add(new 
DashboardContextInjector(dashboardContext));
                DashboardSettings dashboardSettings = DashboardSettings.get();

Modified: 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.properties.xml
URL: 
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.properties.xml?rev=1737761&r1=1737760&r2=1737761&view=diff
==============================================================================
--- 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.properties.xml
 (original)
+++ 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.properties.xml
 Tue Apr  5 04:04:39 2016
@@ -1890,4 +1890,6 @@
        <entry key="admin.email.errorCount">Error Count</entry>
        <entry key="admin.email.lastError">Last Error</entry>
        <entry key="admin.email.reset.status">Reset Status</entry>
+       <entry key="dashboard.widget.admin.title">Admin functions</entry>
+       <entry key="dashboard.widget.admin.desc">General Admin functions</entry>
 </properties>

Modified: 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java?rev=1737761&r1=1737760&r2=1737761&view=diff
==============================================================================
--- 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
 (original)
+++ 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
 Tue Apr  5 04:04:39 2016
@@ -61,6 +61,8 @@ import org.apache.openmeetings.db.entity
 import org.apache.openmeetings.db.util.TimezoneUtil;
 import org.apache.openmeetings.util.OmException;
 import org.apache.openmeetings.web.pages.SwfPage;
+import org.apache.openmeetings.web.user.dashboard.AdminWidget;
+import org.apache.openmeetings.web.user.dashboard.AdminWidgetDescriptor;
 import org.apache.openmeetings.web.user.dashboard.MyRoomsWidget;
 import org.apache.openmeetings.web.user.dashboard.MyRoomsWidgetDescriptor;
 import org.apache.openmeetings.web.user.dashboard.RssWidget;
@@ -243,7 +245,7 @@ public class WebSession extends Abstract
                externalType = u.getExternalType();
                tz = getBean(TimezoneUtil.class).getTimeZone(u);
                ISO8601FORMAT.setTimeZone(tz);
-               setLocale(languageId == 3 ? Locale.GERMANY : 
LabelDao.languages.get(languageId)); //FIXME hack
+               setLocale(languageId == 3 ? Locale.GERMANY : 
LabelDao.languages.get(languageId));
                //FIXMW locale need to be set by User language first
                sdf = DateFormat.getDateTimeInstance(SHORT, SHORT, getLocale());
                if (null == getId()) {
@@ -440,10 +442,11 @@ public class WebSession extends Abstract
        private void initDashboard() {
                DashboardContext dashboardContext = getDashboardContext();
                dashboard = 
(UserDashboard)dashboardContext.getDashboardPersister().load();
-               boolean existMyRoomWidget = false, existRssWidget = false;
+               boolean existMyRoomWidget = false, existRssWidget = false, 
existAdminWidget = false;
                ConfigurationDao cfgDao = getBean(ConfigurationDao.class);
                boolean showMyRoomConfValue = 1 == 
cfgDao.getConfValue(CONFIG_DASHBOARD_SHOW_MYROOMS_KEY, Integer.class, "0");
                boolean showRssConfValue = 1 == 
cfgDao.getConfValue(CONFIG_DASHBOARD_SHOW_RSS_KEY, Integer.class, "0");
+               boolean showAdminWidget = 
getRights().contains(User.Right.Admin);
                boolean save = false;
 
                WidgetFactory widgetFactory = 
dashboardContext.getWidgetFactory();
@@ -459,6 +462,9 @@ public class WebSession extends Abstract
                        if (showRssConfValue) {
                                
dashboard.addWidget(widgetFactory.createWidget(new RssWidgetDescriptor()));
                        }
+                       if (showAdminWidget) {
+                               
dashboard.addWidget(widgetFactory.createWidget(new AdminWidgetDescriptor()));
+                       }
                        save = true;
                } else {
                        for (Iterator<Widget> iter = 
dashboard.getWidgets().iterator(); iter.hasNext();) {
@@ -475,6 +481,12 @@ public class WebSession extends Abstract
                                        if (!showRssConfValue) {
                                                iter.remove();
                                        }
+                               } else if 
((w.getClass().equals(AdminWidget.class))) {
+                                       // AdminWidget is stored in the profile 
of user. check if user is admin.
+                                       existAdminWidget = true;
+                                       if (!showAdminWidget) {
+                                               iter.remove();
+                                       }
                                } else {
                                        w.init();
                                }
@@ -489,6 +501,11 @@ public class WebSession extends Abstract
                                
dashboard.addWidget(widgetFactory.createWidget(new RssWidgetDescriptor()));
                                save = true;
                        }
+                       // user had no admin rights, now he/she has.
+                       if (!existAdminWidget && showAdminWidget && 
!dashboard.isWidgetAdminDeleted()) {
+                               
dashboard.addWidget(widgetFactory.createWidget(new AdminWidgetDescriptor()));
+                               save = true;
+                       }
                }
                if (save) {
                        
dashboardContext.getDashboardPersister().save(dashboard);

Added: 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidget.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidget.java?rev=1737761&view=auto
==============================================================================
--- 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidget.java
 (added)
+++ 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidget.java
 Tue Apr  5 04:04:39 2016
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.web.user.dashboard;
+
+import org.apache.openmeetings.web.app.Application;
+import org.apache.wicket.model.Model;
+
+import ro.fortsoft.wicket.dashboard.AbstractWidget;
+import ro.fortsoft.wicket.dashboard.Widget;
+import ro.fortsoft.wicket.dashboard.WidgetLocation;
+import ro.fortsoft.wicket.dashboard.web.WidgetView;
+
+public class AdminWidget extends AbstractWidget {
+       private static final long serialVersionUID = 1L;
+       public static final String WIDGET_ID_ADMIN = "AdminWidget";
+
+       public AdminWidget() {
+               super();
+               location = new WidgetLocation(0, 2);
+               init();
+       }
+       
+       @Override
+       public void init() {
+               super.init();
+               title = Application.getString("dashboard.widget.admin.title");
+               id = WIDGET_ID_ADMIN;
+       }
+       
+       @Override
+       public WidgetView createView(String viewId) {
+               return new AdminWidgetView(viewId, new Model<Widget>(this));
+       }
+}

Added: 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetDescriptor.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetDescriptor.java?rev=1737761&view=auto
==============================================================================
--- 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetDescriptor.java
 (added)
+++ 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetDescriptor.java
 Tue Apr  5 04:04:39 2016
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.web.user.dashboard;
+
+import org.apache.openmeetings.web.app.Application;
+
+import ro.fortsoft.wicket.dashboard.WidgetDescriptor;
+
+public class AdminWidgetDescriptor implements WidgetDescriptor {
+       private static final long serialVersionUID = 1L;
+
+       @Override
+       public String getName() {
+               return Application.getString("dashboard.widget.admin.title");
+       }
+
+       @Override
+       public String getProvider() {
+               return "Apache Openmeetings";
+       }
+
+       @Override
+       public String getDescription() {
+               return Application.getString("dashboard.widget.admin.desc");
+       }
+
+       @Override
+       public String getWidgetClassName() {
+               return AdminWidget.class.getName();
+       }
+
+       @Override
+       public String getTypeName() {
+               return "om.widget.admin";
+       }
+}

Added: 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.html
URL: 
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.html?rev=1737761&view=auto
==============================================================================
--- 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.html
 (added)
+++ 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.html
 Tue Apr  5 04:04:39 2016
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+      http://www.apache.org/licenses/LICENSE-2.0
+         
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  
+-->
+<html xmlns:wicket="http://wicket.apache.org";>
+<wicket:panel>
+       <h3><wicket:message key="dashboard.widget.admin.title"/></h3>
+</wicket:panel>
+</html>

Added: 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.java?rev=1737761&view=auto
==============================================================================
--- 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.java
 (added)
+++ 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/AdminWidgetView.java
 Tue Apr  5 04:04:39 2016
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") +  you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.web.user.dashboard;
+
+import org.apache.wicket.model.Model;
+
+import ro.fortsoft.wicket.dashboard.Widget;
+import ro.fortsoft.wicket.dashboard.web.WidgetView;
+
+public class AdminWidgetView extends WidgetView {
+       private static final long serialVersionUID = 1L;
+
+       public AdminWidgetView(String id, Model<Widget> model) {
+               super(id, model);
+       }
+}

Modified: 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/util/UserDashboard.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/util/UserDashboard.java?rev=1737761&r1=1737760&r2=1737761&view=diff
==============================================================================
--- 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/util/UserDashboard.java
 (original)
+++ 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/util/UserDashboard.java
 Tue Apr  5 04:04:39 2016
@@ -20,6 +20,7 @@ package org.apache.openmeetings.web.util
 
 import static 
org.apache.openmeetings.web.user.dashboard.MyRoomsWidget.WIDGET_ID_MY_ROOMS;
 import static 
org.apache.openmeetings.web.user.dashboard.RssWidget.WIDGET_ID_RSS;
+import static 
org.apache.openmeetings.web.user.dashboard.AdminWidget.WIDGET_ID_ADMIN;
 import ro.fortsoft.wicket.dashboard.DefaultDashboard;
 import ro.fortsoft.wicket.dashboard.Widget;
 
@@ -27,6 +28,7 @@ public class UserDashboard extends Defau
        private static final long serialVersionUID = 1L;
        private boolean widgetRssDeleted = false;
        private boolean widgetMyRoomsDeleted = false;
+       private boolean widgetAdminDeleted = false;
        
        public UserDashboard(String id, String title) {
                super(id, title);
@@ -48,6 +50,14 @@ public class UserDashboard extends Defau
                this.widgetMyRoomsDeleted = widgetMyRoomsDeleted;
        }
        
+       public boolean isWidgetAdminDeleted() {
+               return widgetAdminDeleted;
+       }
+
+       public void setWidgetAdminDeleted(boolean widgetAdminDeleted) {
+               this.widgetAdminDeleted = widgetAdminDeleted;
+       }
+       
        @Override
        public void deleteWidget(String widgetId) {
                switch (widgetId) {
@@ -57,6 +67,9 @@ public class UserDashboard extends Defau
                        case WIDGET_ID_MY_ROOMS:
                                widgetMyRoomsDeleted = true;
                                break;
+                       case WIDGET_ID_ADMIN:
+                               widgetAdminDeleted = true;
+                               break;
                        default:
                                break;
                }
@@ -72,6 +85,9 @@ public class UserDashboard extends Defau
                        case WIDGET_ID_MY_ROOMS:
                                widgetMyRoomsDeleted = false;
                                break;
+                       case WIDGET_ID_ADMIN:
+                               widgetAdminDeleted = false;
+                               break;
                        default:
                                break;
                }


Reply via email to