$rmks) { if(function_exists('update_'.$func)) // Legacy Method. { $installed = call_user_func("update_".$func); //?! (LAN_UPDATE == $_POST[$func]) if(varsettrue($_POST['update_core'][$func]) && !$installed) { if(function_exists("update_".$func)) { $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); } } } } } 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 "
Found: ".$func; } } function show_updates($dbupdate, $what) { global $frm; $mes = e107::getMessage(); $caption = constant('LAN_UPDATE_CAPTION_'.strtoupper($what)); $text = "
{$caption} "; $updates = 0; // asort($dbupdate); foreach($dbupdate as $func => $rmks) { if(function_exists("update_".$func)) { $text .= ""; if(call_user_func("update_".$func)) { $text .= ""; } else { $updates ++; $text .= ""; } $text .= "\n"; } if(class_exists($func.'_setup')) // plugin_setup.php { $text .= ""; $reason = run_updates_plugin($func,TRUE); // TRUE = Just check if needed. if(!$reason) { $text .= ""; } else { $updates ++; $mes->addDebug($reason); $text .= ""; } $text .= "\n"; } } $text .= "
".LAN_UPDATE_55." ".LAN_UPDATE_2."
{$rmks}".LAN_UPDATE_3."".$frm->admin_button('update_core['.$func.']', LAN_UPDATE, 'warning', '', "id=e-{$func}")."
{$rmks}".LAN_UPDATE_3."".$frm->admin_button('update['.$func.']', LAN_UPDATE, 'warning')."
"; echo $text; return $updates; // Number of updates to do } */ // New in v2.x ------------------------------------------------ class e107Update { var $core = array(); var $updates = 0; var $disabled = 0; function __construct($core=null) { $mes = e107::getMessage(); $this->core = $core; if(varset($_POST['update_core']) && is_array($_POST['update_core'])) { $message = $this->updateCore(); } if(varset($_POST['update']) && is_array($_POST['update'])) // Do plugin updates { $func = key($_POST['update']); $this->updatePlugin($func); } if(vartrue($message)) { $mes->addSuccess($message); } $this->renderForm(); } function updateCore() { $mes = e107::getMessage(); foreach($this->core as $func => $data) { if(function_exists('update_'.$func)) // Legacy Method. { $installed = call_user_func("update_".$func); //?! (LAN_UPDATE == $_POST[$func]) if(varsettrue($_POST['update_core'][$func]) && !$installed) { if(function_exists("update_".$func)) { $message = LAN_UPDATE_7." ".$data['title']; $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); } } } } } } function updatePlugin($path) { e107::getPlugin()->install_plugin_xml($path, 'upgrade'); } function plugins() { if(!$list = e107::getPlugin()->updateRequired()) { return; } $frm = e107::getForm(); $text = ""; foreach($list as $path=>$val) { $text .= " ".$val['@attributes']['name']." ".$frm->admin_button('update['.$path.']', LAN_UPDATE, 'warning', '', 'disabled='.$this->disabled)." "; } return $text; } function core() { $frm = e107::getForm(); $mes = e107::getMessage(); $text = ""; foreach($this->core as $func => $data) { if(function_exists("update_".$func)) { $text .= "".$data['title'].""; if(call_user_func("update_".$func)) { $text .= "".ADMIN_TRUE_ICON.""; } else { if(vartrue($data['message'])) { $mes->addInfo($data['message']); } $this->updates ++; $text .= "".$frm->admin_button('update_core['.$func.']', LAN_UPDATE, 'warning', '', "id=e-{$func}&disabled=".$this->disabled).""; if($data['master'] == true) { $this->disabled = 1; } } $text .= "\n"; } } return $text; } function renderForm() { $ns = e107::getRender(); $mes = e107::getMessage(); $caption = LAN_UPDATE; $text = "
{$caption} "; $text .= $this->core(); $text .= $this->plugins(); $text .= "
".LAN_UPDATE_55." ".LAN_UPDATE_2."
"; $ns->tablerender("Updates",$mes->render() . $text); } } new e107Update($dbupdate); require_once ("footer.php"); /* if(varset($_POST['update_core']) && is_array($_POST['update_core'])) { $message = run_updates($dbupdate); } if(varset($_POST['update']) && is_array($_POST['update'])) // Do plugin updates { $func = key($_POST['update']); run_updates_plugin($func,FALSE); } $total_updates = 0; ob_start(); if(isset($dbupdatep)) { // Show plugin updates done $total_updates += show_updates($dbupdatep, 'plugin'); } // Show core updates done $total_updates += show_updates($dbupdate, 'core'); $text = ob_get_contents(); ob_end_clean(); $e107->ns->tablerender(LAN_UPDATE_56, $mes->render().$text); if($total_updates == 0) { // No updates needed - clear the cache to be sure $e107cache->set_sys("nq_admin_updatecheck", time().', 1, '.$e107info['e107_version'], TRUE); } * * */ ?>