if (!$bool && $group) { if (isset($_POST['checkBool']) || isset($_POST['btnPrimary'])) { $bool = ''; } else { $bool = $group->getBool(); } } $r = new Request(); $r->parse($request); $check = checkBoolEquation($bool, $r, isset($_POST['checkBool'])); if ($check && isset($_POST['displayTmp'])) { $_SESSION['request'] = $r->toS(); header("Location: " . urlStrRedirect("base/computers/tmpdisplay", array('id' => $id, 'request' => 'stored_in_session', 'is_group' => $is_group, 'equ_bool' => $bool, 'name' => urlencode($name), 'save_type' => $save_type, 'visible' => $visible, 'imaging_server' => $imaging_server))); exit; } $name_exists = xmlrpc_group_name_exists($name, $group->id); if (!isset($_POST['btnPrimary']) || $name_exists || !$check || isset($_POST['checkBool']) || isset($_POST['displayTmp']) || $name == '') { if ($id) { $name = $group->getName(); $visible = $group->canShow(); } $r->displayReqListInfos(false, array('gid' => $id)); // TODO : put in class print "<hr/><table><tr>"; if (hasCorrectAcl("base", "computers", "save")) { $_SESSION['request'] = $request; print "<form method='POST' action='" . urlStr("base/computers/save", array('request' => 'stored_in_session', 'id' => $id, 'is_group' => $is_group, 'imaging_server' => $imaging_server)) . "' >" . "<td>" . _T('Name :', 'dyngroup') . " <input name='name' type='text' value=\"" . htmlspecialchars($name) . "\" /></td>"; if ($is_group) { print "<td>" . _T('save as', 'dyngroup') . " <select name='save_type'><option value='1' " . ($save_type == 1 ? 'selected' : '') . ">" . _T("query", "dyngroup") . "</option><option value='2' " . ($save_type == 2 ? 'selected' : '') . ">" . _T('result', 'dyngroup') . "</option></select></td>"; } else { print "<td><input name='save_type' type='hidden' value='2'/></td>";
new NotifyWidgetFailure(_T("Group failed to modify", "dyngroup")); } else { if (count($names) > 0) { new NotifyWidgetFailure(sprintf(_T("Profile failed to modify.<br/>Can't add %s", "dyngroup"), implode(', ', $names))); } else { new NotifyWidgetFailure(_T("Profile failed to modify", "dyngroup")); } } } } elseif (isset($_POST["bconfirm"]) and $name == '') { if ($type == 0) { new NotifyWidgetFailure(_T("You must specify a group name", "dyngroup")); } else { new NotifyWidgetFailure(_T("You must specify a profile name", "dyngroup")); } } elseif (isset($_POST["bconfirm"]) and $type == 0 and xmlrpc_group_name_exists($name, $id)) { new NotifyWidgetFailure(sprintf(_T("A group already exists with name '%s'", "dyngroup"), $name)); } elseif (isset($_POST["bconfirm"]) and $type != 0 and xmlrpc_profile_name_exists($name, $id)) { new NotifyWidgetFailure(sprintf(_T("A profile already exists with name '%s'", "dyngroup"), $name)); } else { $list = $group->members(); $members = array(); foreach ($list as $member) { $members[$member['hostname'] . "##" . $member['uuid']] = $member['hostname']; $listOfMembers[$member['uuid']] = $member; } if (!$members) { $members = array(); } if (!$listOfMembers) { $listOfMembers = array();
$visibility = quickGet('visible'); if (!isset($visibility) || $visibility == '') { $visibility = 'hidden'; } $elementare = quickGet('elementare'); # check group name if (isset($groupname) && $groupname != '' && !xmlrpc_group_name_exists($groupname)) { $group = new Group(); $group->create($groupname, $visibility == 'visible'); $content = file($_FILES['importfile']['tmp_name']); $content = array_map('chop', $content); $group->importMembers($elementare, $content); new NotifyWidgetSuccess(_T("Group successfully created", "dyngroup")); header("Location: " . urlStrRedirect("base/computers/display", array('gid' => $group->id))); exit; } elseif (xmlrpc_group_name_exists($groupname)) { new NotifyWidgetFailure(sprintf(_T("A group already exists with name '%s'", "dyngroup"), $groupname)); } $f = new ValidatingForm(array('enctype' => "multipart/form-data")); $f->push(new Table()); $f->add(new TrFormElement(_T("Group name", "dyngroup"), new InputTpl("groupname")), array("required" => True, "value" => $groupname)); $r = new RadioTpl('visible'); $r->setChoices(array(_T('Yes', 'dyngroup'), _T('No', 'dyngroup'))); $r->setValues(array('visible', 'hidden')); $r->setSelected($visibility); $f->add(new TrFormElement(_T("Add shortcut", "dyngroup"), $r), array("required" => True)); $f->add(new TrFormElement(_T("Select the file you want to import", "dyngroup"), new FileTpl('importfile')), array("required" => True)); $a = getPossiblesCriterionsInMainModule(); $r = new RadioTpl('elementare'); $r->setChoices($a); $r->setValues($a);