Ejemplo n.º 1
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 
}
Ejemplo n.º 2
0
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MMC.  If not, see <http://www.gnu.org/licenses/>.
 */
require_once "modules/pulse2/includes/utilities.php";
# for quickGet method
require "modules/dyngroup/includes/groups.inc.php";
$name = quickGet('name', $p_first = True, $urldecode = False);
$id = quickGet('id');
$visibility = quickGet('visible');
$already_exists = false;
$type = $_GET['type'];
$imaging_server = quickGet('imaging_server');
if ($id) {
    $group = getPGobject($id, true);
    $type = $group->type;
    if (!$name) {
        $name = $group->getName();
    }
    if (!$visibility) {
        $visibility = $group->canShow();
    }
    if ($type == 1) {
        $imaging_server = $group->getImagingServer();
    }
    $already_exists = true;
} else {
    if ($type == 0) {
        $group = new Group();
    } else {
Ejemplo n.º 3
0
 * 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, see <http://www.gnu.org/licenses/>.
 */
require "modules/base/computers/localSidebar.php";
require "graph/navbar.inc.php";
require_once "modules/dyngroup/includes/includes.php";
require_once "modules/pulse2/includes/utilities.php";
/*
 * Display right top shortcuts menu
 */
right_top_shortcuts_display();
$gid = idGet();
$group = getPGobject($gid, True);
$edition = True;
if ($group->isDyn()) {
    if ($group->type == 0) {
        $title = _T("Edit a dynamic group", 'dyngroup');
    } else {
        /* shouldn't happen */
        $title = _T("Edit a profile", 'dyngroup');
    }
    $p = new PageGenerator($title);
    $p->setSideMenu($sidemenu);
    $p->display();
    require "creator.php";
} else {
    if ($group->type == 0) {
        $title = _T("Edit a static group", 'dyngroup');