Topic: Add_access_extensions() Function Call

Hi,

Is there any possibility to move the function call add_access_extensions() from index.php into the last line of includes/session.inc? Because I found a problem when I develop an extension that create an additional tab.

That new tab is appear when I click the other tab. So I'm on the URL like following:
index.php?application=stock
Because the add_access_extension is called in index.php

But when I click one menu, which point to the URL like following.
inventory/transfers.php?NewTransfer=1
My new tab is disappear and there is an error message saying undefined index SA_blablabla.
I found that was because the add_access_extension is not called in that page.

So I think we should move the add_access_extensions() function call to the includes/session.inc file which is called in every page. It could be a bug or me that was wrong, so I need the opinion from you guys about this.

Re: Add_access_extensions() Function Call

There are many places where the session.inc file is included but the add_access_extension() is not called.

Please use the "set_ext_domain()" function - see some extensions for examples like this. Even the logout.php file does not call the add_access_extension() function.

3 (edited by bogeyman2007 02/16/2016 05:09:32 am)

Re: Add_access_extensions() Function Call

I think set_ext_domain() is for separating .po files for each extension isn't it?
I think we need to call the add_access_extension() function in session.inc, or we should call it in each module, or we should manually add $security_areas item for the new extension in includes/access_level.inc. CMIIW.

4 (edited by anoopmb 08/17/2020 06:57:22 am)

Re: Add_access_extensions() Function Call

Another way to overcome this,

use the activate_extension function in module

function activate_extension($company, $check_only = true)
    {
        global $path_to_root, $db_connections;

        $file = $path_to_root . '/includes/session.inc';
        if (file_exists($file)) {
            $mstring = 'add_access_extensions();';
            // Open the file to get existing content
            $current = file_get_contents($file);
            if (strpos($current, $mstring) === false) {
                $current .= $mstring . "\n";
                // Write the contents back to the file
                file_put_contents($file, $current);
            }
        }
        
        $updates = array('update.sql' => array('pos'));
        return $this->update_databases($company, $updates, $check_only);
    }
ANOOP
Experience is the name everyone gives to their mistakes!