Пример #1
0
/**
 * Store the module information in the database.
 *
 * This function will write the generated module data ($PHORUM["mods"] and
 * $PHORUM["hooks"]) to the database.
 */
function phorum_api_modules_save()
{
    global $PHORUM;
    phorum_api_modules_generate_moduleinfo();
    // Store the settings in the database.
    $PHORUM['DB']->update_settings(array("hooks" => $PHORUM["hooks"], "mods" => $PHORUM["mods"], "moddblayers" => $PHORUM["moddblayers"]));
    // Reset the module information update checking data.
    phorum_api_modules_check_updated_info(TRUE);
}
Пример #2
0
/**
 * Store the module information in the database.
 *
 * This function will sort out all module and hook priorities for the
 * enabled modules and write the result data ($PHORUM["mods"] and
 * $PHORUM["hooks"]) to the database.
 */
function phorum_api_modules_save()
{
    global $PHORUM;
    // Load the module info if this was not done yet.
    if (!isset($PHORUM["API"]["mods_modules"])) {
        phorum_api_modules_list();
    }
    // For easy access.
    $modules = $PHORUM["API"]["mods_modules"];
    $priorities = $PHORUM["API"]["mods_priorities"];
    // Create a list of enabled modules.
    $active_mods = array();
    foreach ($PHORUM["mods"] as $mod => $enabled) {
        // Only add modules that were found.
        // Disable modules that do not / no longer exist.
        if (isset($modules[$mod])) {
            if ($enabled) {
                $active_mods[] = $mod;
            }
        } else {
            $PHORUM["mods"][$mod] = 0;
        }
    }
    // First priority ordering pass:
    // run module before|after *
    $active_mods_copy = $active_mods;
    foreach ($active_mods as $mod) {
        if (!isset($priorities["module"][$mod])) {
            continue;
        }
        $mod_priorities = $priorities["module"][$mod];
        foreach ($mod_priorities as $priority) {
            if ($priority[2] == "*") {
                // Remove the module from the list.
                $idx = array_search($mod, $active_mods_copy);
                unset($active_mods_copy[$idx]);
                // Add it do the end of start of the list.
                if ($priority[1] == "after") {
                    array_push($active_mods_copy, $mod);
                } else {
                    array_unshift($active_mods_copy, $mod);
                }
            }
        }
    }
    $active_mods = $active_mods_copy;
    // Second priority ordering pass:
    // run module before|after <othermodule>
    $active_mods_copy = array_values($active_mods);
    foreach ($active_mods as $mod) {
        if (!isset($priorities["module"][$mod])) {
            continue;
        }
        $mod_priorities = $priorities["module"][$mod];
        foreach ($mod_priorities as $priority) {
            if ($priority[2] == '*') {
                continue;
            }
            // Find the current position of the modules.
            $idx1 = array_search($mod, $active_mods_copy);
            $idx2 = array_search($priority[2], $active_mods_copy);
            if ($idx2 === false || $idx2 === NULL) {
                continue;
            }
            //NULL = pre 4.2.0
            // Move module up in the list.
            if ($idx1 > $idx2 && $priority[1] == "before") {
                unset($active_mods_copy[$idx1]);
                array_splice($active_mods_copy, $idx2, 1, array($mod, $priority[2]));
                $active_mods_copy = array_values($active_mods_copy);
            }
            // Move module down in the list.
            if ($idx1 < $idx2 && $priority[1] == "after") {
                array_splice($active_mods_copy, $idx2, 1, array($priority[2], $mod));
                unset($active_mods_copy[$idx1]);
                $active_mods_copy = array_values($active_mods_copy);
            }
        }
    }
    $active_mods = $active_mods_copy;
    # Determine what hooks to run for the activated modules.
    $modules_by_hook = array();
    $functions_by_module = array();
    foreach ($active_mods as $mod) {
        if (!isset($modules[$mod]["hooks"])) {
            continue;
        }
        foreach ($modules[$mod]["hooks"] as $hookinfo) {
            list($hook, $func) = explode("|", $hookinfo);
            $modules_by_hook[$hook][] = $mod;
            $functions_by_module[$mod][$hook] = $func;
        }
    }
    // Third priority ordering pass:
    // run hook <hook> before|after *
    foreach ($modules_by_hook as $hook => $mods) {
        if (!isset($priorities["hook"][$hook])) {
            continue;
        }
        foreach ($active_mods as $mod) {
            if (!isset($priorities["hook"][$hook][$mod])) {
                continue;
            }
            $hook_priorities = $priorities["hook"][$hook][$mod];
            foreach ($hook_priorities as $priority) {
                if ($priority[3] == "*") {
                    // Remove the module from the list.
                    $idx = array_search($mod, $mods);
                    unset($mods[$idx]);
                    // Add it do the end of start of the list.
                    if ($priority[2] == "after") {
                        array_push($mods, $mod);
                    } else {
                        array_unshift($mods, $mod);
                    }
                }
            }
        }
        $mods = array_values($mods);
        // array_values reindexes
        $modules_by_hook[$hook] = $mods;
    }
    // Fourth priority ordering pass:
    // run hook <hook> before|after <othermodule>
    foreach ($modules_by_hook as $hook => $mods) {
        if (!isset($priorities["hook"][$hook])) {
            continue;
        }
        foreach ($active_mods as $mod) {
            if (!isset($priorities["hook"][$hook][$mod])) {
                continue;
            }
            $hook_priorities = $priorities["hook"][$hook][$mod];
            foreach ($hook_priorities as $priority) {
                if ($priority[3] == '*') {
                    continue;
                }
                // Find the current position of the modules.
                $idx1 = array_search($mod, $mods);
                $idx2 = array_search($priority[3], $mods);
                //NULL = pre 4.2.0
                if ($idx2 === false || $idx2 === NULL) {
                    continue;
                }
                // Move module up in the list.
                if ($idx1 > $idx2 && $priority[2] == "before") {
                    unset($mods[$idx1]);
                    array_splice($mods, $idx2, 1, array($mod, $priority[3]));
                    $mods = array_values($mods);
                }
                // Move module down in the list.
                if ($idx1 < $idx2 && $priority[2] == "after") {
                    array_splice($mods, $idx2, 1, array($priority[3], $mod));
                    unset($mods[$idx1]);
                    $mods = array_values($mods);
                }
            }
        }
        $mods = array_values($mods);
        // array_values reindexes
        $modules_by_hook[$hook] = array_values($mods);
    }
    // Create the hooks configuration.
    $hooks = array();
    foreach ($modules_by_hook as $hook => $mods) {
        $hooks[$hook] = array();
        foreach ($mods as $mod) {
            $hooks[$hook]["mods"][] = $mod;
            $hooks[$hook]["funcs"][] = $functions_by_module[$mod][$hook];
        }
    }
    $PHORUM["hooks"] = $hooks;
    // Store the settings in the database.
    phorum_db_update_settings(array("hooks" => $PHORUM["hooks"], "mods" => $PHORUM["mods"]));
    // Reset the module information update checking data.
    phorum_api_modules_check_updated_info(TRUE);
}
Пример #3
0
if (empty($module)) {
    // only show the versioncheck if you are on the front page of the admin
    ?>
    <td class="statusbar_edge" align="center" valign="middle">
      <iframe scrolling="no" frameborder="0" align="top" width="400" height="35" src="versioncheck.php"></iframe>
    </td>
<?php 
} else {
    // Reset the cookie that is used for the version check.
    setcookie("phorum_upgrade_available", '', time() - 86400, $PHORUM["session_path"], $PHORUM["session_domain"]);
}
?>
    <td class="statusbar_edge" align="center" valign="middle">
<?php 
require_once './include/api/modules.php';
$updates = phorum_api_modules_check_updated_info();
if (!empty($updates)) {
    phorum_api_modules_save();
    print "<div style=\"padding:5px;background-color:#fffff0;" . "border:2px solid orange; text-align:left\">" . "<strong>Notification:</strong> " . "Updated module info for module" . (count($updates) == 1 ? "" : "s") . (count($updates) > 10 ? "" : ":" . implode(", ", $updates)) . "</div>";
}
?>
    </td>
    <td class="statusbar_edge" align="right">

    <div id="phorum-status">
<?php 
if ($module != "login" && $module != "install" && $module != "upgrade") {
    ?>
<form id="status-form" action="<?php 
    echo phorum_admin_build_url('base');
    ?>