Topic: Release 2.3 - Creating Extensions and Modules. How to?

Instructions from Janusz
--------------------------------

If you want use the module only locally, there is no need for _init directory at all. If extension is of type theme, chart, language, or it contains only additional reports there is even no need for hooks.php file. For any more complex extension module you have to create hooks.php file containing class definition 'hooks_name_of_the_package' derived from hooks class found in includes/hooks.php. Methods of this class (if defined) are used for module integration with various FrontAccounting parts. Most important hooks are:
* install_tabs() - adds new tabs in FA menu;
* install_options() - adds option to various FA menus;
* install_access() - allow additional permission levels to be defined for module's pages;
* install_extension() - called on extension installation;
* activate_extension() - called when extension is activated for selected company.

All the available hook methods are described in includes/hooks.inc file, and the hook files bundled with extensions in FA central repo can be used as examples.

If you create extension which you want to be placed in central FrontAccounting repository, you should create only single additional _init/config file containing following information used during install/preview:

Package: single_word_package_name
Version: 2.3.4
Name: One line description  of the package
Description: Longer description of the package content. Can be 
 continued on following lines providing the first char in line is space.
Author: name and <email of the author>
Maintenance: name and email of current maintainer (or the author)
Homepage: address of related www page
Type: extension or chart or language or theme
InstallPath: modules/folder_name

That's all. Before the package is placed in repository we make some rough code audit and create all the other needed auxiliary files, so you can don't care about them.

Janusz

2 (edited by apmuthu 09/25/2012 06:53:50 pm)

Re: Release 2.3 - Creating Extensions and Modules. How to?

After the release of FA v2.3.12 (Mercurial Changeset 3061), important changes have been made (in Mercurial Changeset 3068) to the all default themes' renderer.php files that need to be backported to the existing non default themes to make them compatible for use in future releases.

In Mercurial Changeset 3068 certain rendering functions viz.,

    check_application_access
    check_module_access
    hide_inaccessible_menu_items

have been shifted from

    themes/*/renderer.php files

to

    includes/current_user.inc

Hence in the  hitherto non-default themes, the renderer.php files must get rid of the said functions and replace the following calls:

$this->check_application_access($app)
$this->check_application_access($selected_app)
$this->check_module_access($module)
$this->hide_inaccessible_menu_items()

with

$_SESSION["wa_current_user"]->check_application_access($app)
$_SESSION["wa_current_user"]->check_application_access($selected_app)
$_SESSION["wa_current_user"]->check_module_access($module)
$_SESSION["wa_current_user"]->hide_inaccessible_menu_items()

respectively.

Consequently, the function menu_header in the themes/*/renderer.php file will no longer need access to the variable $show_inaccessible_menu_items from the global context as it now has access to it's SESSION variable instead.

ie.,

global $path_to_root, $help_base_url, $db_connections, $show_inaccessible_menu_items;

will now be:

global $path_to_root, $help_base_url, $db_connections;

Re: Release 2.3 - Creating Extensions and Modules. How to?

With reference to Mercurial changeset 3068 you don't have to make any changes to any themes.

The changes in changeset 3068 were made for future major releases. The current themes will still continue to run with its own helper member functions.

If we change the external themes to use the new member functions in current_user, it will not work with earlier 2.3.x versions if you could install the new themes from the repository.

This way we ensure that the themes works with earlier minor releases.

/Joe

Re: Release 2.3 - Creating Extensions and Modules. How to?

Hi I am just starting to write a few extensions.  I have created a new report and can see it in the installed extensions and the report menu.  What I get is the versions are 'Unknown' and the report name does not have a link to the package descripition in the Install/activate extensions screen.   Does this only happen when you have installed the extension centrally?  Is there a file I need ot create or a process I need to go through to install the extension?

All I did was add an entry to installed_extensions.php.

Re: Release 2.3 - Creating Extensions and Modules. How to?

Yes, the package info is available only for packages installed from central Repo (it is read from repo description files).
Janusz

Re: Release 2.3 - Creating Extensions and Modules. How to?

Thanks for the clarification

Re: Release 2.3 - Creating Extensions and Modules. How to?

You can create the modules/_cache/extn-extver-extbuild/_init/config file along with a list of files in the extension and their sha1sums in modules/_cache/extn-extver-extbuild/_init/files and see if it shows up.

Alternatively create your own repo and place your packages in it and change the repo access details in version.php. It hasn't been made easy to get all the files from the repo as the scripts were not deemed ready for distribution yet.

Contact me offline if you want it.

Possibly a GitHub repo may be the answer for manual extension installs. The Linux ar command is used to create the pkg and possibly sign them and hence the ~data file is not extractable in Windows using 7-Zip.

Re: Release 2.3 - Creating Extensions and Modules. How to?

Well, I guess  fighting with modules description in entirely local extensions which are never published is only waste of time. The module description have any real advantage in multi-user environment.
Janusz

Re: Release 2.3 - Creating Extensions and Modules. How to?

joe wrote:

Instructions from Janusz
--------------------------------

If you want use the module only locally, there is no need for _init directory at all. If extension is of type theme, chart, language, or it contains only additional reports there is even no need for hooks.php file. For any more complex extension module you have to create hooks.php file containing class definition 'hooks_name_of_the_package' derived from hooks class found in includes/hooks.php. Methods of this class (if defined) are used for module integration with various FrontAccounting parts. Most important hooks are:
* install_tabs() - adds new tabs in FA menu;
* install_options() - adds option to various FA menus;
* install_access() - allow additional permission levels to be defined for module's pages;
* install_extension() - called on extension installation;
* activate_extension() - called when extension is activated for selected company.

