mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 20:57:26 +02:00
Work on Update-routines - plugin-specific. see e107_plugins/download/download_setup.php for details.
This commit is contained in:
@@ -35,28 +35,52 @@ function run_updates($dbupdate)
|
|||||||
global $mes;
|
global $mes;
|
||||||
foreach($dbupdate as $func => $rmks)
|
foreach($dbupdate as $func => $rmks)
|
||||||
{
|
{
|
||||||
$installed = call_user_func("update_".$func);
|
if(function_exists('update_'.$func)) // Legacy Method.
|
||||||
//?! (LAN_UPDATE == $_POST[$func])
|
|
||||||
if(varsettrue($_POST[$func]) && !$installed)
|
|
||||||
{
|
{
|
||||||
if(function_exists("update_".$func))
|
$installed = call_user_func("update_".$func);
|
||||||
|
//?! (LAN_UPDATE == $_POST[$func])
|
||||||
|
if(varsettrue($_POST[$func]) && !$installed)
|
||||||
{
|
{
|
||||||
$message = LAN_UPDATE_7." {$rmks}";
|
if(function_exists("update_".$func))
|
||||||
$error = call_user_func("update_".$func, "do");
|
|
||||||
if($error != '')
|
|
||||||
{
|
{
|
||||||
$mes->add($message, E_MESSAGE_ERROR);
|
$message = LAN_UPDATE_7." {$rmks}";
|
||||||
$mes->add($error, E_MESSAGE_ERROR);
|
$error = call_user_func("update_".$func, "do");
|
||||||
|
if($error != '')
|
||||||
|
{
|
||||||
|
$mes->add($message, E_MESSAGE_ERROR);
|
||||||
|
$mes->add($error, E_MESSAGE_ERROR);
|
||||||
|
}
|
||||||
|
else $mes->add($message, E_MESSAGE_SUCCESS);
|
||||||
}
|
}
|
||||||
else $mes->add($message, E_MESSAGE_SUCCESS);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function run_updates_plugin($func,$check=TRUE) // New for {plugin}_setup.php
|
||||||
|
{
|
||||||
|
if(class_exists($func.'_setup'))
|
||||||
|
{
|
||||||
|
$class = $func.'_setup';
|
||||||
|
$setObj = new $class;
|
||||||
|
|
||||||
|
if(method_exists($setObj,'upgrade_post'))
|
||||||
|
{
|
||||||
|
return $setObj->upgrade_post($check);
|
||||||
|
}
|
||||||
|
// print_a($setObj);
|
||||||
|
// echo "<br />Found: ".$func;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function show_updates($dbupdate, $what)
|
function show_updates($dbupdate, $what)
|
||||||
{
|
{
|
||||||
global $frm;
|
global $frm;
|
||||||
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
$caption = constant('LAN_UPDATE_CAPTION_'.strtoupper($what));
|
$caption = constant('LAN_UPDATE_CAPTION_'.strtoupper($what));
|
||||||
$text = "
|
$text = "
|
||||||
<form method='post' action='".e_SELF."'>
|
<form method='post' action='".e_SELF."'>
|
||||||
@@ -77,32 +101,42 @@ function show_updates($dbupdate, $what)
|
|||||||
";
|
";
|
||||||
|
|
||||||
$updates = 0;
|
$updates = 0;
|
||||||
|
|
||||||
|
asort($dbupdate);
|
||||||
|
|
||||||
foreach($dbupdate as $func => $rmks)
|
foreach($dbupdate as $func => $rmks)
|
||||||
{
|
{
|
||||||
if(function_exists("update_".$func))
|
if(function_exists("update_".$func))
|
||||||
{
|
{
|
||||||
$text .= "
|
$text .= "<tr><td>{$rmks}</td>";
|
||||||
<tr>
|
|
||||||
<td>{$rmks}</td>
|
if(call_user_func("update_".$func) || run_updates_plugin($func,TRUE)!= TRUE)
|
||||||
";
|
|
||||||
// echo "Core2 Check {$func}=>{$rmks}<br />";
|
|
||||||
if(call_user_func("update_".$func))
|
|
||||||
{
|
{
|
||||||
$text .= "
|
$text .= "<td>".LAN_UPDATE_3."</td>";
|
||||||
<td>".LAN_UPDATE_3."</td>
|
|
||||||
";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$updates ++;
|
$updates ++;
|
||||||
$text .= "
|
$text .= "<td>".$frm->admin_button($func, LAN_UPDATE, 'update', '', "id=e-{$func}")."</td>";
|
||||||
<td>".$frm->admin_button($func, LAN_UPDATE, 'update', '', "id=e-{$func}")."</td>
|
|
||||||
";
|
|
||||||
}
|
}
|
||||||
$text .= "
|
$text .= "</tr>\n";
|
||||||
</tr>
|
}
|
||||||
";
|
elseif(class_exists($func.'_setup')) // plugin_setup.php
|
||||||
|
{
|
||||||
|
$text .= "<tr><td>{$rmks}</td>";
|
||||||
|
|
||||||
|
$reason = run_updates_plugin($func,TRUE); // TRUE = Just check if needed.
|
||||||
|
if(!$reason)
|
||||||
|
{
|
||||||
|
$text .= "<td>".LAN_UPDATE_3."</td>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$updates ++;
|
||||||
|
$mes->addDebug($reason);
|
||||||
|
$text .= "<td>".$frm->admin_button('update['.$func.']', LAN_UPDATE, 'update')."</td>";
|
||||||
|
}
|
||||||
|
$text .= "</tr>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,14 +151,15 @@ function show_updates($dbupdate, $what)
|
|||||||
return $updates; // Number of updates to do
|
return $updates; // Number of updates to do
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_POST)
|
if($_POST['update'])
|
||||||
{
|
{
|
||||||
$message = run_updates($dbupdate);
|
$message = run_updates($dbupdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_POST)
|
if(is_array($_POST['update'])) // Do plugin updates
|
||||||
{ // Do plugin updates
|
{
|
||||||
$message = run_updates($dbupdatep);
|
$func = key($_POST['update']);
|
||||||
|
run_updates_plugin($func,FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
$total_updates = 0;
|
$total_updates = 0;
|
||||||
|
@@ -82,15 +82,18 @@ if ($dont_check_update === TRUE)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!$dont_check_update)
|
if (!$dont_check_update)
|
||||||
{
|
{
|
||||||
if ($sql->db_Select('plugin', 'plugin_version, plugin_path', 'plugin_installflag=1'))
|
if ($sql->db_Select('plugin', 'plugin_id, plugin_version, plugin_path', 'plugin_installflag=1'))
|
||||||
{
|
{
|
||||||
while ($row = $sql->db_Fetch())
|
while ($row = $sql->db_Fetch())
|
||||||
{ // Mark plugins for update which have a specific update file, or a plugin.php file to check
|
{ // Mark plugins for update which have a specific update file, or a plugin.php file to check
|
||||||
if(is_readable(e_PLUGIN.$row['plugin_path'].'/'.$row['plugin_path'].'_update_check.php') || is_readable(e_PLUGIN.$row['plugin_path'].'/plugin.php'))
|
if(is_readable(e_PLUGIN.$row['plugin_path'].'/'.$row['plugin_path'].'_update_check.php') || is_readable(e_PLUGIN.$row['plugin_path'].'/plugin.php') || is_readable(e_PLUGIN.$row['plugin_path'].'/'.$row['plugin_path'].'_setup.php'))
|
||||||
{
|
{
|
||||||
$dbupdateplugs[$row['plugin_path']] = $row['plugin_version'];
|
$dbupdateplugs[$row['plugin_path']] = $row['plugin_version'];
|
||||||
|
//TODO - Add support for {plugins}_setup.php upgrade check and routine.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,6 +104,13 @@ if (!$dont_check_update)
|
|||||||
{
|
{
|
||||||
$fname = e_PLUGIN.$path.'/'.$path.'_update_check.php';
|
$fname = e_PLUGIN.$path.'/'.$path.'_update_check.php';
|
||||||
if (is_readable($fname)) include_once($fname);
|
if (is_readable($fname)) include_once($fname);
|
||||||
|
|
||||||
|
$fname = e_PLUGIN.$path.'/'.$path.'_setup.php';
|
||||||
|
if (is_readable($fname))
|
||||||
|
{
|
||||||
|
$dbupdatep[$path] = $path ; // ' 0.7.x forums '.LAN_UPDATE_9.' 0.8 forums';
|
||||||
|
include_once($fname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -144,9 +154,6 @@ function update_check()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Now check plugins
|
// Now check plugins
|
||||||
foreach($dbupdatep as $func => $rmks)
|
foreach($dbupdatep as $func => $rmks)
|
||||||
{
|
{
|
||||||
@@ -977,7 +984,8 @@ function update_706_to_800($type='')
|
|||||||
|
|
||||||
$med = e107::getMedia();
|
$med = e107::getMedia();
|
||||||
|
|
||||||
$count = $sql->db_Select_gen("SELECT * FROM `#core_media_cat` WHERE `media_cat_nick` = '_common' ");
|
$count = $sql->db_Select_gen("SELECT * FROM `#core_media_cat` WHERE `media_cat_nick` = '_common' ");
|
||||||
|
|
||||||
if($count != 1)
|
if($count != 1)
|
||||||
{
|
{
|
||||||
if ($just_check) return update_needed('Add Media-Manager Categories and Import existing images.');
|
if ($just_check) return update_needed('Add Media-Manager Categories and Import existing images.');
|
||||||
@@ -995,11 +1003,18 @@ function update_706_to_800($type='')
|
|||||||
$med->import('newsthumb',e_IMAGE.'newspost_images',"^thumb_");
|
$med->import('newsthumb',e_IMAGE.'newspost_images',"^thumb_");
|
||||||
$med->import('news',e_IMAGE.'newspost_images');
|
$med->import('news',e_IMAGE.'newspost_images');
|
||||||
$med->import('page',e_IMAGE.'custom');
|
$med->import('page',e_IMAGE.'custom');
|
||||||
$med->import('download',e_FILE.'downloadimages');
|
|
||||||
$med->import('downloadthumb',e_IMAGE.'downloadthumbs');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for Legacy Download Images.
|
||||||
|
if(!$sql->db_Select_gen("SELECT * FROM `#core_media` WHERE `media_category` = 'download' "))
|
||||||
|
{
|
||||||
|
if ($just_check) return update_needed('Import Download Images into Media Manager');
|
||||||
|
$med->import('download',e_FILE.'downloadimages');
|
||||||
|
$med->import('downloadthumb',e_FILE.'downloadthumbs');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$count = $sql->db_Select_gen("SELECT * FROM `#core_media_cat` WHERE media_cat_nick='_icon_16' OR media_cat_nick='_icon_32' ");
|
$count = $sql->db_Select_gen("SELECT * FROM `#core_media_cat` WHERE media_cat_nick='_icon_16' OR media_cat_nick='_icon_32' ");
|
||||||
|
|
||||||
if($count < 2)
|
if($count < 2)
|
||||||
@@ -1019,7 +1034,8 @@ function update_706_to_800($type='')
|
|||||||
}
|
}
|
||||||
|
|
||||||
$med->importIcons(e_PLUGIN);
|
$med->importIcons(e_PLUGIN);
|
||||||
$med->importIcons(e_IMAGE."icons/");
|
$med->importIcons(e_IMAGE."icons/");
|
||||||
|
$med->importIcons(e_IMAGE."icons/",16);
|
||||||
$med->importIcons(e_THEME.$pref['sitetheme']."/images/");
|
$med->importIcons(e_THEME.$pref['sitetheme']."/images/");
|
||||||
e107::getMessage()->addDebug("Icon category added");
|
e107::getMessage()->addDebug("Icon category added");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user