Fixed gh-234 to insure that the FTP server option works. Added the server option to the JCB package backup area.

This commit is contained in:
Llewellyn van der Merwe 2018-02-20 22:46:29 +02:00
parent ab88bd49a0
commit 9d64afe138
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
18 changed files with 685 additions and 427 deletions

View File

@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will safe you lots of time and money. A real must have!
You can install it quite easily and with no limitations. On [github](https://github.com/vdm-io/Joomla-Component-Builder/releases) is the latest release (2.6.15) with **ALL** its features and **ALL** concepts totally open-source and free!
You can install it quite easily and with no limitations. On [github](https://github.com/vdm-io/Joomla-Component-Builder/releases) is the latest release (2.6.16) with **ALL** its features and **ALL** concepts totally open-source and free!
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
@ -126,13 +126,13 @@ 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*: 19th February, 2018
+ *Version*: 2.6.15
+ *Last Build*: 20th February, 2018
+ *Version*: 2.6.16
+ *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*: **182095**
+ *Line count*: **182404**
+ *Field count*: **1639**
+ *File count*: **1167**
+ *File count*: **1168**
+ *Folder count*: **188**
> This **component** was build with a Joomla [Automated Component Builder](http://joomlacomponentbuilder.com).

View File

@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will safe you lots of time and money. A real must have!
You can install it quite easily and with no limitations. On [github](https://github.com/vdm-io/Joomla-Component-Builder/releases) is the latest release (2.6.15) with **ALL** its features and **ALL** concepts totally open-source and free!
You can install it quite easily and with no limitations. On [github](https://github.com/vdm-io/Joomla-Component-Builder/releases) is the latest release (2.6.16) with **ALL** its features and **ALL** concepts totally open-source and free!
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
@ -126,13 +126,13 @@ 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*: 19th February, 2018
+ *Version*: 2.6.15
+ *Last Build*: 20th February, 2018
+ *Version*: 2.6.16
+ *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*: **182095**
+ *Line count*: **182404**
+ *Field count*: **1639**
+ *File count*: **1167**
+ *File count*: **1168**
+ *Folder count*: **188**
> This **component** was build with a Joomla [Automated Component Builder](http://joomlacomponentbuilder.com).

View File

@ -547,6 +547,27 @@
description="COM_COMPONENTBUILDER_CONFIG_BACKUPCRONJOB_NOTE_DESCRIPTION"
heading="h4"
class="backupcronjob_note" />
<!-- Cronjob_backup_type Field. Type: Radio. (joomla) -->
<field type="radio"
name="cronjob_backup_type"
label="COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_TYPE_LABEL"
description="COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_TYPE_DESCRIPTION"
class="btn-group btn-group-yesno"
default="1">
<!-- Option Set.-->
<option value="1">COM_COMPONENTBUILDER_CONFIG_LOCAL_FOLDER</option>
<option value="2">COM_COMPONENTBUILDER_CONFIG_REMOTE_SERVER</option>
</field>
<!-- Cronjob_backup_server Field. Type: Servers. (custom) -->
<field type="servers"
name="cronjob_backup_server"
label="COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_SERVER_LABEL"
description="COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_SERVER_DESCRIPTION"
class="list_class"
multiple="false"
default="0"
showon="cronjob_backup_type:2"
button="true" />
<!-- Cronjob_backup_folder_path Field. Type: Text. (joomla) -->
<field type="text"
name="cronjob_backup_folder_path"
@ -560,7 +581,8 @@
required="false"
filter="PATH"
message="COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_FOLDER_PATH_MESSAGE"
hint="COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_FOLDER_PATH_HINT" />
hint="COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_FOLDER_PATH_HINT"
showon="cronjob_backup_type:1" />
<!-- Backup_email Field. Type: Text. (joomla) -->
<field type="text"
name="backup_email"

View File

@ -242,17 +242,20 @@ class ComponentbuilderControllerJoomla_components extends JControllerAdmin
public function backup()
{
// get params
// get params first
if (!isset($this->params) || !ComponentbuilderHelper::checkObject($this->params))
{
$this->params = JComponentHelper::getParams('com_componentbuilder');
}
// get all component IDs to backup
$pks = componentbuilderHelper::getComponentIDs();
// Get the model
$model = componentbuilderHelper::getModel('joomla_components', JPATH_ADMINISTRATOR . '/components/com_componentbuilder');
// set user
$model->user = $this->getApiUser();
// check if export is allowed for this user. (we need this sorry)
if ($model->user->authorise('joomla_component.export', 'com_componentbuilder') && $model->user->authorise('core.export', 'com_componentbuilder'))
{
// get all component IDs to backup
$pks = componentbuilderHelper::getComponentIDs();
// make sure to set active type to backup
$model->activeType = 'manualBackup';
// set auto loader
@ -378,11 +381,24 @@ class ComponentbuilderControllerJoomla_components extends JControllerAdmin
if ('backup' === 'manualBackup')
{
echo "# " . $backupNoticeStatus . "\n" .implode("\n", $backupNotice);
// clear session
JFactory::getApplication()->getSession()->destroy();
jexit();
}
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), implode("<br />", $backupNotice), $backupNoticeStatus);
return;
}
// quite only if auto backup (adding this script from custom code :)
if ('backup' === 'manualBackup')
{
echo "# Error\n".JText::_('COM_COMPONENTBUILDER_ACCESS_DENIED');
// clear session
JFactory::getApplication()->getSession()->destroy();
jexit();
}
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), JText::_('COM_COMPONENTBUILDER_ACCESS_DENIED'), 'Error');
return;
}
protected function getApiUser()
{

View File

@ -318,37 +318,10 @@ class Compiler extends Infusion
// make sure we have the correct file
if (JFile::exists($xml_update_server_path) && isset($this->componentData->update_server))
{
// use FTP
if ($this->componentData->update_server_protocol == 1)
{
// get server details
if ($ftp = ComponentbuilderHelper::getServer((int) $this->componentData->update_server, 1))
{
// now move the file
if (!$ftp->store($xml_update_server_path, null))
{
$this->app->enqueueMessage(JText::sprintf('The <b>%s</b> file could not be moved to <b>%s</b> server.', $this->updateServerFileName . '.xml', $$ftp->remote_server_name[(int) $this->componentData->update_server]), 'Error');
}
// move to server
ComponentbuilderHelper::moveToServer($xml_update_server_path, $this->updateServerFileName . '.xml', (int) $this->componentData->update_server, $this->componentData->update_server_protocol);
// remove the local file
JFile::delete($xml_update_server_path);
// close the connection
$ftp->quit();
}
}
// use SFTP
elseif ($this->componentData->update_server_protocol == 2)
{
if ($sftp = ComponentbuilderHelper::getServer((int) $this->componentData->update_server, 2))
{
// now move the file
if (!$sftp->put($sftp->remote_server_path[(int) $this->componentData->update_server] . $this->updateServerFileName . '.xml', ComponentbuilderHelper::getFileContents($xml_update_server_path, null)))
{
$this->app->enqueueMessage(JText::sprintf('The <b>%s</b> file could not be moved to <b>%s</b> path on <b>%s</b> server.', $this->updateServerFileName . '.xml', $sftp->remote_server_path[(int) $this->componentData->update_server], $sftp->remote_server_name[(int) $this->componentData->update_server]), 'Error');
}
// remove the local file
JFile::delete($xml_update_server_path);
}
}
}
}
}
@ -519,32 +492,8 @@ class Compiler extends Infusion
// make sure we have the correct file
if (isset($this->componentData->sales_server))
{
// use FTP
if ($this->componentData->sales_server_protocol == 1)
{
if ($ftp = ComponentbuilderHelper::getServer((int) $this->componentData->sales_server, 1))
{
// now move the file
if (!$ftp->store($xml_update_server_path, $this->componentSalesName . '.zip'))
{
$this->app->enqueueMessage(JText::sprintf('The <b>%s</b> file could not be moved to <b>%s</b> server.', $this->componentSalesName . '.zip', $ftp->remote_server_name[(int) $this->componentData->sales_server]), 'Error');
}
// close the connection
$ftp->quit();
}
}
// use SFTP
elseif ($this->componentData->sales_server_protocol == 2)
{
if ($sftp = ComponentbuilderHelper::getServer((int) $this->componentData->sales_server, 2))
{
// now move the file
if (!$sftp->put($sftp->remote_server_path[(int) $this->componentData->sales_server] . $this->componentSalesName . '.zip', ComponentbuilderHelper::getFileContents($this->filepath, null)))
{
$this->app->enqueueMessage(JText::sprintf('The <b>%s</b> file could not be moved to <b>%s</b> path on <b>%s</b> server.', $this->componentSalesName . '.zip', $sftp->remote_server_path[(int) $this->componentData->sales_server], $sftp->remote_server_name[(int) $this->componentData->sales_server]), 'Error');
}
}
}
// move to server
ComponentbuilderHelper::moveToServer($this->filepath, $this->componentSalesName . '.zip', (int) $this->componentData->sales_server, $this->componentData->sales_server_protocol);
}
}
// remove the component folder since we are done

