Skip to content
Permalink
Browse files

Move book appendices inside the chapters

  • Loading branch information
pgorod committed Feb 26, 2020
1 parent be3fdba commit 45353eab9782fa8fe34b6bc6386acffbacb7461a

This file was deleted.

@@ -3,6 +3,8 @@ weight: 6
title: "Metadata"
---

:toc:

= 6. Metadata

== Intro
@@ -794,4 +796,57 @@ used to confirm if a module should be shown in studio for user tweaking.
Note that, unlike other metadata files, the file in
`modules/<TheModule>/metadata/studio.php` will be the only one checked.
A file in `custom/modules/<TheModule>/metadata/studio.php` will have no
effect. link:../metadata[↩]
effect.

== Code Example

This is an example of setting up a function subpanel using Metadata.

In this example the cases module has a custom field `incident_code_c`
which is used to track cases with the same root cause. We’ll add a
subpanel to show all cases that have the same `incident_code_c`.

Initially we add to the `subpanel_setup` section of Cases by creating
the following file in
`custom/Extension/modules/Cases/Ext/Layoutdefs/IncidentLayoutdefs.php`

.Example A.1: IncidentLayoutdefs.php
[source,php]
----
<?php
$layout_defs["Cases"]["subpanel_setup"]['incident_cases'] = array(
'module' => 'Cases',
'title_key' => 'LBL_INCIDENT_CASES',
'subpanel_name' => 'default',
'get_subpanel_data' => 'function:get_cases_by_incident',
'function_parameters' =>
array('import_function_file' => 'custom/modules/Cases/IncidentUtils.php',),
"generate_select" => true,
);
----



Next we create the file which will define our `get_cases_by_incident`
function `custom/modules/Cases/IncidentUtils.php`.

.Example A.2: IncidentUtils.php
[source,php]
----
<?php
function get_cases_by_incident(){
global $db;
//Get the current bean
$bean = $GLOBALS['app']->controller->bean;
$incidentCode = $db->quote($bean->incident_code_c);
//Create the SQL array
$ret = array();
$ret['select'] = ' SELECT id FROM cases ';
$ret['from'] = ' FROM cases ';
$ret['join'] = "";
//Get all cases where the incident code matches but exclude the current case.
$ret['where']="WHERE cases.deleted = 0 AND cases_cstm.incident_code_c = '{$incidentCode}' AND cases.id != '{$bean->id}'";
return $ret;
}
----

@@ -4,6 +4,8 @@ weight: 15
title: "Module Installer"
---

:toc:

= 15. Module Installer

As detailed in the other chapters of this book there are many ways to
@@ -19,8 +21,7 @@ to install the package.
== manifest.php

The `manifest.php` file contains the definition of three arrays. Let’s
look at each of these arrays in turn. See
link:../appendix-a-code-examples/[Appendix A] for the full sample
look at each of these arrays in turn. See below for a full sample
`manifest.php` file.

{{% notice info %}}
@@ -410,3 +411,113 @@ functionality.
`scripts/post_uninstall.php`::
A PHP script which defines a method `post_uninstall()`. This method
will be called after the package is uninstalled. link:../module-installer[↩]

== Sample manifest file

The following is a basic example manifest file.

.Example A.3: Example manifest file
[source,php]
----
$manifest = array(
'name' => 'Example manifest',
'description' => 'A basic manifest example',
'version' => '1.2.3',
'author' => 'Jim Mackin',
'readme' => 'This is a manifest example for the SuiteCRM for Developers book',
'acceptable_sugar_flavors' => array('CE'),
'acceptable_sugar_versions' => array(
'exact_matches' => array('6.5.20',),
),
'dependencies' => array(
array(
'id_name' => 'hello_world',
'version' => '3.2.1'
),
),
'icon' => 'ManifestExample.png',
'is_uninstallable' => true,
'published_date' => '2015-05-05',
'type' => 'module',
'remove_tables' => 'prompt',
);
$installdefs = array(
'id' => 'suitecrmfordevelopers_example_manifest',
'image_dir' => '/images/',
'copy' => array(
array(
'from' => '/modules/ExampleModule',
'to' => 'modules/ExampleModule',
),
),
'dashlets' => array(
array(
'from' => '/modules/ExampleModule/Dashlets/',
'name' => 'ExampleModuleDashlet'
)
),
'language' => array(
array(
'from' => 'application/language/en_us.examplemoduleadmin.php',
'to_module' => 'application',
'language' => 'en_us'
),
array(
'from' => '/modules/Accounts/language/en_us.examplemodule.php',
'to_module' => 'Accounts',
'language' => 'en_us'
),
array(
'from' => '/application/language/es_es.examplemoduleadmin.php',
'to_module' => 'application',
'language' => 'es_es'
),
array(
'from' => '/modules/Accounts/language/es_es.examplemodule.php',
'to_module' => 'Accounts',
'language' => 'es_es'
),
),
'custom_fields' => array(
array(
'name' => 'example_field',
'label' => 'Example Field',
'type' => 'varchar',
'max_size' => 100,
'module' => 'Accounts',
),
),
'vardefs' => array(
array(
'from' => 'modules/Accounts/vardefs/examplemodule_vardefs.php',
'to_module' => 'Accounts',
),
),
'beans' => array(
array(
'module' => 'ExampleModule',
'class' => 'ExampleModule',
'path' => 'modules/ExampleModule/ExampleModule.php',
),
),
'logic_hooks' => array(
array(
'module' => 'Accounts',
'hook' => 'before_save',
'order' => 100,
'description' => 'Example module before save hook',
'file' => 'modules/ExampleModule/ExampleModuleHook.php',
'class' => 'ExampleModuleLogicHooks',
'function' => 'accounts_before_save',
),
),
'administration' => array(
array(
'from' => 'modules/administration/examplemodule_admin.php',
),
),
);
$upgrade_manifest = array(
);
----

@@ -108,8 +108,8 @@ a post argument.
The arguments to the REST API calls are:

`method`::
The method which will be called, i.e. `login` or `get_entry_list`. See
link:../../appendix-b-api-methods/[Appendix B] for a list of API methods.
The method which will be called, i.e. `login` or `get_entry_list`. See the
link:../api-v4.1-methods[list of API v4.1 methods].
`input_type`::
The input type of the rest_data. This is usually `JSON` but can also
be `Serialize`.
@@ -203,7 +203,7 @@ print_r($result);


For a full list of API methods and their arguments see
link:../../appendix-b-api-methods/[Appendix B].
link:../api-v4.1-methods[here].

== Adding custom API methods

0 comments on commit 45353ea

Please sign in to comment.
You can’t perform that action at this time.