Page 5 of 6 FirstFirst ... 3456 LastLast
Results 41 to 50 of 58
  1. #41
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    934
    Plugin Contributions
    9

    Default Re: Modern admin dashboard

    Small question, I had a module that was being loaded in via notifiers... I don't see it up here. Where did it go?

  2. #42
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    934
    Plugin Contributions
    9

    Default Re: Modern admin dashboard

    Just a note: the admin/includes/functions/general.php undoes a change that moves that delete function to the orders class I submitted into 2.2.0

  3. #43
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,740
    Plugin Contributions
    22

    Default Re: Modern admin dashboard

    Quote Originally Posted by retched View Post
    Small question, I had a module that was being loaded in via notifiers... I don't see it up here. Where did it go?
    I'll assume you're talking about NOTIFY_ADMIN_DASHBOARD_WIDGETS, correct? Since I haven't seen ANY plugins ever that use that observer, I'm guessing it's something custom-built. You'll need to modify that observer because we're no longer adding to the $widgets[], but instead you need to define which zone it goes to.
    Old code:
    Code:
    $zco_notifier->notify('NOTIFY_ADMIN_DASHBOARD_WIDGETS', null, $widgets);
    New code:
    Code:
    $zco_notifier->notify('NOTIFY_ADMIN_DASHBOARD_ZONES', null, $zones);
    You have the following zones: main, sidebar and bottom.

    Also, I would suggest downloading the plugin from Github as it contains A LOT of improvements.

  4. #44
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,740
    Plugin Contributions
    22

    Default Re: Modern admin dashboard

    Quote Originally Posted by retched View Post
    Just a note: the admin/includes/functions/general.php undoes a change that moves that delete function to the orders class I submitted into 2.2.0
    The plugin that's submitted here is for version 2.1.0, definitely NOT for 2.2.0.
    There ARE some differences between the 2 version, and I was hoping for the changes to go into core, thus the 2.2.0 version is only as a PR on Github. The file you mentioned is modified for order status color coding, and if I'm not mistaken, it does contain your changes: https://github.com/zencart/zencart/p...7f839cc96cf85e

    The PR is currently on hold since Scott mentioned we'll discuss it later on. So, when I get some feedback and a go-ahead with changes expected, I'll update the PR to match the current state of the plugin for 2.1.0.

  5. #45
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    934
    Plugin Contributions
    9

    Default Re: Modern admin dashboard

    Quote Originally Posted by balihr View Post
    I'll assume you're talking about NOTIFY_ADMIN_DASHBOARD_WIDGETS, correct? Since I haven't seen ANY plugins ever that use that observer, I'm guessing it's something custom-built. You'll need to modify that observer because we're no longer adding to the $widgets[], but instead you need to define which zone it goes to.
    Old code:
    Code:
    $zco_notifier->notify('NOTIFY_ADMIN_DASHBOARD_WIDGETS', null, $widgets);
    New code:
    Code:
    $zco_notifier->notify('NOTIFY_ADMIN_DASHBOARD_ZONES', null, $zones);
    You have the following zones: main, sidebar and bottom.

    Also, I would suggest downloading the plugin from Github as it contains A LOT of improvements.
    There's one plugin that uses that notifier, the one I co-wrote (AbuseIPDB). It adds a widget to the dashboard for triggering boosted API limits for the AbuseIPDB API. But that can be changed (and modified) to handle both.

  6. #46
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,740
    Plugin Contributions
    22

    Default Re: Modern admin dashboard

    Ah, I had no idea, I don't use that plugin...

    Since the dashboard now has a completely different structure, the old observer won't work, obviously.

    I have to leave now, but I did download the plugin and I can see the admin observer and yes, there are changes needed there. Let me get back to you tomorrow with an updated observer.

  7. #47
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,931
    Plugin Contributions
    96

    Default Re: Modern admin dashboard

    Quote Originally Posted by balihr View Post
    Ah, I had no idea, I don't use that plugin...

    Since the dashboard now has a completely different structure, the old observer won't work, obviously.

    I have to leave now, but I did download the plugin and I can see the admin observer and yes, there are changes needed there. Let me get back to you tomorrow with an updated observer.
    I'll note that there's no harm, IMO, in leaving the original widget notification and adding the zone notification.

  8. #48
    Join Date
    Jun 2007
    Location
    Bronx, New York, United States
    Posts
    934
    Plugin Contributions
    9

    Default Re: Modern admin dashboard

    Quote Originally Posted by lat9 View Post
    I'll note that there's no harm, IMO, in leaving the original widget notification and adding the zone notification.
    Oh no that was my general idea. To make two separate notifiers. One for the original layout and one for the new one.

  9. #49
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,740
    Plugin Contributions
    22

    Default Re: Modern admin dashboard

    Mind if I ask what's the point of leaving both notifiers? Either way, the observer needs to be modified to return now completely different code, so what's the gain in leaving the old notifier next to the new one in index_dashboard.php? I would understand leaving both in the observer files of a plugin so it can attach to either version of the dashboard, but leaving both notifiers could IMO just cause confusion and possibly issues down the road. Or am I missing something here because my coffee hasn't kicked in yet?

    Here's an updated admin observer for AbuseIPDB plugin:
    Code:
    <?php
    /**
     * Module: AbuseIPDB
     *
     * @requires    Zen Cart 2.1.0 or later, PHP 7.4+ (recommended: PHP 8.x)
     * @author      Marcopolo
     * @copyright   2023-2025
     * @license     GNU General Public License (GPL) - https://www.gnu.org/licenses/gpl-3.0.html
     * @version     4.0.5
     * @updated     07-Feb-2026 (Modern Admin Dashboard)
     * @github      https://github.com/CcMarc/AbuseIPDB
     */
    
    
    class zcObserverAbuseIPDBWidget extends base
    {
        function __construct()
        {
            $this->attach($this, array(
                'NOTIFY_ADMIN_DASHBOARD_ZONES',   // Modern Admin Dashboard
                'NOTIFY_ADMIN_DASHBOARD_WIDGETS'  // Legacy Dashboard
            ));
        }
    
        private function getPluginConfig()
        {
            if (!defined('ABUSEIPDB_WIDGET_ENABLED') || ABUSEIPDB_WIDGET_ENABLED !== 'true') {
                return false;
            }
    
            global $db;
    
            $version_sql = $db->execute("SELECT version FROM " . TABLE_PLUGIN_CONTROL . " WHERE unique_key = 'AbuseIPDB'");
            if ($version_sql->EOF) return false;
            $version = $version_sql->fields["version"];
    
            $session_rate_limit_enabled = false;
            $session_setting = $db->Execute("SELECT configuration_value FROM " . TABLE_CONFIGURATION . " WHERE configuration_key = 'ABUSEIPDB_SESSION_RATE_LIMIT_ENABLED'");
            if (!$session_setting->EOF && $session_setting->fields['configuration_value'] === 'true') {
                $session_rate_limit_enabled = true;
            }
    
            return [$version, $session_rate_limit_enabled];
        }
    
        /**
         * handler for Modern Admin Dashboard
         */
        public function updateNotifyAdminDashboardZones(&$class, $eventID, $empty, &$zones)
        {
            $config = $this->getPluginConfig();
            if (!$config) return;
    
            list($version, $session_rate_limit_enabled) = $config;
    
            $widget_filename = 'AbuseIPDBDashboardWidget.php';
            $widget_path = DIR_FS_CATALOG . "zc_plugins/AbuseIPDB/$version/admin/includes/modules/dashboard_widgets/$widget_filename";
    
            $found = false;
    
            // scan ALL zones. If widget found, update it to the full path
            foreach ($zones as $zone_name => &$widgets_list) {
                if (!is_array($widgets_list)) continue;
    
                foreach ($widgets_list as $key => &$val) {
                    if (basename($val) === $widget_filename) {
                        $found = true;
                        // overwrite the simple filename with the full plugin path
                        $val = $widget_path;
                    }
                }
            }
    
            // inject if NOT found anywhere
            if (!$found) {
                if ($session_rate_limit_enabled) {
                    // sidebar
                    if (!isset($zones['sidebar'])) $zones['sidebar'] = [];
                    array_unshift($zones['sidebar'], $widget_path);
                } else {
                    // main
                    if (!isset($zones['main'])) $zones['main'] = [];
                    $zones['main'][] = $widget_path;
                }
            }
        }
    
        /**
         * handler for Legacy Dashboard
         */
        public function updateNotifyAdminDashboardWidgets(&$class, $eventID, $empty, &$widgets)
        {
            $config = $this->getPluginConfig();
            if (!$config) return;
    
            list($version, $session_rate_limit_enabled) = $config;
    
            $widget_path = DIR_FS_CATALOG . "zc_plugins/AbuseIPDB/$version/admin/includes/modules/dashboard_widgets/AbuseIPDBDashboardWidget.php";
    
            if ($session_rate_limit_enabled) {
                // Place widget in column 3 (right), at the top
                $filteredWidgets = array_filter($widgets, function($item) {
                    return $item['column'] === 3;
                });
                $sortValues = array_column($filteredWidgets, 'sort');
                $minSort = empty($sortValues) ? 10 : min($sortValues) - 10;
                $minSort = max(10, $minSort);
    
                $widgets[] = [
                    'column' => 3,
                    'sort' => $minSort,
                    'visible' => true,
                    'path' => $widget_path
                ];
            } else {
                // Place widget in column 1 (left), at the bottom
                $filteredWidgets = array_filter($widgets, function($item) {
                    return $item['column'] === 1;
                });
                $sortValues = array_column($filteredWidgets, 'sort');
                $maxSort = empty($sortValues) ? 10 : max($sortValues) + 10;
    
                $widgets[] = [
                    'column' => 1,
                    'sort' => $maxSort,
                    'visible' => true,
                    'path' => $widget_path
                ];
            }
        }
    }
    There's also a required change in index_dashboard.php (simply replace the current render_zone() function:
    Code:
    function render_zone($zone_name, $widgets_array)
    {
        global $db, $currencies, $show_status_pills, $target_status_ids, $sniffer, $zco_notifier, $messageStack; // Globals needed inside widgets
    
        echo '<ul id="zone-' . $zone_name . '" class="sortable-list list-unstyled row" style="min-height: 200px; padding-bottom: 50px;">';
    
        foreach ($widgets_array as $widget_file) {
            $path = '';
    
            // check if this is an Encapsulated Plugin (absolute path provided)
            if (file_exists($widget_file)) {
                $path = $widget_file;
            }
            // treat as Core Widget (relative filename provided)
            else {
                $path = DIR_WS_MODULES . 'dashboard_widgets/' . $widget_file;
            }
    
            if (file_exists($path)) {
    
                $widget_name = basename($path);
    
                $col_class = 'col-md-12';
    
                if ($zone_name == 'bottom') {
                    if ($widget_name == 'TrafficDashboardWidget.php') {
                        $col_class = 'col-xs-12 col-md-6'; // traffic gets half width
                    } else {
                        $col_class = 'col-xs-12 col-md-3'; // others get quarter width
                    }
                }
    
                // data-markers for JS
                $data_attr = 'data-id="' . $widget_name . '"';
                $li_class = $col_class . ' widget-li';
    
                // Traffic widget - prevent it moving to sidebar
                if ($widget_name == 'TrafficDashboardWidget.php') {
                    $li_class .= ' locked-bottom';
                }
    
                echo '<li class="' . $li_class . '" ' . $data_attr . '>';
                include $path;
                echo '</li>';
            }
        }
        echo '</ul>';
    }
    Please let me know how you feel about this before I update the plugin on github. THX

  10. #50
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,931
    Plugin Contributions
    96

    Default Re: Modern admin dashboard

    Quote Originally Posted by balihr View Post
    Mind if I ask what's the point of leaving both notifiers? Either way, the observer needs to be modified to return now completely different code, so what's the gain in leaving the old notifier next to the new one in index_dashboard.php? I would understand leaving both in the observer files of a plugin so it can attach to either version of the dashboard, but leaving both notifiers could IMO just cause confusion and possibly issues down the road. Or am I missing something here because my coffee hasn't kicked in yet?

    Here's an updated admin observer for AbuseIPDB plugin:
    Code:
    <?php
    /**
     * Module: AbuseIPDB
     *
     * @requires    Zen Cart 2.1.0 or later, PHP 7.4+ (recommended: PHP 8.x)
     * @author      Marcopolo
     * @copyright   2023-2025
     * @license     GNU General Public License (GPL) - https://www.gnu.org/licenses/gpl-3.0.html
     * @version     4.0.5
     * @updated     07-Feb-2026 (Modern Admin Dashboard)
     * @github      https://github.com/CcMarc/AbuseIPDB
     */
    
    
    class zcObserverAbuseIPDBWidget extends base
    {
        function __construct()
        {
            $this->attach($this, array(
                'NOTIFY_ADMIN_DASHBOARD_ZONES',   // Modern Admin Dashboard
                'NOTIFY_ADMIN_DASHBOARD_WIDGETS'  // Legacy Dashboard
            ));
        }
    
        private function getPluginConfig()
        {
            if (!defined('ABUSEIPDB_WIDGET_ENABLED') || ABUSEIPDB_WIDGET_ENABLED !== 'true') {
                return false;
            }
    
            global $db;
    
            $version_sql = $db->execute("SELECT version FROM " . TABLE_PLUGIN_CONTROL . " WHERE unique_key = 'AbuseIPDB'");
            if ($version_sql->EOF) return false;
            $version = $version_sql->fields["version"];
    
            $session_rate_limit_enabled = false;
            $session_setting = $db->Execute("SELECT configuration_value FROM " . TABLE_CONFIGURATION . " WHERE configuration_key = 'ABUSEIPDB_SESSION_RATE_LIMIT_ENABLED'");
            if (!$session_setting->EOF && $session_setting->fields['configuration_value'] === 'true') {
                $session_rate_limit_enabled = true;
            }
    
            return [$version, $session_rate_limit_enabled];
        }
    
        /**
         * handler for Modern Admin Dashboard
         */
        public function updateNotifyAdminDashboardZones(&$class, $eventID, $empty, &$zones)
        {
            $config = $this->getPluginConfig();
            if (!$config) return;
    
            list($version, $session_rate_limit_enabled) = $config;
    
            $widget_filename = 'AbuseIPDBDashboardWidget.php';
            $widget_path = DIR_FS_CATALOG . "zc_plugins/AbuseIPDB/$version/admin/includes/modules/dashboard_widgets/$widget_filename";
    
            $found = false;
    
            // scan ALL zones. If widget found, update it to the full path
            foreach ($zones as $zone_name => &$widgets_list) {
                if (!is_array($widgets_list)) continue;
    
                foreach ($widgets_list as $key => &$val) {
                    if (basename($val) === $widget_filename) {
                        $found = true;
                        // overwrite the simple filename with the full plugin path
                        $val = $widget_path;
                    }
                }
            }
    
            // inject if NOT found anywhere
            if (!$found) {
                if ($session_rate_limit_enabled) {
                    // sidebar
                    if (!isset($zones['sidebar'])) $zones['sidebar'] = [];
                    array_unshift($zones['sidebar'], $widget_path);
                } else {
                    // main
                    if (!isset($zones['main'])) $zones['main'] = [];
                    $zones['main'][] = $widget_path;
                }
            }
        }
    
        /**
         * handler for Legacy Dashboard
         */
        public function updateNotifyAdminDashboardWidgets(&$class, $eventID, $empty, &$widgets)
        {
            $config = $this->getPluginConfig();
            if (!$config) return;
    
            list($version, $session_rate_limit_enabled) = $config;
    
            $widget_path = DIR_FS_CATALOG . "zc_plugins/AbuseIPDB/$version/admin/includes/modules/dashboard_widgets/AbuseIPDBDashboardWidget.php";
    
            if ($session_rate_limit_enabled) {
                // Place widget in column 3 (right), at the top
                $filteredWidgets = array_filter($widgets, function($item) {
                    return $item['column'] === 3;
                });
                $sortValues = array_column($filteredWidgets, 'sort');
                $minSort = empty($sortValues) ? 10 : min($sortValues) - 10;
                $minSort = max(10, $minSort);
    
                $widgets[] = [
                    'column' => 3,
                    'sort' => $minSort,
                    'visible' => true,
                    'path' => $widget_path
                ];
            } else {
                // Place widget in column 1 (left), at the bottom
                $filteredWidgets = array_filter($widgets, function($item) {
                    return $item['column'] === 1;
                });
                $sortValues = array_column($filteredWidgets, 'sort');
                $maxSort = empty($sortValues) ? 10 : max($sortValues) + 10;
    
                $widgets[] = [
                    'column' => 1,
                    'sort' => $maxSort,
                    'visible' => true,
                    'path' => $widget_path
                ];
            }
        }
    }
    There's also a required change in index_dashboard.php (simply replace the current render_zone() function:
    Code:
    function render_zone($zone_name, $widgets_array)
    {
        global $db, $currencies, $show_status_pills, $target_status_ids, $sniffer, $zco_notifier, $messageStack; // Globals needed inside widgets
    
        echo '<ul id="zone-' . $zone_name . '" class="sortable-list list-unstyled row" style="min-height: 200px; padding-bottom: 50px;">';
    
        foreach ($widgets_array as $widget_file) {
            $path = '';
    
            // check if this is an Encapsulated Plugin (absolute path provided)
            if (file_exists($widget_file)) {
                $path = $widget_file;
            }
            // treat as Core Widget (relative filename provided)
            else {
                $path = DIR_WS_MODULES . 'dashboard_widgets/' . $widget_file;
            }
    
            if (file_exists($path)) {
    
                $widget_name = basename($path);
    
                $col_class = 'col-md-12';
    
                if ($zone_name == 'bottom') {
                    if ($widget_name == 'TrafficDashboardWidget.php') {
                        $col_class = 'col-xs-12 col-md-6'; // traffic gets half width
                    } else {
                        $col_class = 'col-xs-12 col-md-3'; // others get quarter width
                    }
                }
    
                // data-markers for JS
                $data_attr = 'data-id="' . $widget_name . '"';
                $li_class = $col_class . ' widget-li';
    
                // Traffic widget - prevent it moving to sidebar
                if ($widget_name == 'TrafficDashboardWidget.php') {
                    $li_class .= ' locked-bottom';
                }
    
                echo '<li class="' . $li_class . '" ' . $data_attr . '>';
                include $path;
                echo '</li>';
            }
        }
        echo '</ul>';
    }
    Please let me know how you feel about this before I update the plugin on github. THX
    It's called backwards compatibility, so that plugins that use the "old" notifier don't need to change.

 

 
Page 5 of 6 FirstFirst ... 3456 LastLast

Similar Threads

  1. Admin Activity Dashboard
    By g2ktcf in forum General Questions
    Replies: 3
    Last Post: 23 May 2022, 03:14 PM
  2. v153 Couldnt access admin dashboard - too many redirects error
    By Arvinrags in forum Installing on a Linux/Unix Server
    Replies: 17
    Last Post: 18 May 2022, 10:46 AM
  3. Admin Dashboard customization
    By Mikeondraco in forum General Questions
    Replies: 2
    Last Post: 1 Jan 2019, 11:26 PM
  4. v154 Icons or images are not showing in admin dashboard
    By Annie_zaz in forum General Questions
    Replies: 2
    Last Post: 21 Jan 2016, 03:57 PM
  5. Survey for Zen Cart v2.0 Admin Dashboard
    By Kim in forum General Questions
    Replies: 35
    Last Post: 4 Jul 2011, 03:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg