示例#1
0
function get_post_install_scripts($f, $post_install_scripts, $post_installs) {
    $already_orders = array();
    $elt = array("id_None" => _T("Not selected", "imaging"));
    $elt_values = array("id_None"=> "None");
    $h_pis = array();
    foreach ($post_install_scripts as $lpis) {
        $h_pis[$lpis['imaging_uuid']] = $lpis;
        $already_orders[$lpis['order']] = True;
    }
    $i = 0;
    foreach ($post_installs as $pis) {
        $elt["id_".$i] = "$i";
        $elt_values["id_".$i] = "$i";
        $i += 1;
    }
    $a_label = array();
    $a_desc = array();
    $a_order = array();
    $a_pis_id = array();
    foreach ($post_installs as $pis) {
        $a_pis_id[] = "order_".$pis['imaging_uuid'];
        $a_label[] = $pis['default_name'];
        $a_desc[] = $pis['default_desc'];

        $order = new MySelectItem("order_".$pis['imaging_uuid'], "exclusive_orders");

        $order = new MySelectItem("order_".$pis['imaging_uuid'], "exclusive_orders");
        $order->setJsFuncParams(array('this'));
        $order->setElements($elt);
        $order->setElementsVal($elt_values);
        if (array_key_exists($pis['imaging_uuid'], $h_pis)) {
            $order->setSelected($h_pis[$pis['imaging_uuid']]['order']);
        } else {
            $order->setSelected("None");
        }
        $a_order[] = $order;
    }
    $l = new MyListInfos($a_label, _T("Name", "imaging"));
    $l->setPostInstallCount(count($post_installs));
    $l->addExtraInfo($a_desc, _T("Description", "imaging"));
    $l->addExtraInfo($a_order, _T("Order", "imaging"));

    $l->disableFirstColumnActionLink();
    $l->setRowsPerPage(count($post_installs));

    $f->add($l);

    print_exclusive_orders_js($a_pis_id);
    return $f;
}
示例#2
0
 if ($is_registering && $type == '') {
     $networks = xmlCall('base.getComputersNetwork', array(array('uuid' => $_GET["target_uuid"])));
     $networks = $networks[0][1];
     foreach (range(0, count($networks['ipHostNumber']) - 1) as $i) {
         $ip = explode(":", $networks['ipHostNumber'][$i]);
         if (filter_var($ip[0], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) == "") {
             unset($networks['ipHostNumber'][$i]);
             unset($networks['macAddress'][$i]);
             unset($networks['networkUuids'][$i]);
             unset($networks['domain'][$i]);
         }
     }
     if (is_array($networks) && count($networks) > 1 and isset($networks['macAddress'])) {
         if (count($networks['macAddress']) > 1) {
             $f->push(new Table());
             $macs_choice = new MySelectItem("choose_network", 'exclusive_orders');
             $elements = array();
             $values = array();
             foreach (range(0, count($networks['macAddress']) - 1) as $i) {
                 $elements[] = sprintf("%s / %s", $networks['ipHostNumber'][$i], $networks['macAddress'][$i]);
                 $values[] = $networks['networkUuids'][$i];
             }
             $macs_choice->setElements($elements);
             $macs_choice->setElementsVal($values);
             $f->add(new TrFormElement(_T("Choose the MAC address you want to use", "imaging"), $macs_choice));
             $f->pop();
         } elseif (count($networks['macAddress']) == 1) {
             $f->add(new HiddenTpl("choose_network"), array("value" => $networks['networkUuids'][0], "hide" => True));
         }
     }
 }