mirror of
https://github.com/e107inc/e107.git
synced 2025-04-22 13:41:52 +02:00
Work on Update-routines - plugin-specific. see e107_plugins/download/download_setup.php for details.
This commit is contained in:
parent
5178e66567
commit
6837ea5154
e107_admin
@ -35,28 +35,52 @@ function run_updates($dbupdate)
|
||||
global $mes;
|
||||
foreach($dbupdate as $func => $rmks)
|
||||
{
|
||||
$installed = call_user_func("update_".$func);
|
||||
//?! (LAN_UPDATE == $_POST[$func])
|
||||
if(varsettrue($_POST[$func]) && !$installed)
|
||||
if(function_exists('update_'.$func)) // Legacy Method.
|
||||
{
|
||||
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}";
|
||||
$error = call_user_func("update_".$func, "do");
|
||||
if($error != '')
|
||||
if(function_exists("update_".$func))
|
||||
{
|
||||
$mes->add($message, E_MESSAGE_ERROR);
|
||||
$mes->add($error, E_MESSAGE_ERROR);
|
||||
$message = LAN_UPDATE_7." {$rmks}";
|
||||
$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)
|
||||
{
|
||||
global $frm;
|
||||
$mes = e107::getMessage();
|
||||
|
||||
$caption = constant('LAN_UPDATE_CAPTION_'.strtoupper($what));
|
||||
$text = "
|
||||
<form method='post' action='".e_SELF."'>
|
||||
@ -77,32 +101,42 @@ function show_updates($dbupdate, $what)
|
||||
";
|
||||
|
||||
$updates = 0;
|
||||
|
||||
asort($dbupdate);
|
||||
|
||||
foreach($dbupdate as $func => $rmks)
|
||||
{
|
||||
if(function_exists("update_".$func))
|
||||
{
|
||||
$text .= "
|
||||
<tr>
|
||||
<td>{$rmks}</td>
|
||||
";
|
||||
// echo "Core2 Check {$func}=>{$rmks}<br />";
|
||||
if(call_user_func("update_".$func))
|
||||
$text .= "<tr><td>{$rmks}</td>";
|
||||
|
||||
if(call_user_func("update_".$func) || run_updates_plugin($func,TRUE)!= TRUE)
|
||||
{
|
||||
$text .= "
|
||||
<td>".LAN_UPDATE_3."</td>
|
||||
";
|
||||
$text .= "<td>".LAN_UPDATE_3."</td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$updates ++;
|
||||
$text .= "
|
||||
<td>".$frm->admin_button($func, LAN_UPDATE, 'update', '', "id=e-{$func}")."</td>
|
||||
";
|
||||
$text .= "<td>".$frm->admin_button($func, LAN_UPDATE, 'update', '', "id=e-{$func}")."</td>";
|
||||
}
|
||||
$text .= "
|
||||
</tr>
|
||||
";
|
||||
$text .= "</tr>\n";
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
if($_POST)
|
||||
if($_POST['update'])
|
||||
{
|
||||
$message = run_updates($dbupdate);
|
||||
}
|
||||
|
||||
if($_POST)
|
||||
{ // Do plugin updates
|
||||
$message = run_updates($dbupdatep);
|
||||
if(is_array($_POST['update'])) // Do plugin updates
|
||||
{
|
||||
$func = key($_POST['update']);
|
||||
run_updates_plugin($func,FALSE);
|
||||
}
|
||||
|
||||
$total_updates = 0;
|
||||
|
@ -82,15 +82,18 @@ if ($dont_check_update === TRUE)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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())
|
||||
{ // 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'];
|
||||
//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';
|
||||
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
|
||||
foreach($dbupdatep as $func => $rmks)
|
||||
{
|
||||
@ -977,7 +984,8 @@ function update_706_to_800($type='')
|
||||
|
||||
$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 ($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('news',e_IMAGE.'newspost_images');
|
||||
$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' ");
|
||||
|
||||
if($count < 2)
|
||||
@ -1019,7 +1034,8 @@ function update_706_to_800($type='')
|
||||
}
|
||||
|
||||
$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/");
|
||||
e107::getMessage()->addDebug("Icon category added");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user