wiki:Modules/Core

The Core Class and Module

The core class is special in compare to "normal" modules. It is one of the main utility classes in the whole corinis-framework.

Because of this, the main functions will be discussed here. Remember that they do not behave like normal modules (ie. are not callable by other modules, most ufnctions do not return an xml) but like a normal java class. Because of this, the core class has to be initialized like a normal java class (almost). You might have seen this already a few times, but here it is again. Before you can use the core class make sure oyu have following in your JSP file:

<%@ page language="java" import="corinis.util.*,corinis.*" %> 
<%
   Core core = new Core(pageContext);
%>

the import might consist of more packages, but these two are required for the function described here.

 isLoggedOn()

Checks if the current user is logged on.

Example:

<%
// only show profile link if the user is logged on
if (core.isLoggedOn())
{
%>
   <a href="profile.jsp">Edit your profile</a>
<%
}
%>

 checkAuthority(String)

Checks if the current user has the authority from the given parameter.

You can add/remove custom authorities in the Core administration to be checked by this function. Beware that the Authority is always MODULE_AUTHORITY for all predefined authorities. If you create your own, this convention obviously does not hold any more.

<%
// only allow acces to this pages if the user has the authority to edit his profile - send him pack to the main page if not
if (!core.checkAuthority("PROFILER_MODIFY"))
{
   response.sendRedirect("index.jsp");
   return;
}
%>

 getUserIdbyName(String

Returns the userid of the given name. This function is useful for external modules like the Alerter, where only a username is entered. Can also be used for a usersearch-function.