fix for can_manage()

This commit is contained in:
Roland Gruber 2014-07-12 14:12:19 +00:00
parent 1129cbce33
commit 4413d34f29
2 changed files with 25 additions and 43 deletions

View File

@ -1,11 +1,10 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Module HowTo - Basic concepts</title>
<html><head><title>Module HowTo - Basic concepts</title>
<link rel="stylesheet" type="text/css" href="style/layout.css">
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico">
</head>
<body>
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"></head><body>
<div style="text-align: center;">
<h1>Module HowTo - Basic concepts<br>
</h1>
@ -23,8 +22,7 @@ LAM is distributed with a copy of the GPL license.<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
configuration dialog, on all other pages LAM will show a provided <span
style="font-style: italic;">alias</span> name.<br>
configuration dialog, on all other pages LAM will show a provided <span style="font-style: italic;">alias</span> name.<br>
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>
@ -32,9 +30,7 @@ and the file must have the same name as its inside class.<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>,
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>
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>
<br>
<br>
<h2>3. Defining the class</h2>
@ -44,8 +40,7 @@ for all required class functions.<br>
<br>
<span style="font-weight: bold;">Example:</span><br>
<br>
<table style="width: 100%; text-align: left;" class="mod-code"
border="0" cellpadding="2" cellspacing="2">
<table style="width: 100%; text-align: left;" class="mod-code" border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top;">/**<br>
@ -54,8 +49,7 @@ for all required class functions.<br>
* @package modules<br>
*/<span style="font-weight: bold;"><br>
class</span> <span style="color: rgb(255, 0, 0);">ieee802Device</span>
<span style="font-style: italic;">extends </span><span
style="font-weight: bold;">baseModule</span> {<br>
<span style="font-style: italic;">extends </span><span style="font-weight: bold;">baseModule</span> {<br>
<br>
}<br>
</td>
@ -72,14 +66,11 @@ 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>
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>
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>
<br>
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br>
<br>
<table style="width: 100%; text-align: left;" class="mod-code"
border="0" cellpadding="2" cellspacing="2">
<table style="width: 100%; text-align: left;" class="mod-code" border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top;">&nbsp;&nbsp;&nbsp; /**<br>
@ -88,12 +79,10 @@ class<br>
&nbsp;&nbsp;&nbsp; *<br>
&nbsp;&nbsp;&nbsp; * @return array array with meta data<br>
&nbsp;&nbsp;&nbsp; */<br>
&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span> <span
style="color: rgb(255, 0, 0);">get_metaData</span>() {<br>
&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span> <span style="color: rgb(255, 0, 0);">get_metaData</span>() {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return = array();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // manages host accounts<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return["account_types"] =
array("host");<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // icon<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return['icon'] = 'user.png';<br>
&nbsp;&nbsp;&nbsp; }<br>
</td>
</tr>
@ -106,5 +95,4 @@ HowTo.<br>
<h2><span style="font-weight: bold;"></span></h2>
</div>
</div>
</body>
</html>
</body></html>

View File

@ -2,9 +2,10 @@
<html><head><title>Module HowTo - General module options</title>
<link rel="stylesheet" type="text/css" href="style/layout.css"></head><body>
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico">
<link rel="stylesheet" type="text/css" href="style/layout.css"><link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"></head><body>
<div style="text-align: center;">
<h1>Module HowTo - General module options<br>
</h1>
@ -13,11 +14,10 @@
<div style="text-align: left;"><br>
<h2>1. Account types<br>
</h2>
LAM currently provides three account types: <span style="font-weight: bold;">users, groups, hosts<br>
LAM provides multiple account types (e.g. users, groups, hosts).<span style="font-weight: bold;"><br>
</span>A module can manage one or more account types.<br>
<br>
The types are specified with <span style="font-weight: bold;">can_manage()</span>
or <span style="font-weight: bold;">meta['account_types']</span>.<br>
The types are specified with <span style="font-weight: bold;">can_manage()</span>.<br>
<br>
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;">
<br>
@ -28,18 +28,12 @@ module will be used only for host accounts.<br>
<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; * Returns true if this module can manage accounts of the current type, otherwise false.<br>
&nbsp;&nbsp;&nbsp; * <br>
&nbsp;&nbsp;&nbsp; * @return boolean true if module fits<br>
&nbsp;&nbsp;&nbsp; */<br>
&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span>
get_metaData() {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return = array();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // manages host accounts<br>
<span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; $return["account_types"] = array("host");</span><br style="color: rgb(255, 0, 0);">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return $return;<br>
&nbsp;&nbsp;&nbsp; public function <span style="color: red;">can_manage()</span> {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return $this-&gt;get_scope() == 'host';<br>
&nbsp;&nbsp;&nbsp; }<br>
</td>
</tr>