$emptyAction = new EmptyActionItem();
foreach ($lines as $ipaddress => $infos) {
    $hosts[] = $infos["hostname"];
    $ipaddresses[] = long2ip($ipaddress);
    $macaddresses[] = $infos["macaddress"];
    $types[] = $infos["type"];
    $params[] = array("host" => $infos["hostname"], "macaddress" => $infos["macaddress"], "subnet" => $subnet);
    if ($infos["type"] == _T("Static", "network")) {
        $actionsAdd[] = $emptyAction;
        $actionsDel[] = $deleteAction;
        $actionsEdit[] = $editAction;
    } else {
        $actionsAdd[] = $addAction;
        $actionsDel[] = $emptyAction;
        $actionsEdit[] = $emptyAction;
    }
}
$n = new ListInfos($ipaddresses, _T("IP address", "network"));
$n->setNavBar(new AjaxNavBar(count($ipaddresses), $filter));
$n->disableFirstColumnActionLink();
$n->setTableHeaderPadding(1);
$n->addExtraInfo($hosts, _T("Host name", "network"));
$n->addExtraInfo($macaddresses, _T("MAC address", "network"));
$n->addExtraInfo($types, _T("Type", "network"));
$n->setName(_T("Host", "network"));
$n->setParamInfo($params);
$n->addActionItemArray($actionsAdd);
$n->addActionItemArray($actionsEdit);
$n->addActionItemArray($actionsDel);
$n->display();
Example #2
0
$arrayTMP = getStatutProxy();

foreach($arrayTMP as $key => $value) {
    $info[]=$key;
    if ($value) $extraInfo[]=_T("enabled");
    else $extraInfo[]=_T("disabled");
}

$p = new PageGenerator();
$p->setSideMenu($sidemenu);
$p->displaySideMenu();

$n = new ListInfos($info,_T("Services"));
$n->setName(_T("Proxy status"));
$n->addExtraInfo($extraInfo,_T("Status"));
$n->display(0);

?>

<form method="post" action="main.php?module=proxy&amp;submod=blacklist&amp;action=restart">
<input name="goto" type="hidden" value="<?php 
echo $root;
?>
main.php" />
<input name="brestart" type="submit" class="btnPrimary" value="<?php 
echo _T('Restart service');
?>
" />
</form>

Example #3
0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MMC; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
require "modules/samba/includes/machines.inc.php";
$filter = $_GET['filter'];
$computers = search_machines($filter);
//print_r($computers);
$names = array();
$desc = array();
$active = array();
foreach ($computers as $computer) {
    $names[] = $computer[0];
    $desc[] = $computer[1];
    $active[] = $computer[2];
}
$l = new ListInfos($names, _T("Computer name", "samba"));
$l->disableFirstColumnActionLink();
$l->setCssClass("machineName");
$l->setNavBar(new AjaxNavBar(count($computers), $filter));
$l->addExtraInfo($desc, _T("Description", "samba"));
$l->addExtraInfo($active, _T("Active", "samba"));
$l->addActionItem(new ActionItem(_T("Edit"), "edit", "edit", "machine"));
$l->addActionItem(new ActionPopupItem(_T("Delete"), "delete", "delete", "machine"));
$l->setName(_("Computers"));
$l->display();
Example #4
0
    $status[] = _T("Stopped");
    $actionsStart[] = $startAction;
    $actionsStop[] = $emptyAction;
    $actionsRestart[] = $emptyAction;
}
$actionsLog[] = $logAction;
$actionsReload[] = $reloadAction;
if (dnsService("status")) {
    $status[] = _T("Started");
    $actionsStart[] = $emptyAction;
    $actionsStop[] = $stopAction;
    $actionsRestart[] = $restartAction;
} else {
    $status[] = _T("Stopped");
    $actionsStart[] = $startAction;
    $actionsStop[] = $emptyAction;
    $actionsRestart[] = $emptyAction;
}
$l = new ListInfos(array("DHCP", "DNS"), _T("Services"));
$l->setName(_T("Network services status"));
$l->addExtraInfo($status, _T("Status"));
$l->setParamInfo(array(array("service" => "DHCP"), array("service" => "DNS")));
$l->setTableHeaderPadding(1);
$l->disableFirstColumnActionLink();
$l->addActionItemArray($actionsStart);
$l->addActionItemArray($actionsStop);
$l->addActionItemArray($actionsRestart);
$l->addActionItemArray($actionsReload);
$l->addActionItemArray($actionsLog);
$l->display(0);
Example #5
0
$errStrings = array("no free leases", "Error", "error", "Not configured to listen on any interfaces!", "Can't");

