Re: Dropdown theme showing error and not displaying custom modules

No it is not. I looks like an early Alpha or Beta of 2.4.

/Joe

Re: Dropdown theme showing error and not displaying custom modules

Isn't it better removed from the Official 2.4 PKG repo?

Post's attachments

Official_Themes_FA24x.png 50.9 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: Dropdown theme showing error and not displaying custom modules

Ah, now I understand what you mean. I didn't know that it was also in the extension library.

Of course it should be removed from there. Thanks for investigating.

I will ask Janusz to remove it asap. And thanks again.

/Joe

29 (edited by boxygen 11/02/2017 02:42:03 am)

Re: Dropdown theme showing error and not displaying custom modules

Sorry to enter the discussion very late.

I have just given a new look to the whole issue.

I took the dropdown theme that is shipped with the download package.

Found that adding just one line at Line 103:

add_access_extensions();

is resolving the problem

@notrinos pointed the solution in post #12 but things got confused due to different instances of theme.

Thanks for all of you for taking your time.

Below would be the correct code after fixing

<?php
/**********************************************************************
    Copyright (C) FrontAccounting, LLC.
    Released under the terms of the GNU General Public License, GPL,
    as published by the Free Software Foundation, either version 3
    of the License, or (at your option) any later version.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
// Author: Joe Hunt, 17/11/2015. Upgraded to release 2.4. 10/11/2015.

    class renderer
    {
        function wa_get_apps($title, $applications, $sel_app)
        {
            foreach($applications as $app)
            {
                foreach ($app->modules as $module)
                {
                    $apps = array();
                    foreach ($module->lappfunctions as $appfunction)
                        $apps[] = $appfunction;
                    foreach ($module->rappfunctions as $appfunction)
                        $apps[] = $appfunction;
                    $application = array();
                    foreach ($apps as $application)
                    {
                        $url = explode('?', $application->link);
                        $app_lnk = $url[0];
                        $pos = strrpos($app_lnk, "/");
                        if ($pos > 0)
                        {
                            $app_lnk = substr($app_lnk, $pos + 1);
                            $lnk = $_SERVER['REQUEST_URI'];
                            $url = explode('?', $lnk);
                            $asset = false;
                            if (isset($url[1]))
                                $asset = strstr($url[1], "FixedAsset");
                            $lnk = $url[0];
                            $pos = strrpos($lnk, "/");
                            $lnk = substr($lnk, $pos + 1);
                            if ($app_lnk == $lnk)
                            {
                                $acc = access_string($app->name);
                                $app_id = ($asset != false ? "assets" : $app->id);
                                return array($acc[0], $module->name, $application->label, $app_id);
                            }
                        }
                    }
                }
            }
            return array("", "", "", $sel_app);
        }

        function wa_header()
        {
            page(_($help_context = "Main Menu"), false, true);
        }

        function wa_footer()
        {
            end_page(false, true);
        }
        function shortcut($url, $label)
        {
            echo "<li>";
            echo menu_link($url, $label);
            echo "</li>";
        }
        function menu_header($title, $no_menu, $is_index)
        {
            global $path_to_root, $SysPrefs, $version;

            $sel_app = $_SESSION['sel_app'];
            echo "<div class='fa-main'>\n";
            if (!$no_menu)
            {
                $applications = $_SESSION['App']->applications;
                $local_path_to_root = $path_to_root;
                $pimg = "<img src='$local_path_to_root/themes/".user_theme()."/images/preferences.gif' style='width:14px;height:14px;border:0;vertical-align:middle;padding-bottom:3px;' alt='"._('Preferences')."'>&nbsp;&nbsp;";
                $limg = "<img src='$local_path_to_root/themes/".user_theme()."/images/lock.gif' style='width:14px;height:14px;border:0;vertical-align:middle;padding-bottom:3px;' alt='"._('Change Password')."'>&nbsp;&nbsp;";
                $img = "<img src='$local_path_to_root/themes/".user_theme()."/images/on_off.png' style='width:14px;height:14px;border:0;vertical-align:middle;padding-bottom:3px;' alt='"._('Logout')."'>&nbsp;&nbsp;";
                $himg = "<img src='$local_path_to_root/themes/".user_theme()."/images/help.gif' style='width:14px;height:14px;border:0;vertical-align:middle;padding-bottom:3px;' alt='"._('Help')."'>&nbsp;&nbsp;";
                echo "<div id='header'>\n";
                echo "<ul>\n";
                echo "  <li><a href='$local_path_to_root/admin/display_prefs.php?'>$pimg" . _("Preferences") . "</a></li>\n";
                echo "  <li><a href='$local_path_to_root/admin/change_current_user_password.php?selected_id=" . $_SESSION["wa_current_user"]->username . "'>$limg" . _("Change password") . "</a></li>\n";
                if ($SysPrefs->help_base_url != null)
                    echo "  <li><a target = '_blank' onclick=" .'"'."javascript:openWindow(this.href,this.target); return false;".'" '. "href='".
                        help_url()."'>$himg" . _("Help") . "</a></li>";
                echo "  <li><a href='$path_to_root/access/logout.php?'>$img" . _("Logout") . "</a></li>";
                echo "</ul>\n";
                $indicator = "$path_to_root/themes/".user_theme(). "/images/ajax-loader.gif";
                echo "<h1>$SysPrefs->power_by $version<span style='padding-left:300px;'><img id='ajaxmark' src='$indicator' align='center' style='visibility:hidden;'></span></h1>\n";
                echo "</div>\n"; // header

                echo "<div id='cssmenu'>\n";
                echo "<ul>\n";
                $i = 0;
                $account = $this->wa_get_apps($title, $applications, $sel_app);
                add_access_extensions();
                foreach($applications as $app)
                {
                    if ($_SESSION["wa_current_user"]->check_application_access($app))
                    {
                        $acc = access_string($app->name);
                        $class = ($account[3] == $app->id ? "active" : "");
                        $n = count($app->modules);
                        if ($n)
                            $class .= " has-sub";
                        $dashboard = "";
                        $u_agent = $_SERVER['HTTP_USER_AGENT'];
                        if (preg_match('/android/i', $u_agent) && preg_match('/mobile/i', $u_agent)) {
                            $link = "#'";
                            $dashboard = "$local_path_to_root/index.php?application=$app->id";
                        }
                        else
                            $link = "$local_path_to_root/index.php?application=$app->id '$acc[1]";
                        echo "  <li class ='$class'><a href='$link><span>" . $acc[0] . "</span></a>\n";
                        if (!$n)
                        {
                            echo "  </li>\n";
                            continue;
                        }
                        echo "    <ul>\n";
                           if ($dashboard !="")
                            echo "      <li><a href='$dashboard'><span><font color='red'>"._("Dashboard")."</font></span></a></li>\n";
                        foreach ($app->modules as $module)
                        {
                            if (!$_SESSION["wa_current_user"]->check_module_access($module))
                                continue;
                             echo "      <li class='has-sub'><a href='#'><span>$module->name</span></a>\n";
                             $apps2 = array();
                             foreach ($module->lappfunctions as $appfunction)
                                $apps2[] = $appfunction;
                            foreach ($module->rappfunctions as $appfunction)
                                $apps2[] = $appfunction;
                            $application = array();
                               $n = count($apps2);
                               $class = "";
                               if ($i > 5)
                                   $class = "class='align_right'";
                            if ($n)
                                echo "        <ul $class>\n";
                            else
                            {
                                echo "      </li>\n";
                                continue;
                            }
                            foreach ($apps2 as $application)
                            {
                                $lnk = access_string($application->label);
                                if ($_SESSION["wa_current_user"]->can_access_page($application->access))
                                {
                                    if ($application->label != "")
                                    {
                                        echo "          <li><a href='$path_to_root/$application->link'><span>$lnk[0]</span></a></li>\n";
                                    }
                                }
                                elseif (!$_SESSION["wa_current_user"]->hide_inaccessible_menu_items())
                                    echo "          <li><a href='#'><span><font color='gray'>$lnk[0]</font></span></a></li>\n";
                            }
                            if ($n)
                                echo "        </ul>\n";
                            echo "      </li>\n";
                        }
                        echo "    </ul>\n"; // menu
                    }
                    echo"  </li>\n";
                    $i++;
                }
                echo "</ul>\n";
                echo "</div>\n"; // menu
            }
            echo "<div class='fa-body'>\n";
            if ($no_menu)
                echo "<br>";
            elseif ($title && !$no_menu && !$is_index)
            {
                echo "<div class='fa-content'>\n";
                echo "<center><table id='title'><tr><td width='100%' class='titletext'>$title</td>"
                ."<td align=right>"
                .(user_hints() ? "<span id='hints'></span>" : '')
                ."</td>"
                ."</tr></table></center>";
            }
        }

        function menu_footer($no_menu, $is_index)
        {
            global $path_to_root, $SysPrefs, $version, $db_connections;
            include_once($path_to_root . "/includes/date_functions.inc");

            if (!$no_menu && !$is_index)
                echo "</div>\n"; // fa-content
            echo "</div>\n"; // fa-body
            if (!$no_menu)
            {
                   echo "<script type='text/javascript'>if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))
                          {document.getElementById('cssmenu').style.position = 'fixed';}</script>\n";
                echo "<div class='fa-footer'>\n";
                if (isset($_SESSION['wa_current_user']))
                {
                    echo "<span class='power'><a target='_blank' href='$SysPrefs->power_url'>$SysPrefs->power_by $version</a></span>\n";
                    echo "<span class='date'>".Today() . "&nbsp;" . Now()."</span>\n";
                    echo "<span class='date'>" . $db_connections[$_SESSION["wa_current_user"]->company]["name"] . "</span>\n";
                    echo "<span class='date'>" . $_SERVER['SERVER_NAME'] . "</span>\n";
                    echo "<span class='date'>" . $_SESSION["wa_current_user"]->name . "</span>\n";
                    echo "<span class='date'>" . _("Theme:") . " " . user_theme() . "</span>\n";
                    echo "<span class='date'>".show_users_online()."</span>\n";
                }
                echo "</div>\n"; // footer
            }
            echo "</div>\n"; // fa-main
        }

        function display_applications(&$waapp)
        {
            global $path_to_root;

            $sel = $waapp->get_selected_application();
            meta_forward("$path_to_root/admin/dashboard.php", "sel_app=$sel->id");
            end_page();
            exit;
        }
    }
www.boxygen.pk

Re: Dropdown theme showing error and not displaying custom modules

This is not required as the add_access_extensions(); is available at the top of the file import_items.php itself.

Re: Dropdown theme showing error and not displaying custom modules

@kvvaradha & @boxygen: There is no use of solutions where none are needed. Ambiguous statements will only confuse the end user.

The standard FA 2.4.2+ works with the standard import_items PKG from the official PKG repo. Minor updates to it are available from the FA24extensions repo which I maintain independent of the official FA repos..

Users are best advised to update their install to the latest release / master before seeking assistance in the forum and state the versions of all pertinent applications used and any dated / specific versions assistance can be taken offline so as not to confuse other users.

Re: Dropdown theme showing error and not displaying custom modules

Dropdown theme has now been removed from the Official PKG Repo since it is part of the core. Thanks.

Post's attachments

Official_Themes_2017-11-02.png 18.5 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

33 (edited by boxygen 11/02/2017 07:45:10 am)

Re: Dropdown theme showing error and not displaying custom modules

This is not required as the add_access_extensions(); is available at the top of the file import_items.php itself.

You may be right as default FA theme is working perfectly without add_access_extensions(); in renderer.php file but Dropdown theme has an issue unless we add this function. I have checked it 3 times.

@kvvaradha & @boxygen: There is no use of solutions where none are needed. Ambiguous statements will only confuse the end user.
The standard FA 2.4.2+ works with the standard import_items PKG from the official PKG repo. Minor updates to it are available from the FA24extensions repo which I maintain independent of the official FA repos..
Users are best advised to update their install to the latest release / master before seeking assistance in the forum and state the versions of all pertinent applications used and any dated / specific versions assistance can be taken offline so as not to confuse other users.

I needed the solution because I am using this Dropdown theme in Production. I never intended to confuse anyone. The problem still persist. I have just donwloaded the latest repo from Github and tested it. Please give it a try.

My post # 29 fixes the issue.

Secondly I just used item_imorts as an example to show the bug. But this problem exists (Unless we apply the Fix) with all extensions that have user defined Security Areas.

Regards.

www.boxygen.pk

Re: Dropdown theme showing error and not displaying custom modules

I have tested it both on Windows (XAMPP v1.7.3 / PHP 5.3.1) and on Debian 6 (PHP 5.3.3-7). The default FA 2.4.2+ works fine with official import_items module - you can try to patch it to the latest as well from my FA24extensions repo - it will also work.

The reason is that the said function add_access_extensions() is executed on line 12 of import_items.php itself and there is no need for it in the renderer.php of the themes at all.

Themes get populated with data mostly from the $_SESSION variable which would have got populated with the security parameters before the display template is used. Hence the add_access_extensions() is not required to be executed in any theme at all.

35 (edited by boxygen 11/02/2017 07:27:36 pm)

Re: Dropdown theme showing error and not displaying custom modules

Have you tested this extension with dropdown theme also? I would be surprised if that is working without any fix.

You must get this error without any fix

screenshot

You may check it live here
id: admin
pass: Pakistan1947

I hope you will not get irritate due my repetitive posts. I am just trying to realize you the problem. And it matters to the community because Dropdown theme is now one of the official themes.

www.boxygen.pk

Re: Dropdown theme showing error and not displaying custom modules

After installing the extension and activating it for the target company and logging in to it, go to Setup -> Access Setup -> System Administrator -> tick the permissions and save the role. Logout and login again. Choose the dropdown theme and see if the Import CSV is greyed out. If so, visit the Setup -> Access Setup page and then see if the menu item is visible. This problem does not exist in the Canvas and Default themes as they do not use the meta forward to go to the dashboard.php file.

Just tested it out again for both the original and the patched versions of the extension.

Checked in the apache error logs and the tmp/errors.log - nothing there.

@joe: can confirm that when switching back and forth from / to the dropdown theme, the import_items extension (original) does get disabled without error but visiting Setup -> Access Setup page seems to re-enable it when done from the said theme itself.

Post's attachments

import_items_files.zip 26.2 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: Dropdown theme showing error and not displaying custom modules

No need to execute add_access_extensions(); in any theme's renderer.php and in any extension file as well normally. We can place it in the beginning / end of the includes/page/header.inc file (has only global functions) which is always loaded just before the renderer.php wherever the latter is used. The header.inc is called in the following files:

access/login.php
access/logout.php
access/password_reset.php
includes/main.inc

The function add_access_extensions() is defined in includes/access_levels.inc and is explicitly called in admin/security_roles.php (called only by applications/setup.php - visit to Access Setup enables extension) and index.php which pretty much covers it's entire use. Hope Ajax does not become vulnerable because of all this...

@joe: is this how we fix this?

Re: Dropdown theme showing error and not displaying custom modules

I am having a discussion with Janusz if there are sideeffects (Ajax etc).

/Joe

Re: Dropdown theme showing error and not displaying custom modules

Thanks @joe/@itronics. This will help streamline all the extensions as well and avoid security tinkering in the themes.

40 (edited by poncho1234 05/17/2019 09:07:17 pm)

Re: Dropdown theme showing error and not displaying custom modules

Is this still unresolved? Cannot find entry in mantis for it

This is still a bug in 2.4.6

The included 'dropdown' theme in 2.4.6 render.php does not have the function call add_access_extensions() and still gives the same Undefined index: errors for installed extensions as previous posts in this topic.

To replicate

clean install 2.4.6
From Install/Activate Extensions downloaded FrontHrm; activated; changed access roles.

No other changes or ext installed

Works fine for themes default & canvas, but not theme dropdown

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/