| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 | <html lang="en"><head><title>Module HowTo - General module options</title> |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | <link rel="stylesheet" type="text/css" href="style/layout.css"><link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"></head><body> |
| 8 | |
| 9 | <div style="text-align: center;"> |
| 10 | <h1>Module HowTo - General module options<br> |
| 11 | </h1> |
| 12 | <br> |
| 13 | <br> |
| 14 | <div style="text-align: left;"><br> |
| 15 | <h2>1. Account types<br> |
| 16 | </h2> |
| 17 | LAM provides multiple account types (e.g. users, groups, hosts).<span style="font-weight: bold;"><br> |
| 18 | </span>A module can manage one or more account types.<br> |
| 19 | <br> |
| 20 | The types are specified with <span style="font-weight: bold;">can_manage()</span>.<br> |
| 21 | <br> |
| 22 | <span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;"> |
| 23 | <br> |
| 24 | Our <span style="font-style: italic;">ieee802Device</span> |
| 25 | module will be used only for host accounts.<br> |
| 26 | <br> |
| 27 | <div class="mod-code"> |
| 28 | * Returns true if this module can manage accounts of the current type, otherwise false.<br> |
| 29 | * <br> |
| 30 | * @return boolean true if module fits<br> |
| 31 | */<br> |
| 32 | public function <span style="color: red;">can_manage()</span> {<br> |
| 33 | return $this->get_scope() == 'host';<br> |
| 34 | }<br> |
| 35 | </div> |
| 36 | <br> |
| 37 | <br> |
| 38 | <h2>2. Base modules<br> |
| 39 | </h2> |
| 40 | In LDAP every entry needs exactly one <span style="font-style: italic;">structural |
| 41 | object class</span>. Therefore all modules which provide a <span style="font-style: italic;">structural object class</span> are marked |
| 42 | as <span style="font-weight: bold;">base module</span>.<br> |
| 43 | <br> |
| 44 | This is done with <span style="font-weight: bold;">is_base_module()</span> |
| 45 | or <span style="font-weight: bold;">meta['is_base']</span>.<br> |
| 46 | <br> |
| 47 | <span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;"> |
| 48 | <br> |
| 49 | The <span style="font-style: italic;">inetOrgPerson</span> |
| 50 | module manages the structural object class "inetOrgPerson" and |
| 51 | therefore is a <span style="font-weight: bold;">base module</span>.<br> |
| 52 | If your module is not a base module you can skip the meta data for |
| 53 | this, default is <span style="font-style: italic;">false</span>.<br> |
| 54 | <br> |
| 55 | <div class="mod-code"> |
| 56 | * Returns meta data that is interpreted by parent |
| 57 | class<br> |
| 58 | *<br> |
| 59 | * @return array array with meta data<br> |
| 60 | */<br> |
| 61 | <span style="font-weight: bold;">function</span> |
| 62 | get_metaData() {<br> |
| 63 | $return = array();<br> |
| 64 | // base module<br> |
| 65 | <span style="color: rgb(255, 0, 0);"> |
| 66 | $return["is_base"] = true;</span><br style="color: rgb(255, 0, 0);"> |
| 67 | return $return;<br> |
| 68 | }<br> |
| 69 | </div> |
| 70 | <br> |
| 71 | <br> |
| 72 | <h2>3. Alias name</h2> |
| 73 | The module name is very limited, therefore every module has an <span style="font-style: italic;">alias name</span>. This <span style="font-style: italic;">alias name</span> has no limitations and |
| 74 | can be translated. It may contain special characters but make sure that |
| 75 | it does not contain HTML special characters like "<".<br> |
| 76 | The <span style="font-style: italic;">alias name </span>can be the |
| 77 | same for all managed <span style="font-style: italic;">account types</span> |
| 78 | or differ for each type.<br> |
| 79 | <br> |
| 80 | The <span style="font-style: italic;">alias name</span> is specified |
| 81 | with <span style="font-weight: bold;">get_alias()</span> |
| 82 | or <span style="font-weight: bold;">meta['alias']</span>.<br> |
| 83 | <br> |
| 84 | <span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;"> |
| 85 | <br> |
| 86 | Our <span style="font-style: italic;">ieee802Device</span> |
| 87 | module will get the alias MAC address.<br> |
| 88 | <br> |
| 89 | <div class="mod-code"> |
| 90 | * Returns meta data that is interpreted by parent |
| 91 | class<br> |
| 92 | *<br> |
| 93 | * @return array array with meta data<br> |
| 94 | */<br> |
| 95 | <span style="font-weight: bold;">function</span> |
| 96 | get_metaData() {<br> |
| 97 | $return = array();<br> |
| 98 | // alias name<br> |
| 99 | <span style="color: rgb(255, 0, 0);"> |
| 100 | $return["alias"] = _("MAC address");</span><br style="color: rgb(255, 0, 0);"> |
| 101 | return $return;<br> |
| 102 | }<br> |
| 103 | </div> |
| 104 | <br> |
| 105 | <br> |
| 106 | <h2>4. Dependencies</h2> |
| 107 | Modules can depend on each other. This is useful if you need to access |
| 108 | attributes from other modules or the managed object classes of your |
| 109 | module are not structural.<br> |
| 110 | <br> |
| 111 | The dependencies are specified with <span style="font-weight: bold;">get_dependencies()</span> |
| 112 | or <span style="font-weight: bold;">meta['dependencies']</span>.<br> |
| 113 | <br> |
| 114 | <span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;"> |
| 115 | <br> |
| 116 | Our <span style="font-style: italic;">ieee802Device</span> |
| 117 | module depends on the account module (because it is the only structural |
| 118 | module at this time).<br> |
| 119 | <br> |
| 120 | <div class="mod-code"> |
| 121 | * Returns meta data that is interpreted by parent |
| 122 | class<br> |
| 123 | *<br> |
| 124 | * @return array array with meta data<br> |
| 125 | */<br> |
| 126 | <span style="font-weight: bold;">function</span> |
| 127 | get_metaData() {<br> |
| 128 | $return = array();<br> |
| 129 | // module dependencies<br> |
| 130 | <span style="color: rgb(255, 0, 0);"> |
| 131 | $return['dependencies'] = array('depends' => |
| 132 | array('account'), 'conflicts' => array());</span><br style="color: rgb(255, 0, 0);"> |
| 133 | return $return;<br> |
| 134 | }<br> |
| 135 | </div> |
| 136 | <br> |
| 137 | <br> |
| 138 | <h2>5. Messages</h2> |
| 139 | There are many situations where you will display messages to the user. |
| 140 | The modules should define such messages at a common place to make it |
| 141 | easier to modify them without searching the complete file.<br> |
| 142 | The <span style="font-style: italic;">baseModule</span> offers the $<span style="font-weight: bold;">messages</span> variable for this. It |
| 143 | should be filled by a function called <span style="font-weight: bold;">load_Messages()</span>.<br> |
| 144 | The <span style="font-style: italic;">baseModule</span> will |
| 145 | automatically check if you have implemented this function and call it |
| 146 | at construction time.<br> |
| 147 | <br> |
| 148 | <span style="font-weight: bold; text-decoration: underline;">Example:</span><br style="font-weight: bold; text-decoration: underline;"> |
| 149 | <br> |
| 150 | Now let our <span style="font-style: italic;">ieee802Device</span> |
| 151 | module define a message.<br> |
| 152 | <br> |
| 153 | <div class="mod-code"> |
| 154 | * This function fills the error message array with |
| 155 | messages<br> |
| 156 | */<br> |
| 157 | <span style="font-weight: bold;">function</span> <span style="color: rgb(255, 0, 0);">load_Messages</span>() {<br> |
| 158 | $this->messages['mac'][0] = |
| 159 | array('ERROR', 'MAC address is invalid!'); // third array value |
| 160 | is set dynamically<br> |
| 161 | }<br> |
| 162 | </div> |
| 163 | <br> |
| 164 | <br> |
| 165 | <h2>6. Managed object classes<br> |
| 166 | </h2> |
| 167 | You can tell LAM what object classes are managed by your module.<br> |
| 168 | LAM will then check the spelling of the objectClass attributes and |
| 169 | correct it automatically. This is useful if other applications (e.g. |
| 170 | smbldap-tools) also create accounts and the spelling is different.<br> |
| 171 | <br> |
| 172 | <span style="font-weight: bold; text-decoration: underline;">Example:</span><br> |
| 173 | <br> |
| 174 | The <span style="font-style: italic;">ieee802Device</span> module |
| 175 | manages one object class.<br> |
| 176 | <br> |
| 177 | <div class="mod-code"> |
| 178 | * Returns meta data that is interpreted by parent |
| 179 | class<br> |
| 180 | *<br> |
| 181 | * @return array array with meta data<br> |
| 182 | */<br> |
| 183 | <span style="font-weight: bold;">function</span> |
| 184 | get_metaData() {<br> |
| 185 | $return = array();<br> |
| 186 | // managed object classes<br> |
| 187 | <span style="color: rgb(255, 0, 0);"> |
| 188 | $return['objectClasses'] = array('ieee802Device');</span><br> |
| 189 | return $return;<br> |
| 190 | }<br> |
| 191 | </div> |
| 192 | <br> |
| 193 | <br> |
| 194 | <h2>7. Known LDAP aliases<br> |
| 195 | </h2> |
| 196 | LDAP attributes can have several names (e.g. "cn" and "commonName" are |
| 197 | the same). If you manage such attributes then tell LAM about the alias |
| 198 | names.<br> |
| 199 | LAM will then convert all alias names to the given attribute names |
| 200 | automatically.<br> |
| 201 | <br> |
| 202 | <span style="font-weight: bold; text-decoration: underline;">Example:</span><br> |
| 203 | <br> |
| 204 | The <span style="font-style: italic;">posixGroup</span> module manages |
| 205 | the "cn" attribute. This attribute is also known under the alias |
| 206 | "commonName".<br> |
| 207 | This way the module will never see attributes called "commonName" |
| 208 | because LAM renames them as soon as the LDAP entry is loaded.<br> |
| 209 | <br> |
| 210 | <div class="mod-code"> |
| 211 | * Returns meta data that is interpreted by parent |
| 212 | class<br> |
| 213 | *<br> |
| 214 | * @return array array with meta data<br> |
| 215 | */<br> |
| 216 | <span style="font-weight: bold;">function</span> |
| 217 | get_metaData() {<br> |
| 218 | $return = array();<br> |
| 219 | // LDAP aliases<br> |
| 220 | <span style="color: rgb(255, 0, 0);"> |
| 221 | $return['LDAPaliases'] = array('commonName' => |
| 222 | 'cn');</span><br> |
| 223 | return $return;<br> |
| 224 | }<br> |
| 225 | </div> |
| 226 | <br> |
| 227 | <br> |
| 228 | <span style="font-weight: bold;"></span> |
| 229 | </div> |
| 230 | </div> |
| 231 | <h2>8. Icon<br> |
| 232 | </h2> |
| 233 | You can specify a icon for you module. It will be displayed on the |
| 234 | account pages and other module specific places (e.g. file upload).<br> |
| 235 | The icons must be 32x32 pixels in size. The location is relative to the <span style="font-style: italic;">graphics</span> directory.<br> |
| 236 | |
| 237 | <br> |
| 238 | |
| 239 | <span style="font-weight: bold; text-decoration: underline;">Example:</span><br> |
| 240 | |
| 241 | <br> |
| 242 | |
| 243 | The <span style="font-style: italic;">posixGroup</span> module uses the "tux.png" from the graphics directory.<br> |
| 244 | |
| 245 | <br> |
| 246 | |
| 247 | <div class="mod-code"> |
| 248 | * Returns meta data that is interpreted by parent |
| 249 | class<br> |
| 250 | *<br> |
| 251 | * @return array array with meta data<br> |
| 252 | */<br> |
| 253 | <span style="font-weight: bold;">function</span> |
| 254 | get_metaData() {<br> |
| 255 | $return = array();<br> // icon<br> |
| 256 | <span style="color: rgb(255, 0, 0);">$return['icon'] = 'tux.png';</span><br> |
| 257 | return $return;<br> |
| 258 | }<br> |
| 259 | </div> |
| 260 | <br> |
| 261 | <br> |
| 262 | </body></html> |