/** * Constructor * * @param $ID ID of the ocs server ID **/ function __construct($ID) { global $CFG_GLPI; $this->ocsservers_id = $ID; if ($CFG_GLPI["use_ocs_mode"]) { $data = OcsServer::getConfig($ID); $this->dbhost = $data["ocs_db_host"]; $this->dbuser = $data["ocs_db_user"]; $this->dbpassword = rawurldecode($data["ocs_db_passwd"]); $this->dbdefault = $data["ocs_db_name"]; $this->dbenc = $data["ocs_db_utf8"] ? "utf8" : "latin1"; parent::__construct(); } }
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 GLPI; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -------------------------------------------------------------------------- */ // ---------------------------------------------------------------------- // Original Author of file: // Purpose of file: // ---------------------------------------------------------------------- define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; checkRight("ocsng", "w"); $ocs = new OcsServer(); if (!isset($_GET["id"])) { $_GET["id"] = ""; } commonHeader($LANG['ocsng'][0], $_SERVER['PHP_SELF'], "config", "ocsng"); //Delete template or server if (isset($_POST["delete"])) { $ocs->delete($_POST); $ocs->redirectToList(); //Update server } else { if (isset($_POST["update"])) { $ocs->update($_POST); glpi_header($_SERVER["HTTP_REFERER"]); //Update server } else {
if (is_dir(GLPI_SESSION_DIR) && is_writable(GLPI_SESSION_DIR)) { echo "GLPI_SESSION_DIR_OK\n"; } else { echo "GLPI_SESSION_DIR_PROBLEM\n"; $ok = false; } // Reestablished DB connection if (($ok_master || $ok_slave) && DBConnection::establishDBConnection(false, false, false)) { // Check OCS connections $query = "SELECT `id`, `name`\n FROM `glpi_ocsservers`"; if ($result = $DB->query($query)) { if ($DB->numrows($result)) { echo "Check OCS servers:"; while ($data = $DB->fetch_assoc($result)) { echo " " . $data['name']; if (OcsServer::checkOCSconnection($data['id'])) { echo "_OK"; } else { echo "_PROBLEM"; $ok = false; } echo "\n"; } } else { echo "No OCS server\n"; } } // Check Auth connections $auth = new Auth(); $auth->getAuthMethods(); $ldap_methods = $auth->authtypes["ldap"];
/** * Print the computer form * * @param $ID integer ID of the item * @param $options array * - target for the Form * - withtemplate template or basic computer * *@return Nothing (display) * **/ function showForm($ID, $options = array()) { global $LANG, $CFG_GLPI, $DB; if (!haveRight("computer", "r")) { return false; } if ($ID > 0) { $this->check($ID, 'r'); } else { // Create item $this->check(-1, 'w'); } if (isset($options['withtemplate']) && $options['withtemplate'] == 2) { $template = "newcomp"; $datestring = $LANG['computers'][14] . " : "; $date = convDateTime($_SESSION["glpi_currenttime"]); } else { if (isset($options['withtemplate']) && $options['withtemplate'] == 1) { $template = "newtemplate"; $datestring = $LANG['computers'][14] . " : "; $date = convDateTime($_SESSION["glpi_currenttime"]); } else { $datestring = $LANG['common'][26] . ": "; $date = convDateTime($this->fields["date_mod"]); $template = false; } } $this->showTabs($options); $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][16] . ($template ? "*" : "") . " :</td>"; echo "<td>"; $objectName = autoName($this->fields["name"], "name", $template === "newcomp", $this->getType(), $this->fields["entities_id"]); autocompletionTextField($this, 'name', array('value' => $objectName)); echo "</td>"; echo "<td>" . $LANG['state'][0] . " :</td>"; echo "<td>"; Dropdown::show('State', array('value' => $this->fields["states_id"])); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][15] . " : </td>"; echo "<td>"; Dropdown::show('Location', array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"])); echo "</td>"; echo "<td>" . $LANG['common'][17] . " : </td>"; echo "<td>"; Dropdown::show('ComputerType', array('value' => $this->fields["computertypes_id"])); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][10] . " : </td>"; echo "<td>"; User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'interface', 'entity' => $this->fields["entities_id"])); echo "</td>"; echo "<td>" . $LANG['common'][5] . " : </td>"; echo "<td>"; Dropdown::show('Manufacturer', array('value' => $this->fields["manufacturers_id"])); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][21] . " : </td>"; echo "<td >"; autocompletionTextField($this, 'contact_num'); echo "</td>"; echo "<td>" . $LANG['common'][22] . " : </td>"; echo "<td>"; Dropdown::show('ComputerModel', array('value' => $this->fields["computermodels_id"])); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][18] . " :</td>"; echo "<td>"; autocompletionTextField($this, 'contact'); echo "</td>"; echo "<td>" . $LANG['common'][19] . " :</td>"; echo "<td >"; autocompletionTextField($this, 'serial'); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][34] . " : </td>"; echo "<td>"; User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all')); echo "</td>"; echo "<td>" . $LANG['common'][20] . ($template ? "*" : "") . " :</td>"; echo "<td>"; $objectName = autoName($this->fields["otherserial"], "otherserial", $template === "newcomp", $this->getType(), $this->fields["entities_id"]); autocompletionTextField($this, 'otherserial', array('value' => $objectName)); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][35] . " :</td>"; echo "<td>"; Dropdown::show('Group', array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"])); echo "</td>"; echo "<td>" . $LANG['setup'][88] . " :</td>"; echo "<td>"; Dropdown::show('Network', array('value' => $this->fields["networks_id"])); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['setup'][89] . " :</td>"; echo "<td >"; Dropdown::show('Domain', array('value' => $this->fields["domains_id"])); echo "</td>"; echo "<td rowspan='8'>" . $LANG['common'][25] . " :</td>"; echo "<td rowspan='8' class='middle'>"; echo "<textarea cols='45' rows='11' name='comment' >" . $this->fields["comment"] . "</textarea>"; echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['computers'][9] . " :</td>"; echo "<td>"; Dropdown::show('OperatingSystem', array('value' => $this->fields["operatingsystems_id"])); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['computers'][53] . " :</td>"; echo "<td >"; Dropdown::show('OperatingSystemServicePack', array('value' => $this->fields["operatingsystemservicepacks_id"])); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['computers'][52] . " :</td>"; echo "<td >"; Dropdown::show('OperatingSystemVersion', array('value' => $this->fields["operatingsystemversions_id"])); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['computers'][11] . " :</td>"; echo "<td >"; autocompletionTextField($this, 'os_licenseid'); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['computers'][10] . " :</td>"; echo "<td >"; autocompletionTextField($this, 'os_license_number'); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['computers'][58] . " :</td>"; echo "<td >"; autocompletionTextField($this, 'uuid'); echo "</td></tr>\n"; // Get OCS Datas : $dataocs = array(); if (!empty($ID) && $this->fields["is_ocs_import"] && haveRight("view_ocsng", "r")) { $query = "SELECT *\n FROM `glpi_ocslinks`\n WHERE `computers_id` = '{$ID}'"; $result = $DB->query($query); if ($DB->numrows($result) == 1) { $dataocs = $DB->fetch_array($result); } } echo "<tr class='tab_bg_1'>"; echo "<td colspan='2' class='center'>" . $datestring . $date; if (!$template && !empty($this->fields['template_name'])) { echo "<span class='small_space'>(" . $LANG['common'][13] . " : " . $this->fields['template_name'] . ")</span>"; } if (!empty($ID) && $this->fields["is_ocs_import"] && haveRight("view_ocsng", "r") && count($dataocs)) { echo "<br>"; echo $LANG['ocsng'][14] . " : " . convDateTime($dataocs["last_ocs_update"]); echo "<br>"; echo $LANG['ocsng'][13] . " : " . convDateTime($dataocs["last_update"]); echo "<br>"; if (haveRight("ocsng", "r")) { echo $LANG['common'][52] . " <a href='" . $CFG_GLPI["root_doc"] . "/front/ocsserver.form.php?id=" . OcsServer::getByMachineID($ID) . "'>" . OcsServer::getServerNameByID($ID) . "</a>"; $query = "SELECT `ocs_agent_version`, `ocsid`\n FROM `glpi_ocslinks`\n WHERE `computers_id` = '{$ID}'"; $result_agent_version = $DB->query($query); $data_version = $DB->fetch_array($result_agent_version); $ocs_config = OcsServer::getConfig(OcsServer::getByMachineID($ID)); //If have write right on OCS and ocsreports url is not empty in OCS config if (haveRight("ocsng", "w") && $ocs_config["ocs_url"] != '') { echo ", " . OcsServer::getComputerLinkToOcsConsole(OcsServer::getByMachineID($ID), $data_version["ocsid"], $LANG['ocsng'][57]); } if ($data_version["ocs_agent_version"] != NULL) { echo " , " . $LANG['ocsng'][49] . " : " . $data_version["ocs_agent_version"]; } } else { echo $LANG['common'][52] . " " . OcsServer::getServerNameByID($ID); } } echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; if (!empty($ID) && $this->fields["is_ocs_import"] && haveRight("view_ocsng", "r") && haveRight("sync_ocsng", "w") && count($dataocs)) { echo "<td >" . $LANG['ocsng'][6] . " " . $LANG['Menu'][33] . " :</td>"; echo "<td >"; Dropdown::showYesNo("_auto_update_ocs", $dataocs["use_auto_update"]); echo "</td>"; } else { echo "<td colspan=2></td>"; } echo "<td>" . $LANG['computers'][51] . " :</td>"; echo "<td >"; Dropdown::show('AutoUpdateSystem', array('value' => $this->fields["autoupdatesystems_id"])); echo "</td></tr>"; $this->showFormButtons($options); $this->addDivForTabs(); return true; }
function prepareInputDataForProcess($input, $computers_id) { global $DBocs; $tables = $this->getTablesForQuery(); $fields = $this->getFieldsForQuery(); $rule_parameters = array(); $select_sql = ""; //Build the select request foreach ($fields as $field) { switch (utf8_strtoupper($field)) { //OCS server ID is provided by extra_params -> get the configuration associated with the ocs server case "OCS_SERVER": $rule_parameters["OCS_SERVER"] = $this->ocsservers_id; break; //TAG and DOMAIN should come from the OCS DB //TAG and DOMAIN should come from the OCS DB default: $select_sql .= ($select_sql != "" ? " , " : "") . $field; } } //Build the FROM part of the request //Remove all the non duplicated table names $from_sql = "FROM `hardware` "; foreach ($tables as $table => $linkfield) { if ($table != 'hardware' && !empty($linkfield)) { $from_sql .= " LEFT JOIN `{$table}` ON (`{$table}`.`{$linkfield}` = `hardware`.`ID`)"; } } if ($select_sql != "") { //Build the all request $sql = "SELECT {$select_sql}\n {$from_sql}\n WHERE `hardware`.`ID` = '{$computers_id}'"; OcsServer::checkOCSconnection($this->ocsservers_id); $result = $DBocs->query($sql); $ocs_datas = array(); $fields = $this->getFieldsForQuery(1); //May have more than one line : for example in case of multiple network cards if ($DBocs->numrows($result) > 0) { while ($datas = $DBocs->fetch_array($result)) { foreach ($fields as $field) { if ($field != "OCS_SERVER" && isset($datas[$field])) { $ocs_datas[$field][] = $datas[$field]; } } } } //This cas should never happend but... //Sometimes OCS can't find network ports but fill the right ip in hardware table... //So let's use the ip to proceed rules (if IP is a criteria of course) if (in_array("IPADDRESS", $fields) && !isset($ocs_datas['IPADDRESS'])) { $ocs_datas['IPADDRESS'] = OcsServer::getGeneralIpAddress($this->ocsservers_id, $computers_id); } return array_merge($rule_parameters, $ocs_datas); } return $rule_parameters; }
break; case 7: Link::showForItem('Computer', $_POST["id"]); break; case 10: showNotesForm($_POST['target'], 'Computer', $_POST["id"]); break; case 11: Reservation::showForItem('Computer', $_POST["id"]); break; case 12: Log::showForItem($computer); break; case 13: OcsLink::showForItem($computer); OcsServer::editLock($_POST['target'], $_POST["id"]); break; case 14: RegistryKey::showForComputer($_POST["id"]); break; case 20: ComputerDisk::showForComputer($computer); break; case 21: ComputerVirtualMachine::showForVirtualMachine($computer); ComputerVirtualMachine::showForComputer($computer); break; default: if (!Plugin::displayAction($computer, $_REQUEST['glpi_tab'])) { Computer_Device::showForComputer($computer); }
/** * Actions done when item is deleted from the database * Overloaded to manage autoupdate feature * *@return nothing **/ function cleanDBonPurge() { global $CFG_GLPI; if (!isset($this->input['_no_auto_action'])) { //Get the computer name $computer = new Computer(); $computer->getFromDB($this->fields['computers_id']); //Get device fields if (class_exists($this->fields['itemtype'])) { $device = new $this->fields['itemtype'](); if ($device->getFromDB($this->fields['items_id'])) { if (!$device->getField('is_global')) { $updates = array(); if ($CFG_GLPI["is_location_autoclean"] && $device->isField('locations_id')) { $updates['locations_id'] = 0; } if ($CFG_GLPI["is_user_autoclean"] && $device->isField('users_id')) { $updates['users_id'] = 0; } if ($CFG_GLPI["is_group_autoclean"] && $device->isField('groups_id')) { $updates['groups_id'] = 0; } if ($CFG_GLPI["is_contact_autoclean"] && $device->isField('contact')) { $updates['contact'] = ""; } if ($CFG_GLPI["is_contact_autoclean"] && $device->isField('contact_num')) { $updates['contact_num'] = ""; } if ($CFG_GLPI["state_autoclean_mode"] < 0 && $device->isField('states_id')) { $updates['states_id'] = 0; } if ($CFG_GLPI["state_autoclean_mode"] > 0 && $device->isField('states_id') && $device->getField('states_id') != $CFG_GLPI["state_autoclean_mode"]) { $updates['states_id'] = $CFG_GLPI["state_autoclean_mode"]; } if (count($updates)) { $updates['id'] = $this->fields['items_id']; $device->update($updates); } } if (isset($this->input['_ocsservers_id'])) { $ocsservers_id = $this->input['_ocsservers_id']; } else { $ocsservers_id = OcsServer::getByMachineID($this->fields['computers_id']); } if ($ocsservers_id > 0) { //Get OCS configuration $ocs_config = OcsServer::getConfig($ocsservers_id); //Get the management mode for this device $mode = OcsServer::getDevicesManagementMode($ocs_config, $this->fields['itemtype']); $decoConf = $ocs_config["deconnection_behavior"]; //Change status if : // 1 : the management mode IS NOT global // 2 : a deconnection's status have been defined // 3 : unique with serial if ($mode >= 2 && strlen($decoConf) > 0) { //Delete periph from glpi if ($decoConf == "delete") { $tmp["id"] = $this->fields['items_id']; $device->delete($tmp, 1); //Put periph in trash } else { if ($decoConf == "trash") { $tmp["id"] = $this->fields['items_id']; $device->delete($tmp, 0); } } } } // $ocsservers_id>0 } } } }
} else { if (isset($_POST["unlock_field"])) { $computer->check($_POST['id'], 'w'); if (isset($_POST["lockfield"]) && count($_POST["lockfield"])) { foreach ($_POST["lockfield"] as $key => $val) { OcsServer::deleteInOcsArray($_POST["id"], $key, "computer_update"); } } glpi_header($_SERVER['HTTP_REFERER']); } else { if (isset($_POST["force_ocs_resynch"])) { $computer->check($_POST['id'], 'w'); //Get the ocs server id associated with the machine $ocsservers_id = OcsServer::getByMachineID($_POST["id"]); //Update the computer OcsServer::updateComputer($_POST["resynch_id"], $ocsservers_id, 1, 1); glpi_header($_SERVER['HTTP_REFERER']); } else { //print computer informations commonHeader($LANG['Menu'][0], $_SERVER['PHP_SELF'], "inventory", "computer"); //show computer form to add $computer->showForm($_GET["id"], array('withtemplate' => $_GET["withtemplate"])); commonFooter(); } } } } } } } }
} if (isset($_GET["ocsservers_id"]) && $_GET["ocsservers_id"]) { $name = ""; if (isset($_GET["ocsservers_id"])) { $_SESSION["ocsservers_id"] = $_GET["ocsservers_id"]; } $sql = "SELECT `name`\n FROM `glpi_ocsservers`\n WHERE `id` = '" . $_SESSION["ocsservers_id"] . "'"; $result = $DB->query($sql); if ($DB->numrows($result) > 0) { $datas = $DB->fetch_array($result); $name = " : " . $datas["name"]; } echo "<div class='center'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/logoOcs.png' alt='" . $LANG['ocsng'][0] . "' title=\"" . $LANG['ocsng'][0] . "\" ></td>"; echo "</div>"; echo "<div class='center'><table class='tab_cadre'>"; echo "<tr><th>" . $LANG['ocsng'][0] . " " . $name . "</th></tr>"; if (haveRight('ocsng', 'w')) { echo "<tr class='tab_bg_1'><td class='center b'><a href='ocsng.import.php'>" . $LANG['ocsng'][2] . "</a></td></tr>"; echo "<tr class='tab_bg_1'><td class='center b'><a href='ocsng.sync.php'>" . $LANG['ocsng'][1] . "</a></td></tr>"; echo "<tr class='tab_bg_1'><td class='center b'><a href='ocsng.link.php'>" . $LANG['ocsng'][4] . "</a></td></tr>"; } if (haveRight('clean_ocsng', 'r')) { echo "<tr class='tab_bg_1'><td class='center b'><a href='ocsng.clean.php'>" . $LANG['ocsng'][3] . "</a></td> </tr>"; } echo "</table></div>"; OcsServer::manageDeleted($_SESSION["ocsservers_id"]); } else { OcsServer::showFormServerChoice(); } commonFooter();
$display_list = false; } } if (!isset($_POST["import_ok"])) { if (!isset($_GET['check'])) { $_GET['check'] = 'all'; } if (!isset($_GET['start'])) { $_GET['start'] = 0; } if (isset($_SESSION["ocs_import"])) { unset($_SESSION["ocs_import"]); } OcsServer::manageDeleted($_SESSION["ocsservers_id"]); if ($display_list) { OcsServer::showComputersToAdd($_SESSION["ocsservers_id"], $_SESSION["change_import_mode"], $_GET['check'], $_GET['start'], $_SESSION['glpiactiveentities']); } } else { if (count($_POST['toimport']) > 0) { $_SESSION["ocs_import_count"] = 0; foreach ($_POST['toimport'] as $key => $val) { if ($val == "on") { $_SESSION["ocs_import"]["id"][] = $key; if (isset($_POST['toimport_entities'])) { $_SESSION["ocs_import"]["entities_id"][$key] = $_POST['toimport_entities'][$key]; } if (isset($_POST['toimport_locations'])) { $_SESSION["ocs_import"]["locations_id"][$key] = $_POST['toimport_locations'][$key]; } $_SESSION["ocs_import_count"]++; }
along with GLPI; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -------------------------------------------------------------------------- */ // ---------------------------------------------------------------------- // Original Author of file: // Purpose of file: // ---------------------------------------------------------------------- define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; commonHeader($LANG['ocsng'][0], $_SERVER['PHP_SELF'], "utils", "ocsng", "clean"); if (!isset($_POST["clean_ok"])) { checkRight("clean_ocsng", "r"); if (!isset($_GET['check'])) { $_GET['check'] = 'all'; } if (!isset($_GET['start'])) { $_GET['start'] = 0; } OcsServer::manageDeleted($_SESSION["ocsservers_id"]); OcsServer::showComputersToClean($_SESSION["ocsservers_id"], $_GET['check'], $_GET['start']); } else { checkRight("clean_ocsng", "w"); if (count($_POST['toclean']) > 0) { OcsServer::cleanLinksFromList($_SESSION["ocsservers_id"], $_POST['toclean']); echo "<div class='center b'>" . $LANG['ocsng'][3] . " - " . $LANG['log'][45] . "<br>"; displayBackLink(); echo "</div>"; } } commonFooter();
// ---------------------------------------------------------------------- // Original Author of file: // Purpose of file: // ---------------------------------------------------------------------- define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; header("Content-Type: text/html; charset=UTF-8"); header_nocache(); if (!isset($_POST["id"])) { exit; } if (!isset($_REQUEST['glpi_tab'])) { exit; } checkRight("ocsng", "w"); $ocs = new OcsServer(); if ($_POST["id"] > 0 && $ocs->can($_POST["id"], 'r')) { switch ($_REQUEST['glpi_tab']) { case -1: $ocs->showDBConnectionStatus($_POST["id"]); $ocs->ocsFormImportOptions($_POST['target'], $_POST["id"]); $ocs->ocsFormConfig($_POST['target'], $_POST["id"]); Plugin::displayAction($ocs, $_REQUEST['glpi_tab']); break; case 2: $ocs->ocsFormImportOptions($_POST['target'], $_POST["id"]); break; case 3: $ocs->ocsFormConfig($_POST['target'], $_POST["id"]); break; case 12:
function preProcessPreviewResults($output) { return OcsServer::previewRuleImportProcess($output); }
function synchroOCS($p_xml) { global $DB; $ptais = new PluginFusioninventoryAgentsInventoryState(); $this->setXML($p_xml); $query = "SELECT *\n\t\tFROM glpi_ocs_link\n\t\tWHERE ocs_deviceid='" . $this->sxml->DEVICEID . "'"; $result = $DB->query($query); if ($DB->numrows($result) == 1) { $line = $DB->fetch_assoc($result); $ptais->changeStatus($line['glpi_id'], 5); OcsServer::updateComputer($line['ID'], $line['ocs_server_id'], 1); $ptais->changeStatus($line['glpi_id'], 6); } }
case "compute_software_category": case "replay_dictionnary": case "force_ocsng_update": case "force_user_ldap_update": case "delete": case "purge": case "restore": case "add_transfer_list": case "activate_infocoms": case "delete_email": case 'reset': echo "<input type='submit' name='massiveaction' class='submit' value='" . $LANG['buttons'][2] . "'>\n"; break; case "unlock_ocsng_field": $fields['all'] = $LANG['common'][66]; $fields += OcsServer::getLockableFields(); Dropdown::showFromArray("field", $fields); echo " <input type='submit' name='massiveaction' class='submit' value='" . $LANG['buttons'][2] . "'>"; break; case "unlock_ocsng_monitor": case "unlock_ocsng_peripheral": case "unlock_ocsng_software": case "unlock_ocsng_printer": case "unlock_ocsng_disk": case "unlock_ocsng_ip": echo "<input type='submit' name='massiveaction' class='submit' value='" . $LANG['buttons'][2] . "'>"; break; case "install": Software::dropdownSoftwareToInstall("softwareversions_id", $_SESSION["glpiactive_entity"], 1); echo " <input type='submit' name='massiveaction' class='submit' value='" . $LANG['buttons'][4] . "'>"; break;
OcsServer::showStatistics($_SESSION["ocs_update"]['statistics'], true); unset($_SESSION["ocs_update"]); $display_list = false; echo "<div class='center b'><br>"; echo "<a href='" . $_SERVER['PHP_SELF'] . "'>" . $LANG['buttons'][13] . "</a></div>"; } } if (!isset($_POST["update_ok"])) { if (!isset($_GET['check'])) { $_GET['check'] = 'all'; } if (!isset($_GET['start'])) { $_GET['start'] = 0; } OcsServer::manageDeleted($_SESSION["ocsservers_id"]); if ($display_list) { OcsServer::showComputersToUpdate($_SESSION["ocsservers_id"], $_GET['check'], $_GET['start']); } } else { if (count($_POST['toupdate']) > 0) { $_SESSION["ocs_update_count"] = 0; foreach ($_POST['toupdate'] as $key => $val) { if ($val == "on") { $_SESSION["ocs_update"]['computers'][] = $key; $_SESSION["ocs_update_count"]++; } } } glpi_header($_SERVER['PHP_SELF']); } commonFooter();
$_SESSION['glpi_massiveaction']['items'][$key] = $key; } } $_SESSION['glpi_massiveaction']['item_count'] = count($_SESSION['glpi_massiveaction']['items']); glpi_header($_SERVER['PHP_SELF'] . '?multiple_actions=1'); } else { if (count($_SESSION['glpi_massiveaction']['items']) > 0) { $key = array_pop($_SESSION['glpi_massiveaction']['items']); //Try to get the OCS server whose machine belongs $query = "SELECT `ocsservers_id`, `id`\n FROM `glpi_ocslinks`\n WHERE `computers_id` = '{$key}'"; $result = $DB->query($query); if ($DB->numrows($result) == 1) { $data = $DB->fetch_assoc($result); if ($data['ocsservers_id'] != -1) { //Force update of the machine OcsServer::updateComputer($data['id'], $data['ocsservers_id'], 1, 1); } } glpi_header($_SERVER['PHP_SELF'] . '?multiple_actions=1'); } else { $REDIRECT = $_SESSION['glpi_massiveaction']['REDIRECT']; unset($_SESSION['glpi_massiveaction']); glpi_header($REDIRECT); } } break; case "compute_software_category": $softcatrule = new RuleSoftwareCategoryCollection(); $soft = new Software(); foreach ($_POST["item"] as $key => $val) { if ($val == 1) {
static function checkConfig($what = 1) { global $DBocs; # Check OCS version if ($what & 1) { $result = $DBocs->query("SELECT `TVALUE`\n FROM `config`\n WHERE `NAME` = 'GUI_VERSION'"); // Update OCS version on ocsservers if ($DBocs->numrows($result)) { $server = new OcsServer(); $server->update(array('id' => $DBocs->ocsservers_id, 'ocs_version' => $DBocs->result($result, 0, 0))); } if ($DBocs->numrows($result) != 1 || $DBocs->result($result, 0, 0) < self::OCS_VERSION_LIMIT && strpos($DBocs->result($result, 0, 0), '2.0') !== 0) { // hack for 2.0 RC return false; } } // Check TRACE_DELETED in CONFIG if ($what & 2) { $result = $DBocs->query("SELECT `IVALUE`\n FROM `config`\n WHERE `NAME` = 'TRACE_DELETED'"); if ($DBocs->numrows($result) != 1 || $DBocs->result($result, 0, 0) != 1) { $query = "UPDATE `config`\n SET `IVALUE` = '1'\n WHERE `NAME` = 'TRACE_DELETED'"; if (!$DBocs->query($query)) { return false; } } } // Check write access on hardware.CHECKSUM if ($what & 4) { if (!$DBocs->query("UPDATE `hardware`\n SET `CHECKSUM` = CHECKSUM\n LIMIT 1")) { return false; } } // Check delete access on deleted_equiv if ($what & 8) { if (!$DBocs->query("DELETE\n FROM `deleted_equiv`\n LIMIT 0")) { return false; } } return true; }