View File

@ -1953,6 +1953,49 @@ abstract class ComponentbuilderHelper
require_once JPATH_ADMINISTRATOR.'/components/com_componentbuilder/helpers/vendor/autoload.php';
}
/**
* Move File to Server
*
* @param string $localPath The local path to the file
* @param string $fileName The the actual file name
* @param int $serverID The server local id to use
* @param int $protocol The server protocol to use
* @param string $permission The permission validation area
*
* @return bool true on success
**/
public static function moveToServer($localPath, $fileName, $serverID, $protocol = null, $permission = 'core.export')
{
// get the server
if ($server = self::getServer( (int) $serverID, $protocol, $permission))
{
// use the FTP protocol
if (1 == $server->jcb_protocol)
{
// now move the file
if (!$server->store($localPath, $fileName))
{
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_SERVER', $fileName, $server->jcb_remote_server_name[(int) $serverID]), 'Error');
return false;
}
// close the connection
$server->quit();
}
// use the SFTP protocol
elseif (2 == $server->jcb_protocol)
{
// now move the file
if (!$server->put($server->jcb_remote_server_path[(int) $serverID] . $fileName, self::getFileContents($localPath, null)))
{
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_PATH_ON_BSB_SERVER', $fileName, $server->jcb_remote_server_path[(int) $serverID], $server->jcb_remote_server_name[(int) $serverID]), 'Error');
return false;
}
}
return true;
}
return false;
}
/**
* the SFTP objects
**/
@ -1972,8 +2015,13 @@ abstract class ComponentbuilderHelper
*
* @return object on success server object
**/
public static function getServer($serverID, $protocol, $permission = 'core.export')
public static function getServer($serverID, $protocol = null, $permission = 'core.export')
{
// if not protocol is given get it (sad I know)
if (!$protocol)
{
$protocol = self::getVar('server', (int) $serverID, 'id', 'protocol');
}
// return the server object
switch ($protocol)
{
@ -2016,6 +2064,8 @@ abstract class ComponentbuilderHelper
$server->port = (isset($server->port) && is_int($server->port) && $server->port > 0) ? $server->port : 22;
// open the connection
self::$sftp[$server->cache] = new phpseclib\Net\SFTP($server->host, $server->port);
// heads-up on protocol
self::$sftp[$server->cache]->jcb_protocol = 2; // SFTP <-- if called not knowing what type of protocol is being used
// now login based on authentication type
switch($server->authentication)
{
@ -2077,14 +2127,14 @@ abstract class ComponentbuilderHelper
if (isset(self::$sftp[$server->cache]) && self::checkObject(self::$sftp[$server->cache]))
{
// set the unique buckets
if (!isset(self::$sftp[$server->cache]->remote_server_name))
if (!isset(self::$sftp[$server->cache]->jcb_remote_server_name))
{
self::$sftp[$server->cache]->remote_server_name = array();
self::$sftp[$server->cache]->remote_server_path = array();
self::$sftp[$server->cache]->jcb_remote_server_name = array();
self::$sftp[$server->cache]->jcb_remote_server_path = array();
}
// always set the name and remote server path
self::$sftp[$server->cache]->remote_server_name[$serverID] = $server->name;
self::$sftp[$server->cache]->remote_server_path[$serverID] = (self::checkString($server->path) && $server->path !== '/') ? $server->path : '';
self::$sftp[$server->cache]->jcb_remote_server_name[$serverID] = $server->name;
self::$sftp[$server->cache]->jcb_remote_server_path[$serverID] = (self::checkString($server->path) && $server->path !== '/') ? $server->path : '';
// return the sftp object
return self::$sftp[$server->cache];
}
@ -2109,7 +2159,7 @@ abstract class ComponentbuilderHelper
if (isset(self::$ftp[$server->cache]) && self::$ftp[$server->cache] instanceof JClientFtp)
{
// always set the name and remote server path
self::$ftp[$server->cache]->remote_server_name[$serverID] = $server->name;
self::$ftp[$server->cache]->jcb_remote_server_name[$serverID] = $server->name;
// if still connected we are ready to go
if (self::$ftp[$server->cache]->isConnected())
{
@ -2162,13 +2212,15 @@ abstract class ComponentbuilderHelper
// check if we are connected
if (self::$ftp[$server->cache] instanceof JClientFtp && self::$ftp[$server->cache]->isConnected())
{
// heads-up on protocol
self::$ftp[$server->cache]->jcb_protocol = 1; // FTP <-- if called not knowing what type of protocol is being used
// set the unique buckets
if (!isset(self::$ftp[$server->cache]->remote_server_name))
if (!isset(self::$ftp[$server->cache]->jcb_remote_server_name))
{
self::$ftp[$server->cache]->remote_server_name = array();
self::$ftp[$server->cache]->jcb_remote_server_name = array();
}
// always set the name and remote server path
self::$ftp[$server->cache]->remote_server_name[$serverID] = $server->name;
self::$ftp[$server->cache]->jcb_remote_server_name[$serverID] = $server->name;
// return the FTP instance
return self::$ftp[$server->cache];
}

View File

@ -1,6 +1,7 @@
COM_COMPONENTBUILDER="Component Builder"
COM_COMPONENTBUILDER_ABOVE_TABS="Above Tabs"
COM_COMPONENTBUILDER_ACCESS_BULK_TOOLS="Access Bulk Tools"
COM_COMPONENTBUILDER_ACCESS_DENIED="Access denied!"
COM_COMPONENTBUILDER_ACTIVE_ONLY_FOUR_TEXT_FIELD="Active (only 4 text_field)"
COM_COMPONENTBUILDER_ADD_ACCESS="Add Access"
COM_COMPONENTBUILDER_ADD_CORRESPONDING_LINE_NUMBERS_TO_THE_DYNAMIC_COMMENTS_SO_TO_SEE_WHERE_IN_THE_COMPILER_THE_LINES_OF_CODE_WAS_BUILD_THIS_WILL_HELP_IF_YOU_NEED_TO_GET_MORE_TECHNICAL_WITH_AN_ISSUE_ON_GITHUB_OR_EVEN_FOR_YOUR_OWN_DEBUGGING="Add corresponding line numbers to the dynamic comments, so to see where in the compiler the lines of code was build. This will help if you need to get more technical with an issue on github, or even for your own debugging."
@ -2241,6 +2242,10 @@ COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_FOLDER_PATH_DESCRIPTION="Here you can
COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_FOLDER_PATH_HINT="/home/user/fullbackup"
COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_FOLDER_PATH_LABEL="Cronjob Backup Folder Path"
COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_FOLDER_PATH_MESSAGE="Error! Please add some text here."
COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_SERVER_DESCRIPTION="Select your backup server for JCB package backups."
COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_SERVER_LABEL="Cronjob Backup Server"
COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_TYPE_DESCRIPTION="Select how you would like to backup JCB"
COM_COMPONENTBUILDER_CONFIG_CRONJOB_BACKUP_TYPE_LABEL="Cronjob Backup type"
COM_COMPONENTBUILDER_CONFIG_CUSTOM_FOLDER_PATH_DESCRIPTION="Here you can set the path to the custom folder"
COM_COMPONENTBUILDER_CONFIG_CUSTOM_FOLDER_PATH_HINT="/home/user/custom"
COM_COMPONENTBUILDER_CONFIG_CUSTOM_FOLDER_PATH_LABEL="Custom Folder Path"
@ -2330,6 +2335,7 @@ COM_COMPONENTBUILDER_CONFIG_GLOBAL_DESC="The Global Parameters"
COM_COMPONENTBUILDER_CONFIG_GLOBAL_LABEL="Global"
COM_COMPONENTBUILDER_CONFIG_GRADIANT_LOAD="Gradient"
COM_COMPONENTBUILDER_CONFIG_INACTIVE="Inactive"
COM_COMPONENTBUILDER_CONFIG_LOCAL_FOLDER="Local Folder"
COM_COMPONENTBUILDER_CONFIG_MAILER_DESCRIPTION="Select what mailer you would like to use to send emails."
COM_COMPONENTBUILDER_CONFIG_MAILER_LABEL="Mailer"
COM_COMPONENTBUILDER_CONFIG_MAILONLINE_DESCRIPTION="Warning this will stop all emails from going out."
@ -2384,6 +2390,7 @@ COM_COMPONENTBUILDER_CONFIG_PACKAGE_NAME_PLAEHOLDERS_LABEL="Package Name Placeho
COM_COMPONENTBUILDER_CONFIG_PERCENTAGELANGUAGEADD_DESCRIPTION="Select percentage any language should be translated before the system should add the language to the component during compilation."
COM_COMPONENTBUILDER_CONFIG_PERCENTAGELANGUAGEADD_LABEL="Add Language if %? ready."
COM_COMPONENTBUILDER_CONFIG_PHP_MAIL="PHP Mail"
COM_COMPONENTBUILDER_CONFIG_REMOTE_SERVER="Remote Server"
COM_COMPONENTBUILDER_CONFIG_REPLYNAME_DESCRIPTION="Text displayed in the header &quot;Reply To:&quot; field when replying to the site email. Usually the the person that receives the response. (leave blank for none)"
COM_COMPONENTBUILDER_CONFIG_REPLYNAME_HINT="Reply Name Here"
COM_COMPONENTBUILDER_CONFIG_REPLYNAME_LABEL="Reply to Name"
@ -6134,6 +6141,8 @@ COM_COMPONENTBUILDER_THERE_ARE_NO_SNIPPETS_TO_UPDATE_AT_THIS_TIME="There are no
COM_COMPONENTBUILDER_THERE_HAS_BEEN_AN_ERROR_IF_THIS_CONTINUES_PLEASE_INFORM_YOUR_SYSTEM_ADMINISTRATOR_OF_A_TYPE_ERROR_IN_THE_FIELDS_DISPLAY_REQUEST="There has been an error, if this continues please inform your system administrator of a type error in the fields display request!"
COM_COMPONENTBUILDER_THERE_WAS_A_PROBLEM_BNO_VIEW_OR_ID_FOUND_IN_SESSION_OR_VIEW_NOT_ALLOWED_TO_ACCESS_AREAB_WE_COULD_NOT_LOAD_ANY_LINKED_TO_VALUES_PLEASE_INFORM_YOUR_SYSTEM_ADMINISTRATOR="There was a problem, <b>no view or id found in session or view not allowed to access area</b>, we could not load any linked to values. Please inform your system administrator!"
COM_COMPONENTBUILDER_THE_BPHPSECLIBNETSFTPB_LIBRARYCLASS_IS_NOT_AVAILABLE_THIS_LIBRARYCLASS_SHOULD_HAVE_BEEN_ADDED_TO_YOUR_ADMINHELPERSVENDOR_FOLDER_OF_JCB_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO="The <b>phpseclib\NET\SFTP</b> library\class is not available! This library\class should have been added to your admin/helpers/vendor folder of JCB. Please contact your system administrator for more info"
COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_PATH_ON_BSB_SERVER="The <b>%s</b> file could not be moved to <b>%s</b> path on <b>%s</b> server."
COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_SERVER="The <b>%s</b> file could not be moved to <b>%s</b> server."
COM_COMPONENTBUILDER_THE_BSB_LIBRARY_CAN_NOT_BE_DELETED_OR_THINGS_WILL_BREAK="The <b>%s</b> library can not be deleted, or things will break."
COM_COMPONENTBUILDER_THE_COMPONENT_ADMIN_VIEWS="The component admin views"
COM_COMPONENTBUILDER_THE_COMPONENT_CONFIG="The component config"

View File

@ -1772,7 +1772,7 @@ class ComponentbuilderModelAjax extends JModelList
public function usedin($functioName, $id, $targeting)
{
// get the table being targeted
if ($target = $this->getTableQueryOptions($targeting))
if ($target = $this->getCodeSearchKeys($targeting, 'query'))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
@ -1842,114 +1842,139 @@ class ComponentbuilderModelAjax extends JModelList
}
/**
* Get the table query to search for function used in
* Get the keys of the values to search custom code in
*
* @param string $targe The table targeted
* @param string $type The type of get
*
* @return array The query options
*
*/
protected function getTableQueryOptions($target)
protected function getCodeSearchKeys($target, $type = null)
{
$query = array();
// #__componentbuilder_joomla_component as a
$query['a'] = array();
$query['a']['table'] = 'joomla_component';
$query['a']['view'] = 'joomla_components';
$query['a']['select'] = array('id', 'system_name', 'php_preflight_install','php_postflight_install',
// set the template if type is query
if ('query' === $type)
{
$tables = array(
'a' => 'joomla_component',
'b' => 'admin_view',
'c' => 'custom_admin_view',
'd' => 'site_view',
'e' => 'field',
'f' => 'dynamic_get',
'g' => 'template',
'h' => 'layout',
'i' => 'component_dashboard',
'j' => 'library',
);
// check if we have a match
if (isset($tables[$target]))
{
$target = $tables[$target];
}
}
// start target arrays
$targets = array();
// #__componentbuilder_joomla_component
$targets['joomla_component'] = array();
$targets['joomla_component']['search'] = array('id', 'system_name', 'php_preflight_install','php_postflight_install',
'php_preflight_update','php_postflight_update','php_method_uninstall',
'php_helper_admin','php_admin_event','php_helper_both','php_helper_site',
'php_site_event','javascript');
$query['a']['not_base64'] = array();
$query['a']['name'] = 'system_name';
$targets['joomla_component']['view'] = 'joomla_components';
$targets['joomla_component']['not_base64'] = array();
$targets['joomla_component']['name'] = 'system_name';
// #__componentbuilder_admin_view as b
$query['b'] = array();
$query['b']['table'] = 'admin_view';
$query['b']['view'] = 'admin_views';
$query['b']['select'] = array('id', 'system_name', 'javascript_view_file','javascript_view_footer','javascript_views_file',
'javascript_views_footer','php_getitem','php_save','php_postsavehook','php_getitems',
'php_getitems_after_all','php_getlistquery','php_allowedit','php_before_delete',
'php_after_delete','php_before_publish','php_after_publish','php_batchcopy',
'php_batchmove','php_document','php_model','php_controller','php_import_display',
'php_import','php_import_setdata','php_import_save','html_import_view','php_ajaxmethod');
$query['b']['not_base64'] = array();
$query['b']['name'] = 'system_name';
// #__componentbuilder_component_dashboard
$targets['component_dashboard'] = array();
$targets['component_dashboard']['search'] = array('id', 'joomla_component', 'php_dashboard_methods','dashboard_tab');
$targets['component_dashboard']['view'] = 'components_dashboard';
$targets['component_dashboard']['not_base64'] = array('dashboard_tab' => 'json');
$targets['component_dashboard']['name'] = 'joomla_component->id:joomla_component.system_name';
// #__componentbuilder_custom_admin_view as c
$query['c'] = array();
$query['c']['table'] = 'custom_admin_view';
$query['c']['view'] = 'custom_admin_views';
$query['c']['select'] = array('id', 'system_name', 'default','php_view','php_jview','php_jview_display','php_document',
// #__componentbuilder_admin_view
$targets['admin_view'] = array();
$targets['admin_view']['search'] = array('id', 'system_name', 'javascript_view_file','javascript_view_footer',
'javascript_views_file','javascript_views_footer','html_import_view',
'php_after_delete','php_after_publish','php_ajaxmethod','php_allowedit','php_batchcopy',
'php_batchmove','php_before_delete','php_before_publish','php_before_save','php_controller',
'php_controller_list','php_document','php_getitem','php_getitems','php_getitems_after_all',
'php_getlistquery','php_import','php_import_display','php_import_ext','php_import_headers',
'php_import_save','php_import_setdata','php_model','php_model_list','php_postsavehook','php_save');
$targets['admin_view']['view'] = 'admin_views';
$targets['admin_view']['not_base64'] = array();
$targets['admin_view']['name'] = 'system_name';
// #__componentbuilder_custom_admin_view
$targets['custom_admin_view'] = array();
$targets['custom_admin_view']['search'] = array('id', 'system_name', 'default','php_view','php_jview','php_jview_display','php_document',
'js_document','css_document','css','php_ajaxmethod','php_model','php_controller');
$query['c']['not_base64'] = array();
$query['c']['name'] = 'system_name';
$targets['custom_admin_view']['view'] = 'custom_admin_views';
$targets['custom_admin_view']['not_base64'] = array();
$targets['custom_admin_view']['name'] = 'system_name';
// #__componentbuilder_site_view as d
$query['d'] = array();
$query['d']['table'] = 'site_view';
$query['d']['view'] = 'site_views';
$query['d']['select'] = array('id', 'system_name', 'default','php_view','php_jview','php_jview_display','php_document',
// #__componentbuilder_site_view
$targets['site_view'] = array();
$targets['site_view']['search'] = array('id', 'system_name', 'default','php_view','php_jview','php_jview_display','php_document',
'js_document','css_document','css','php_ajaxmethod','php_model','php_controller');
$query['d']['not_base64'] = array();
$query['d']['name'] = 'system_name';
$targets['site_view']['view'] = 'site_views';
$targets['site_view']['not_base64'] = array();
$targets['site_view']['name'] = 'system_name';
// #__componentbuilder_field as e
$query['e'] = array();
$query['e']['table'] = 'field';
$query['e']['view'] = 'fields';
$query['e']['select'] = array('id', 'name', 'xml','javascript_view_footer','javascript_views_footer');
$query['e']['not_base64'] = array('xml' => 'json');
$query['e']['name'] = 'name';
// #__componentbuilder_field
$targets['field'] = array();
$targets['field']['search'] = array('id', 'name', 'xml','javascript_view_footer','javascript_views_footer');
$targets['field']['view'] = 'fields';
$targets['field']['not_base64'] = array('xml' => 'json');
$targets['field']['name'] = 'name';
// #__componentbuilder_dynamic_get as f
$query['f'] = array();
$query['f']['table'] = 'dynamic_get';
$query['f']['view'] = 'dynamic_gets';
$query['f']['select'] = array('id', 'name', 'php_before_getitem','php_after_getitem','php_before_getitems','php_after_getitems',
// #__componentbuilder_dynamic_get
$targets['dynamic_get'] = array();
$targets['dynamic_get']['search'] = array('id', 'name', 'php_before_getitem','php_after_getitem','php_before_getitems','php_after_getitems',
'php_getlistquery');
$query['f']['not_base64'] = array();
$query['f']['name'] = 'name';
$targets['dynamic_get']['view'] = 'dynamic_gets';
$targets['dynamic_get']['not_base64'] = array();
$targets['dynamic_get']['name'] = 'name';
// #__componentbuilder_template as g
$query['g'] = array();
$query['g']['table'] = 'template';
$query['g']['view'] = 'templates';
$query['g']['select'] = array('id', 'name', 'php_view','template');
$query['g']['not_base64'] = array();
$query['g']['name'] = 'name';
// #__componentbuilder_template
$targets['template'] = array();
$targets['template']['search'] = array('id', 'name', 'php_view','template');
$targets['template']['view'] = 'templates';
$targets['template']['not_base64'] = array();
$targets['template']['name'] = 'name';
// #__componentbuilder_layout as h
$query['h'] = array();
$query['h']['table'] = 'layout';
$query['h']['view'] = 'layouts';
$query['h']['select'] = array('id', 'name', 'php_view','layout');
$query['h']['not_base64'] = array();
$query['h']['name'] = 'name';
// #__componentbuilder_layout
$targets['layout'] = array();
$targets['layout']['search'] = array('id', 'name', 'php_view','layout');
$targets['layout']['view'] = 'layouts';
$targets['layout']['not_base64'] = array();
$targets['layout']['name'] = 'name';
// #__componentbuilder_component_dashboard as i
$query['i'] = array();
$query['i']['table'] = 'component_dashboard';
$query['i']['view'] = 'components_dashboard';
$query['i']['select'] = array('id', 'joomla_component', 'php_dashboard_methods','dashboard_tab');
$query['i']['not_base64'] = array('dashboard_tab' => 'json');
$query['i']['name'] = 'joomla_component->id:joomla_component.system_name';
// #__componentbuilder_library
$targets['library'] = array();
$targets['library']['view'] = 'libraries';
$targets['library']['search'] = array('id', 'name', 'php_setdocument');
$targets['library']['view'] = 'libraries';
$targets['library']['not_base64'] = array();
$targets['library']['name'] = 'name';
// #__componentbuilder_library as j
$query['j'] = array();
$query['j']['table'] = 'library';
$query['j']['view'] = 'libraries';
$query['j']['select'] = array('id', 'name', 'php_setdocument');
$query['j']['not_base64'] = array();
$query['j']['name'] = 'name';
// return the query string to search
if (isset($query[$target]))
// return result ready for a.query
if ('query' === $type && isset($targets[$target]))
{
// add the .a to the selection array
$query[$target]['select'] = array_map( function($select) { return 'a.'.$select; },$query[$target]['select']);
$targets[$target]['select'] = array_map( function($select) { return 'a.'.$select; }, $targets[$target]['search']);
// also set the table
$targets[$target]['table'] = $target;
// remove search
unset($targets[$target]['search']);
// return
return $query[$target];
return $targets[$target];
}
// return the query string to search
elseif (isset($targets[$target]))
{
// remove name and id
return $targets[$target];
}
return false;
}

View File

@ -151,7 +151,7 @@ class JFormFieldServers extends JFormFieldList
{
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.name','a.protocol'),array('id','update_server_name', 'protocol')));
$query->select($db->quoteName(array('a.id','a.name','a.protocol'),array('id','cronjob_backup_server_name', 'protocol')));
$query->from($db->quoteName('#__componentbuilder_server', 'a'));
$query->where($db->quoteName('a.published') . ' >= 1');
$query->order('a.name ASC');
@ -163,8 +163,8 @@ class JFormFieldServers extends JFormFieldList
$options[] = JHtml::_('select.option', '', 'Select an option');
foreach($items as $item)
{
$item->protocol = ($item->protocol == 2) ? JText::_('SSH') : JText::_('FTP');
$options[] = JHtml::_('select.option', $item->id, $item->update_server_name.' ['.$item->protocol.']');
$item->protocol = ($item->protocol == 2) ? JText::_('SFTP') : JText::_('FTP');
$options[] = JHtml::_('select.option', $item->id, $item->cronjob_backup_server_name.' ['.$item->protocol.']');
}
}
return $options;

View File

@ -136,7 +136,10 @@ class ComponentbuilderModelJoomla_components extends JModelList
if (ComponentbuilderHelper::checkArray($items))
{
// set params
if (!ComponentbuilderHelper::checkObject($this->params))
{
$this->params = JComponentHelper::getParams('com_componentbuilder');
}
// set custom folder path
$this->customPath = $this->params->get('custom_folder_path', JPATH_COMPONENT_ADMINISTRATOR.'/custom');
// check what type of export or backup this is
@ -149,6 +152,13 @@ class ComponentbuilderModelJoomla_components extends JModelList
$comConfig = JFactory::getConfig();
$this->backupPath = $comConfig->get('tmp_path');
}
// check what backup type we are working with here
$this->backupType = $this->params->get('cronjob_backup_type', 1); // 1 = local folder; 2 = remote server (default is local)
// if remote server get the ID
if (2 == $this->backupType)
{
$this->backupServer = $this->params->get('cronjob_backup_server', null);
}
// set the date array
$date = JFactory::getDate();
$placeholderDate = array();
@ -636,14 +646,20 @@ class ComponentbuilderModelJoomla_components extends JModelList
// view icon
$this->moveIt(array($item->icon), 'image');
}
// add snippets
// add snippets (was removed please use snippet importer)
if (isset($item->snippet) && is_numeric($item->snippet))
{
$this->setExportIDs((int) $item->snippet, 'snippet');
}
}
// actions to take if table is template and layout
if ('layout' === $table || 'template' === $table)
{
// add snippets
// add snippets (was removed please use snippet importer)
if (isset($item->snippet) && is_numeric($item->snippet))
{
$this->setExportIDs((int) $item->snippet, 'snippet');
}
// search for templates & layouts
$this->getTemplateLayout(base64_decode($item->$table), $this->user);
// add search array templates and layouts
@ -730,6 +746,16 @@ class ComponentbuilderModelJoomla_components extends JModelList
{
return false;
}
// move to remote server if needed
if (2 == $this->backupType)
{
if (!ComponentbuilderHelper::moveToServer($this->zipPath, $this->packageName.'.zip', $this->backupServer, null, 'joomla_component.export'))
{
return false;
}
// remove the local file
JFile::delete($this->zipPath);
}
// remove the folder
if (!ComponentbuilderHelper::removeFolder($this->packagePath))
{
@ -828,6 +854,7 @@ class ComponentbuilderModelJoomla_components extends JModelList
{
if ('file' === $type)
{
// TODO we must add the new all over files to this... will be a little tricky.
$tmpFilePath = str_replace('//', '/', $tmpPath.'/'.$item);
$customFilePath = str_replace('//', '/', $this->customPath.'/'.$item);
if (!JFile::exists($tmpFilePath) && JFile::exists($customFilePath))
@ -1099,7 +1126,11 @@ class ComponentbuilderModelJoomla_components extends JModelList
{
foreach ($keys['search'] as $key)
{
if (!isset($keys['not_base64'][$key]))
if ('id' === $key || 'name' === $key || 'system_name' === $key)
{
continue;
}
elseif (!isset($keys['not_base64'][$key]))
{
$value = base64_decode($item->{$key});
}
@ -1226,72 +1257,135 @@ class ComponentbuilderModelJoomla_components extends JModelList
* Get the keys of the values to search custom code in
*
* @param string $targe The table targeted
* @param string $type The type of get
*
* @return array The query options
*
*/
protected function getCodeSearchKeys($target)
protected function getCodeSearchKeys($target, $type = null)
{
// set the template if type is query
if ('query' === $type)
{
$tables = array(
'a' => 'joomla_component',
'b' => 'admin_view',
'c' => 'custom_admin_view',
'd' => 'site_view',
'e' => 'field',
'f' => 'dynamic_get',
'g' => 'template',
'h' => 'layout',
'i' => 'component_dashboard',
'j' => 'library',
);
// check if we have a match
if (isset($tables[$target]))
{
$target = $tables[$target];
}
}
// start target arrays
$targets = array();
// #__componentbuilder_joomla_component
$targets['joomla_component'] = array();
$targets['joomla_component']['search'] = array('php_preflight_install','php_postflight_install',
$targets['joomla_component']['search'] = array('id', 'system_name', 'php_preflight_install','php_postflight_install',
'php_preflight_update','php_postflight_update','php_method_uninstall',
'php_helper_admin','php_admin_event','php_helper_both','php_helper_site',
'php_site_event');
'php_site_event','javascript');
$targets['joomla_component']['view'] = 'joomla_components';
$targets['joomla_component']['not_base64'] = array();
$targets['joomla_component']['name'] = 'system_name';
// #__componentbuilder_component_dashboard
$targets['component_dashboard'] = array();
$targets['component_dashboard']['search'] = array('php_dashboard_methods','dashboard_tab');
$targets['component_dashboard']['search'] = array('id', 'joomla_component', 'php_dashboard_methods','dashboard_tab');
$targets['component_dashboard']['view'] = 'components_dashboard';
$targets['component_dashboard']['not_base64'] = array('dashboard_tab' => 'json');
$targets['component_dashboard']['name'] = 'joomla_component->id:joomla_component.system_name';
// #__componentbuilder_admin_view
$targets['admin_view'] = array();
$targets['admin_view']['search'] = array('javascript_view_file','javascript_view_footer','javascript_views_file',
'javascript_views_footer','php_getitem','php_save','php_postsavehook','php_getitems',
'php_getitems_after_all','php_getlistquery','php_allowedit','php_before_delete',
'php_after_delete','php_before_publish','php_after_publish','php_batchcopy',
'php_batchmove','php_document','php_model','php_controller','php_import_display',
'php_import','php_import_setdata','php_import_save','html_import_view','php_ajaxmethod');
$targets['admin_view']['search'] = array('id', 'system_name', 'javascript_view_file','javascript_view_footer',
'javascript_views_file','javascript_views_footer','html_import_view',
'php_after_delete','php_after_publish','php_ajaxmethod','php_allowedit','php_batchcopy',
'php_batchmove','php_before_delete','php_before_publish','php_before_save','php_controller',
'php_controller_list','php_document','php_getitem','php_getitems','php_getitems_after_all',
'php_getlistquery','php_import','php_import_display','php_import_ext','php_import_headers',
'php_import_save','php_import_setdata','php_model','php_model_list','php_postsavehook','php_save');
$targets['admin_view']['view'] = 'admin_views';
$targets['admin_view']['not_base64'] = array();
$targets['admin_view']['name'] = 'system_name';
// #__componentbuilder_custom_admin_view
$targets['custom_admin_view'] = array();
$targets['custom_admin_view']['search'] = array('default','php_view','php_jview','php_jview_display','php_document',
'js_document','css_document','css','php_model','php_controller');
$targets['custom_admin_view']['search'] = array('id', 'system_name', 'default','php_view','php_jview','php_jview_display','php_document',
'js_document','css_document','css','php_ajaxmethod','php_model','php_controller');
$targets['custom_admin_view']['view'] = 'custom_admin_views';
$targets['custom_admin_view']['not_base64'] = array();
$targets['custom_admin_view']['name'] = 'system_name';
// #__componentbuilder_site_view
$targets['site_view'] = array();
$targets['site_view']['search'] = array('default','php_view','php_jview','php_jview_display','php_document',
$targets['site_view']['search'] = array('id', 'system_name', 'default','php_view','php_jview','php_jview_display','php_document',
'js_document','css_document','css','php_ajaxmethod','php_model','php_controller');
$targets['site_view']['view'] = 'site_views';
$targets['site_view']['not_base64'] = array();
$targets['site_view']['name'] = 'system_name';
// #__componentbuilder_field
$targets['field'] = array();
$targets['field']['search'] = array('xml','javascript_view_footer','javascript_views_footer');
$targets['field']['search'] = array('id', 'name', 'xml','javascript_view_footer','javascript_views_footer');
$targets['field']['view'] = 'fields';
$targets['field']['not_base64'] = array('xml' => 'json');
$targets['field']['name'] = 'name';
// #__componentbuilder_dynamic_get
$targets['dynamic_get'] = array();
$targets['dynamic_get']['search'] = array('php_before_getitem','php_after_getitem','php_before_getitems','php_after_getitems',
$targets['dynamic_get']['search'] = array('id', 'name', 'php_before_getitem','php_after_getitem','php_before_getitems','php_after_getitems',
'php_getlistquery');
$targets['dynamic_get']['view'] = 'dynamic_gets';
$targets['dynamic_get']['not_base64'] = array();
$targets['dynamic_get']['name'] = 'name';
// #__componentbuilder_template
$targets['template'] = array();
$targets['template']['search'] = array('php_view','template');
$targets['template']['search'] = array('id', 'name', 'php_view','template');
$targets['template']['view'] = 'templates';
$targets['template']['not_base64'] = array();
$targets['template']['name'] = 'name';
// #__componentbuilder_layout
$targets['layout'] = array();
$targets['layout']['search'] = array('php_view','layout');
$targets['layout']['search'] = array('id', 'name', 'php_view','layout');
$targets['layout']['view'] = 'layouts';
$targets['layout']['not_base64'] = array();
$targets['layout']['name'] = 'name';
// return the query string to search
if (isset($targets[$target]))
// #__componentbuilder_library
$targets['library'] = array();
$targets['library']['view'] = 'libraries';
$targets['library']['search'] = array('id', 'name', 'php_setdocument');
$targets['library']['view'] = 'libraries';
$targets['library']['not_base64'] = array();
$targets['library']['name'] = 'name';
// return result ready for a.query
if ('query' === $type && isset($targets[$target]))
{
// add the .a to the selection array
$targets[$target]['select'] = array_map( function($select) { return 'a.'.$select; }, $targets[$target]['search']);
// also set the table
$targets[$target]['table'] = $target;
// remove search
unset($targets[$target]['search']);
// return
return $targets[$target];
}
// return the query string to search
elseif (isset($targets[$target]))
{
// remove name and id
return $targets[$target];
}
return false;

View File

@ -0,0 +1 @@

View File

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2" method="upgrade">
<name>COM_COMPONENTBUILDER</name>
<creationDate>19th February, 2018</creationDate>
<creationDate>20th February, 2018</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://joomlacomponentbuilder.com</authorUrl>
<copyright>Copyright (C) 2015. All Rights Reserved</copyright>
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
<version>2.6.15</version>
<version>2.6.16</version>
<description><![CDATA[
<h1>Component Builder (v.2.6.15)</h1>
<h1>Component Builder (v.2.6.16)</h1>
<div style="clear: both;"></div>
<p>The Component Builder for [Joomla](https://extensions.joomla.org/extension/component-builder/) is highly advanced tool that is truly able to build extremely complex components in a fraction of the time.

View File

@ -424,4 +424,21 @@
<maintainerurl>http://joomlacomponentbuilder.com</maintainerurl>
<targetplatform name="joomla" version="3.*"/>
</update>
<update>
<name>Component Builder</name>
<description>Builds Complex Joomla Components</description>
<element>com_componentbuilder</element>
<type>component</type>
<version>2.6.16</version>
<infourl title="Component Builder!">http://joomlacomponentbuilder.com</infourl>
<downloads>
<downloadurl type="full" format="zip">https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.6.16/JCB_v2.6.16.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
</tags>
<maintainer>Llewellyn van der Merwe</maintainer>
<maintainerurl>http://joomlacomponentbuilder.com</maintainerurl>
<targetplatform name="joomla" version="3.*"/>
</update>
</updates>

View File

@ -3590,7 +3590,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","percentagelanguageadd":"50","set_browser_storage":"1","storage_time_to_live":"global","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","percentagelanguageadd":"50","set_browser_storage":"1","storage_time_to_live":"global","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(
@ -4739,7 +4739,7 @@ class com_componentbuilderInstallerScript
echo '<a target="_blank" href="http://joomlacomponentbuilder.com" title="Component Builder">
<img src="components/com_componentbuilder/assets/images/vdm-component.jpg"/>
</a>
<h3>Upgrade to Version 2.6.15 Was Successful! Let us know if anything is not working as expected.</h3>';
<h3>Upgrade to Version 2.6.16 Was Successful! Let us know if anything is not working as expected.</h3>';
}
}
}

View File

@ -52,17 +52,20 @@ class ComponentbuilderControllerApi extends JControllerForm
public function backup()
{
// get params
// get params first
if (!isset($this->params) || !ComponentbuilderHelper::checkObject($this->params))
{
$this->params = JComponentHelper::getParams('com_componentbuilder');
}
// get all component IDs to backup
$pks = componentbuilderHelper::getComponentIDs();
// Get the model
$model = componentbuilderHelper::getModel('joomla_components', JPATH_ADMINISTRATOR . '/components/com_componentbuilder');
// set user
$model->user = $this->getApiUser();
// check if export is allowed for this user. (we need this sorry)
if ($model->user->authorise('joomla_component.export', 'com_componentbuilder') && $model->user->authorise('core.export', 'com_componentbuilder'))
{
// get all component IDs to backup
$pks = componentbuilderHelper::getComponentIDs();
// make sure to set active type to backup
$model->activeType = 'backup';
// set auto loader
@ -188,11 +191,24 @@ class ComponentbuilderControllerApi extends JControllerForm
if ('backup' === 'backup')
{
echo "# " . $backupNoticeStatus . "\n" .implode("\n", $backupNotice);
// clear session
JFactory::getApplication()->getSession()->destroy();
jexit();
}
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), implode("<br />", $backupNotice), $backupNoticeStatus);
return;
}
// quite only if auto backup (adding this script from custom code :)
if ('backup' === 'backup')
{
echo "# Error\n".JText::_('COM_COMPONENTBUILDER_ACCESS_DENIED');
// clear session
JFactory::getApplication()->getSession()->destroy();
jexit();
}
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), JText::_('COM_COMPONENTBUILDER_ACCESS_DENIED'), 'Error');
return;
}
protected function getApiUser()
{

View File

@ -1019,6 +1019,49 @@ abstract class ComponentbuilderHelper
require_once JPATH_ADMINISTRATOR.'/components/com_componentbuilder/helpers/vendor/autoload.php';
}
/**
* Move File to Server
*
* @param string $localPath The local path to the file
* @param string $fileName The the actual file name
* @param int $serverID The server local id to use
* @param int $protocol The server protocol to use
* @param string $permission The permission validation area
*
* @return bool true on success
**/
public static function moveToServer($localPath, $fileName, $serverID, $protocol = null, $permission = 'core.export')
{
// get the server
if ($server = self::getServer( (int) $serverID, $protocol, $permission))
{
// use the FTP protocol
if (1 == $server->jcb_protocol)
{
// now move the file
if (!$server->store($localPath, $fileName))
{
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_SERVER', $fileName, $server->jcb_remote_server_name[(int) $serverID]), 'Error');
return false;
}
// close the connection
$server->quit();
}
// use the SFTP protocol
elseif (2 == $server->jcb_protocol)
{
// now move the file
if (!$server->put($server->jcb_remote_server_path[(int) $serverID] . $fileName, self::getFileContents($localPath, null)))
{
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_PATH_ON_BSB_SERVER', $fileName, $server->jcb_remote_server_path[(int) $serverID], $server->jcb_remote_server_name[(int) $serverID]), 'Error');
return false;
}
}
return true;
}
return false;
}
/**
* the SFTP objects
**/
@ -1038,8 +1081,13 @@ abstract class ComponentbuilderHelper
*
* @return object on success server object
**/
public static function getServer($serverID, $protocol, $permission = 'core.export')
public static function getServer($serverID, $protocol = null, $permission = 'core.export')
{
// if not protocol is given get it (sad I know)
if (!$protocol)
{
$protocol = self::getVar('server', (int) $serverID, 'id', 'protocol');
}
// return the server object
switch ($protocol)
{
@ -1082,6 +1130,8 @@ abstract class ComponentbuilderHelper
$server->port = (isset($server->port) && is_int($server->port) && $server->port > 0) ? $server->port : 22;
// open the connection
self::$sftp[$server->cache] = new phpseclib\Net\SFTP($server->host, $server->port);
// heads-up on protocol
self::$sftp[$server->cache]->jcb_protocol = 2; // SFTP <-- if called not knowing what type of protocol is being used
// now login based on authentication type
switch($server->authentication)
{
@ -1143,14 +1193,14 @@ abstract class ComponentbuilderHelper
if (isset(self::$sftp[$server->cache]) && self::checkObject(self::$sftp[$server->cache]))
{
// set the unique buckets
if (!isset(self::$sftp[$server->cache]->remote_server_name))
if (!isset(self::$sftp[$server->cache]->jcb_remote_server_name))
{
self::$sftp[$server->cache]->remote_server_name = array();
self::$sftp[$server->cache]->remote_server_path = array();
self::$sftp[$server->cache]->jcb_remote_server_name = array();
self::$sftp[$server->cache]->jcb_remote_server_path = array();
}
// always set the name and remote server path
self::$sftp[$server->cache]->remote_server_name[$serverID] = $server->name;
self::$sftp[$server->cache]->remote_server_path[$serverID] = (self::checkString($server->path) && $server->path !== '/') ? $server->path : '';
self::$sftp[$server->cache]->jcb_remote_server_name[$serverID] = $server->name;
self::$sftp[$server->cache]->jcb_remote_server_path[$serverID] = (self::checkString($server->path) && $server->path !== '/') ? $server->path : '';
// return the sftp object
return self::$sftp[$server->cache];
}
@ -1175,7 +1225,7 @@ abstract class ComponentbuilderHelper
if (isset(self::$ftp[$server->cache]) && self::$ftp[$server->cache] instanceof JClientFtp)
{
// always set the name and remote server path
self::$ftp[$server->cache]->remote_server_name[$serverID] = $server->name;
self::$ftp[$server->cache]->jcb_remote_server_name[$serverID] = $server->name;
// if still connected we are ready to go
if (self::$ftp[$server->cache]->isConnected())
{
@ -1228,13 +1278,15 @@ abstract class ComponentbuilderHelper
// check if we are connected
if (self::$ftp[$server->cache] instanceof JClientFtp && self::$ftp[$server->cache]->isConnected())
{
// heads-up on protocol
self::$ftp[$server->cache]->jcb_protocol = 1; // FTP <-- if called not knowing what type of protocol is being used
// set the unique buckets
if (!isset(self::$ftp[$server->cache]->remote_server_name))
if (!isset(self::$ftp[$server->cache]->jcb_remote_server_name))
{
self::$ftp[$server->cache]->remote_server_name = array();
self::$ftp[$server->cache]->jcb_remote_server_name = array();
}
// always set the name and remote server path
self::$ftp[$server->cache]->remote_server_name[$serverID] = $server->name;
self::$ftp[$server->cache]->jcb_remote_server_name[$serverID] = $server->name;
// return the FTP instance
return self::$ftp[$server->cache];
}

View File

@ -1,4 +1,5 @@
COM_COMPONENTBUILDER="Component Builder"
COM_COMPONENTBUILDER_ACCESS_DENIED="Access denied!"
COM_COMPONENTBUILDER_API="Api"
COM_COMPONENTBUILDER_API_DESC="Sync Portal API"
COM_COMPONENTBUILDER_BACKUP_FAILED_PLEASE_TRY_AGAIN_IF_THE_ERROR_CONTINUE_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR="Backup failed, please try again. If the error continue, please contact your system administrator."
@ -38,6 +39,8 @@ COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_IMPORT_PROCESS
COM_COMPONENTBUILDER_THAT_MEANS_ANYONE_WHO_HAS_THIS_PACKAGE_CAN_INSTALL_IT_INTO_JCB_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_BSETTINGSB_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_BEXPORT_KEYB="That means anyone who has this package can install it into JCB. To add an export key simply open the component, go to the tab called <b>settings</b>, bottom right there is a field called <b>Export Key</b>."
COM_COMPONENTBUILDER_THAT_MEANS_ANYONE_WHO_HAS_THIS_PACKAGE_CAN_INSTALL_IT_INTO_JCB_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_SETTINGS_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_EXPORT_KEY="That means anyone who has this package can install it into JCB. To add an export key simply open the component, go to the tab called settings, bottom right there is a field called Export Key."
COM_COMPONENTBUILDER_THE_BPHPSECLIBNETSFTPB_LIBRARYCLASS_IS_NOT_AVAILABLE_THIS_LIBRARYCLASS_SHOULD_HAVE_BEEN_ADDED_TO_YOUR_ADMINHELPERSVENDOR_FOLDER_OF_JCB_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO="The <b>phpseclib\NET\SFTP</b> library\class is not available! This library\class should have been added to your admin/helpers/vendor folder of JCB. Please contact your system administrator for more info"
COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_PATH_ON_BSB_SERVER="The <b>%s</b> file could not be moved to <b>%s</b> path on <b>%s</b> server."
COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_SERVER="The <b>%s</b> file could not be moved to <b>%s</b> server."
COM_COMPONENTBUILDER_THE_FTP_CONNECTION_FOR_BSB_COULD_NOT_BE_MADE_PLEASE_CHECK_YOUR_SIGNATURE_DETAILS="The FTP connection for <b>%s</b> could not be made. Please check your signature details!"
COM_COMPONENTBUILDER_THE_FTP_SIGNATURE_FOR_BSB_WAS_NOT_WELL_FORMED_PLEASE_CHECK_YOUR_SIGNATURE_DETAILS="The FTP signature for <b>%s</b> was not well formed, please check your signature details!"
COM_COMPONENTBUILDER_THE_LOGIN_TO_BSB_HAS_FAILED_PLEASE_CHECK_THAT_YOUR_DETAILS_ARE_CORRECT="The login to <b>%s</b> has failed, please check that your details are correct!"

View File

@ -45,6 +45,8 @@ class ComponentbuilderViewApi extends JViewLegacy
$this->user = JFactory::getUser();
// Initialise variables.
$this->item = $this->get('Item');
// do not load the display
jexit('Access Denied!');
// Set the toolbar
$this->addToolBar();