Page 1 of 5 123 ... LastLast
Results 1 to 10 of 50
  1. #1
    Join Date
    Aug 2004
    Location
    Belfast, Northern Ireland
    Posts
    2,480
    Plugin Contributions
    14

    Default Admin Page Registration for 3rd Party Modules

    Hi,

    How exactly are third party modules supposed to add pages to the Admin, now that support for boxes/extra_boxes has been dropped?

    Obviously a call to zen_register_admin_page() can be made but there is no documentation with this new version of Zen Cart about when the appropriate time would be to make that call... which seems like a pretty major omission for the docs! :)

    At the minute I'm thinking of simply adding a file which gets loaded by one of the existing auto-loading directories.

    But this file would simply call the above function to register a page that can then be accessed by the admin user through the admin menu.

    This seems rather wasteful of system resources as this file will autoload every time an admin page is opened.

    The solution to that is then to unlink() the auto-loading file once the module's page has been accessed through the menu for the first time, but none of this is a "desirable" way to work.

    Any information for a confused third party developer would be greatly received.

    Thanks!

    All the best..

    Conor

  2. #2
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Admin Page Registration for 3rd Party Modules

    Hi Conor

    Your mods generally (possibly always) undertake the database installation programmatically. Most mods don't have that level of sophistication and would use SQL inserts such as those discussed in this thread.

    For modules such as yours a call to zen_register_admin_page() would be the right way to go. The full call is:

    zen_register_admin_page($page_key, $language_key, $main_page, $page_params, $menu_key, $display_on_menu, $sort_order);

    where:
    • page_key is a unique text id
    • language _key is the name of the define for the page name that would previous have been used in the box files (for compatibility with existing language packs)
    • main_page is the define starting FILENAME_ used in the box file and code to direct to the admin page
    • page_params are whatever parameters are needed for the page (generally relevant only to configuration and modules pages
    • menu_key is a foreign key for the admin_menus table
    • display_on_menu is a char with value "Y" or "N" depending on whether it's a page visible on the admin menu, or a subpage called by another page
    • sort_order is a numeric value indicating how high up the menu the entry would appear, a high value sinks it down


    The current release is a beta, and there will be more documentation on this feature following along before the formal release.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  3. #3
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Admin Page Registration for 3rd Party Modules

    I'm suspecting that part of your concern is the chicken and egg problem of not being able to access the page from which you install until after you've installed.

    That's a legitimate issue, and one of several where PCI requirements frustrate my developer's sensibilities too.

    One possibility might be a standalone installer, i.e. a file uploaded with the mod, to which the admin browses to trigger execution of the SQL, and is then deleted (possibly by the script itself). Not as good as what you do currently, and I'm not sure what the PCI guys would make of it, but alas admin access to pages not yet registered has gone.
    Last edited by kuroi; 5 Aug 2011 at 09:49 PM.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  4. #4
    Join Date
    Aug 2004
    Location
    Belfast, Northern Ireland
    Posts
    2,480
    Plugin Contributions
    14

    Default Re: Admin Page Registration for 3rd Party Modules

    Hi,

    You're answering lots and lots of posts recently! I hope you're finding time for real life too! :)

    Quote Originally Posted by kuroi View Post
    I'm suspecting that part of your concern is the chicken and egg problem of not being able to access the page from which you install until after you've installed.
    Right you are!

    Quote Originally Posted by kuroi View Post
    That's a legitimate issue, and one of several where PCI requirements frustrate my developer's sensibilities too.
    Anyone who's talked to me about it knows what I think of PCI compliance.. reasonable concept, organised badly.. bureaucratic rubbish.. :) Eventually software will be good but when, oh when, will we all learn? ;-)

    Quote Originally Posted by kuroi View Post
    One possibility might be a standalone installer, i.e. a file uploaded with the mod, to which the admin browses to trigger execution of the SQL, and is then deleted (possibly by the script itself).
    That's essentially what I was saying in my initial post that I see as the only option. A script that simply creates the page links, and code which will delete this wasteful script when the "actual" admin pages are accessed for the first time.

    At that point, 1.5.0 would act like previous versions and the auto-installation and upgrade/config checks recent Ceon software employs would then run as normal.

    Quote Originally Posted by kuroi View Post
    Not as good as what you do currently, and I'm not sure what the PCI guys would make of it, but alas admin access to pages not yet registered has gone.
    The "PCI guys" don't appear to have too many brain cells to scrub together so I wouldn't want to involve them and harm their poor heads any further. Any solution which avoids any need to involve them is definitely desired.

    Oh well, looks like my initial idea is the only idea then! I believe in making things easy for users when they should be, especially when there are no security repercussions!

    Thanks for taking the time to reply. Now go enjoy some of the weekend, life is short! :)

    All the best...

    Conor

  5. #5
    Join Date
    Aug 2004
    Location
    Belfast, Northern Ireland
    Posts
    2,480
    Plugin Contributions
    14

    Idea or Suggestion Re: Admin Page Registration for 3rd Party Modules

    Hi,

    Quote Originally Posted by conor View Post
    At the minute I'm thinking of simply adding a file which gets loaded by one of the existing auto-loading directories.

    But this file would simply call the above function to register a page that can then be accessed by the admin user through the admin menu.

    This seems rather wasteful of system resources as this file will autoload every time an admin page is opened.

    The solution to that is then to unlink() the auto-loading file once the module's page has been accessed through the menu for the first time, but none of this is a "desirable" way to work.
    Given that this seemed ot be the only way to do things, this is how I've implemented this in Ceon URI Mapping v4.0.3.

    It works perfectly well but is a strange way to have had to make things work.

    Just letting know in case any other developer wants to add a link to the Zen Cart admin...


    How to add a menu item to the Zen Cart admin, when users are only copying files across:

    Simply create a file that goes in:

    admin/includes/auto_loaders

    Sample content (minus obligatory comments which should already have been added for good coding standards:)

    PHP Code:
    if (!defined('IS_ADMIN_FLAG')) {
        die(
    'Illegal Access');


    $autoLoadConfig[199][] = array(
        
    'autoType' => 'init_script',
        
    'loadFile' => 'init_ceon_uri_mapping_config.php'
        
    ); 
    Then create a file in

    admin/includes/init_includes

    Sample content:

    PHP Code:
    if (!defined('IS_ADMIN_FLAG')) {
        die(
    'Illegal Access');
    }

    if (
    function_exists('zen_register_admin_page')) {
        if (!
    zen_page_key_exists('ceon_uri_mapping_config')) {
            
    // Add the link to the Ceon URI Mapping Config Utility
            
    zen_register_admin_page('ceon_uri_mapping_config''BOX_CEON_URI_MAPPING',
                
    'FILENAME_CEON_URI_MAPPING_CONFIG''''modules''Y'40);
        }
    }

    // Now that the menu item has been created/registered, can stop the wasteful process of having
    // this script run again by removing it from the auto-loader array
    @unlink(DIR_FS_ADMIN DIR_WS_INCLUDES 'auto_loaders/config.ceon_uri_mapping_config.php'); 
    Obviously adjust as desired for your own software!

    All the best...

    Conor
    ceon

  6. #6
    Join Date
    Dec 2010
    Location
    Seattle
    Posts
    83
    Plugin Contributions
    1

    Default Re: Admin Page Registration for 3rd Party Modules

    I was just searching for a solution to this exact problem. Thanks so much for the detailed instructions!

  7. #7
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Admin Page Registration for 3rd Party Modules

    As an alternative, one could just as easily put the suggested init_includes code into a file in the /admin/includes/extra_functions/ folder, and skip the auto_loaders file.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  8. #8
    Join Date
    Aug 2004
    Location
    Belfast, Northern Ireland
    Posts
    2,480
    Plugin Contributions
    14

    Idea or Suggestion Re: Admin Page Registration for 3rd Party Modules

    Hi,

    Quote Originally Posted by DrByte View Post
    As an alternative, one could just as easily put the suggested init_includes code into a file in the /admin/includes/extra_functions/ folder, and skip the auto_loaders file.
    I tried that but it doesn't work as the registration function doesn't exist at the time the file in the extra_functions folder loads.

    My solution as outlined above appears to be the best way to have a module add options to the admin menus upon initial installation of the module.

    Hope that helps other developers here!

    All the best...

    Conor
    ceon

  9. #9
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Admin Page Registration for 3rd Party Modules

    That'll be fixed in the next 1.5 update (changed the breakpoint for admin_access function file being loaded from 70 to 35).
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  10. #10
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Admin Page Registration for 3rd Party Modules

    Quote Originally Posted by DrByte View Post
    As an alternative, one could just as easily put the suggested init_includes code into a file in the /admin/includes/extra_functions/ folder, and skip the auto_loaders file.
    Quote Originally Posted by conor View Post
    I tried that but it doesn't work as the registration function doesn't exist at the time the file in the extra_functions folder loads.
    Fixed in latest beta update: http://www.zen-cart.com/forum/showth...66#post1065366
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 
Page 1 of 5 123 ... LastLast

Similar Threads

  1. v151 3rd party software access using XML-RPC for PHP
    By torvista in forum Contribution-Writing Guidelines
    Replies: 7
    Last Post: 24 Oct 2012, 10:39 PM
  2. Integrate api code from 3rd party for m commerce
    By ronaldlb in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 5 Apr 2011, 04:05 PM
  3. looking for product_id to implement 3rd party tool in my site
    By Greywacke in forum General Questions
    Replies: 1
    Last Post: 2 Feb 2010, 01:02 PM
  4. 3rd party SSL Certificate Admin and Customer Login don't work
    By gws76 in forum Installing on a Linux/Unix Server
    Replies: 6
    Last Post: 9 Feb 2009, 10:44 AM
  5. 3rd Party PayPal Website Payments Pro Modules
    By webrob in forum Addon Payment Modules
    Replies: 4
    Last Post: 27 Jun 2007, 04:46 AM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR