From 74f2d8df569e22191fffee1bd0b5c145e2d21761 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Thu, 26 Apr 2018 02:09:15 +0200 Subject: [PATCH] Added a switch to control the message display of the expand feature when cronjob runs --- README.md | 6 +- admin/README.txt | 6 +- admin/config.xml | 15 ++++ .../en-GB/en-GB.com_componentbuilder.ini | 4 ++ componentbuilder.xml | 2 +- script.php | 2 +- site/controllers/api.php | 68 +++++++++++++------ 7 files changed, 73 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 1b002a182..660f9cddf 100644 --- a/README.md +++ b/README.md @@ -126,12 +126,12 @@ Component Builder is mapped as a component in itself on my local development env + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](http://joomlacomponentbuilder.com) + *First Build*: 30th April, 2015 -+ *Last Build*: 24th April, 2018 ++ *Last Build*: 26th April, 2018 + *Version*: 2.7.6 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **193223** -+ *Field count*: **1026** ++ *Line count*: **193266** ++ *Field count*: **1027** + *File count*: **1201** + *Folder count*: **193** diff --git a/admin/README.txt b/admin/README.txt index 1b002a182..660f9cddf 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -126,12 +126,12 @@ Component Builder is mapped as a component in itself on my local development env + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](http://joomlacomponentbuilder.com) + *First Build*: 30th April, 2015 -+ *Last Build*: 24th April, 2018 ++ *Last Build*: 26th April, 2018 + *Version*: 2.7.6 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **193223** -+ *Field count*: **1026** ++ *Line count*: **193266** ++ *Field count*: **1027** + *File count*: **1201** + *Folder count*: **193** diff --git a/admin/config.xml b/admin/config.xml index acedbd074..890b879d7 100644 --- a/admin/config.xml +++ b/admin/config.xml @@ -665,6 +665,21 @@ /> + + + + + + diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.ini b/admin/language/en-GB/en-GB.com_componentbuilder.ini index d0c324446..fe0910bfe 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.ini @@ -2324,6 +2324,7 @@ COM_COMPONENTBUILDER_CONFIG_DEFAULT="Default" COM_COMPONENTBUILDER_CONFIG_DEVELOPMENT_METHOD="Development Method" COM_COMPONENTBUILDER_CONFIG_DEVELOPMENT_METHOD_DESCRIPTION="Select what development method you would like to use." COM_COMPONENTBUILDER_CONFIG_DEVELOPMENT_METHOD_LABEL="Development Method" +COM_COMPONENTBUILDER_CONFIG_DISPLAY_MESSAGE="Display Message" COM_COMPONENTBUILDER_CONFIG_DKIM="DKIM" COM_COMPONENTBUILDER_CONFIG_DKIM_DESCRIPTION="Set this option to Yes if you want to sign your emails using DKIM." COM_COMPONENTBUILDER_CONFIG_DKIM_DOMAIN_DESCRIPTION="Set the domain. Eg. domain.com" @@ -2497,6 +2498,7 @@ COM_COMPONENTBUILDER_CONFIG_NOTE_LANGUAGE_GLOBAL_DESCRIPTION="

Here you can se COM_COMPONENTBUILDER_CONFIG_NOTE_LANGUAGE_GLOBAL_LABEL="Global Language Source" COM_COMPONENTBUILDER_CONFIG_OFF="Off" COM_COMPONENTBUILDER_CONFIG_ON="On" +COM_COMPONENTBUILDER_CONFIG_ONLY_BOOLEAN="Only Boolean" COM_COMPONENTBUILDER_CONFIG_ONLY_EXTRA="Only Extra" COM_COMPONENTBUILDER_CONFIG_PACKAGE_NAME_PLAEHOLDERS_DESCRIPTION="[YEAR] [MONTH] [DAY] [HOUR] [MINUTE]" COM_COMPONENTBUILDER_CONFIG_PACKAGE_NAME_PLAEHOLDERS_LABEL="Package Name Placeholders" @@ -2511,6 +2513,8 @@ COM_COMPONENTBUILDER_CONFIG_REPLYNAME_HINT="Reply Name Here" COM_COMPONENTBUILDER_CONFIG_REPLYNAME_LABEL="Reply to Name" COM_COMPONENTBUILDER_CONFIG_REPOSITORY_DESCRIPTION="Should the component be moved to your local repository folder?" COM_COMPONENTBUILDER_CONFIG_REPOSITORY_LABEL="Add to Repository Folder" +COM_COMPONENTBUILDER_CONFIG_RETURN_OPTIONS_BUILD_DESCRIPTION="Should the system return the build info/messages, or simply 1 for success and 0 for failure." +COM_COMPONENTBUILDER_CONFIG_RETURN_OPTIONS_BUILD_LABEL="Return Options for Build" COM_COMPONENTBUILDER_CONFIG_SENDMAIL="Sendmail" COM_COMPONENTBUILDER_CONFIG_SENDMAIL_DESCRIPTION="Enter the path to the sendmail program directory on your host server." COM_COMPONENTBUILDER_CONFIG_SENDMAIL_HINT="/usr/sbin/sendmail" diff --git a/componentbuilder.xml b/componentbuilder.xml index e095e3201..ae4a8985e 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 24th April, 2018 + 26th April, 2018 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://joomlacomponentbuilder.com diff --git a/script.php b/script.php index 0f86f196e..b4b18579d 100644 --- a/script.php +++ b/script.php @@ -3692,7 +3692,7 @@ class com_componentbuilderInstallerScript $query = $db->getQuery(true); // Field to update. $fields = array( - $db->quoteName('params') . ' = ' . $db->quote('{"autorName":"Llewellyn van der Merwe","autorEmail":"llewellyn@joomlacomponentbuilder.com","minify":"0","language":"en-GB","percentagelanguageadd":"50","compiler_field_builder_type":"2","set_browser_storage":"1","storage_time_to_live":"global","development_method":"1","expansion":"0","cronjob_backup_type":"1","cronjob_backup_server":"0","backup_package_name":"JCB_Backup_[YEAR]_[MONTH]_[DAY]","export_license":"GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html","export_copyright":"Copyright (C) 2015. All Rights Reserved","check_in":"-1 day","save_history":"1","history_limit":"10","uikit_load":"1","uikit_min":"","uikit_style":""}'), + $db->quoteName('params') . ' = ' . $db->quote('{"autorName":"Llewellyn van der Merwe","autorEmail":"llewellyn@joomlacomponentbuilder.com","minify":"0","language":"en-GB","percentagelanguageadd":"50","compiler_field_builder_type":"2","set_browser_storage":"1","storage_time_to_live":"global","development_method":"1","expansion":"0","return_options_build":"2","cronjob_backup_type":"1","cronjob_backup_server":"0","backup_package_name":"JCB_Backup_[YEAR]_[MONTH]_[DAY]","export_license":"GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html","export_copyright":"Copyright (C) 2015. All Rights Reserved","check_in":"-1 day","save_history":"1","history_limit":"10","uikit_load":"1","uikit_min":"","uikit_style":""}'), ); // Condition. $conditions = array( diff --git a/site/controllers/api.php b/site/controllers/api.php index 91ff579f9..dd934c995 100644 --- a/site/controllers/api.php +++ b/site/controllers/api.php @@ -219,6 +219,8 @@ class ComponentbuilderControllerApi extends JControllerForm } // check if expansion is enabled $method = $this->params->get('development_method', 1); + // check what kind of return values show we give + $returnOptionsBuild = $this->params->get('return_options_build', 2); if (2 == $method) { // get expansion components @@ -228,8 +230,25 @@ class ComponentbuilderControllerApi extends JControllerForm { // check if user has the right $user = $this->getApiUser(); + // the message package + $message = array(); if ($user->authorise('core.admin', 'com_componentbuilder')) { + // make sure to not unlock + $unlock = false; + // get messages + $callback = function($messages) use (&$message, &$unlock) { + // unlock messages if needed + if ($unlock) { + $messages = ComponentbuilderHelper::unlock($messages); + } + // check if we have any messages + if (ComponentbuilderHelper::checkArray($messages)) { + $message[] = implode("
\n", $messages); + } else { + // var_dump($messages); // error debug message + } + }; // we have two options, doing them one at a time, use using curl to do tome somewhat asynchronously if (count ( (array) $expansion) > 1 && function_exists('curl_version')) { @@ -238,17 +257,8 @@ class ComponentbuilderControllerApi extends JControllerForm { ComponentbuilderHelper::setWorker($component, 'compileInstall'); } - // get messages function - $callback = function($messages) { - $messages = ComponentbuilderHelper::unlock($messages); - // check if we have any messages - if (ComponentbuilderHelper::checkArray($messages)) - { - // echo "
\n".implode("
\n", $messages); // (TODO) adding a switch to show messages - } else { - var_dump($messages); // error debug message - } - }; + // make sure to unlock + $unlock = true; // run workers ComponentbuilderHelper::runWorker('compileInstall', 1, $callback); } @@ -265,26 +275,40 @@ class ComponentbuilderControllerApi extends JControllerForm $model->compileInstall($component); } // check if we have any messages - if (ComponentbuilderHelper::checkArray($model->messages)) - { - // echo the messages - // echo "
\n".implode("
\n", $model->messages); // (TODO) adding a switch to show messages - } else { - var_dump($messages); // error debug message - } + $callback($model->messages); + } + // return messages if found + if (1== $returnOptionsBuild && ComponentbuilderHelper::checkArray($message)) + { + echo implode("
\n", $message); + } + else + { + echo 1; } // clear session JFactory::getApplication()->getSession()->destroy(); jexit(); } - // clear session - JFactory::getApplication()->getSession()->destroy(); - jexit('Access Denied!'); + // check if message is to be returned + if (1== $returnOptionsBuild) + { + // clear session + JFactory::getApplication()->getSession()->destroy(); + jexit('Access Denied!'); + } } } // clear session JFactory::getApplication()->getSession()->destroy(); - jexit('Expansion Disabled!'); + // check if message is to be returned + if (1== $returnOptionsBuild) + { + jexit('Expansion Disabled!'); + } + // return bool + echo 0; + jexit(); } protected function getApiUser()