Skip to content

Commit

Permalink
added option to enter moodle login credentials in admin portlet refs l…
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfien committed Feb 3, 2017
1 parent 6ebbc3b commit 847c0f9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.service.LayoutLocalServiceUtil;
import com.liferay.portal.util.PortalUtil;
Expand All @@ -22,7 +23,9 @@
*/
public class ActivitiesAdminPortlet extends MVCPortlet {

private static final String _moodleServiceEndpoint = "http://localhost";
private static final String _moodleServiceEndpoint = "http://localhost",
_moodleServiceUsername = "test",
_moodleServicePassword = "test";

@Override
public void processAction(ActionRequest actionRequest,
Expand All @@ -37,6 +40,14 @@ public void processAction(ActionRequest actionRequest,
if (!param.equals(StringPool.BLANK))
prefs.setValue("moodle.service.endpoint", param);

param = ParamUtil.getString(actionRequest, "moodleServiceUsername");
if (!param.equals(StringPool.BLANK))
prefs.setValue("moodle.service.username", param);

param = ParamUtil.getString(actionRequest, "moodleServicePassword");
if (!param.equals(StringPool.BLANK))
prefs.setValue("moodle.service.password", param);

prefs.store();
} catch (Exception e) {

Expand All @@ -50,6 +61,15 @@ public static final String getMoodleServiceEndpoint () {
return (result != null ? result : _moodleServiceEndpoint);
}

public static final String getMoodleServiceUsername () {
String result = determinePortletPreferencesValue("moodle.service.username");
return (result != null ? result : _moodleServiceUsername);
}

public static final String getMoodleServicePassword () {
String result = determinePortletPreferencesValue("moodle.service.password");
return (result != null ? result : _moodleServicePassword);
}

private static String determinePortletPreferencesValue(String key) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

<aui:form action="<%= configurationURL %>" method="post" name="fm">

<aui:input name="moodleServiceEndpoint" label="Moodle Service Endpoint" value="<%= ActivitiesAdminPortlet.getMoodleServiceEndpoint() %>"/>
<aui:input name="moodleServiceEndpoint" label="Moodle Service Endpoint" value="<%= ActivitiesAdminPortlet.getMoodleServiceEndpoint() %>"/>
<aui:input name="moodleServiceUsername" label="Moodle Service Username" value="<%= ActivitiesAdminPortlet.getMoodleServiceUsername() %>"/>
<aui:input name="moodleServicePassword" label="Moodle Service Password" value="<%= ActivitiesAdminPortlet.getMoodleServicePassword() %>" type="password"/>

<aui:button-row>
<aui:button type="submit" />
Expand Down

0 comments on commit 847c0f9

Please sign in to comment.