LDAPAccountManager/lam/docs/devel/toolsHowTo.htm

145 lines
6.9 KiB
HTML
Raw Normal View History

2014-07-15 18:21:39 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta content="text/html; charset=ISO-8859-15" http-equiv="content-type">
<title>Tools HowTo</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>
<h1 style="text-align: center;">Tools HowTo<br>
</h1>
<div style="text-align: center;"><br>
</div>
<div style="text-align: center;"><br>
<div style="text-align: left;">You can add your own tools easily.
Please follow the following steps to create a custom tool. Tools are
displayed in the tools menu in the upper right corner of LAM.<br>
<br>
<h2>Create tool definition class</h2>
All tools contain a definition class and a separate PHP page that displays the content itself.<br>
First, you need to create a new tool definition class in <span style="font-weight: bold;">lib/tools</span>. The file name does not need to follow any patterns but there must be a class included that implements the <span style="font-weight: bold;">LAMTool</span> interface.<br>
<br>
Example:<br>
<br>
<pre>/**</pre>
<pre>&nbsp;* Server information</pre>
<pre>&nbsp;* </pre>
<pre>&nbsp;* @package tools</pre>
<pre>&nbsp;*/ </pre>
<pre>class toolServerInformation implements LAMTool {</pre>
<pre>&nbsp;&nbsp;&nbsp; </pre>
<pre>&nbsp;&nbsp;&nbsp; /**</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* Returns the name of the tool.</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* </pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* @return string name</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;*/</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;function getName() {</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; return _("Server information");</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;}</pre>
<pre>&nbsp;&nbsp;&nbsp; </pre>
<pre>&nbsp;&nbsp;&nbsp; /**</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* returns a description text for the tool.</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* </pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* @return string description</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;*/</pre>
<pre>&nbsp;&nbsp;&nbsp; function getDescription() {</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return _("Information about the LDAP server.");</pre>
<pre>&nbsp;&nbsp;&nbsp; }</pre>
<pre>&nbsp;&nbsp;&nbsp; </pre>
<pre>&nbsp;&nbsp;&nbsp; /**</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* Returns a link to the tool page (relative to templates/).</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* </pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* @return string link</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;*/</pre>
<pre>&nbsp;&nbsp;&nbsp; function getLink() {</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return "serverInfo.php";</pre>
<pre>&nbsp;&nbsp;&nbsp; }</pre>
<pre>&nbsp;&nbsp;&nbsp; </pre>
<pre>&nbsp;&nbsp;&nbsp; /** </pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* Returns if the tool requires write access to LDAP.</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* </pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* @return boolean true if write access is needed</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;*/</pre>
<pre>&nbsp;&nbsp;&nbsp; function getRequiresWriteAccess() {</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return false;</pre>
<pre>&nbsp;&nbsp;&nbsp; }</pre>
<pre>&nbsp;&nbsp;&nbsp; </pre>
<pre>&nbsp;&nbsp;&nbsp; /**</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* Returns if the tool requires password change rights.</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* </pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* @return boolean true if password change rights are needed</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;*/</pre>
<pre>&nbsp;&nbsp;&nbsp; function getRequiresPasswordChangeRights() {</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return true;</pre>
<pre>&nbsp;&nbsp;&nbsp; }</pre>
<pre>&nbsp;&nbsp;&nbsp; </pre>
<pre>&nbsp;&nbsp;&nbsp; /**</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* Returns the link to the tool image (relative to graphics/)</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;*</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* @return string image URL</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;*/</pre>
<pre>&nbsp;&nbsp;&nbsp; function getImageLink() {</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return 'tree_info.png';</pre>
<pre>&nbsp;&nbsp;&nbsp; }</pre>
<pre>&nbsp;&nbsp;&nbsp; </pre>
<pre>&nbsp;&nbsp;&nbsp; /**</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* Returns the prefered position of this tool on the tools page.</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* The position may be between 0 and 1000. 0 is the top position.</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;*</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* @return int prefered position</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;*/</pre>
<pre>&nbsp;&nbsp;&nbsp; function getPosition() {</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return 600;</pre>
<pre>&nbsp;&nbsp;&nbsp; }</pre>
<pre>&nbsp;&nbsp;&nbsp; </pre>
<pre>&nbsp;&nbsp;&nbsp; /**</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* Returns a list of sub tools or an empty array.</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* </pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* @return array list of subtools (LAMTool)</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;*/</pre>
<pre>&nbsp;&nbsp;&nbsp; function getSubTools() {</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return array();</pre>
<pre>&nbsp;&nbsp;&nbsp; }</pre>
<pre>&nbsp;&nbsp;&nbsp; </pre>
<pre>&nbsp;&nbsp;&nbsp; /**</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* Returns if the tool is visible in the menu.</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;*</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* @return boolean visible</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;*/</pre>
<pre>&nbsp;&nbsp;&nbsp; function isVisible() {</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return true;</pre>
<pre>&nbsp;&nbsp;&nbsp; }</pre>
<pre>&nbsp;&nbsp;&nbsp; </pre>
<pre>&nbsp;&nbsp;&nbsp; /**</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* Returns if a tool may be hidden by configuration in the LAM server profile.</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* </pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;* @return boolean hideable</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;*/</pre>
<pre>&nbsp;&nbsp;&nbsp; function isHideable() {</pre>
<pre>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return true;</pre>
<pre>&nbsp;&nbsp;&nbsp; }</pre>
<pre>&nbsp;&nbsp;&nbsp; </pre>
<pre>}</pre>
The functions are quite self-descriptive.<br>
LAM Pro provides multiple access levels. The functions <span style="font-weight: bold;">getRequiresWriteAccess()/getRequiresPasswordChangeRights()</span> can restrict the visibility of the tool.<br>
<br>
You will also need a logo for your tool. This can be any image in the folder <span style="font-weight: bold;">graphics</span>.<br>
<br>
Sometimes you may want to create a submenu to group multiple tools. This is possible by using the function <span style="font-weight: bold;">getSubTools()</span>. It returns a list of LAMSubTool objects.<br>
<br>
<h2>Create the tool page</h2>
Each tool definition provides the path to its tool page with the function <span style="font-weight: bold;">getLink()</span>. The tool page can be any PHP page inside the directory <span style="font-weight: bold;">templates</span>.<br>
<br>
This is all that you need to create your own tool for LAM. :)<br>
</div>
</div>
</body></html>