1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
<!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> * Server information</pre>
<pre> * </pre>
<pre> * @package tools</pre>
<pre> */ </pre>
<pre>class toolServerInformation implements LAMTool {</pre>
<pre> </pre>
<pre> /**</pre>
<pre> * Returns the name of the tool.</pre>
<pre> * </pre>
<pre> * @return string name</pre>
<pre> */</pre>
<pre> function getName() {</pre>
<pre> return _("Server information");</pre>
<pre> }</pre>
<pre> </pre>
<pre> /**</pre>
<pre> * returns a description text for the tool.</pre>
<pre> * </pre>
<pre> * @return string description</pre>
<pre> */</pre>
<pre> function getDescription() {</pre>
<pre> return _("Information about the LDAP server.");</pre>
<pre> }</pre>
<pre> </pre>
<pre> /**</pre>
<pre> * Returns a link to the tool page (relative to templates/).</pre>
<pre> * </pre>
<pre> * @return string link</pre>
<pre> */</pre>
<pre> function getLink() {</pre>
<pre> return "serverInfo.php";</pre>
<pre> }</pre>
<pre> </pre>
<pre> /** </pre>
<pre> * Returns if the tool requires write access to LDAP.</pre>
<pre> * </pre>
<pre> * @return boolean true if write access is needed</pre>
<pre> */</pre>
<pre> function getRequiresWriteAccess() {</pre>
<pre> return false;</pre>
<pre> }</pre>
<pre> </pre>
<pre> /**</pre>
<pre> * Returns if the tool requires password change rights.</pre>
<pre> * </pre>
<pre> * @return boolean true if password change rights are needed</pre>
<pre> */</pre>
<pre> function getRequiresPasswordChangeRights() {</pre>
<pre> return true;</pre>
<pre> }</pre>
<pre> </pre>
<pre> /**</pre>
<pre> * Returns the link to the tool image (relative to graphics/)</pre>
<pre> *</pre>
<pre> * @return string image URL</pre>
<pre> */</pre>
<pre> function getImageLink() {</pre>
<pre> return 'tree_info.png';</pre>
<pre> }</pre>
<pre> </pre>
<pre> /**</pre>
<pre> * Returns the preferred position of this tool on the tools page.</pre>
<pre> * The position may be between 0 and 1000. 0 is the top position.</pre>
<pre> *</pre>
<pre> * @return int preferred position</pre>
<pre> */</pre>
<pre> function getPosition() {</pre>
<pre> return 600;</pre>
<pre> }</pre>
<pre> </pre>
<pre> /**</pre>
<pre> * Returns a list of sub tools or an empty array.</pre>
<pre> * </pre>
<pre> * @return array list of subtools (LAMTool)</pre>
<pre> */</pre>
<pre> function getSubTools() {</pre>
<pre> return array();</pre>
<pre> }</pre>
<pre> </pre>
<pre> /**</pre>
<pre> * Returns if the tool is visible in the menu.</pre>
<pre> *</pre>
<pre> * @return boolean visible</pre>
<pre> */</pre>
<pre> function isVisible() {</pre>
<pre> return true;</pre>
<pre> }</pre>
<pre> </pre>
<pre> /**</pre>
<pre> * Returns if a tool may be hidden by configuration in the LAM server profile.</pre>
<pre> * </pre>
<pre> * @return boolean hideable</pre>
<pre> */</pre>
<pre> function isHideable() {</pre>
<pre> return true;</pre>
<pre> }</pre>
<pre> </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>
|