Example #1
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 #2
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();
}