1 (edited by evilive 02/01/2011 08:46:03 am)

Topic: Hooking Up an Extension

I'm trying to install new extension but so far I'm failed to achieved what I wanted. I'm trying to install new :

1. Tab
2. Menu/Link
3. Security Access

So far I have :
1. Create a directory named "claim" inside "modules" directory.
2. Create file named "hooks.php" inside "claim" directory and it looks like this :

<?php
define ('SS_CL',71<<8);

class hooks_claim extends hooks {
        var $module_name = 'claim'; // extension module name.

        function install_tabs($app) {
                set_ext_domain('modules/claim');        // set text domain for gettext
                $app->add_application(new claim_app); // add menu tab defined by example_class
                set_ext_domain();
        }

        function install_access()
        {
                $security_sections[SS_CL] =     _("Claim");

                $security_areas['SA_CLAPPLY'] = array(SS_CL|1, _("Claim Application"));
                $security_areas['SA_CLCHECK'] = array(SS_CL|2, _("Check Claim"));
                $security_areas['SA_CLAPPROVE'] = array(SS_CL|3, _("Approve Claim"));
                $security_areas['SA_CLPAYMENT'] = array(SS_CL|4, _("Release Payment"));
                $security_areas['SA_CLVIEW'] = array(SS_CL|5, _("View My Claim"));

                return array($security_areas, $security_sections);
        }

}

?>

Result : I got blank/empty page.

I knew that I don't have any problem with the "install_access". So I figured that I have problem with the following line in install_tabs :

$app->add_application(new claim_app); // add menu tab defined by example_class

Don't have any idea of what it's mean but I'm sure that what causing the problem. So I ended up create a new file named "claim.php" inside "application" directory. And it looks like this :

<?php

class claim_app extends application 
{
    function claim_app() 
    {
        $this->application("claim", _($this->help_context = "&Claim"));
    
        $this->add_module(_("Claim Application"));
        $this->add_lapp_function(0, _("Sales Travelling Claim"),
            $path_to_root.'/modules/claim/travel.php', 'SA_CLAPPLY', MENU_CLAIM);
        $this->add_lapp_function(0, _("Overtime Claim"),
            $path_to_root.'/modules/claim/overtime.php', 'SA_CLAPPLY', MENU_CLAIM);
        $this->add_lapp_function(0, _("Monthly Claim"),
            $path_to_root.'/modules/claim/monthly.php', 'SA_CLAPPLY', MENU_CLAIM);
        $this->add_lapp_function(0, _("Petty Cash"),
            $path_to_root.'/modules/claim/pettycash.php', 'SA_CLAPPLY', MENU_CLAIM);
        $this->add_lapp_function(0, "","");
        $this->add_rapp_function(0, _("View My Claim"),
            $path_to_root.'/modules/claim/myclaim.php', 'SA_CLVIEW', MENU_CLAIM);
        

        $this->add_module(_("Administer Claim"));
        $this->add_lapp_function(1, _("Claim Check Up"),
            $path_to_root.'/modules/claim/ccheck.php', 'SA_CLCHECK', MENU_CLAIM);
        $this->add_lapp_function(1, _("Approved Claim"),
            $path_to_root.'/modules/claim/capprove.php', 'SA_CLAPPROVE', MENU_CLAIM);
        $this->add_lapp_function(1, _("Claim Payment"),
            $path_to_root.'/modules/claim/capprove.php', 'SA_CLPAYMENT', MENU_CLAIM);
        $this->add_lapp_function(1, "","");
        

        $this->add_extensions();
    }
}

?>

Result : I still got blank/empty page.

What's my mistake? Am I missing something? Really need some guidance here.

Re: Hooking Up an Extension

You have to include() your claim_app file into hooks.php - it will not be included automatically even when placed in application folder.

The blank page is because all the extension files are included before error reporting is switched on in config.php. We will fix this issue in next minor release to make developers live easier. In mean time you can just put

ini_set("display_errors", "On"); 

at the top of session.inc file to see php errors during development.
Janusz

Re: Hooking Up an Extension

