Exemple #1
0
if (isset($params['uuid'])) {
    $_GET['type'] = '';
    $_GET['target_uuid'] = $params['uuid'];
    $_GET['target_name'] = $params['hostname'];
    unset($_GET['gid']);
    $params['type'] = '';
    $params['target_uuid'] = $params['uuid'];
    $params['target_name'] = $params['hostname'];
    if (!isset($_GET['uuid']) || $_GET['uuid'] == '') {
        $_GET['uuid'] = $params['uuid'];
    }

    $params['hostname'] = $hostname;

    $canReg = xmlrpc_canIRegisterThisComputer($params['target_uuid']);
    if (!$canReg[0] && $canReg[1]) {
        $p = new PageGenerator(sprintf(_T("%s's computer imaging", 'imaging'), $hostname));
        $sidemenu->forceActiveItem("index");
        $p->setSideMenu($sidemenu);
        $p->display();
        # when the computer is in a profile, but the profile is not registered
        # display an information message
        $msg = _T("This computer can't be declared in the Imaging module, it's part of a profile, but the profile is not declared in the Imaging.", "imaging");
        $t1 = new TitleElement($msg, 3);
        $t1->display();
        # give a link to the profile registering
        if (count($canReg) == 2 and $canReg[1] != '') {
            $group = new Group($canReg[1], true);
            $params = array("id"=>$canReg[1], "gid"=>$canReg[1], "groupname"=>$group->getName());
            $url = urlStr("base/computers/groupimgtabs", $params);
Exemple #2
0
function drawGroupList($machines, $members, $listOfMembers, $visibility, $diff, $gid, $name, $filter = '', $type = 0)
{
    if ($type == 0) {
        $label_name = _T('Group name', 'dyngroup');
        $label_visible = _T('Make favourite', 'dyngroup');
        $label_members = _T("Group members", "dyngroup");
    } else {
        $label_name = _T('Group name', 'dyngroup');
        // Imaging group
        $label_visible = _T('Make favourite', 'dyngroup');
        $label_members = _T("Group members", "dyngroup");
    }
    $willBeUnregistered = array();
    if ($type == 1) {
        $listOfMembersUuids = array_keys($listOfMembers);
        foreach ($listOfMembersUuids as $target_uuid) {
            $ret = xmlrpc_canIRegisterThisComputer($target_uuid);
            if (!$ret[0]) {
                $willBeUnregistered[] = $target_uuid;
            } elseif ($ret[0] && isset($ret[1]) && $ret[1] != False) {
                $willBeUnregistered[] = $target_uuid;
            }
        }
    }
    $currentGroup = getPGobject($gid, true);
    if ($type == 1) {
        // Check if machines who are displayed are part of an existing profile
        $machinesInProfile = arePartOfAProfile(array_keys($listOfMembers));
        // If we edit an imaging group, exclude machines of current group. else they
        // will be reported as machines in imaging group
        $computersgroupedit = 0;
        if (isset($_GET['action']) && $_GET['action'] == 'computersgroupedit') {
            $computersgroupedit = 1;
            $i = 0;
            foreach ($machinesInProfile as $uuid => $group) {
                if ($group['groupname'] == $currentGroup->name) {
                    unset($machinesInProfile[$uuid]);
                    unset($willBeUnregistered[array_search($uuid, $willBeUnregistered)]);
                }
                $i++;
            }
        }
    }
    ?>

<form action="<?php 
    echo $_SERVER["REQUEST_URI"];
    ?>
" method="post">
<table style="border: none;" cellspacing="0">
<tr><td><?php 
    echo $label_name;
    ?>
</td><td></td><td><input name="name" value="<?php 
    echo $name;
    ?>
" type="text"/></td></tr>
<tr><td><?php 
    echo $label_visible;
    ?>
</td><td></td><td>
    <input name='visible' value='show' <?php 
    if ($visibility == 'show') {
        echo 'checked';
    }
    ?>
 type='radio'/><?php 
    echo _T('Yes', 'dyngroup');
    ?>
 
    <input name='visible' value='hide' <?php 
    if ($visibility != 'show') {
        echo 'checked';
    }
    ?>
 type='radio'/><?php 
    echo _T('No', 'dyngroup');
    ?>
</td></tr>
<!-- add all group inupts -->
</table>

<div id="grouplist">
<table style="border: none;" cellspacing="0">
<tr>
 <td style="border: none;">
  <div class="list">
    <h3><?php 
    echo _T("All machines", "dyngroup");
    ?>
</h3>
    <input name='filter' type='text' value='<?php 
    echo $filter;
    ?>
'/>
    <input type="image" name="bfiltmachine" style="padding: 5px;" src="img/common/icn_show.gif" value = "-->"/>
    <br/><br/>
    <select multiple size="13" class="list" name="machines[]">
    <?php 
    foreach ($diff as $idx => $machine) {
        if ($machine == "") {
            unset($machines[$idx]);
            continue;
        }
        echo "<option value=\"" . $idx . "\">" . $machine . "</option>\n";
    }
    ?>
    </select>
    <br/>
  </div>
 </td>
 <td style="border: none;">
  <div>
   <input type="image" name="baddmachine" style="padding: 5px;" src="img/common/icn_arrowright.gif" value = "-->"/><br/>
   <input type="image" name="bdelmachine" style="padding: 5px;" src="img/common/icn_arrowleft.gif" value="<--" />
  </div>
 </td>
 <td style="border: none;">
  <div class="list" style="padding-left: 10px;">
    <h3><?php 
    echo $label_members;
    ?>
</h3>
    <select multiple size="15" class="list" name="members[]">
    <?php 
    foreach ($members as $idx => $member) {
        $currentUuid = explode('##', $idx);
        $currentUuid = $currentUuid[1];
        if ($member == "") {
            unset($members[$idx]);
            continue;
        }
        $style = '';
        if ($type == 1) {
            // Imaging group
            // Check if machines who are displayed are part of an existing profile
            if (in_array($currentUuid, array_keys($machinesInProfile))) {
                $style = 'background: red; color: white;';
            } elseif (in_array($currentUuid, $willBeUnregistered)) {
                $style = 'background: purple; color: white;';
            }
        }
        echo "<option style=\"" . $style . "\" value=\"" . $idx . "\">" . $member . "</option>\n";
    }
    ?>
    </select>
    <br/>
  </div>
  <div class="clearer"></div>
 </td>
</tr>
</table>
</div>

<?php 
    if ($type == 1) {
        // Imaging group
        $warningMessage = False;
        if (count($machinesInProfile) > 0) {
            $warningMessage = True;
            print '<p>';
            print _T('Computers listed below are already part of another imaging group.', 'dyngroup');
            echo '<ul>';
            foreach ($machinesInProfile as $machineUuid => $group) {
                printf(_T('<li>%s is part of <a href="%s">%s</a></li>'), $listOfMembers[$machineUuid]['hostname'], urlStrRedirect('imaging/manage/display', array('gid' => $group['groupid'], 'groupname' => $group['groupname'])), $group['groupname']);
            }
            echo '</ul>';
            print '</p>';
        }
        $standAloneImagingRegistered = array_diff($willBeUnregistered, array_keys($machinesInProfile));
        if (count($standAloneImagingRegistered) > 0) {
            $warningMessage = True;
            print '<p>';
            print _T('Computers listed below are already stand-alone registered in imaging.', 'dyngroup');
            echo '<ul>';
            foreach ($standAloneImagingRegistered as $machineUuid) {
                printf('<li>%s</li>', $listOfMembers[$machineUuid]['hostname']);
            }
            echo '</ul>';
            print '</p>';
        }
        if ($warningMessage) {
            echo _T('<p>These computers will move to this group and their bootmenus <strong>will be rewritten</strong></p>', 'dyngroup');
            echo '<p>' . _T('All related images to these computers will be <strong>DELETED</strong>', 'dyngroup') . '</p>';
        }
    }
    ?>

<input type="hidden" name="type" value="<?php 
    echo $type;
    ?>
" />
<input type="hidden" name="lmachines" value="<?php 
    echo base64_encode(serialize($machines));
    ?>
" />
<input type="hidden" name="lmembers" value="<?php 
    echo base64_encode(serialize($members));
    ?>
" />
<input type="hidden" name="lsmembers" value="<?php 
    echo base64_encode(serialize($listOfMembers));
    ?>
" />
<input type="hidden" name="willBeUnregistered" value="<?php 
    echo base64_encode(serialize($willBeUnregistered));
    ?>
" />
<input type="hidden" name="computersgroupedit" value="<?php 
    echo $computersgroupedit;
    ?>
" />
<input type="hidden" name="id" value="<?php 
    echo $gid;
    ?>
" />
<input type="submit" name="bconfirm" class="btnPrimary" value="<?php 
    echo _("Confirm");
    ?>
" />
<input type="submit" name="breset" class="btnSecondary" value="<?php 
    echo _("Cancel");
    ?>
" />
</form>

<style type="text/css">
<!--
#grouplist
{
        color: #666;
        background-color: #F0F4F7;
        border: solid 1px #CCC;
        padding: 10px 5px 5px 10px;
        margin: 0 5px 20px 0;
        width: 632px;
}

#grouplist div.list
{
        float: left;
}

select.list
{
        width: 250px;
}
-->
</style>

<?php 
}