File: toolsHowTo.htm

package info (click to toggle)
ldap-account-manager 8.3-1
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 103,380 kB
  • sloc: php: 249,996; javascript: 154,941; pascal: 38,010; perl: 414; xml: 252; sh: 195; makefile: 184
file content (145 lines) | stat: -rw-r--r-- 7,070 bytes parent folder | download | duplicates (3)
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>&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 preferred 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 preferred 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>