LDAPAccountManager/lam/docs/devel/mod_basics.htm

98 lines
4.1 KiB
HTML
Raw Permalink Normal View History

2004-11-01 13:56:54 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2014-07-12 14:12:19 +00:00
<html><head><title>Module HowTo - Basic concepts</title>
2004-11-01 13:56:54 +00:00
<link rel="stylesheet" type="text/css" href="style/layout.css">
2014-07-12 14:12:19 +00:00
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"></head><body>
2004-11-01 13:56:54 +00:00
<div style="text-align: center;">
<h1>Module HowTo - Basic concepts<br>
</h1>
<br>
<br>
<div style="text-align: left;"><br>
<h2>1. Licensing</h2>
LAM is licensed under the <a href="http://www.gnu.org/licenses/gpl.txt">GNU
General Public License</a>. This means your plugins need a compatible
license.<br>
LAM is distributed with a copy of the GPL license.<br>
<br>
<h2>2. Naming and position in directory structure</h2>
<br>
Module names are usually named after the object class they manage.
However, you can use any name you want, it should be short and
containing only a-z and 0-9. The module name is only shown in the
2014-07-12 14:12:19 +00:00
configuration dialog, on all other pages LAM will show a provided <span style="font-style: italic;">alias</span> name.<br>
2004-11-01 13:56:54 +00:00
All account modules are stored in <span style="font-weight: bold;">lib/modules</span>.
The filename must end with <span style="font-weight: bold;">.inc</span>
and the file must have the same name as its inside class.<br>
<br>
<span style="font-weight: bold; text-decoration: underline;">Example:</span>
Our example module will provide the <span style="font-weight: bold;">class
ieee802Devic</span><span style="font-style: italic; font-weight: bold;">e</span>,
2014-07-12 14:12:19 +00:00
therefore the file will be called <span style="font-weight: bold;">lib/modules/ieee802Devic</span><span style="font-style: italic; font-weight: bold;">e.inc</span>.<span style="font-style: italic;"></span><br>
2004-11-01 13:56:54 +00:00
<br>
<br>
<h2>3. Defining the class</h2>
2009-11-02 17:36:20 +00:00
All module classes have <span style="font-weight: bold;">baseModule</span>
2004-11-01 13:56:54 +00:00
as parent class. This provides common functionality and dummy functions
for all required class functions.<br>
<br>
<span style="font-weight: bold;">Example:</span><br>
<br>
2014-07-12 14:12:19 +00:00
<table style="width: 100%; text-align: left;" class="mod-code" border="0" cellpadding="2" cellspacing="2">
2004-11-01 13:56:54 +00:00
<tbody>
<tr>
<td style="vertical-align: top;">/**<br>
* Provides MAC addresses for hosts.<br>
*<br>
* @package modules<br>
*/<span style="font-weight: bold;"><br>
class</span> <span style="color: rgb(255, 0, 0);">ieee802Device</span>
2014-07-12 14:12:19 +00:00
<span style="font-style: italic;">extends </span><span style="font-weight: bold;">baseModule</span> {<br>
2004-11-01 13:56:54 +00:00
<br>
}<br>
</td>
</tr>
</tbody>
</table>
<br>
<h2>4. Meta data</h2>
2020-03-03 19:54:24 +00:00
The module interface includes a lot of required and optional functions.
2004-11-01 13:56:54 +00:00
Many of these functions do not need to be implemented directly in the
module, you can define <span style="font-weight: bold;">meta data</span>
for them and the <span style="font-weight: bold;">baseModule</span>
will do the rest.<br>
Providing <span style="font-weight: bold;">meta data</span> is
optional, you can implement the required functions in your class, too.<br>
<br>
2014-07-12 14:12:19 +00:00
The <span style="font-weight: bold;">baseModule</span> reads the <span style="font-weight: bold;">meta data</span> by calling <span style="font-weight: bold;">get_metaData()</span> in your class.<br>
2004-11-01 13:56:54 +00:00
<br>
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br>
<br>
2014-07-12 14:12:19 +00:00
<table style="width: 100%; text-align: left;" class="mod-code" border="0" cellpadding="2" cellspacing="2">
2004-11-01 13:56:54 +00:00
<tbody>
<tr>
<td style="vertical-align: top;">&nbsp;&nbsp;&nbsp; /**<br>
&nbsp;&nbsp;&nbsp; * Returns meta data that is interpreted by parent
class<br>
&nbsp;&nbsp;&nbsp; *<br>
&nbsp;&nbsp;&nbsp; * @return array array with meta data<br>
&nbsp;&nbsp;&nbsp; */<br>
2014-07-12 14:12:19 +00:00
&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span> <span style="color: rgb(255, 0, 0);">get_metaData</span>() {<br>
2004-11-01 13:56:54 +00:00
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return = array();<br>
2014-07-12 14:12:19 +00:00
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // icon<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return['icon'] = 'user.png';<br>
2004-11-01 13:56:54 +00:00
&nbsp;&nbsp;&nbsp; }<br>
</td>
</tr>
</tbody>
</table>
<br>
You will see this functions several times in the next parts of this
HowTo.<br>
<br>
<h2><span style="font-weight: bold;"></span></h2>
</div>
</div>
2014-07-12 14:12:19 +00:00
</body></html>