$level = 0; if ($mode == "creation") { $level = 1; } foreach (array('id', 'label', 'version', 'description', 'mode', 'Qvendor', 'Qsoftware', 'Qversion', 'boolcnd', 'licenses') as $post) { $package[$post] = $_POST[$post]; } foreach (array('reboot', 'associateinventory') as $post) { $package[$post] = $_POST[$post] == 'on' ? 1 : 0; } // Package command $package['command'] = array('name' => $_POST['commandname'], 'command' => $_POST['commandcmd']); // Simple package: not a bundle $package['sub_packages'] = array(); // Send Package Infos via XMLRPC $ret = putPackageDetail($p_api_id, $package, $need_assign); $pid = $ret[3]['id']; $plabel = $ret[3]['label']; $pversion = $ret[3]['version']; if (!isXMLRPCError() and $ret and $ret != -1) { if ($_POST['package-method'] == "upload") { $cbx = array($random_dir); } else { if ($_POST['package-method'] == "package") { $cbx = array(); foreach ($_POST as $post => $v) { if (preg_match("/cbx_/", $post) > 0) { $cbx[] = preg_replace("/cbx_/", "", $post); } } if (isset($_POST['rdo_files'])) {
$package = array('label' => $_POST['label'], 'description' => $_POST['description'], 'version' => $_POST['version'], 'sub_packages' => array(), 'boolcnd' => '', 'Qsoftware' => '', 'Qversion' => '', 'Qvendor' => '', 'command' => array('command' => '', 'name' => ''), 'licenses' => '', 'id' => ''); // Edition mode if (isset($_POST['pid'])) { $package['id'] = $_POST['pid']; } else { // Creation mode $package['mode'] = 'creation'; } $package['reboot'] = empty($_POST['do_reboot']) ? '0' : 1; $package['associateinventory'] = empty($_POST['do_associateinventory']) ? '0' : 1; for ($i = 0; $i < count($_POST['sub_packages']['pids']); $i++) { $pid = $_POST['sub_packages']['pids'][$i]; $condition = $_POST['sub_packages']['conditions'][$i]; $package['sub_packages'][] = array('pid' => $pid, 'condition' => $condition); } putPackageDetail($_POST['p_api'], $package, True); if (!isXMLRPCError()) { new NotifyWidgetSuccess(_T("Bundle successfully edited", "pkgs")); } } // ================================================================================== // Add or Edit if (!empty($_GET['p_api'])) { $p = new PageGenerator(_T("Edit bundle", "pkgs")); } else { $p = new PageGenerator(_T("Add bundle", "pkgs")); } $p->setSideMenu($sidemenu); $p->display(); // display an edit config form $f = new ValidatingForm();