All the available hook methods are described in includes/hooks.inc file, and the hook files bundled with extensions in FA central repo can be used as examples.

If you create extension which you want to be placed in central FrontAccounting repository, you should create only single additional _init/config file containing following information used during install/preview:

Package: single_word_package_name
Version: 2.3.4
Name: One line description  of the package
Description: Longer description of the package content. Can be 
 continued on following lines providing the first char in line is space.
Author: name and <email of the author>
Maintenance: name and email of current maintainer (or the author)
Homepage: address of related www page
Type: extension or chart or language or theme
InstallPath: modules/folder_name

That's all. Before the package is placed in repository we make some rough code audit and create all the other needed auxiliary files, so you can don't care about them.

Janusz


I am new in front accounting. I don't understand anything.
My situation is like this. I must add 3 application menu (Asset Manager, HR Management, and Payroll). My question is :
1. What is this called? Module, plugin, or extension?
2. Is there any step by step explanation how to create this (I don't know what it is called, maybe extension)?
3. I already read https://frontaccounting.com/fawiki/index.php?n=Devel.Extensions and it still don't give me and idea about how to begin.
4. I already tried to create manually without extension (or plugin or module). I create a file in application folder and make a folder for my extension and I can see the menu but stuck in access level. When I open access level file, I don't understand anything. Where I must start add or edit or what must I add.

Please help me with some beginner tutorial or at least give me some link or some example because I already download front accounting repo manually and I still cannot install it even once. Thank you if you want to help me.

Re: Release 2.3 - Creating Extensions and Modules. How to?

Please refer the files in the existing extensions at:
https://github.com/apmuthu/frontaccounting/extensions/Extensions

Re: Release 2.3 - Creating Extensions and Modules. How to?

apmuthu wrote:

Please refer the files in the existing extensions at:
https://github.com/apmuthu/frontaccounting/extensions/Extensions

I already download it and I still don't know which one would be the best example because I think the extension mostly just add some menu in transcaction/inquire & reporting/maintenance in some application, like sales or another application. What I want is to create some new application. Can you tell me which one the best example and how can I install the extension? I already tried many method but still not success. The only thing that I can install is themes. Thank you.

Re: Release 2.3 - Creating Extensions and Modules. How to?

Okay, I already understand after I read hooks.inc. Maybe I will write some step-by-step instruction for newbie like me so that they can easily understand how modules really works because with security section and security area, I think newbie like me will frightened to create some extension.

13 (edited by apmuthu 01/13/2014 02:43:37 am)

Re: Release 2.3 - Creating Extensions and Modules. How to?

Creating extensions have been the preserve of only a few and it would be nice to have a detailed step by step example to get it done. That is the very purpose of putting all the extension files online so that they can be forked and extended.

An example comprising a new table with a field in it linked to any existing FA table (foreign key) to enable adding/editing/deleting entries in the new table having menu entries in a new tab including one to display data from the new table as well as a few from the linked table would do well to illustrate the method. Permissions can also be demonstrated in the example for complete illustration.

The easiest understood example would be a new "customer notes" table that links to the "customer" table with a tab called "notes" where it would be easy to add new "note description" records in the "customer notes" table and edit and/or delete them whilst displaying the "customer name" from the "customer" table as a link to the "customer details display" page.

Re: Release 2.3 - Creating Extensions and Modules. How to?

I have taken the initiative to produce the step by step examples of the topics that I know, and also share some extensions that I have developed as Themes (rounded and iOS7), Localization (Spanish Mexico with function to convert numbers to letters), COA's (chart_es_MX-empty , to start a chart from scratch, chart_es_MX-SAT compatible withe the electronic accounting required in Mexico) and two plug-ins for currency conversion through Web Services (MXN to USD and COP to USD). Additionally, for users interested in Mexico Electronic Invoicing I developed an commercial extension. This is a project I've just started, wait news! All this packages will be accesibles through my Repository in http://repo.Garrapato.com

Regards

Re: Release 2.3 - Creating Extensions and Modules. How to?

Wow @Garrapato! Way to go!

You might consider forking my Unofficial GitHub Repo (or the Official Git Mirror and adding the extension files) and then adding your extensions to it providing me a pull request so that we can have it propagated to all the forks.

You might also want to write an Article (or extend an existing one) in the FA Wiki.

Re: Release 2.3 - Creating Extensions and Modules. How to?

Could someone please post a screeenshot of the resulting tabs or menus once various 'import' extensions are activated.   I have 'installed' several, but they are showing 'active -false' in the "installation_extensions.php" and I recently turned on php 5.4 "fast cgi".     I don't see them anywhere on their proper screens, but realized I don't even know how they will look, once active. 

And, anyone who can help with why they are not showing active, even though 'installed', please help.
Thanks much.

17 (edited by albertolima 09/23/2016 02:56:10 am)

Re: Release 2.3 - Creating Extensions and Modules. How to?

Hi @GoodNewShar:
Go to setup tab, Access Roles, select the role you want, and enable the desired extension features for that role (i.e. System Administrator). Then logout, login again and you should see the menu item(s) that you have enabled for that role.