예제 #1
0
function displayPlugins($location)
{
    global $pluginForm;
    $allPlugins = Plugins::get_plugins();
    $pluginNames = array();
    $pluginHandler = array();
    $pluginHeadings = array("All Plugins");
    foreach ($allPlugins as $id => $value) {
        $curPlugin = new Plugins($id);
        if ($curPlugin->get_location() == $location && $curPlugin->get_enabled() == true) {
            if ($curPlugin->get_icon_path() != "NONE") {
                $iconPath = str_replace(" ", "%20", $curPlugin->get_icon_path());
                array_push($pluginNames, "<img class='plugIcon' src='" . $iconPath . "'></img>" . $curPlugin->get_name());
            } else {
                array_push($pluginNames, $curPlugin->get_name());
            }
            array_push($pluginHandler, "handleEvent('plugins.php?pluginaction=showPlugin&pluginID=" . $id . "&className=" . $curPlugin->get_class_name() . "')");
        }
    }
    $pluginForm->setHeadings($pluginHeadings);
    $pluginForm->setTableWidth("150px");
    $pluginForm->setEventHandler($pluginHandler);
    $pluginForm->setTitles($pluginNames);
    $pluginForm->setSortable(true);
    return $pluginForm->showAll();
}
예제 #2
0
function checkPlugin($location)
{
    $allPlugins = Plugins::get_plugins();
    $location = strtolower($location);
    $pluginNames = array();
    $pluginHeadings = array("All Plugins");
    foreach ($allPlugins as $id => $value) {
        $curPlugin = new Plugins($id);
        $plugLocation = strtolower($curPlugin->get_location());
        if ($plugLocation == $location && $curPlugin->get_enabled() == true) {
            $pluginNames[$id] = $curPlugin->get_name();
        }
    }
    return $pluginNames;
}
예제 #3
0
function displayPlugins()
{
    global $tool, $propertyForm;
    $plugins = Plugins::get_plugins();
    echo "<style>";
    foreach ($plugins as $id => $value) {
        echo "#modalBox #dialog" . $id;
        echo "{\n\t\t\twidth:auto;\n\t\t\tmax-width: 80%;\n\t\t\tmin-width:40%;\n\t\t\theight:auto;\n\t\t\tpadding:10px;\n\t\t\tpadding-top:10px;\n\t\t\toverflow:auto;\n\t\t}";
    }
    echo "</style>";
    echo "</div><form method='post' action='' style='width:1024px;'>";
    echo "<table id=\"sortDataTable\" class='sortable' cellspacing=\"0\" cellpadding=\"0\" border=\"1\" style='width:100%; clear:left;'>\n\t\t<thead>\n\t\t<tr><th style='text-align:left;'>Plugins</th>\n\t\t\t<th style='text-align:left;'>Description</th>\n\t\t\t<th style='text-align:left;'>Version</th>\n\t\t\t<th style='text-align:left;'>Poller Script</th>\n\t\t\t<th style='text-align:left;'>Poller Interval</th>\n\t\t\t<th style='text-align:left;'>Location</th>\n\t\t\t<th style='text-align:left;'>Action</th></tr>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>";
    if ($_GET['mode'] == refreshPlugins) {
        $dir = "plugins/";
        $status = checkDirForPlugins($dir);
        if ($status != true) {
            $propertyForm->warning("Failed to refresh. Reason: " . $status);
        }
    }
    foreach ($plugins as $id => $value) {
        echo "<tr>";
        $curPlugin = new Plugins($id);
        if (file_exists($curPlugin->get_conf_path())) {
            // If this passes the plugin still exists
            $fileExists = fopen($curPlugin->get_filename(), 'r');
            if ($curPlugin->get_enabled()) {
                echo "<td><input type='checkbox' checked name='list[]' value='" . $curPlugin->get_id() . "' />" . $curPlugin->get_name() . "</td>";
            } else {
                echo "<td><input type='checkbox' name='list[]' value='" . $curPlugin->get_id() . "' />" . $curPlugin->get_name() . "</td>";
            }
            echo "<td>" . $curPlugin->get_description() . "</td>";
            echo "<td>" . $curPlugin->get_version() . "</td>";
            $poller_string = "N/A";
            $poller_interval_string = "";
            if ($curPlugin->get_poller()) {
                $poller_string = $curPlugin->get_poller_script();
                $poller_interval_string = $curPlugin->get_poller_interval() . "min";
            }
            echo "<td>{$poller_string}</td>";
            echo "<td>{$poller_interval_string}</td>";
            if ($curPlugin->get_location() != '') {
                print "<td>" . $curPlugin->get_location() . "</td>";
            } else {
                print "<td> <a class='tooltip' title='This should only be the case for poller plugins.<br> \n\t\t\t\t\tAll other plugins should have content.<br> Location is defined in the config.xml file<br> \n\t\t\t\t\tExample: &lt; location&gt;statistics&lt;&#8260;location&gt;'><img src='icons/Info.png' height='16' width='16'>\n\t\t\t\t\tNo Content</a></td>";
            }
            //print "file is -" . $curPlugin->get_filename() ."-<br>";
            if ($fileExists) {
                if (include_once $curPlugin->get_filename()) {
                    $className = $curPlugin->get_class_name();
                    if ($className && $className != '') {
                        $pluginClass = new $className();
                        if (method_exists($pluginClass, 'get_config')) {
                            echo "<td><a name='modal' href='#dialog" . $id . "'>Configure</a></td>";
                        } else {
                            echo "<td> </td>";
                        }
                    } else {
                        echo "<td> </td>";
                    }
                } else {
                    echo "<td> </td>";
                }
            }
            echo "</tr>";
        } else {
            if (!$curPlugin->remove_plugin()) {
                $propertyForm->warning("You widget does not exist, but we failed to remove it from the database. Reason: " . $curPlugin->get_error());
            }
        }
    }
    echo "</tbody>\n\t</table>";
    echo "<input type='submit' name='savePlugins' value='Enable checked plugins for users' style='float:left; clear:left; margin-bottom:5px;' />";
    echo "<input type='button' name='refresh' value='Refresh Plugins' onclick=\"return LoadPage('configurations.php?action=plugins&mode=refreshPlugins', 'settingsInfo')\" style='float:right; margin-bottom:5px;' />";
    echo "</form>";
    foreach ($plugins as $id => $value) {
        $curPlugin = new Plugins($id);
        include_once $curPlugin->get_filename();
        $className = $curPlugin->get_class_name();
        if ($className && $className != '') {
            $pluginClass = new $className();
            if (method_exists($pluginClass, 'get_config')) {
                echo "<div id='modalBox'>\n\t\t\t\t\t<div id='dialog" . $id . "' class='window'>\n\t\t\t\t\t<div style='clear:both;'></div>";
                echo "<a href='#'class='close' /><img src='icons/close.png'></a>";
                echo $pluginClass->get_config($id);
                echo "</div>\n\t\t\t\t\t<div id='mask'></div>\n\t\t\t\t\t</div>";
            }
        }
    }
}