Thanx for the help and clarification Janusz. Finally, it's working.

I ended up  doing it like this.

<?php
define ('SS_CL',71<<8);

class claim_app extends application
{
        function claim_app()
        {
                $this->application("claim", _($this->help_context = "&Claim"));

                $this->add_module(_("Claim Application"));
                $this->add_lapp_function(0, _("Sales Travelling Claim"),
                        $path_to_root.'/modules/claim/travel.php', 'SA_CLAPPLY', MENU_CLAIM);
                $this->add_lapp_function(0, _("Overtime Claim"),
                        $path_to_root.'/modules/claim/overtime.php', 'SA_CLAPPLY', MENU_CLAIM);
                $this->add_lapp_function(0, _("Monthly Claim"),
                        $path_to_root.'/modules/claim/monthly.php', 'SA_CLAPPLY', MENU_CLAIM);
                $this->add_lapp_function(0, _("Petty Cash"),
                        $path_to_root.'/modules/claim/pettycash.php', 'SA_CLAPPLY', MENU_CLAIM);
                $this->add_lapp_function(0, "","");
                $this->add_rapp_function(0, _("View My Claim"),
                        $path_to_root.'/modules/claim/myclaim.php', 'SA_CLVIEW', MENU_CLAIM);


                $this->add_module(_("Administer Claim"));
                $this->add_lapp_function(1, _("Claim Check Up"),
                        $path_to_root.'/modules/claim/ccheck.php', 'SA_CLCHECK', MENU_CLAIM);
                $this->add_lapp_function(1, _("Approved Claim"),
                        $path_to_root.'/modules/claim/capprove.php', 'SA_CLAPPROVE', MENU_CLAIM);
                $this->add_lapp_function(1, _("Claim Payment"),
                        $path_to_root.'/modules/claim/capprove.php', 'SA_CLPAYMENT', MENU_CLAIM);
                $this->add_lapp_function(1, "","");


                $this->add_extensions();
        }
}


class hooks_claim extends hooks {
        var $module_name = 'claim'; // extension module name.

        function install_tabs($app) {
                set_ext_domain('modules/claim');        // set text domain for gettext
                $app->add_application(new claim_app); // add menu tab defined by example_class
                set_ext_domain();
        }


        function install_access()
        {
                $security_sections[SS_CL] =     _("Claim");

                $security_areas['SA_CLAPPLY'] = array(SS_CL|1, _("Claim Application"));
                $security_areas['SA_CLCHECK'] = array(SS_CL|2, _("Check Claim"));
                $security_areas['SA_CLAPPROVE'] = array(SS_CL|3, _("Approve Claim"));
                $security_areas['SA_CLPAYMENT'] = array(SS_CL|4, _("Release Payment"));
                $security_areas['SA_CLVIEW'] = array(SS_CL|5, _("View My Claim"));

                return array($security_areas, $security_sections);
        }

}

?>

Re: Hooking Up an Extension

Sure. Clean and easy way.
Janusz

Re: Hooking Up an Extension

Sue. Clean and easy way.
Janusz

Re: Hooking Up an Extension

Hi! do you experimented this issue ?
https://frontaccounting.com/punbb/viewtopic.php?pid=8289

I have an extension like yours and I have my tab missed when I enter to a link in any tab.

Re: Hooking Up an Extension

I created second extension called hr and managed to install and activate the extension. The problem is that the tab and setup access for the new extension are not showing up. I thought I messed up the hooks.php file but that's not the case.

When I deactivate my first installed extension called claim, the tab and setup access for hr showing up just fine. So, I came to conclusion that only one installed extension can be use at one time.

Is that the case or am I missing something?

Re: Hooking Up an Extension

No, FA should suport multiply extensions. Maybe you have misconfigured hooks file, or you have found a bug.

Re: Hooking Up an Extension

BTW, I think you forgot to include "global $path_to_root;" inside claim_app constructor.

    function claim_app()
    {
        global $path_to_root;

Without it, $path_to_root will become null or empty string.

kuro

Regards, [url=http://captainkuro.com]captain_kuro[/url]