Results 1 to 4 of 4

Thread: HOW TO: Cleaning add a custom entry point

  1. #1
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default HOW TO: Cleaning add a custom entry point

    Adding a custom entry to the custom/include/MVC/Controller/entry_point_registry.php by simply copying the file during install will cause issues if a previously installed module also makes use of the file. To add and remove just yours during install add the following files to your module zip (NOTE: this can be cleaned up and better generalized):

    scripts/pre_install.php:
    PHP Code:
    <?php
    if (! defined('sugarEntry') || ! sugarEntry)
        die(
    'Not A Valid Entry Point');


    function 
    pre_install() {

        
    /** add following:
        $entry_point_registry['CustomEntryPointOne'] = array('file' => 'custom/modules/MyCustomEntry/CustomEntryPointOne.php', 'auth' => true);
        $entry_point_registry['CustomEntryPointTwo'] = array('file' => 'custom/modules/MyCustomEntry/CustomEntryPointTwo.php', 'auth' => true);
        */

        
    $add_entry_point false;
        
    $new_contents "";
        
    $entry_point_registry null;
        if(
    file_exists("custom/include/MVC/Controller/entry_point_registry.php")){

            
    // This will load an array of the hooks to process
            
    include("custom/include/MVC/Controller/entry_point_registry.php");

            
            if(!isset(
    $entry_point_registry['CustomEntryPointOne'])) {
                
    $add_entry_point true;
                
    $entry_point_registry['CustomEntryPointOne'] = array('file' => 'custom/modules/MyCustomEntry/CustomEntryPointOne.php''auth' => true);
            }
            if(!isset(
    $entry_point_registry['CustomEntryPointTwo'])) {
                
    $add_entry_point true;
                
    $entry_point_registry['CustomEntryPointTwo'] = array('file' => 'custom/modules/MyCustomEntry/CustomEntryPointTwo.php''auth' => true);
            }
        } else {
            
    $add_entry_point true;    
            
    $entry_point_registry['CustomEntryPointOne'] = array('file' => 'custom/modules/MyCustomEntry/CustomEntryPointOne.php''auth' => true);
            
    $entry_point_registry['CustomEntryPointTwo'] = array('file' => 'custom/modules/MyCustomEntry/CustomEntryPointTwo.php''auth' => true);
        }
        if(
    $add_entry_point == true){

            require_once(
    'include/utils/array_utils.php');
            require_once(
    'include/utils/sugar_file_utils.php');

            foreach(
    $entry_point_registry as $entryPoint => $epArray){
                
    $new_contents .= "\$entry_point_registry['".$entryPoint."'] = array('file' => '".$epArray['file']."' , 'auth' => '".$epArray['auth']."'); \n";
            }
            
            
    $new_contents "<?php\n$new_contents\n?>";
            
    $file 'custom/include/MVC/Controller/entry_point_registry.php';
            
    $paths explode('/',$file);
            
    $dir '';
            for(
    $i 0$i sizeof($paths) - 1$i++)
            {
                if(
    $i 0$dir .= '/';
                
    $dir .= $paths[$i];
                if(!
    file_exists($dir))
                {
                    
    sugar_mkdir($dir0755);
                }
            }
            
    $fp sugar_fopen($file'wb');
            
    fwrite($fp,$new_contents);
            
    fclose($fp);
        }
    }
    ?>
    scripts/pre_uninstall.php:
    PHP Code:
    Running pre_uninstall...
    <?php
    if (! defined('sugarEntry') || ! sugarEntry)
        die(
    'Not A Valid Entry Point');


    function 
    pre_uninstall() {

        
    /** remove following:
        $entry_point_registry['CustomEntryPointOne'] = array('file' => 'custom/modules/MyCustomEntry/CustomEntryPointOne.php', 'auth' => true);
        $entry_point_registry['CustomEntryPointTwo'] = array('file' => 'custom/modules/MyCustomEntry/CustomEntryPointTwo.php', 'auth' => true);
        */
        
    $remove_entry_point false;
        
    $new_contents "";
        
    $entry_point_registry null;
        if(
    file_exists("custom/include/MVC/Controller/entry_point_registry.php")){
        
            include(
    "custom/include/MVC/Controller/entry_point_registry.php");

            if(isset(
    $entry_point_registry['CustomEntryPointOne'])) {
                
    $remove_entry_point true;
                unset(
    $entry_point_registry['CustomEntryPointOne']);
            }
            if(isset(
    $entry_point_registry['CustomEntryPointTwo'])) {
                
    $remove_entry_point true;
                unset(
    $entry_point_registry['CustomEntryPointTwo']);
            }
            if(
    $remove_entry_point == true){        

                require_once(
    'include/utils/array_utils.php');
                require_once(
    'include/utils/sugar_file_utils.php');
            
                foreach(
    $entry_point_registry as $entryPoint => $epArray){
                    
    $new_contents .= "\$entry_point_registry['".$entryPoint."'] = array('file' => '".$epArray['file']."' , 'auth' => '".$epArray['auth']."'); \n";
                }
                
    $new_contents "<?php\n$new_contents\n?>";
                
    $file 'custom/include/MVC/Controller/entry_point_registry.php';
                
    $fp sugar_fopen($file'wb');
                
    fwrite($fp,$new_contents);
                
    fclose($fp);
            }
            
        }    
    }
    ?>

  2. #2
    beschaeftigt.de's Avatar
    beschaeftigt.de is offline Sugar Community Member
    Join Date
    Mar 2009
    Location
    Europe
    Posts
    24

    Default Re: HOW TO: Cleaning add a custom entry point

    Thank you for your scripts. They really helped me.
    I hope some day it will become included into sugar itself.

  3. #3
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: HOW TO: Cleaning add a custom entry point

    Good insight Jason!

    SugarCRM will introduce, in 6.3 or 6.4, several other features inside installer, including entry points.

    Best regards
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  4. #4
    ibrs is offline Member
    Join Date
    Sep 2007
    Posts
    16

    Default Re: HOW TO: Cleaning add a custom entry point

    Did this functionality make it into 6.3, i.e., adding entry points from the module builder?

    I'm testing 6.3 RC and can't see this

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. custom entry point clarification needed
    By JVWay in forum Developer Help
    Replies: 2
    Last Post: 2008-10-15, 09:18 PM
  2. Not a valid entry point
    By 4people in forum Polish
    Replies: 0
    Last Post: 2006-09-19, 10:11 AM
  3. Not A Valid Entry Point
    By beedsley in forum Help
    Replies: 6
    Last Post: 2006-07-11, 09:19 AM
  4. Not A Valid Entry Point
    By kvervo in forum Help
    Replies: 0
    Last Post: 2006-06-25, 10:43 AM
  5. Not A Valid Entry Point
    By alsobrooks in forum Help
    Replies: 0
    Last Post: 2006-06-22, 10:39 PM

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
  •