2009-10-20 03:58:47 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* e107 website system
|
|
|
|
*
|
2012-04-20 07:28:53 +00:00
|
|
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
2009-10-20 03:58:47 +00:00
|
|
|
* Released under the terms and conditions of the
|
|
|
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
|
|
|
*
|
|
|
|
* Custom download install/uninstall/update routines
|
|
|
|
*
|
|
|
|
* $Source: /cvs_backup/e107_0.8/e107_plugins/download/download_setup.php,v $
|
2010-02-10 18:18:01 +00:00
|
|
|
* $Revision$
|
|
|
|
* $Date$
|
|
|
|
* $Author$
|
2009-10-20 03:58:47 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
class download_setup
|
|
|
|
{
|
2012-04-20 07:28:53 +00:00
|
|
|
|
2009-10-21 12:53:00 +00:00
|
|
|
function install_pre($var)
|
2009-10-20 03:58:47 +00:00
|
|
|
{
|
|
|
|
// print_a($var);
|
|
|
|
$mes = eMessage::getInstance();
|
|
|
|
// $mes->add("custom install 'pre' function.", E_MESSAGE_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2009-10-21 12:53:00 +00:00
|
|
|
function install_post($var)
|
2009-10-20 03:58:47 +00:00
|
|
|
{
|
|
|
|
$sql = e107::getDb();
|
|
|
|
$mes = eMessage::getInstance();
|
|
|
|
// $mes->add("custom install 'post' function.", E_MESSAGE_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2009-10-21 12:53:00 +00:00
|
|
|
function uninstall_pre($var)
|
2009-10-20 03:58:47 +00:00
|
|
|
{
|
|
|
|
$sql = e107::getDb();
|
|
|
|
$mes = eMessage::getInstance();
|
|
|
|
// $mes->add("custom uninstall 'pre' function.", E_MESSAGE_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2012-04-20 07:28:53 +00:00
|
|
|
|
|
|
|
// 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.
|
|
|
|
/*
|
|
|
|
* @var $needed - true when only a check for a required update is being performed.
|
|
|
|
* Return: Reason the upgrade is required, otherwise set it to return FALSE.
|
|
|
|
*/
|
|
|
|
function upgrade_post($needed)
|
2009-10-20 03:58:47 +00:00
|
|
|
{
|
2012-11-07 03:40:07 +00:00
|
|
|
/*
|
|
|
|
* Currently Installed version (prior to upgrade): $needed->current_plug['plugin_version'];
|
2012-11-07 03:55:08 +00:00
|
|
|
* Add "IF" statements as needed, and other upgrade_x_y() methods as required.
|
|
|
|
* eg. if($needed->current_plug['plugin_version'] == '1.0')
|
|
|
|
* {
|
|
|
|
* $this->upgrade_from_1();
|
|
|
|
* }
|
2012-11-07 03:40:07 +00:00
|
|
|
*/
|
|
|
|
|
2009-10-20 03:58:47 +00:00
|
|
|
$sql = e107::getDb();
|
2012-04-20 07:28:53 +00:00
|
|
|
$mes = e107::getMessage();
|
2012-11-07 03:40:07 +00:00
|
|
|
$qry = "SELECT * FROM #download WHERE download_image !='' AND SUBSTRING(download_image, 1, 3) != '{e_' ";
|
2012-04-20 07:28:53 +00:00
|
|
|
|
|
|
|
if($sql->db_Select_gen($qry))
|
|
|
|
{
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$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");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$mes->addError("Failed to update Download-Thumbnail paths");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-07 03:55:08 +00:00
|
|
|
$qry = "SELECT * FROM #download_category WHERE download_category_icon !='' AND SUBSTRING(download_category_icon, 1, 3) != '{e_' ";
|
2012-04-20 07:28:53 +00:00
|
|
|
if($sql->db_Select_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($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");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$mes->addError("Failed to update Download-Image paths");
|
|
|
|
}
|
|
|
|
}
|
2009-10-20 03:58:47 +00:00
|
|
|
|
2012-04-20 07:28:53 +00:00
|
|
|
if($needed == TRUE){ return FALSE; }
|
|
|
|
|
2009-10-20 03:58:47 +00:00
|
|
|
}
|
|
|
|
}
|