foreach (xmlCall("network.getDhcpLog",array($_SESSION['ajax']['filter'])) as $line) {
    if (is_array($line)) {
        $found = False;
        foreach($errStrings as $err) {
            if (strpos($line["extra"], $err) !== False) {
                $extra[] = '<div class="error">' . $line["extra"] . "</div>";
                $found = True;
                break;
            }
        }
        if (!$found) $extra[] = $line["extra"];
	$op[] = '<a href="#" onClick="$(\'param\').value=\''.$line["op"].'\'; pushSearch(); return false">'.$line["op"].'</a>';
        $dateparsed = strftime('%b %d %H:%M:%S',$line["time"]);
        $date[] = str_replace(" ", "&nbsp;", $dateparsed);
    } else {
        $date[] = "";
        $extra[] = $line;
    }
}

$n = new ListInfos($date, _T("Date", "network"),"1px");
$n->addExtraInfo($op, _T("Operations", "network"));
$n->addExtraInfo($extra, _T("Informations", "network"));
$n->end = 200;
$n->setTableHeaderPadding(1);
$n->display(0,0);

?>
</div>
Example #6
0
 function display()
 {
     $lines = array();
     $errlines = array();
     foreach ($this->logs as $line => $msg) {
         if (strpos($msg, "===") === 0) {
             $msg = "<b>" . "{$msg}" . "</b>";
         } else {
             if (strpos($msg, $this->errstr) === 0) {
                 $msg = "<span id=\"err{$line}\" class=\"LOG_ERR\">" . "{$msg}" . "</span>";
                 $errlines[] = $line;
             }
         }
         foreach ($this->colors as $pattern => $color) {
             if (strpos($msg, $pattern) > 0) {
                 $msg = "<span id=\"err{$line}\" class=\"{$color}\">" . "{$msg}" . "</span>";
                 continue;
             }
         }
         $lines[] = sprintf("<span class=\"linenumber\">%04d:</span>", $line) . " " . $msg;
     }
     foreach ($errlines as $line) {
         print "<p class =\"LOG_ERR\" onClick=\"javascript:new Element.scrollTo('err{$line}');\">Click here to scroll to error on line {$line}.</p>";
     }
     $l = new ListInfos($lines, _T("Backup log messages", "imaging"));
     $l->setCssClass("imagelogs");
     $l->setRowsPerPage(count($lines));
     $l->setNavBar(False);
     $l->display(0, 1);
 }
