1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

Issue #2589 Downloads plugin version bumped to v1.1. Detect old URL settings/files and remove during upgrade.

This commit is contained in:
Cameron 2017-04-27 15:26:20 -07:00
parent 4650aa8d91
commit eb4445ee24
2 changed files with 65 additions and 29 deletions

View File

@ -40,6 +40,14 @@ class download_setup
}
function upgrade_required()
{
return false;
}
// IMPORTANT : This function below is for modifying the CONTENT of the tables only, NOT the table-structure.
// To Modify the table-structure, simply modify your {plugin}_sql.php file and an update will be detected automatically.
/*
@ -55,52 +63,86 @@ class download_setup
* {
* $this->upgrade_from_1();
* }
*/
*/
$config = e107::getPref('url_config');
if(!empty($config['download']))
{
e107::getConfig()
->removePref('url_config/download')
->removePref('url_locations/download')
->save(false,true);
if(file_exists(e_PLUGIN."download/url/url.php"))
{
@unlink(e_PLUGIN."download/url/url.php");
@unlink(e_PLUGIN."download/url/sef_url.php");
}
$bld = new eRouter;
$bld->buildGlobalConfig();
}
return $this->upgradeFilePaths($needed);
}
private function upgradeFilePaths($needed)
{
$sql = e107::getDb();
$mes = e107::getMessage();
$qry = "SELECT * FROM #download WHERE download_image !='' AND SUBSTRING(download_image, 1, 3) != '{e_' ";
if($sql->db_Select_gen($qry))
if($sql->gen($qry))
{
if($needed == TRUE){ return "Incorrect download image paths"; } // Signal that an update is required.
if($needed == TRUE){ return "Incorrect download image paths"; } // Signal that an update is required.
if($sql->db_Update("download","download_image = CONCAT('{e_FILE}downloadimages/',download_image) WHERE download_image !='' "))
{
$mes->addSuccess("Updated Download-Image paths");
$mes->addSuccess("Updated Download-Image paths");
}
else
{
$mes->addError("Failed to update Download-Image paths");
$mes->addError("Failed to update Download-Image paths");
}
if($sql->db_Update("download"," download_thumb = CONCAT('{e_FILE}downloadthumbs/',download_thumb) WHERE download_thumb !='' "))
{
$mes->addSuccess("Updated Download-Thumbnail paths");
$mes->addSuccess("Updated Download-Thumbnail paths");
}
else
{
$mes->addError("Failed to update Download-Thumbnail paths");
}
$mes->addError("Failed to update Download-Thumbnail paths");
}
}
$qry = "SELECT * FROM #download_category WHERE download_category_icon !='' AND SUBSTRING(download_category_icon, 1, 3) != '{e_' ";
if($sql->db_Select_gen($qry))
if($sql->gen($qry))
{
// Signal that an update is required.
if($needed == TRUE){ return "Downloads-Category icon paths need updating"; } // Must have a value if an update is needed. Text used for debug purposes.
if($needed == TRUE){ return "Downloads-Category icon paths need updating"; } // Must have a value if an update is needed. Text used for debug purposes.
if($sql->db_Update("download_category","download_category_icon = CONCAT('{e_IMAGE}icons/',download_category_icon) WHERE download_category_icon !='' "))
{
$mes->addSuccess("Updated Download-Image paths");
$mes->addSuccess("Updated Download-Image paths");
}
else
{
$mes->addError("Failed to update Download-Image paths");
}
$mes->addError("Failed to update Download-Image paths");
}
}
if($needed == TRUE){ return FALSE; }
if($needed == TRUE){ return FALSE; }
}
}

View File

@ -1,16 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<e107Plugin name="Downloads" lan="LAN_PLUGIN_DOWNLOAD_NAME" version="1.0" date="2012-08-01" compatibility="2.0" installRequired="true">
<e107Plugin name="Downloads" lan="LAN_PLUGIN_DOWNLOAD_NAME" version="1.1" date="2017-04-27" compatibility="2.0" installRequired="true">
<author name="e107 Inc." url="http://e107.org" />
<description lan="LAN_PLUGIN_DOWNLOAD_DIZ">This plugin is a fully featured File-download system</description>
<category>content</category>
<adminLinks>
<link url='admin_download.php' description='LAN_CONFIGURE' icon='images/downloads_32.png' iconSmall='images/downloads_16.png' primary='true' >DOWLAN_CAPTION</link>
<link url='admin_download.php' description='' icon='manage' iconSmall=''>DOWLAN_29</link>
<link url='admin_download.php?create' description='' icon='add' iconSmall=''>DOWLAN_30</link>
<link url='admin_download.php?cat' description='' icon='images/downloads_32.png' iconSmall=''>DOWLAN_31</link>
<link url='admin_download.php?opt' description='' icon='settings' iconSmall=''>DOWLAN_32</link>
<link url='admin_download.php?limits' description='' icon='images/downloads_32.png' iconSmall=''>DOWLAN_112</link>
<link url='admin_download.php?mirror' description='' icon='images/downloads_32.png' iconSmall=''>DOWLAN_128</link>
</adminLinks>
<siteLinks>
<link url="{e_PLUGIN}download/download.php" sef='index' perm="everyone">LAN_PLUGIN_DOWNLOAD_NAME</link>