AnsweredAssumed Answered

Is there a way to conditionally terminate the installation of a Module Loader package?

Question asked by Ramblin Ramblin on Jan 29, 2014
Latest reply on Jun 21, 2014 by Ramblin Ramblin
I am working on SugarCRM CE v6.5.16 on a CentOS 6.4 base

During the install of a package via Module Loader, when I have the pre_execute script called from the manifest file, is there a way to have the logic in pre-execute.php stop all further installation if a certain set of conditions (calculated in the pre-execute.php script) are met?

I have tried putting die(); and exit; in the condition test in the pre-execute script, but that just terminates the running of the pre_execute script, NOT the full installation.  I need the action to terminate the full installation from the pre_execute script.

I am creating a new package using Module Builder, but I also need to edit the editview (and detailview) of the Contacts and Account modules as part of the installation.  If the installation has not already customized the editview /detailview, it is a simple process to copy the editviewdefs.php and detailviewdefs.php files
from <sugar_root>/modules/Contacts/metadata/
to <sugar_root>/custom/modules/Contacts/metadata/
and do the edits required to the files now in the custom directory.

However, if the installation has previously customized the editview/detailview files and they are already in the custom directory, then I want to test for this in my pre_execute file and then give the user a chance to stop the installation if they do not want the editview/detailview files changed.  (The changes are significant)

I have, in the manifest.php file, in the $installdefs array, the follwing to call the pre-execute file:
<pre><code>
    'post_execute' => array
    (
        0 =>  '<basepath>/scripts/post_execute.php',
    ),
</code></pre>
and in the pre_execute.php file in the scripts directory in the package I have the following code (simplified for purposes of this question)
<pre><code>
<?php
if (file_exists('custom/modules/Contacts/metadata/editviewdefs.php)
{
   die('The views are already customized');
}
?>
echo "This will not print out if the file already exists <br />":
</code></pre>

If the file does already exist (the view has already been customized) the pre_execute.php file terminates before echoing the line "This will not print out if the file already exists".

But the other parts of the manifest file continue to do what they are supposed to do (copy files, run post_execute scripts, ...) and I want everything to stop.

Is there a way to have the logic in pre-execute.php stop all further installation?

Ramblin









Outcomes