Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic check to make sure the bulk import seperator is being used. #19982

Merged
merged 10 commits into from
Apr 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions administrator/components/com_redirect/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<fieldset
name="redirect"
label="COM_REDIRECT_ADVANCED_OPTIONS"
>
>
<field
name="mode"
type="radio"
Expand All @@ -22,13 +22,24 @@
description="COM_REDIRECT_BULK_SEPARATOR_DESC"
default="|"
/>
<field
name="defaultImportState"
type="radio"
label="COM_REDIRECT_DEFAULT_IMPORT_STATE_LABEL"
description="COM_REDIRECT_DEFAULT_IMPORT_STATE_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JENABLED</option>
<option value="0">JDISABLED</option>
</field>
</fieldset>

<fieldset
name="permissions"
label="JCONFIG_PERMISSIONS_LABEL"
description="JCONFIG_PERMISSIONS_DESC"
>
>
<field
name="rules"
type="rules"
Expand Down
13 changes: 12 additions & 1 deletion administrator/components/com_redirect/controllers/links.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,18 @@ public function batch()
if (!empty($batch_urls_line))
{
$params = JComponentHelper::getParams('com_redirect');
$batch_urls[] = array_map('trim', explode($params->get('separator', '|'), $batch_urls_line));
$separator = $params->get('separator', '|');

// Basic check to make sure the correct separator is being used
if (!\Joomla\String\StringHelper::strpos($batch_urls_line, $separator))
{
$this->setMessage(JText::sprintf('COM_REDIRECT_NO_SEPARATOR_FOUND', $separator), 'error');
$this->setRedirect('index.php?option=com_redirect&view=links');

return false;
}

$batch_urls[] = array_map('trim', explode($separator, $batch_urls_line));
}
}

Expand Down
5 changes: 4 additions & 1 deletion administrator/components/com_redirect/models/links.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ public function batchProcess($batch_urls)
$db = JFactory::getDbo();
$query = $db->getQuery(true);

$params = JComponentHelper::getParams('com_redirect');
$state = (int) $params->get('defaultImportState', 0);

$columns = array(
$db->quoteName('old_url'),
$db->quoteName('new_url'),
Expand Down Expand Up @@ -228,7 +231,7 @@ public function batchProcess($batch_urls)

$query->insert($db->quoteName('#__redirect_links'), false)
->values(
$db->quote($old_url) . ', ' . $db->quote($new_url) . ' ,' . $db->quote('') . ', ' . $db->quote('') . ', 0, 0, ' .
$db->quote($old_url) . ', ' . $db->quote($new_url) . ' ,' . $db->quote('') . ', ' . $db->quote('') . ', 0, ' . $state . ', ' .
$db->quote(JFactory::getDate()->toSql())
);
}
Expand Down
3 changes: 3 additions & 0 deletions administrator/language/en-GB/en-GB.com_redirect.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ COM_REDIRECT_COLLECT_URLS_ENABLED="%1$s The option 'Collect URLs' is enabled."
; The following string is deprecated and will be removed with 4.0.
COM_REDIRECT_COLLECT_URLS_DISABLED="The 'Collect URLs' option in the <a href="_QQ_"%s"_QQ_">Redirect System Plugin</a> is disabled. Error page URLs will not be collected by this component."
COM_REDIRECT_CONFIGURATION="Redirect: Options"
COM_REDIRECT_DEFAULT_IMPORT_STATE_DESC="When batch importing redirects, enable or disable by default."
COM_REDIRECT_DEFAULT_IMPORT_STATE_LABEL="Import State"
COM_REDIRECT_DISABLE_LINK="Disable Link"
COM_REDIRECT_EDIT_LINK="Edit Link #%d"
COM_REDIRECT_EDIT_PLUGIN_SETTINGS="Edit Plugin Settings"
Expand Down Expand Up @@ -84,6 +86,7 @@ COM_REDIRECT_N_LINKS_UPDATED_1="1 link has been updated."
COM_REDIRECT_NEW_LINK="New Link"
COM_REDIRECT_NO_ITEM_ADDED="No links added."
COM_REDIRECT_NO_ITEM_SELECTED="No links selected."
COM_REDIRECT_NO_SEPARATOR_FOUND="The separator %s was not found in your import."
; The following string is deprecated and will be removed with 4.0.
COM_REDIRECT_PLUGIN_DISABLED="The <a href="_QQ_"%s"_QQ_">Redirect System Plugin</a> is disabled. It needs to be enabled for this component to work."
COM_REDIRECT_PLUGIN_ENABLED="The Redirect Plugin is enabled."
Expand Down