/program/modules/crew/crew_install.php - installer of the crew module
This file contains the crew module installer. The interface consists of these functions:
These functions can be called from the main installer and/or admin.php.
Note You cannot be sure about the environment from which these routines are called. If the caller is the Install Wizard, you do not have all subroutines available. However, it IS possible to manipulate the database via the db_*() routines and/or the global $DB object. Therefore you have to keep the install routine extremly simple. You also have no option to interact with the user; the install has to be a silent install; you can only indicate success (TRUE) or failure (FALSE) and maybe an error message in $messages[] but that's it. Good luck.
add demonstration data to the system
this routine goes through the motions to install a (demo) workshop. However, since configuration of the required websocket server is non-trivial, the demo is not complete. It does show that the module actually exists.
Note If the module is installed via the Install Wizard, this routine is called. However, if a module is installed as an additional module after installation, the {$mode}_demodata() routine is never called. This is because the only time you know that demodata is installed is when the Install Wizard runs. If we're called from admin.php, the webmaster may have already deleted existing (core) demodata so you never can be sure what to expect. To put it another way: it is hard to re-construct $config when we're NOT the Instal Wizard.
install the module
this routine installs the module. For this module there are a few properties that need to be stored in the main modules_properties table. The specific table for this module is already created based on the tabledefs); see install/crew_tabledefs.php.
Note that the record for this module is already created in the modules table; the pkey is $module_id.
uninstall the module
this is a hook for future extensions of Website@School. For now we simply return success. Any real code could look like this: DELETE FROM workshops; to delete all existing data (but who would want that). For now this is simply a nop.
Note that bluntly deleting from the workshops table might lead to nodes without a valid module. The better way to do it would be something like this:
upgrade the module
this routine performs an upgrade to the installed module. Note that this module does not need any upgrade at all because there never was an earlier version.
However, if there was to be a newer version of this module, this routine is THE place to bring the database up to date compared with the existing version. For example, if an additional field 'crew_extension' was to be added to the crew-table, it could be added using a suitable (default) value, e.g. an empty string or whatever
Any existing crew records could then be updated here to fill the new field with data, e.g.
UPDATE workshops SET crew_extension = '';
etcetera. For now this routine is a nop.
Documentation generated on Tue, 28 Jun 2016 19:09:01 +0200 by phpDocumentor 1.4.0