Custom Extensions
Interestingly the extension framework can be used to add new extensions. This allows you to create customisations that are easily customised by others (in a similar manner to, for example, how vardefs can be added - see the chapter on Vardefs).
To create a custom extension you simply add a new file in
custom/Extension/application/Ext/Extensions. This can be given a name of your choosing. Our
¹The language extensions are treated specially and, as such, aren’t compiled to a single file.
Extension Framework 80 example will use
custom/Extension/application/Ext/Extensions/SportsList.php and will look like:
Example 14.1: Adding an entry point entry Example 14.1: Adding an entry point entry 1 <?php
2 $extensions["sports_list"] = array array(
3 "section" => "sports_list", 4 "extdir" => "SportsList", 5 "file" => 'sportslist.ext.php', 6 "module" => "");
Now when a Quick Repair and rebuild is run any files in
custom/Extension/application/Ext/SportsList/ will be consolidated into
custom/application/Ext/SportsList/sportslist.ext.php. On it’s own this file will not do anything but you are now able to write custom code that checks the consolidated file rather than having to worry about searching for customisations.
15. Module Installer 15. Module Installer
As detailed in the other chapters of this book there are many ways to customise SuiteCRM.
The module installer allows you to package these changes and install them onto other SuiteCRM instances. This is achieved by creating a package.
At the minimum a package is a zip file that contains a manifest.php file in it’s root. The manifest file is responsible for providing information about the installer as well as providing information on how to install the package.
manifest.php manifest.php
The manifest.php file contains the definition of three arrays. Let’s look at each of these arrays in turn. See Appendix A for the full sample manifest.php file.
Within path in the manifest file you can use <basepath> to refer to the base directory of the installer. For example <basepath>/Foo.txt will refer to the Foo.txt file in the root of the installer package.
$manifest $manifest
The$manifestarray provides information on the package itself such as it’s name, readme etc. (it also defines the copy array for patch packages). A sample definition of the manifest array will appear something like this:
Example 15.1: Example
Example 15.1: Example $manifest $manifest array definition array definition 1 $manifest = array array(
2 'name' => 'My First Package',
3 'description' => 'This is a simple package example manifest file', 4 'version' => '1.5',
5 'author' => 'Jim Mackin', 6 'readme' => 'readme.txt',
7 'acceptable_sugar_flavors' => array array('CE'), 8 'acceptable_sugar_versions' => array array(
9 'exact_matches' => array array(),
10 'regex_matches' => array array('6\\.5\\.[0-9]$'),
11 ),
81
Module Installer 82
12 'copy_files' => array array (
13 'from_dir' => '<basepath>/custom/', 14 'to_dir' => 'custom',
15 'force_copy' => array array (),
16 ),
17 'dependencies' => array array(
18 array(array
19 'id_name' => 'example_dependency_package', 20 'version' => '2.4',
21 ),
22 ),
23 );
name
name The name of the package. This is how the package will appear to the user during installation and in the Module Loader package list. The package name is required.
description description
A brief description of the package.
version version
The version of this package. This can be any string but is usually a traditional version number (such as 3.1.4).
author author
The author of the package.
readme readme
A brief readme string. Note that if a README.txt is found in the root of the package this will be used instead.
acceptable_sugar_flavors acceptable_sugar_flavors
A remnant of the SugarCRM packages. This should always be an array with (at least) a CE entry. If you would like the installer to target both SuiteCRM and SugarCRM editions then this can contain one of the other SugarCRM flavours (PRO, CORP , ULT or ENT).
acceptable_sugar_versions acceptable_sugar_versions
An array detailing the matching SugarCRM versions. Note that the SugarCRM version is distinct from the SuiteCRM version. This array has two keys. exact_matches is simply an array of the allowed versions. regex_matches allows specifying regexes to match versions.
For SuiteCRM you only need to worry about supporting the 6.5.* versions which can be matched with the regex 6\\.5\\.[0-9]$. At the time of writing the current SugarCRM version for SuiteCRM is 6.5.20.
Module Installer 83
copy_files copy_files
This is only used for patch installers and will copy files in the from_dir key to those in the
to_dir key. Finally the force_copy key can be used to specify files that should be forcibly copied over.
dependencies dependencies
An array of other packages that are relied on by this package. Each entry is an array with
id_name - the id of the package and version - the required version of the package.
icon
icon The path (within the installer) to an icon to be displayed during installation.
is_uninstallable is_uninstallable
Whether or not uninstalls should be allowed.
published_date published_date
The date that the package was published. There is no fixed format for the date, it is simply a string.
key
key Specifies a key to ensure that modules do not clash. This will prefix the insta lled modules and tables with key. This is used by the module builder when creating packages but can be specified if you wish.
remove_tables remove_tables
A string specifying whether module tables should be removed when uninstalling this package.
Accepted values are true, false and prompt. The default is true.
type
type The type of the installer, one of langpack, module, patch or theme. See the types section.