Example #7
0
$inventoriesId = array();
$detailsParams = array();
$detailsButtons = array();
$i = 0;
// Call the methods to get the inventory history
$count = countMachineInventoryHistory($params);
$inventory_history = getMachineInventoryHistory($params);
// Loop through the inventory history to extract infos
foreach ($inventory_history as $inventory) {
    $inventoriesDates[] = _toDate($inventory[1]);
    // Add the details link (unless we are on the last line)
    if ($i < count($inventory_history) - 1) {
        $detailsButtons[] = new ActionItem(_T("View differences since previous inventory", "inventory"), "invdiff", "display");
    } else {
        $detailsButtons[] = new EmptyActionItem();
    }
    $detailsParams[$i]['inventoryId'] = $inventory[0];
    $detailsParams[$i++]['uuid'] = $params['uuid'];
}
// Create a ListInfos that will display the inventories dates
$list = new ListInfos($inventoriesDates, _T("Inventory Date", "inventory"));
// Add extra params in the "details" link
$list->setParamInfo($detailsParams);
$list->disableFirstColumnActionLink();
$list->setName(_T("Inventory", "inventory"));
$list->addActionItemArray($detailsButtons);
$list->setTableHeaderPadding(0);
$list->start = 0;
$list->end = count($inventoriesDates);
$list->display();
Example #8
0
            // Loop through elems to change arrays into dates
            foreach ($elem as $k => $v) {
                if (is_array($v)) {
                    $elem[$k] = _toDate($v);
                }
            }
            // Create a ListInfos to display the infos of the element in a list
            $list = new ListInfos(array_keys($elem), _T("Element", "inventory"));
            $list->addExtraInfo(array_values($elem), _T("Value", "inventory"));
            $list->setName(_T($part));
            $list->setTableHeaderPadding(0);
            // Append the ListInfo in an array, to display all ListInfos together at the end of the page loading
            $removed_part_lists[] = $list;
        }
    }
}
// Display the page
$p->display();
// Display the added elements (without navbar)
print "<h3>" . _T("Added elements", "inventory") . "</h3>";
foreach ($added_part_lists as $list) {
    print '<h4>' . $list->name . '</h4>';
    $list->display($navbar = 0, $header = 0);
}
print "<br/><br/><br/>";
// Display the removed elements (without navbar)
print "<h3>" . _T("Removed elements", "inventory") . "</h3>";
foreach ($removed_part_lists as $list) {
    print '<h4>' . $list->name . '</h4>';
    $list->display($navbar = 0, $header = 0);
}
Example #9
0
/**
 * (c) 2004-2007 Linbox / Free&ALter Soft, http://linbox.com
 * (c) 2007-2008 Mandriva, http://www.mandriva.com/
 *
 * $Id$
 *
 * This file is part of Mandriva Management Console (MMC).
 *
 * MMC is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * MMC is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MMC; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
function list_computers($names, $filter, $count = 0, $delete_computer = false, $remove_from_result = false, $is_group = false, $msc_can_download_file = false, $msc_vnc_show_icon = false)
{
    /* $pull_list is an array with UUIDs of pull machines */
    $pull_list = in_array("pulse2", $_SESSION["modulesList"]) ? get_pull_targets() : array();
    $emptyAction = new EmptyActionItem();
    $inventAction = new ActionItem(_("Inventory"), "invtabs", "inventory", "inventory", "base", "computers");
    $glpiAction = new ActionItem(_("GLPI Inventory"), "glpitabs", "inventory", "inventory", "base", "computers");
    $logAction = new ActionItem(_("Read log"), "msctabs", "logfile", "computer", "base", "computers", "tablogs");
    $mscAction = new ActionItem(_("Software deployment"), "msctabs", "install", "computer", "base", "computers");
    $imgAction = new ActionItem(_("Imaging management"), "imgtabs", "imaging", "computer", "base", "computers");
    $downloadFileAction = new ActionItem(_("Download file"), "download_file", "download", "computer", "base", "computers");
    $vncClientAction = new ActionPopupItem(_("Remote control"), "vnc_client", "vncclient", "computer", "base", "computers");
    $profileAction = new ActionItem(_("Show Profile"), "computersgroupedit", "logfile", "computer", "base", "computers");
    $actionInventory = array();
    $actionLogs = array();
    $actionMsc = array();
    $actionImaging = array();
    $actionDownload = array();
    $actionVncClient = array();
    $actionProfile = array();
    $params = array();
    $cssClasses = array();
    $headers = getComputersListHeaders();
    $columns = array();
    foreach ($headers as $header) {
        $columns[$header[0]] = array();
    }
    function getUUID($machine)
    {
        return $machine['objectUUID'];
    }
    $uuids = array_map("getUUID", $names);
    /*if (in_array("dyngroup", $_SESSION["modulesList"])) {
          $profiles = xmlrpc_getmachinesprofiles($uuids);
          $h_profiles = array();
          $i = 0;
          foreach ($uuids as $uuid) {
              $h_profiles[$uuid] = $profiles[$i++];
          }
      }*/
    foreach ($names as $value) {
        $cssClasses[] = in_array($value['objectUUID'], $pull_list) ? 'machinePull' : 'machineName';
        foreach ($headers as $header) {
            if (!empty($value[$header[0]])) {
                $v = $value[$header[0]];
            } else {
                $v = '';
            }
            $columns[$header[0]][] = $v;
        }
        if (isset($filter['gid'])) {
            $value['gid'] = $filter['gid'];
        }
        if (in_array("inventory", $_SESSION["supportModList"])) {
            $actionInventory[] = $inventAction;
        } else {
            $actionInventory[] = $glpiAction;
        }
        if (in_array("msc", $_SESSION["supportModList"])) {
            $actionMsc[] = $mscAction;
            $actionLogs[] = $logAction;
        }
        if (in_array("imaging", $_SESSION["supportModList"])) {
            $actionImaging[] = $imgAction;
        }
        /*
        if (in_array("dyngroup", $_SESSION["modulesList"])) {
            $profile = $h_profiles[$value['objectUUID']];
            if ($profile) {
                $actionProfile[] = $profileAction;
                $value['id'] = $profile;
            } else {
                $actionProfile[] = $emptyAction;
            }
        }
        */
        if ($msc_can_download_file) {
            $actionDownload[] = $downloadFileAction;
        }
        if ($msc_vnc_show_icon) {
            $actionVncClient[] = $vncClientAction;
        }
        $params[] = $value;
    }
    if (isset($filter['location'])) {
        $filter = $filter['hostname'] . '##' . $filter['location'];
    } else {
        $filter = $filter['hostname'] . '##';
    }
    $n = null;
    if ($count) {
        foreach ($headers as $header) {
            if ($n == null) {
                if (in_array("glpi", $_SESSION["modulesList"])) {
                    $n = new OptimizedListInfos($columns[$header[0]], _T($header[1], 'glpi'));
                } else {
                    $n = new OptimizedListInfos($columns[$header[0]], _($header[1]));
                }
            } else {
                if (in_array("glpi", $_SESSION["modulesList"])) {
                    $n->addExtraInfo($columns[$header[0]], _T($header[1], 'glpi'));
                } else {
                    $n->addExtraInfo($columns[$header[0]], _($header[1]));
                }
            }
        }
        $n->setItemCount($count);
        $n->setNavBar(new AjaxNavBar($count, $filter));
        $n->start = 0;
        $n->end = $count - 1;
    } else {
        foreach ($headers as $header) {
            if ($n == null) {
                $n = new ListInfos($columns[$header[0]], _($header[1]));
            } else {
                $n->addExtraInfo($columns[$header[0]], _($header[1]));
            }
        }
        $n->setNavBar(new AjaxNavBar(count($columns[$headers[0][0]]), $filter));
    }
    $n->setName(_("Computers list"));
    $n->setParamInfo($params);
    //$n->setCssClass("machineName");
    $n->setMainActionClasses($cssClasses);
    $n->addActionItemArray($actionInventory);
    if ($msc_can_download_file) {
        $n->addActionItemArray($actionDownload);
    }
    if (in_array("backuppc", $_SESSION["supportModList"])) {
        $n->addActionItem(new ActionItem(_("Backup status"), "hostStatus", "backuppc", "backuppc", "backuppc", "backuppc"));
    }
    if ($msc_vnc_show_icon) {
        $n->addActionItemArray($actionVncClient);
    }
    /*if (in_array("dyngroup", $_SESSION["modulesList"])) {
          $n->addActionItemArray($actionProfile);
      }*/
    if (in_array("msc", $_SESSION["supportModList"])) {
        $n->addActionItemArray($actionLogs);
        $n->addActionItemArray($actionMsc);
    }
    if (in_array("imaging", $_SESSION["supportModList"])) {
        $n->addActionItemArray($actionImaging);
    }
    if ($delete_computer && canDelComputer()) {
        // set popup window to 400px width
        $n->addActionItem(new ActionPopupItem(_("Delete computer"), "delete", "delete", "computer", "base", "computers", null, 400));
    }
    if ($remove_from_result) {
        $n->addActionItem(new ActionPopupItem(_("Remove machine from group"), "remove_machine", "remove_machine", "name", "base", "computers"));
    }
    $n->display();
}
Example #10
0
    echo '<link rel="stylesheet" href="modules/imaging/graph/css/default.min.css">';
    echo '<script src="modules/imaging/graph/highlight/highlight.min.js"></script>';
    echo '<script>hljs.initHighlightingOnLoad();</script>';
    //$file must be existing
    if (!($file = xmlrpc_selectWindowsAnswerFile($_GET['display']))) {
        $file = array();
    }
    echo '<pre>';
    foreach ($file as $line) {
        echo htmlentities($line);
    }
    echo '</pre>';
} else {
    //Get the list of answer files
    $list = xmlrpc_Windows_Answer_list_File(0, -1);
    //Display sidemenu
    $page = new PageGenerator(_T("All Windows Answer Files", 'imaging'));
    $page->setSideMenu($sidemenu);
    $page->display();
    //Create list of sysprep answer file
    $table = new ListInfos($list['file'], _T("File name", "imaging"));
    //Add informations on each row
    $table->addExtraInfo($list['os'], _T("OS", "imaging"));
    $table->addExtraInfo($list['description'], _T("Description", "imaging"));
    //Add actions on each row
    $table->addActionItem(new ActionItem(_T("Display sysprep file", "imaging"), "sysprepView", "display", "display", "imaging", "manage"));
    $table->addActionItem(new ActionItem(_T("Edit sysprep file", "imaging"), "unattended", "edit", "edit", "imaging", "manage"));
    $table->addActionItem(new ActionConfirmItem(_T("Delete sysprep file", 'imaging'), "sysprepList", "delete", "deleteFile", "imaging", "manage", _T('Are you sure you want to unset this sysrep answer file?', 'imaging')));
    // Display the list
    $table->display();
}
Example #11
0
function item_list() {

    if(isset($_GET['gid'])) {
        $type = 'group';
        list($count, $menu) = xmlrpc_getProfileBootMenu($_GET['gid']);
    } else {
        $type = '';
        list($count, $menu) = xmlrpc_getComputerBootMenu($_GET['uuid']);
    }

    $params = getParams();

    // forge params
    $upAction = new ActionItem(_T("Move Up"), $type."imgtabs", "up", "item", "base", "computers", $type."tabbootmenu", "up");
    $downAction = new ActionItem(_T("Move down"), $type."imgtabs", "down", "item", "base", "computers", $type."tabbootmenu", "down");
    $editAction = new ActionItem(_T("Edit"), $type."imgtabs", "edit", "item", "base", "computers", $type."tabbootmenu", "edit");
    $deleteAction = new ActionPopupItem(_T("Delete"), "bootmenu_remove", "delete", "item", "base", "computers", $type."tabbootmenu", 300, "delete");

    $emptyAction = new EmptyActionItem();
    $actionUp = array();
    $actionDown = array();
    $actionEdit = array();
    $actionDelete = array();

    $nbItems = $count;

    $a_label = array();
    $a_desc = array();
    $a_default = array();
    $a_display = array();
    $a_defaultWOL = array();
    $a_displayWOL = array();
    $params['from'] = 'tabbootmenu';

    $i = -1;
    $root_len = 0;
    foreach ($menu as $entry) {
        $i = $i + 1;
        $is_image = False;
        if (isset($entry['image'])) {
            $is_image = True;
        }

        if ($is_image) { # TODO $entry has now a cache for desc.
            $a_desc[] = $entry['image']['desc'];
            $entry['default_name'] = $entry['image']['name'];
            $kind = 'IM';
            if ($entry['read_only']) {
                $url = '<img src="modules/imaging/graph/images/imaging-action-ro.png" style="vertical-align: middle" alt="'._T('master from the profile', 'imaging').'"/> ';
            } else {
                $url = '<img src="modules/imaging/graph/images/imaging-action.png" style="vertical-align: middle" alt="'._T('master', 'imaging').'"/> ';
            }
        } else {
            $a_desc[] = $entry['boot_service']['default_desc'];
            $entry['default_name'] = $entry['boot_service']['default_name'];
            $kind = 'BS';
            if ($entry['read_only']) {
                $url = '<img src="modules/imaging/graph/images/service-action-ro.png" style="vertical-align: middle" alt="'._T('boot service from profile', 'imaging').'"/> ';
            } else {
                $url = '<img src="modules/imaging/graph/images/service-action.png" style="vertical-align: middle" alt="'._T('boot service', 'imaging').'"/> ';
            }
        }

        $list_params[$i] = $params;
        $list_params[$i]["itemid"] = $entry['imaging_uuid'];
        $list_params[$i]["itemlabel"] = urlencode($entry['default_name']);

        if ($entry['read_only']) {
            $actionsDown[] = $emptyAction;
            $actionsUp[] = $emptyAction;
            $root_len += 1;
            $actionEdit[] = $emptyAction;
            $actionDelete[] = $emptyAction;
        } else {
            $actionEdit[] = $editAction;
            $actionDelete[] = $deleteAction;
            if ($i == $root_len) {
                if ($count == 1 || $root_len == $count - 1) {
                    $actionsDown[] = $emptyAction;
                    $actionsUp[] = $emptyAction;
                } else {
                    $actionsDown[] = $downAction;
                    $actionsUp[] = $emptyAction;
                }
            } elseif ($i > $root_len && $i == $nbItems-1) {
                $actionsDown[] = $emptyAction;
                $actionsUp[] = $upAction;
            } elseif ($i > $root_len) {
                $actionsDown[] = $downAction;
                $actionsUp[] = $upAction;
            }
        }

        $a_label[] = sprintf("%s%s", $url, $entry['default_name']); # should be replaced by the label in the good language
        $a_default[] = $entry['default'];
        $a_display[] = ($entry['hidden'] ? False:True);
        $a_defaultWOL[] = $entry['default_WOL'];
        $a_displayWOL[] = ($entry['hidden_WOL'] ? False:True);
    }
    $firstp = "<p>" . _T("\"Preselected choice\" and \"Preselected choice on WOL\" values will be used to set the default imaging client menu item to run, if no choice is made by the user on the client side prior to the menu timeout.", "imaging") . "</p>";
    /* Build tooltip text on column name */
    if ($type == "") {
        $text = $firstp . "<p>" . _T("Once the operation triggered by a choice is successfull, the preselected choice will default to the first item of the boot menu.", "imaging") . "</p>";
    } else {
        $text = $firstp . "<p>" . _T("When you modify the \"Preselected choice\" or \"Preselected choice on WOL\" values on a profile, those values will be set on all the boot menu of the computers owned by the profile.", "imaging") . "</p>" . "<p>" . _T("Then for each computer, once the operation triggered by a choice is successfull, the preselected choice will default to the first item of the boot menu.", "imaging") . "</p>";
    }
    $l = new ListInfos($a_label, _T("Label"));
    $l->setParamInfo($list_params);
    $l->addExtraInfo($a_desc, _T("Description", "imaging"));
    $l->addExtraInfo($a_default, _T("Preselected choice", "imaging")
                     , "", $text);
    $l->addExtraInfo($a_display, _T("Displayed", "imaging"));
    $l->addExtraInfo($a_defaultWOL, _T("Preselected choice on WOL", "imaging")
                     , "", $text);
    $l->addExtraInfo($a_displayWOL, _T("Displayed on WOL", "imaging"));
    $l->addActionItemArray($actionsUp);
    $l->addActionItemArray($actionsDown);
    $l->addActionItemArray($actionEdit);
    if ($count > 1) {
        $l->addActionItemArray($actionDelete);
    }
    $l->disableFirstColumnActionLink();
    $l->setTableHeaderPadding(19);
    $l->display();
}
Example #12
0
function item_list()
{
    if (isset($_GET['gid'])) {
        $type = 'group';
        list($count, $menu) = xmlrpc_getProfileBootMenu($_GET['gid']);
    } else {
        $type = '';
        list($count, $menu) = xmlrpc_getComputerBootMenu($_GET['uuid']);
    }
    $params = getParams();
    // forge params
    if ($type == 'group') {
        $module = "imaging";
        $submod = "manage";
    } else {
        $module = "base";
        $submod = "computers";
    }
    $upAction = new ActionItem(_T("Move Up"), $type . "imgtabs", "up", "item", $module, $submod, $type . "tabbootmenu", "up");
    $downAction = new ActionItem(_T("Move down"), $type . "imgtabs", "down", "item", $module, $submod, $type . "tabbootmenu", "down");
    $editAction = new ActionItem(_T("Edit"), $type . "imgtabs", "edit", "item", $module, $submod, $type . "tabbootmenu", "edit");
    $deleteAction = new ActionPopupItem(_T("Delete"), $type . "bootmenu_remove", "delete", "item", $module, $submod, $type . "tabbootmenu", 300, "delete");
    $emptyAction = new EmptyActionItem();
    $actionUp = array();
    $actionDown = array();
    $actionEdit = array();
    $actionDelete = array();
    $nbItems = $count;
    $a_label = array();
    $a_desc = array();
    $a_default = array();
    $a_display = array();
    $a_defaultWOL = array();
    $a_displayWOL = array();
    $params['from'] = 'tabbootmenu';
    $i = -1;
    $root_len = 0;
    foreach ($menu as $entry) {
        $i = $i + 1;
        $is_image = False;
        if (isset($entry['image'])) {
            $is_image = True;
        }
        if ($is_image) {
            # TODO $entry has now a cache for desc.
            $a_desc[] = $entry['image']['desc'];
            $entry['default_name'] = $entry['image']['name'];
            $kind = 'IM';
            if ($entry['read_only']) {
                $url = '<img src="modules/imaging/graph/images/imaging-action-ro.png" style="vertical-align: middle" alt="' . _T('master from the profile', 'imaging') . '"/> ';
            } else {
                $url = '<img src="modules/imaging/graph/images/imaging-action.png" style="vertical-align: middle" alt="' . _T('master', 'imaging') . '"/> ';
            }
        } else {
            $a_desc[] = $entry['boot_service']['default_desc'];
            $entry['default_name'] = $entry['boot_service']['default_name'];
            $kind = 'BS';
            if ($entry['read_only']) {
                $url = '<img src="modules/imaging/graph/images/service-action-ro.png" style="vertical-align: middle" alt="' . _T('boot service from profile', 'imaging') . '"/> ';
            } else {
                $url = '<img src="modules/imaging/graph/images/service-action.png" style="vertical-align: middle" alt="' . _T('boot service', 'imaging') . '"/> ';
            }
        }
        $list_params[$i] = $params;
        $list_params[$i]["itemid"] = $entry['imaging_uuid'];
        $list_params[$i]["itemlabel"] = urlencode($entry['default_name']);
        if ($entry['read_only']) {
            $actionsDown[] = $emptyAction;
            $actionsUp[] = $emptyAction;
            $root_len += 1;
            $actionEdit[] = $emptyAction;
            $actionDelete[] = $emptyAction;
        } else {
            $actionEdit[] = $editAction;
            $actionDelete[] = $deleteAction;
            if ($i == $root_len) {
                if ($count == 1 || $root_len == $count - 1) {
                    $actionsDown[] = $emptyAction;
                    $actionsUp[] = $emptyAction;
                } else {
                    $actionsDown[] = $downAction;
                    $actionsUp[] = $emptyAction;
                }
            } elseif ($i > $root_len && $i == $nbItems - 1) {
                $actionsDown[] = $emptyAction;
                $actionsUp[] = $upAction;
            } elseif ($i > $root_len) {
                $actionsDown[] = $downAction;
                $actionsUp[] = $upAction;
            }
        }
        $a_label[] = sprintf("%s%s", $url, $entry['default_name']);
        # should be replaced by the label in the good language
        $a_default[] = $entry['default'];
        $a_display[] = $entry['hidden'] ? False : True;
        $a_defaultWOL[] = $entry['default_WOL'];
        $a_displayWOL[] = $entry['hidden_WOL'] ? False : True;
    }
    $firstp = "<p>" . _T("Use \"Preselected choice\" or \"Preselected choice on WOL\" to define the default boot entry.", "imaging") . "</p>";
    /* Build tooltip text on column name */
    if ($type == "") {
        $text = $firstp . "<p>" . _T("If the default entry is an image creation or restore, the following network boots will fall back to the first menu entry.", "imaging") . "</p>";
    } else {
        $text = $firstp . "<p>" . _T("When changing \"Preselected choice\" or \"Preselected choice on WOL\" entry, this value will be set on all the computers in this group.", "imaging") . "</p>" . "<p>" . _T("If the default entry is an image creation or restore, the following network boots will fall back to the first menu entry.", "imaging") . "</p>";
    }
    $l = new ListInfos($a_label, _T("Label"));
    $l->setParamInfo($list_params);
    $l->addExtraInfo($a_desc, _T("Description", "imaging"));
    $l->addExtraInfo($a_default, _T("Preselected choice", "imaging"), "", $text);
    $l->addExtraInfo($a_display, _T("Displayed", "imaging"));
    $l->addExtraInfo($a_defaultWOL, _T("Preselected choice on WOL", "imaging"), "", $text);
    $l->addExtraInfo($a_displayWOL, _T("Displayed on WOL", "imaging"));
    $l->addActionItemArray($actionsUp);
    $l->addActionItemArray($actionsDown);
    $l->addActionItemArray($actionEdit);
    if ($count > 1) {
        $l->addActionItemArray($actionDelete);
    }
    $l->disableFirstColumnActionLink();
    $l->setTableHeaderPadding(19);
    $l->display();
}
Example #13
0
 function displayReqListInfos($canbedeleted = false, $default_params = array())
 {
     if (!$default_params['target']) {
         $default_params['target'] = 'creator';
     }
     if (!strlen($default_params['tab'])) {
         $default_params['tab'] = null;
     }
     $parameters = array();
     $parts = array();
     foreach ($this->subs as $id => $sub) {
         array_push($parts, $sub->display());
         $p = $default_params;
         $p['subedition'] = 1;
         #$p['delete'] = $id;
         $p['sub_id'] = $id;
         $p['request'] = $this->toS();
         array_push($parameters, $p);
     }
     $n = new ListInfos($parts, _T('Search part', 'dyngroup'), "&amp;id=" . $default_params['gid']);
     if ($canbedeleted) {
         $n->setParamInfo($parameters);
         $n->addActionItem(new ActionItem(_T("Edit", 'dyngroup'), $default_params['target_edit'], "edit", "params", null, null, $default_params['tab']));
         $n->addActionItem(new ActionItem(_T("Delete", 'dyngroup'), $default_params['target_del'], "delete", "params", null, null, $default_params['tab']));
     }
     $n->disableFirstColumnActionLink();
     $n->display();
     print "<br/>";
     // or the previous/next will be on the next line...
 }