Howto develop a learnloop module


Introduction

It's quite easy to develop a learnloop module. You don't need to know anything about the learnloop core and you can still take full advantage of all the functionality.

Unpacking the module-template

The first thing you need to do is unpack the module-template.
cd learnloop2/modules
tar xfvz template.tar.gz
Then rename the created folder template to whatever your module is called.
mv template my_module

Module configuration-file

First of all, modify the module.conf-file. The file is pretty well commented, but there are some things that needs futher explenation, like the type-parameter:
There are fore kinds of modules and the type-parameter sets this:
user This is a module that can be created in the personal area "My Resources".
workspace Can be created in the workspaces.
singleuser This module always lies on the toplevel in "My Resources" and can not be removed. Modules of this kind don't use any module_id, instead it looks at the logged in user_id.
singleworkspace Same as singleuser but instead it lies in every workspace.
There can be combinations of the types like: user,workspace (the default) or singleuser,singleworkspace (like the calendar-module that always exists in both "My Resources" and every workspace)

The optional file_class and class-paremetes also needs futher explenation:
If you want to take advantage of some special functions in the LearnLoop-core you need a module-class that extends the LLModules-class. You need the LLModule-class to check access (with the aGetUserAccess-function), get the modules data-directory (directory with write-access that you need if your uploading files) and if your own class has a function called sGetDHTMLMenu you can create submenus to the DHTML-menu on the left.

The identifier

The identifier is a string that is always send to and from the module. The identifier explains for the LLModule-class and for the LearnLoop-core what kind of module it is and where it's located.
If you create a link or a form in your module always remember to send the identifier as a querystring:
<a href="page.php?identifier=<?echo $sIdentifier?>">module-link</a>
<form action="save_form.php?identifier=<?echo $sIdentifier?>" method="post">
</form>
Then the module will know if the user has access to the module or not.

Database tables

The create.sql-file is executed when the module is installed. Although there is some naming-conversion we want you to follow so that the core knows that this is db-table for modules.
The tablename always needs the prefix mod_. And if the module-type is user and/or workspace then you need a relation called module_id (or modules_id) in related tables. This because the core will know what rows to remove if the module is deleted.

Example-file

Check out the content of the index.php-file. It's quite simple to understand.

Accessing the data-directory

If you need access to the writable data-directory then call the function sGetDatadir in the LLModule-class. This function returns a string with the specific directory for the current module. If the directory didn't exists before then the sGetDatadir will create it.
If your uploading files to this directory please use the safe mode-enabled functions move_uploaded_file and is_uploaded_file.
There is also a LLModule-function called bClearDataDir that deletes all the content of this modules data-directory.