Developers > Kernel Documentation > Fundamentals > Module.pm

Module.pm


ExSite::Module

This package contains utility functions that are useful for managing and handling plug-in modules.

ExSite::Module::read_conf($module)

Looks for a config file in /cgi/conf/[MODULE].conf and if found, loads its parameters into $config{MODULE}{...}.

We try not to reload the config file if it has already been read. We look for a _loaded flag in the config data to tell us that the file has already been read, and we set this flag if it is found. This allows us to hard-code default configurations (a la Config.pm) and then override them with local config files.

ExSite::Module::icon($module)

Looks for an icon graphic to represent the module.

First, we look in /_Modules/[MODULE] for a file called icon.gif or icon.png. If none found, we look for /_Modules/icon.gif.

Icons are assumed to be 64x64 GIF or PNG graphics.

ExSite::Module::get_module($module,$auth,$site)

Instantiates a module, and returns an object. Returns undef if the user is not permitted to use the module.

$auth can be set to 1 to skip authorization checks (eg. if you are pre-approving use of the module, or if you will be performing your own authorization checks). If allowing get_module to determine authorization, you can pass $site (a section ID) to it to approve use of the module on a particular site; otherwise, we look for a user license.

If this routine returns undef, you can inspect $@ to determine the reason. If null, then the module instantiated but failed to authorize; otherwise perl had a problem instantiating the module, and $@ will contain the error message.

Once the module is instantiated, you can use standard module calls to query the module and generate content, eg.

    $mod = &ExSite::Modules::get_module("MyMod");
print $mod->write();

ExSite::Module::module_list()

Returns a list of name of modules that are installed on the system.

ExSite::Module::my_module_list()

Returns a list of names of modules that are installed on the system, and which the user is authorized to use.

ExSite::Module::site_license($module,$site)

Returns True/False (1/0) depending on whether the module is licensed to be used on a the given site. ($site should be a section ID.)

Modules require licenses if they respond True (1) to the ``isRestricted'' ioctl query. Otherwise, site licenses are granted automatically.

To grant a license, add a ``service'' record linking the module to the website.

ExSite::Module::user_license($module)

Returns True/False (1/0) depending on whether the module is licensed to be used by a given user.

Modules require licenses if they respond True (1) to the ``isRestricted'' ioctl query. If so, a license must exist for this Module on at least one of the user's web sites.

For modules that respond False (0) or do not respond to the ``IsRestricted'' ioctl query, user licenses are granted automatically.

ExSite::Module::service_page($module,$site)

Returns a Page object representing the page on the site that will be servicing the given module. If there is no service page, returns undef.

If multiple services pages are defined for a module, it tries to select the most appropriate one, as follows:

ExSite::Module::control_panel($module)

Returns the URL to the module's control panel, if any.

Topics