/** * Handled Multi add item * * @since version 0.83 (before addMulti) * * @param $input array of values **/ function executeAddMulti(array $input) { $this->check(-1, CREATE, $input); for ($i = $input["_from"]; $i <= $input["_to"]; $i++) { $input["name"] = $input["_before"] . $i . $input["_after"]; $this->add($input); } Event::log(0, "dropdown", 5, "setup", sprintf(__('%1$s adds several netpoints'), $_SESSION["glpiname"])); }
function post_addItem() { global $LANG, $CFG_GLPI; // Add document if needed $this->addFiles($this->fields['id']); if (isset($this->input["_followup"]) && is_array($this->input["_followup"]) && strlen($this->input["_followup"]['content']) > 0) { $fup = new TicketFollowup(); $type = "new"; if (isset($this->fields["status"]) && $this->fields["status"] == "solved") { $type = "solved"; } $toadd = array("type" => $type, "tickets_id" => $this->fields['id']); if (isset($this->input["_followup"]['content']) && strlen($this->input["_followup"]['content']) > 0) { $toadd["content"] = $this->input["_followup"]['content']; } if (isset($this->input["_followup"]['is_private'])) { $toadd["is_private"] = $this->input["_followup"]['is_private']; } $toadd['_no_notif'] = true; $fup->add($toadd); } if (isset($this->input["plan"]) || isset($this->input["_hour"]) && isset($this->input["_minute"]) && isset($this->input["realtime"]) && $this->input["realtime"] > 0) { $task = new TicketTask(); $type = "new"; if (isset($this->fields["status"]) && $this->fields["status"] == "solved") { $type = "solved"; } $toadd = array("type" => $type, "tickets_id" => $this->fields['id']); if (isset($this->input["_hour"])) { $toadd["hour"] = $this->input["_hour"]; } if (isset($this->input["_minute"])) { $toadd["minute"] = $this->input["_minute"]; } if (isset($this->input["plan"])) { $toadd["plan"] = $this->input["plan"]; } $toadd['_no_notif'] = true; $task->add($toadd); } $ticket_ticket = new Ticket_Ticket(); // From interface if (isset($this->input['_link'])) { $this->input['_link']['tickets_id_1'] = $this->fields['id']; if ($ticket_ticket->can(-1, 'w', $this->input['_link'])) { $ticket_ticket->add($this->input['_link']); } } // From mailcollector : do not check rights if (isset($this->input["_linkedto"])) { $input2['tickets_id_1'] = $this->fields['id']; $input2['tickets_id_2'] = $this->input["_linkedto"]; $input2['link'] = Ticket_Ticket::LINK_TO; $ticket_ticket->add($input2); } // Manage SLA Level : add actions if (isset($this->input["slas_id"]) && $this->input["slas_id"] > 0 && isset($this->input["slalevels_id"]) && $this->input["slalevels_id"] > 0) { $sla = new SLA(); if ($sla->getFromDB($this->input["slas_id"])) { // Add first level in working table if ($this->input["slalevels_id"] > 0) { $sla->addLevelToDo($this); } } } // Add user groups linked to tickets $ticket_user = new Ticket_User(); $group_ticket = new Group_Ticket(); if (isset($this->input["_users_id_requester"]) && ($this->input["_users_id_requester"] > 0 || isset($this->input["_users_id_requester_notif"]['alternative_email']) && !empty($this->input["_users_id_requester_notif"]['alternative_email']))) { $input2 = array('tickets_id' => $this->fields['id'], 'users_id' => $this->input["_users_id_requester"], 'type' => self::REQUESTER); if (isset($this->input["_users_id_requester_notif"])) { foreach ($this->input["_users_id_requester_notif"] as $key => $val) { $input2[$key] = $val; } } $ticket_user->add($input2); } if (isset($this->input["_users_id_observer"]) && ($this->input["_users_id_observer"] > 0 || isset($this->input["_users_id_observer_notif"]['alternative_email']) && !empty($this->input["_users_id_observer_notif"]['alternative_email']))) { $input2 = array('tickets_id' => $this->fields['id'], 'users_id' => $this->input["_users_id_observer"], 'type' => self::OBSERVER); if (isset($this->input["_users_id_observer_notif"])) { foreach ($this->input["_users_id_observer_notif"] as $key => $val) { $input2[$key] = $val; } } $ticket_user->add($input2); } if (isset($this->input["_users_id_assign"]) && $this->input["_users_id_assign"] > 0) { $input2 = array('tickets_id' => $this->fields['id'], 'users_id' => $this->input["_users_id_assign"], 'type' => self::ASSIGN); if (isset($this->input["_users_id_assign_notif"])) { foreach ($this->input["_users_id_assign_notif"] as $key => $val) { $input2[$key] = $val; } } $ticket_user->add($input2); } if (isset($this->input["_groups_id_requester"]) && $this->input["_groups_id_requester"] > 0) { $group_ticket->add(array('tickets_id' => $this->fields['id'], 'groups_id' => $this->input["_groups_id_requester"], 'type' => self::REQUESTER)); } if (isset($this->input["_groups_id_assign"]) && $this->input["_groups_id_assign"] > 0) { $group_ticket->add(array('tickets_id' => $this->fields['id'], 'groups_id' => $this->input["_groups_id_assign"], 'type' => self::ASSIGN)); } if (isset($this->input["_groups_id_observer"]) && $this->input["_groups_id_observer"] > 0) { $group_ticket->add(array('tickets_id' => $this->fields['id'], 'groups_id' => $this->input["_groups_id_observer"], 'type' => self::OBSERVER)); } // Additional actors : using default notification parameters // Observers : for mailcollector if (isset($this->input["_additional_observers"]) && is_array($this->input["_additional_observers"]) && count($this->input["_additional_observers"])) { $input2 = array('tickets_id' => $this->fields['id'], 'type' => self::OBSERVER); foreach ($this->input["_additional_observers"] as $tmp) { if (isset($tmp['users_id'])) { foreach ($tmp as $key => $val) { $input2[$key] = $val; } $ticket_user->add($input2); } } } if (isset($this->input["_additional_assigns"]) && is_array($this->input["_additional_assigns"]) && count($this->input["_additional_assigns"])) { $input2 = array('tickets_id' => $this->fields['id'], 'type' => self::ASSIGN); foreach ($this->input["_additional_assigns"] as $tmp) { if (isset($tmp['users_id'])) { foreach ($tmp as $key => $val) { $input2[$key] = $val; } $ticket_user->add($input2); } } } if (isset($this->input["_additional_requesters"]) && is_array($this->input["_additional_requesters"]) && count($this->input["_additional_requesters"])) { $input2 = array('tickets_id' => $this->fields['id'], 'type' => self::REQUESTER); foreach ($this->input["_additional_requesters"] as $tmp) { if (isset($tmp['users_id'])) { foreach ($tmp as $key => $val) { $input2[$key] = $val; } $ticket_user->add($input2); } } } //Action for send_validation rule if (isset($this->input["_add_validation"]) && $this->input["_add_validation"] > 0) { $validation = new Ticketvalidation(); $values['tickets_id'] = $this->fields['id']; $values['users_id_validate'] = $this->input["_add_validation"]; if ($validation->can(-1, 'w', $values)) { $validation->add($values); Event::log($this->fields['id'], "ticket", 4, "tracking", $_SESSION["glpiname"] . " " . $LANG['log'][21]); } } // Processing Email if ($CFG_GLPI["use_mailing"]) { // Clean reload of the ticket $this->getFromDB($this->fields['id']); $type = "new"; if (isset($this->fields["status"]) && $this->fields["status"] == "solved") { $type = "solved"; } NotificationEvent::raiseEvent($type, $this); } if (isset($_SESSION['glpiis_ids_visible']) && !$_SESSION['glpiis_ids_visible']) { addMessageAfterRedirect($LANG['help'][18] . " (" . $LANG['job'][38] . " " . "<a href='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $this->fields['id'] . "'>" . $this->fields['id'] . "</a>)"); } }
$problem_user = new Problem_User(); $problem_user->check($_POST['id'], 'd'); $problem_user->delete($_POST); Event::log($_POST['problems_id'], "problem", 4, "maintain", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"])); Html::redirect($CFG_GLPI["root_doc"] . "/front/problem.form.php?id=" . $_POST['problems_id']); } else { if (isset($_POST['delete_group'])) { $group_problem = new Group_Problem(); $group_problem->check($_POST['id'], 'd'); $group_problem->delete($_POST); Event::log($_POST['problems_id'], "problem", 4, "maintain", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"])); Html::redirect($CFG_GLPI["root_doc"] . "/front/problem.form.php?id=" . $_POST['problems_id']); } else { if (isset($_POST['delete_supplier'])) { $problem_supplier = new Problem_Supplier(); $problem_supplier->check($_POST['id'], 'd'); $problem_supplier->delete($_POST); Event::log($_POST['problems_id'], "problem", 4, "maintain", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"])); Html::redirect($CFG_GLPI["root_doc"] . "/front/problem.form.php?id=" . $_POST['problems_id']); } else { Html::header(Problem::getTypeName(2), $_SERVER['PHP_SELF'], "maintain", "problem"); $problem->showForm($_GET["id"], $_GET); Html::footer(); } } } } } } } }
/** @file * @brief * @since version 0.85 */ if (!defined('GLPI_ROOT')) { include '../inc/includes.php'; } $link = new Supplier_Ticket(); Session::checkLoginUser(); Html::popHeader(__('Email followup'), $_SERVER['PHP_SELF']); if (isset($_POST["update"])) { $link->check($_POST["id"], UPDATE); $link->update($_POST); echo "<script type='text/javascript' >\n"; echo "window.parent.location.reload();"; echo "</script>"; } else { if (isset($_POST['delete'])) { $link->check($_POST['id'], DELETE); $link->delete($_POST); Event::log($link->fields['tickets_id'], "ticket", 4, "tracking", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"])); Html::redirect($CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $link->fields['tickets_id']); } else { if (isset($_GET["id"])) { $link->showSupplierNotificationForm($_GET["id"]); } else { Html::displayErrorAndDie('Lost'); } } } Html::popFooter();
$ruleaction = new RuleAction(get_class($rule)); if (isset($_POST["add_action"])) { $rulecollection->checkGlobal(CREATE); $ruleaction->add($_POST); Html::back(); } else { if (isset($_POST["update"])) { $rulecollection->checkGlobal(UPDATE); $rule->update($_POST); Event::log($_POST['id'], "rules", 4, "setup", sprintf(__('%s updates an item'), $_SESSION["glpiname"])); Html::back(); } else { if (isset($_POST["add"])) { $rulecollection->checkGlobal(CREATE); $newID = $rule->add($_POST); Event::log($newID, "rules", 4, "setup", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $newID)); Html::redirect($_SERVER['HTTP_REFERER'] . "?id={$newID}"); } else { if (isset($_POST["purge"])) { $rulecollection->checkGlobal(PURGE); $rulecollection->deleteRuleOrder($_POST["ranking"]); $rule->delete($_POST, 1); Event::log($_POST["id"], "rules", 4, "setup", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); $rule->redirectToList(); } } } } Html::header(Rule::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], 'admin', $rulecollection->menu_type, $rulecollection->menu_option); $rule->display(array('id' => $_GET["id"])); Html::footer();
$fup = new TicketFollowup(); if (isset($_POST["add"])) { $fup->check(-1, CREATE, $_POST); $fup->add($_POST); Event::log($fup->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s adds a followup'), $_SESSION["glpiname"])); Html::back(); } else { if (isset($_POST['add_close']) || isset($_POST['add_reopen'])) { $ticket = new Ticket(); if ($ticket->getFromDB($_POST["tickets_id"]) && $ticket->canApprove()) { $fup->add($_POST); Event::log($fup->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s approves or refuses a solution'), $_SESSION["glpiname"])); Html::back(); } } else { if (isset($_POST["update"])) { $fup->check($_POST['id'], UPDATE); $fup->update($_POST); Event::log($fup->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s updates a followup'), $_SESSION["glpiname"])); Html::redirect(Toolbox::getItemTypeFormURL('Ticket') . "?id=" . $fup->getField('tickets_id')); } else { if (isset($_POST["purge"])) { $fup->check($_POST['id'], PURGE); $fup->delete($_POST, 1); Event::log($fup->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s purges a followup'), $_SESSION["glpiname"])); Html::redirect(Toolbox::getItemTypeFormURL('Ticket') . "?id=" . $fup->getField('tickets_id')); } } } } Html::displayErrorAndDie('Lost');
/* ---------------------------------------------------------------------- Purpose of file: Send image generated by a plugin to browser Argument : - plugin : name of the plugin, also the subdir in files/_plugins - name : of the image in the files/_plugins/xxxx dir - clean : delete the image after send it ---------------------------------------------------------------------- */ define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; if (!isset($_GET["name"]) || !isset($_GET["plugin"])) { Event::log("-1", "system", 2, "security", $_SESSION["glpiname"] . " bad usage."); die("security"); } if (basename($_GET["name"]) != $_GET["name"] || basename($_GET["plugin"]) != $_GET["plugin"]) { Event::log("-1", "system", 1, "security", $_SESSION["glpiname"] . " try to use a non standard path."); die("security"); } $Path = GLPI_PLUGIN_DOC_DIR . "/" . $_GET["plugin"] . "/"; // Now send the file with header() magic header("Expires: Sun, 30 Jan 1966 06:30:00 GMT"); header('Pragma: private'); /// IE BUG + SSL header('Cache-control: private, must-revalidate'); /// IE BUG + SSL header('Content-disposition: filename="' . $_GET["name"] . '"'); header("Content-type: image/png"); if (file_exists($Path . $_GET["name"])) { readfile($Path . $_GET["name"]); if (isset($_GET["clean"])) { unlink($Path . $_GET["name"]);
Html::footer(); } else { if (isset($_POST['add_ext_auth_ldap'])) { Session::checkRight("user", User::IMPORTEXTAUTHUSERS); if (isset($_POST['login']) && !empty($_POST['login'])) { AuthLdap::importUserFromServers(array('name' => $_POST['login'])); } Html::back(); } else { if (isset($_POST['add_ext_auth_simple'])) { if (isset($_POST['login']) && !empty($_POST['login'])) { Session::checkRight("user", User::IMPORTEXTAUTHUSERS); $input = array('name' => $_POST['login'], '_extauth' => 1, 'add' => 1); $user->check(-1, CREATE, $input); $newID = $user->add($input); Event::log($newID, "users", 4, "setup", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["login"])); } Html::back(); } else { Session::checkRight("user", READ); Html::header(User::getTypeName(Session::getPluralNumber()), '', "admin", "user"); $user->display(array('id' => $_GET["id"])); Html::footer(); } } } } } } } }
Html::displayRightError(); } if (isset($_POST["id"])) { $_GET["id"] = $_POST["id"]; } else { if (!isset($_GET["id"])) { $_GET["id"] = -1; } } if (isset($_POST["purge"])) { $item_device->check($_POST["id"], PURGE); $item_device->delete($_POST, 1); Event::log($_POST["id"], get_class($item_device), 4, "setup", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); $device = $item_device->getOnePeer(1); Html::redirect($device->getLinkURL()); } else { if (isset($_POST["update"])) { $item_device->check($_POST["id"], UPDATE); $item_device->update($_POST); Event::log($_POST["id"], get_class($item_device), 4, "setup", sprintf(__('%s updates an item'), $_SESSION["glpiname"])); Html::back(); } else { Html::header($item_device->getTypeName(Session::getPluralNumber()), '', "config", "commondevice", get_class($item_device)); if (!isset($options)) { $options = array(); } $options['id'] = $_GET["id"]; $item_device->display($options); Html::footer(); } }
/** * Manage use authentication and initialize the session * * @param $login_name string * @param $login_password string * @param $noauto boolean (false by default) * * @return boolean (success) */ function Login($login_name, $login_password, $noauto = false) { global $DB, $CFG_GLPI; $this->getAuthMethods(); $this->user_present = 1; $this->auth_succeded = false; //In case the user was deleted in the LDAP directory $user_deleted_ldap = false; // Trim login_name : avoid LDAP search errors $login_name = trim($login_name); if (!$noauto && ($authtype = self::checkAlternateAuthSystems())) { if ($this->getAlternateAuthSystemsUserLogin($authtype) && !empty($this->user->fields['name'])) { // Used for log when login process failed $login_name = $this->user->fields['name']; $this->auth_succeded = true; $this->extauth = 1; $this->user_present = $this->user->getFromDBbyName(addslashes($login_name)); $this->user->fields['authtype'] = $authtype; $user_dn = false; $ldapservers = ''; //if LDAP enabled too, get user's infos from LDAP if (Toolbox::canUseLdap()) { $ldapservers = array(); //User has already authenticate, at least once : it's ldap server if filled if (isset($this->user->fields["auths_id"]) && $this->user->fields["auths_id"] > 0) { $authldap = new AuthLdap(); //If ldap server is enabled if ($authldap->getFromDB($this->user->fields["auths_id"]) && $authldap->fields['is_active']) { $ldapservers[] = $authldap->fields; } //User has never beeen authenticated : try all active ldap server to find the right one } else { foreach (getAllDatasFromTable('glpi_authldaps', "`is_active`='1'") as $ldap_config) { $ldapservers[] = $ldap_config; } } foreach ($ldapservers as $ldap_method) { $ds = AuthLdap::connectToServer($ldap_method["host"], $ldap_method["port"], $ldap_method["rootdn"], Toolbox::decrypt($ldap_method["rootdn_passwd"], GLPIKEY), $ldap_method["use_tls"], $ldap_method["deref_option"]); if ($ds) { $params['method'] = AuthLdap::IDENTIFIER_LOGIN; $params['fields'][AuthLdap::IDENTIFIER_LOGIN] = $ldap_method["login_field"]; $user_dn = AuthLdap::searchUserDn($ds, array('basedn' => $ldap_method["basedn"], 'login_field' => $ldap_method['login_field'], 'search_parameters' => $params, 'user_params' => array('method' => AuthLDAP::IDENTIFIER_LOGIN, 'value' => $login_name), 'condition' => $ldap_method["condition"])); if ($user_dn) { $this->user->fields['auths_id'] = $ldap_method['id']; $this->user->getFromLDAP($ds, $ldap_method, $user_dn['dn'], $login_name, !$this->user_present); break; } } } } if (count($ldapservers) == 0 && $authtype == self::EXTERNAL) { // Case of using external auth and no LDAP servers, so get data from external auth $this->user->getFromSSO(); } else { //If user is set as present in GLPI but no LDAP DN found : it means that the user //is not present in an ldap directory anymore if (!$user_dn && $this->user_present) { $user_deleted_ldap = true; $this->user_deleted_ldap = true; } } // Reset to secure it $this->user->fields['name'] = $login_name; $this->user->fields["last_login"] = $_SESSION["glpi_currenttime"]; } else { $this->addToError(__('Empty login or password')); } } // If not already auth if (!$this->auth_succeded) { if (empty($login_name) || strstr($login_name, "") || empty($login_password) || strstr($login_password, "")) { $this->addToError(__('Empty login or password')); } else { // exists=0 -> user doesn't yet exist // exists=1 -> user is present in DB with password // exists=2 -> user is present in DB but without password $exists = $this->userExists(array('name' => addslashes($login_name))); // Pas en premier car sinon on ne fait pas le blankpassword // First try to connect via le DATABASE if ($exists == 1) { // Without UTF8 decoding if (!$this->auth_succeded) { $this->auth_succeded = $this->connection_db(addslashes($login_name), $login_password); if ($this->auth_succeded) { $this->extauth = 0; $this->user_present = $this->user->getFromDBbyName(addslashes($login_name)); $this->user->fields["authtype"] = self::DB_GLPI; $this->user->fields["password"] = $login_password; } } } else { if ($exists == 2) { //The user is not authenticated on the GLPI DB, but we need to get information about him //to find out his authentication method $this->user->getFromDBbyName(addslashes($login_name)); //If the user has already been logged, the method_auth and auths_id are already set //so we test this connection first switch ($this->user->fields["authtype"]) { case self::CAS: case self::EXTERNAL: case self::LDAP: if (Toolbox::canUseLdap()) { AuthLdap::tryLdapAuth($this, $login_name, $login_password, $this->user->fields["auths_id"], $this->user->fields["user_dn"]); if (!$this->auth_succeded && $this->user_deleted_ldap) { $user_deleted_ldap = true; } } break; case self::MAIL: if (Toolbox::canUseImapPop()) { AuthMail::tryMailAuth($this, $login_name, $login_password, $this->user->fields["auths_id"]); } break; case self::NOT_YET_AUTHENTIFIED: break; } } else { if (!$exists) { //test all ldap servers only is user is not present in glpi's DB if (!$this->auth_succeded && Toolbox::canUseLdap()) { AuthLdap::tryLdapAuth($this, $login_name, $login_password, 0, false, false); } //test all imap/pop servers if (!$this->auth_succeded && Toolbox::canUseImapPop()) { AuthMail::tryMailAuth($this, $login_name, $login_password, 0, false); } } } } // Fin des tests de connexion } } if ($user_deleted_ldap) { User::manageDeletedUserInLdap($this->user->fields["id"]); } // Ok, we have gathered sufficient data, if the first return false the user // is not present on the DB, so we add him. // if not, we update him. if ($this->auth_succeded) { //Set user an not deleted from LDAP $this->user->fields['is_deleted_ldap'] = 0; // Prepare data $this->user->fields["last_login"] = $_SESSION["glpi_currenttime"]; if ($this->extauth) { $this->user->fields["_extauth"] = 1; } if ($DB->isSlave()) { if (!$this->user_present) { // Can't add in slave mode $this->addToError(__('User not authorized to connect in GLPI')); $this->auth_succeded = false; } } else { if ($this->user_present) { // First stripslashes to avoid double slashes $input = Toolbox::stripslashes_deep($this->user->fields); // Then ensure addslashes $input = Toolbox::addslashes_deep($input); // update user and Blank PWD to clean old database for the external auth $this->user->update($input); if ($this->extauth) { $this->user->blankPassword(); } } else { if ($CFG_GLPI["is_users_auto_add"]) { // Auto add user // First stripslashes to avoid double slashes $input = Toolbox::stripslashes_deep($this->user->fields); // Then ensure addslashes $input = Toolbox::addslashes_deep($input); unset($this->user->fields); $this->user->add($input); } else { // Auto add not enable so auth failed $this->addToError(__('User not authorized to connect in GLPI')); $this->auth_succeded = false; } } } } // Log Event (if possible) if (!$DB->isSlave()) { // GET THE IP OF THE CLIENT $ip = getenv("HTTP_X_FORWARDED_FOR") ? getenv("HTTP_X_FORWARDED_FOR") : getenv("REMOTE_ADDR"); if ($this->auth_succeded) { if (GLPI_DEMO_MODE) { // not translation in GLPI_DEMO_MODE Event::log(-1, "system", 3, "login", $login_name . " log in from " . $ip); } else { //TRANS: %1$s is the login of the user and %2$s its IP address Event::log(-1, "system", 3, "login", sprintf(__('%1$s log in from IP %2$s'), $login_name, $ip)); } } else { if (GLPI_DEMO_MODE) { Event::log(-1, "system", 1, "login", "login", "Connection failed for " . $login_name . " ({$ip})"); } else { //TRANS: %1$s is the login of the user and %2$s its IP address Event::log(-1, "system", 1, "login", sprintf(__('Failed login for %1$s from IP %2$s'), $login_name, $ip)); } } } Session::init($this); if ($noauto) { $_SESSION["noAUTO"] = 1; } return $this->auth_succeded; }
if (!isset($_GET["id"])) { $_GET["id"] = ""; } if (!isset($_GET["projects_id"])) { $_GET["projects_id"] = ""; } $cost = new ProjectCost(); if (isset($_POST["add"])) { $cost->check(-1, CREATE, $_POST); if ($newID = $cost->add($_POST)) { Event::log($_POST['projects_id'], "project", 4, "maintain", sprintf(__('%s adds a cost'), $_SESSION["glpiname"])); } Html::back(); } else { if (isset($_POST["purge"])) { $cost->check($_POST["id"], PURGE); if ($cost->delete($_POST, 1)) { Event::log($cost->fields['projects_id'], "project", 4, "maintain", sprintf(__('%s purges a cost'), $_SESSION["glpiname"])); } Html::redirect(Toolbox::getItemTypeFormURL('Project') . '?id=' . $cost->fields['projects_id']); } else { if (isset($_POST["update"])) { $cost->check($_POST["id"], UPDATE); if ($cost->update($_POST)) { Event::log($cost->fields['projects_id'], "project", 4, "maintain", sprintf(__('%s updates a cost'), $_SESSION["glpiname"])); } Html::back(); } } } Html::displayErrorAndDie('Lost');
function post_addItem() { global $CFG_GLPI; // Log this event $username = '******'; if (isset($_SESSION["glpiname"])) { $username = $_SESSION["glpiname"]; } Event::log($this->fields['id'], "ticket", 4, "tracking", sprintf(__('%1$s adds the item %2$s'), $username, $this->fields['id'])); if (isset($this->input["_followup"]) && is_array($this->input["_followup"]) && strlen($this->input["_followup"]['content']) > 0) { $fup = new TicketFollowup(); $type = "new"; if (isset($this->fields["status"]) && $this->fields["status"] == self::SOLVED) { $type = "solved"; } $toadd = array("type" => $type, "tickets_id" => $this->fields['id']); if (isset($this->input["_followup"]['content']) && strlen($this->input["_followup"]['content']) > 0) { $toadd["content"] = $this->input["_followup"]['content']; } if (isset($this->input["_followup"]['is_private'])) { $toadd["is_private"] = $this->input["_followup"]['is_private']; } $toadd['_no_notif'] = true; $fup->add($toadd); } if (isset($this->input["plan"]) && count($this->input["plan"]) || isset($this->input["actiontime"]) && $this->input["actiontime"] > 0) { $task = new TicketTask(); $type = "new"; if (isset($this->fields["status"]) && $this->fields["status"] == self::SOLVED) { $type = "solved"; } $toadd = array("type" => $type, "tickets_id" => $this->fields['id'], "actiontime" => $this->input["actiontime"]); if (isset($this->input["plan"]) && count($this->input["plan"])) { $toadd["plan"] = $this->input["plan"]; } if (isset($_SESSION['glpitask_private'])) { $toadd['is_private'] = $_SESSION['glpitask_private']; } $toadd['_no_notif'] = true; $task->add($toadd); } $ticket_ticket = new Ticket_Ticket(); // From interface if (isset($this->input['_link'])) { $this->input['_link']['tickets_id_1'] = $this->fields['id']; // message if ticket's ID doesn't exist if (!empty($this->input['_link']['tickets_id_2'])) { if ($ticket_ticket->can(-1, 'w', $this->input['_link'])) { $ticket_ticket->add($this->input['_link']); } else { Session::addMessageAfterRedirect(__('Unknown ticket'), false, ERROR); } } } // From mailcollector : do not check rights if (isset($this->input["_linkedto"])) { $input2['tickets_id_1'] = $this->fields['id']; $input2['tickets_id_2'] = $this->input["_linkedto"]; $input2['link'] = Ticket_Ticket::LINK_TO; $ticket_ticket->add($input2); } // Manage SLA Level : add actions if (isset($this->input["slas_id"]) && $this->input["slas_id"] > 0 && isset($this->input["slalevels_id"]) && $this->input["slalevels_id"] > 0) { $calendars_id = Entity::getUsedConfig('calendars_id', $this->fields['entities_id']); $sla = new SLA(); if ($sla->getFromDB($this->input["slas_id"])) { $sla->setTicketCalendar($calendars_id); // Add first level in working table if ($this->input["slalevels_id"] > 0) { $sla->addLevelToDo($this); } // Replay action in case of open date is set before now } SlaLevel_Ticket::replayForTicket($this->getID()); } parent::post_addItem(); //Action for send_validation rule if (isset($this->input["_add_validation"])) { $validations_to_send = array(); if (!is_array($this->input["_add_validation"])) { $this->input["_add_validation"] = array($this->input["_add_validation"]); } foreach ($this->input["_add_validation"] as $validation) { switch ($validation) { case 'requester_supervisor': if (isset($this->input['_groups_id_requester']) && $this->input['_groups_id_requester']) { $users = Group_User::getGroupUsers($this->input['_groups_id_requester'], "is_manager='1'"); foreach ($users as $data) { $validations_to_send[] = $data['id']; } } break; case 'assign_supervisor': if (isset($this->input['_groups_id_assign']) && $this->input['_groups_id_assign']) { $users = Group_User::getGroupUsers($this->input['_groups_id_assign'], "is_manager='1'"); foreach ($users as $data) { $validations_to_send[] = $data['id']; } } break; default: $validations_to_send[] = $validation; } } // Keep only one $validations_to_send = array_unique($validations_to_send); $validation = new TicketValidation(); foreach ($validations_to_send as $users_id) { if ($users_id > 0) { $values = array(); $values['tickets_id'] = $this->fields['id']; $values['users_id_validate'] = $users_id; $values['_ticket_add'] = true; // to know update by rules if (isset($this->input["_rule_process"])) { $values['_rule_process'] = $this->input["_rule_process"]; } // if auto_import, tranfert it for validation if (isset($this->input['_auto_import'])) { $values['_auto_import'] = $this->input['_auto_import']; } // Cron or rule process of hability to do if (Session::isCron() || isset($this->input["_auto_import"]) || isset($this->input["_rule_process"]) || $validation->can(-1, 'w', $values)) { // cron or allowed user $validation->add($values); Event::log($this->fields['id'], "ticket", 4, "tracking", sprintf(__('%1$s updates the item %2$s'), $_SESSION["glpiname"], $this->fields['id'])); } } } } // Processing Email if ($CFG_GLPI["use_mailing"]) { // Clean reload of the ticket $this->getFromDB($this->fields['id']); $type = "new"; if (isset($this->fields["status"]) && $this->fields["status"] == self::SOLVED) { $type = "solved"; } NotificationEvent::raiseEvent($type, $this); } if (isset($_SESSION['glpiis_ids_visible']) && !$_SESSION['glpiis_ids_visible']) { Session::addMessageAfterRedirect(sprintf(__('%1$s (%2$s)'), __('Your ticket has been registered, its treatment is in progress.'), sprintf(__('%1$s: %2$s'), __('Ticket'), "<a href='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $this->fields['id'] . "'>" . $this->fields['id'] . "</a>"))); } }
if (isset($_POST["restore"])) { $soft->check($_POST["id"], 'd'); $soft->restore($_POST); Event::log($_POST["id"], "software", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][23]); $soft->redirectToList(); } else { if (isset($_REQUEST["purge"])) { $soft->check($_REQUEST["id"], 'd'); $soft->delete($_REQUEST, 1); Event::log($_REQUEST["id"], "software", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][24]); $soft->redirectToList(); } else { if (isset($_POST["update"])) { $soft->check($_POST["id"], 'w'); $soft->update($_POST); Event::log($_POST["id"], "software", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][21]); glpi_header($_SERVER['HTTP_REFERER']); } else { if (isset($_POST["mergesoftware"])) { popHeader($LANG['Menu'][4]); if (isset($_POST["id"]) && isset($_POST["item"]) && is_array($_POST["item"]) && count($_POST["item"])) { $soft->check($_POST["id"], 'w'); $soft->merge($_POST["item"]); } glpi_header($_SERVER['HTTP_REFERER']); } else { commonHeader($LANG['Menu'][4], $_SERVER['PHP_SELF'], "inventory", "software"); $soft->showForm($_GET["id"], array('withtemplate' => $_GET["withtemplate"])); commonFooter(); } }
<?php include '../../../inc/includes.php'; PluginFpsoftwareVersionhelper::checkRights("software", UPDATE); $usl = new PluginFpsoftwareCommon(); if (isset($_POST["add"])) { if ($_POST['softwarelicenses_id'] > 0) { if ($usl->add($_POST)) { Event::log($_POST['softwarelicenses_id'], "softwarelicense", 4, "inventory", sprintf(__('%s associates an user and a license'), $_SESSION["glpiname"])); } } Html::back(); } Html::displayErrorAndDie('Lost');
if (isset($_POST["update"])) { $cartype->check($_POST["id"], 'w'); if ($cartype->update($_POST)) { Event::log($_POST["id"], "cartridges", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][21]); } glpi_header($_SERVER['HTTP_REFERER']); } else { if (isset($_POST["addtype"])) { $cartype->check($_POST["tID"], 'w'); if ($cartype->addCompatibleType($_POST["tID"], $_POST["printermodels_id"])) { Event::log($_POST["tID"], "cartridges", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][30]); } glpi_header($_SERVER['HTTP_REFERER']); } else { if (isset($_GET["deletetype"])) { $cartype->check($_GET["tID"], 'w'); if ($cartype->deleteCompatibleType($_GET["id"])) { Event::log($_GET["tID"], "cartridges", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][31]); } glpi_header($_SERVER['HTTP_REFERER']); } else { commonHeader($LANG['Menu'][21], $_SERVER['PHP_SELF'], "inventory", "cartridge"); $cartype->showForm($_GET["id"]); commonFooter(); } } } } } } }
$netdevice->check($_POST["id"], DELETE); $netdevice->delete($_POST); Event::log($_POST["id"], "networkequipment", 4, "inventory", sprintf(__('%s deletes an item'), $_SESSION["glpiname"])); $netdevice->redirectToList(); } else { if (isset($_POST["restore"])) { $netdevice->check($_POST["id"], DELETE); $netdevice->restore($_POST); Event::log($_POST["id"], "networkequipment", 4, "inventory", sprintf(__('%s restores an item'), $_SESSION["glpiname"])); $netdevice->redirectToList(); } else { if (isset($_POST["purge"])) { $netdevice->check($_POST["id"], PURGE); $netdevice->delete($_POST, 1); Event::log($_POST["id"], "networkequipment", 4, "inventory", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); $netdevice->redirectToList(); } else { if (isset($_POST["update"])) { $netdevice->check($_POST["id"], UPDATE); $netdevice->update($_POST); Event::log($_POST["id"], "networkequipment", 4, "inventory", sprintf(__('%s updates an item'), $_SESSION["glpiname"])); Html::back(); } else { Html::header(NetworkEquipment::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "networkequipment"); $netdevice->display(array('id' => $_GET["id"], 'withtemplate' => $_GET["withtemplate"])); Html::footer(); } } } } }
------------------------------------------------------------------------ */ if (!defined('GLPI_ROOT')) { define('GLPI_ROOT', realpath('../../..')); } if (!defined("GLPI_PLUGIN_DOC_DIR")) { define("GLPI_PLUGIN_DOC_DIR", GLPI_ROOT . "/files/_plugins"); } Session::checkLoginUser(); $docDir = GLPI_PLUGIN_DOC_DIR . '/fusioninventory'; if (isset($_GET['file'])) { $filename = $_GET['file']; // Security test : document in $docDir if (strstr($filename, "../") || strstr($filename, "..\\")) { echo "Security attack !!!"; Event::log($filename, "sendFile", 1, "security", $_SESSION["glpiname"] . " tries to get a non standard file."); return; } $file = $docDir . '/' . $filename; if (!file_exists($file)) { echo "Error file {$filename} does not exist"; return; } else { // Now send the file with header() magic header("Expires: Mon, 26 Nov 1962 00:00:00 GMT"); header('Pragma: private'); /// IE BUG + SSL //header('Pragma: no-cache'); header('Cache-control: private, must-revalidate'); /// IE BUG + SSL header("Content-disposition: filename=\"{$filename}\"");
$doc->redirectToList(); } else { if (isset($_POST["restore"])) { $doc->check($_POST["id"], 'd'); if ($doc->restore($_POST)) { Event::log($_POST["id"], "documents", 4, "document", sprintf(__('%s restores an item'), $_SESSION["glpiname"])); } $doc->redirectToList(); } else { if (isset($_POST["purge"])) { $doc->check($_POST["id"], 'd'); if ($doc->delete($_POST, 1)) { Event::log($_POST["id"], "documents", 4, "document", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); } $doc->redirectToList(); } else { if (isset($_POST["update"])) { $doc->check($_POST["id"], 'w'); if ($doc->update($_POST)) { Event::log($_POST["id"], "documents", 4, "document", sprintf(__('%s updates an item'), $_SESSION["glpiname"])); } Html::back(); } else { Html::header(Document::getTypeName(2), $_SERVER['PHP_SELF'], "financial", "document"); $doc->showForm($_GET["id"]); Html::footer(); } } } } }
This file is part of GLPI. GLPI is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GLPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 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, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief */ include '../inc/includes.php'; Session::checkRight('tickettemplate', UPDATE); $item = new TicketTemplateMandatoryField(); if (isset($_POST["add"])) { $item->check(-1, UPDATE, $_POST); if ($item->add($_POST)) { Event::log($_POST["tickettemplates_id"], "tickettemplate", 4, "maintain", sprintf(__('%s adds mandatory field'), $_SESSION["glpiname"])); } Html::back(); } Html::displayErrorAndDie("lost");
/** * Manage Validation add from input * * @since version 0.85 * * @param $input array : input array * * @return nothing **/ function manageValidationAdd($input) { //Action for send_validation rule if (isset($input["_add_validation"])) { if (isset($input['entities_id'])) { $entid = $input['entities_id']; } else { if (isset($this->fields['entities_id'])) { $entid = $this->fields['entities_id']; } else { return false; } } $validations_to_send = array(); if (!is_array($input["_add_validation"])) { $input["_add_validation"] = array($input["_add_validation"]); } foreach ($input["_add_validation"] as $key => $validation) { switch ($validation) { case 'requester_supervisor': if (isset($input['_groups_id_requester']) && $input['_groups_id_requester']) { $users = Group_User::getGroupUsers($input['_groups_id_requester'], "is_manager='1'"); foreach ($users as $data) { $validations_to_send[] = $data['id']; } } // Add to already set groups foreach ($this->getGroups(CommonITILActor::REQUESTER) as $d) { $users = Group_User::getGroupUsers($d['groups_id'], "is_manager='1'"); foreach ($users as $data) { $validations_to_send[] = $data['id']; } } break; case 'assign_supervisor': if (isset($input['_groups_id_assign']) && $input['_groups_id_assign']) { $users = Group_User::getGroupUsers($input['_groups_id_assign'], "is_manager='1'"); foreach ($users as $data) { $validations_to_send[] = $data['id']; } } foreach ($this->getGroups(CommonITILActor::ASSIGN) as $d) { $users = Group_User::getGroupUsers($d['groups_id'], "is_manager='1'"); foreach ($users as $data) { $validations_to_send[] = $data['id']; } } break; default: // Group case from rules if ($key === 'group') { foreach ($validation as $groups_id) { $validation_right = 'validate_incident'; if (isset($input['type']) && $input['type'] == Ticket::DEMAND_TYPE) { $validation_right = 'validate_request'; } $opt = array('groups_id' => $groups_id, 'right' => $validation_right, 'entity' => $entid); $data_users = TicketValidation::getGroupUserHaveRights($opt); foreach ($data_users as $user) { $validations_to_send[] = $user['id']; } } } else { $validations_to_send[] = $validation; } } } // Validation user added on ticket form if (isset($input['users_id_validate'])) { if (array_key_exists('groups_id', $input['users_id_validate'])) { foreach ($input['users_id_validate'] as $key => $validation_to_add) { if (is_numeric($key)) { $validations_to_send[] = $validation_to_add; } } } else { foreach ($input['users_id_validate'] as $key => $validation_to_add) { if (is_numeric($key)) { $validations_to_send[] = $validation_to_add; } } } } // Keep only one $validations_to_send = array_unique($validations_to_send); $validation = new TicketValidation(); if (count($validations_to_send)) { $values = array(); $values['tickets_id'] = $this->fields['id']; if (isset($input['id']) && $input['id'] != $this->fields['id']) { $values['_ticket_add'] = true; } // to know update by rules if (isset($input["_rule_process"])) { $values['_rule_process'] = $input["_rule_process"]; } // if auto_import, tranfert it for validation if (isset($input['_auto_import'])) { $values['_auto_import'] = $input['_auto_import']; } // Cron or rule process of hability to do if (Session::isCron() || isset($input["_auto_import"]) || isset($input["_rule_process"]) || $validation->can(-1, CREATE, $values)) { // cron or allowed user $add_done = false; foreach ($validations_to_send as $user) { // Do not auto add twice same validation if (!TicketValidation::alreadyExists($values['tickets_id'], $user)) { $values["users_id_validate"] = $user; if ($validation->add($values)) { $add_done = true; } } } if ($add_done) { Event::log($this->fields['id'], "ticket", 4, "tracking", sprintf(__('%1$s updates the item %2$s'), $_SESSION["glpiname"], $this->fields['id'])); } } } } return true; }
$_GET["id"] = ""; } $sla = new SLA(); if (isset($_POST["add"])) { $sla->check(-1, CREATE); if ($newID = $sla->add($_POST)) { Event::log($newID, "slas", 4, "setup", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"])); if ($_SESSION['glpibackcreated']) { Html::redirect($sla->getFormURL() . "?id=" . $newID); } } Html::redirect($CFG_GLPI["root_doc"] . "/front/sla.php"); } else { if (isset($_POST["purge"])) { $sla->check($_POST["id"], PURGE); $sla->delete($_POST, 1); Event::log($_POST["id"], "slas", 4, "setup", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); $sla->redirectToList(); } else { if (isset($_POST["update"])) { $sla->check($_POST["id"], UPDATE); $sla->update($_POST); Event::log($_POST["id"], "slas", 4, "setup", sprintf(__('%s updates an item'), $_SESSION["glpiname"])); Html::back(); } else { Html::header(SLA::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "config", "sla"); $sla->display(array('id' => $_GET["id"])); Html::footer(); } } }
This file is part of GLPI. GLPI is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GLPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 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, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief * @since version 0.85 */ include '../inc/includes.php'; Session::checkLoginUser(); $item = new Change_Project(); if (isset($_POST["add"])) { $item->check(-1, CREATE, $_POST); if ($newID = $item->add($_POST)) { Event::log($_POST["projects_id"], "project", 4, "maintain", sprintf(__('%s adds a link with an item'), $_SESSION["glpiname"])); } Html::back(); } Html::displayErrorAndDie("lost");
This file is part of GLPI. GLPI is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GLPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 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, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief * @since vesion 0.84 */ include '../inc/includes.php'; Session::checkCentralAccess(); $group_user = new Group_User(); if (isset($_POST["add"])) { $group_user->check(-1, CREATE, $_POST); if ($group_user->add($_POST)) { Event::log($_POST["groups_id"], "groups", 4, "setup", sprintf(__('%s adds a user to a group'), $_SESSION["glpiname"])); } Html::back(); } Html::displayErrorAndDie("lost");
/** * Get port OID list for the SNMP model && create ports in DB if they don't exists * * @param $ID_Device : ID of device * @param $type : type of device (NETWORKING_TYPE, PRINTER_TYPE ...) * @param $oidsModel : oid list from model SNMP * @param $oidvalues : list of values from agent query * @param $ArrayPort_LogicalNum_SNMPNum : array logical port number => SNMP port number (ifindex) * @param $ArrayPort_LogicalNum_SNMPName : array logical port number => SNMP Port name * * @return $oidList : array with logic number => portsID from snmp * **/ static function getOIDPorts($ID_Device, $type, $oidsModel, $oidvalues, $ArrayPort_LogicalNum_SNMPName, $ArrayPort_LogicalNum_SNMPNum) { global $DB, $LANG; if ($_SESSION['fusioninventory_logs'] == "1") { $logs = new PluginFusioninventoryLogs(); } $manufCisco = new PluginFusioninventoryManufacturerCisco(); $netwire = new Netwire(); $np = new Netport(); $ptp = new PluginFusioninventoryPort(); if ($_SESSION['fusioninventory_logs'] == "1") { $logs->write("fusioninventory_fullsync", ">>>>>>>>>> Get OID ports list (SNMP model) and create ports in DB if not exists <<<<<<<<<<", $type, $ID_Device, 1); } $portcounter = $oidvalues[$oidsModel[1][0][""]][""]; if ($_SESSION['fusioninventory_logs'] == "1") { $logs->write("fusioninventory_fullsync", "oid port counter : " . $oidsModel[1][0][""] . " = " . $portcounter, $type, $ID_Device, 1); } $oid_ifType = $oidsModel[0][1]['ifType']; if ($_SESSION['fusioninventory_logs'] == "1") { $logs->write("fusioninventory_fullsync", "type of port : " . $oid_ifType, $type, $ID_Device, 1); } asort($ArrayPort_LogicalNum_SNMPNum); // Reorder ports with good logic number $query = "SELECT `last_PID_update`\n FROM `glpi_plugin_fusioninventory_networking`\n WHERE `FK_networking`='" . $ID_Device . "'\n AND `last_PID_update`='0';"; $result = $DB->query($query); if ($DB->numrows($result) == 1) { foreach ($ArrayPort_LogicalNum_SNMPNum as $num => $ifIndex) { $query_update = "UPDATE `glpi_networking_ports`\n SET `logical_number`='" . $ifIndex . "'\n WHERE `on_device`='" . $ID_Device . "'\n AND `device_type`='" . $type . "'\n AND `name`='" . $ArrayPort_LogicalNum_SNMPName[$num] . "';"; $DB->query($query_update); } } // Get query SNMP to have number of ports if (isset($portcounter) and !empty($portcounter)) { // ** Add ports in DataBase if they don't exists $logicalnumberlist = "("; foreach ($ArrayPort_LogicalNum_SNMPNum as $num => $ifIndex) { //$i is the logical number $logicalnumberlist .= $ifIndex . ","; //for ($i=0 ; $i < $portcounter ; $i++) { // Get type of port $ifType = $oidvalues[$oid_ifType . "." . $ArrayPort_LogicalNum_SNMPNum[$num]][""]; $oidList[$i] = $ArrayPort_LogicalNum_SNMPNum[$num]; if (strstr($ifType, "ethernetCsmacd") or $ifType == "6" or $ifType == "ethernet-csmacd(6)" or strstr($ifType, "iso88023Csmacd") or $ifType == "7") { $goodname = 1; if ($manufCisco->ListVirtualPorts($oidvalues[".1.3.6.1.2.1.1.1.0"][""], $ArrayPort_LogicalNum_SNMPName[$num]) == true) { $goodname = 0; $deleteportname[] = $ifIndex; unset($oidList[$ifIndex]); } if ($goodname == 1) { $query = "SELECT `ID`, `name`\n FROM `glpi_networking_ports`\n WHERE `on_device`='" . $ID_Device . "'\n AND `device_type`='" . $type . "'\n AND `logical_number`='" . $ifIndex . "';"; $result = $DB->query($query); if ($DB->numrows($result) == 0) { unset($array); $array["logical_number"] = $ifIndex; $array["name"] = $ArrayPort_LogicalNum_SNMPName[$num]; $array["on_device"] = $ID_Device; $array["device_type"] = $type; $IDport = $np->add($array); Event::log(0, "networking", 5, "inventory", "FusionInventory " . $LANG["log"][70]); if ($_SESSION['fusioninventory_logs'] == "1") { $logs->write("fusioninventory_fullsync", "Add port in DB (glpi_networking_ports) : " . $ArrayPort_LogicalNum_SNMPName[$i], $type, $ID_Device, 1); } } else { $IDport = $DB->result($result, 0, "ID"); if ($DB->result($result, 0, "name") != $ArrayPort_LogicalNum_SNMPName[$num]) { unset($array); $array["name"] = $ArrayPort_LogicalNum_SNMPName[$num]; $array["ID"] = $DB->result($result, 0, "ID"); $np->update($array); if ($_SESSION['fusioninventory_logs'] == "1") { $logs->write("fusioninventory_fullsync", "Update port in DB (glpi_networking_ports) : ID" . $DB->result($result, 0, "ID") . " & name " . $ArrayPort_LogicalNum_SNMPName[$i], $type, $ID_Device, 1); } } } if ($type == NETWORKING_TYPE) { $queryFusionInventoryPort = "SELECT `ID`\n FROM `glpi_plugin_fusioninventory_networking_ports`\n WHERE `FK_networking_ports`='" . $IDport . "';"; $resultFusionInventoryPort = $DB->query($queryFusionInventoryPort); if ($DB->numrows($resultFusionInventoryPort) == 0) { $queryInsert = "INSERT INTO `glpi_plugin_fusioninventory_networking_ports`\n (`FK_networking_ports`)\n VALUES ('" . $IDport . "');"; $DB->query($queryInsert); if ($_SESSION['fusioninventory_logs'] == "1") { $logs->write("fusioninventory_fullsync", "Add port in DB (glpi_plugin_fusioninventory_networking_ports) : ID " . $IDport, $type, $ID_Device, 1); } } } } } } $logicalnumberlist .= ")"; } // Delete all ports that will be not here $nn = new NetworkPort_NetworkPort(); foreach ($deleteportname as $id => $i) { $query = "SELECT *\n FROM `glpi_networking_ports`\n WHERE `on_device`='" . $ID_Device . "'\n AND `device_type`='" . $type . "'\n AND `logical_number`='" . $i . "';"; $result = $DB->query($query); $data = $DB->fetch_assoc($result); PluginFusioninventorySnmphistory::addLogConnection("remove", $netwire->getOppositeContact($data['ID']), $FK_process); PluginFusioninventorySnmphistory::addLogConnection("remove", $data['ID'], $FK_process); if ($nn->getFromDBForNetworkPort($data['ID'])) { $nn->delete($data); } $ptp->deleteFromDB($data["ID"], 1); $np->delete($data); } // Delete ports where logical number in glpi_plugin_fusioninventory_networking_ports // not exist on switch : it's ports reorder not well $logicalnumberlist = str_replace(",)", ")", $logicalnumberlist); $query = "SELECT *\n FROM `glpi_networking_ports`\n WHERE `on_device`='" . $ID_Device . "'\n AND `device_type`='" . $type . "'\n AND `logical_number` NOT IN " . $logicalnumberlist . ";"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { PluginFusioninventorySnmphistory::addLogConnection("remove", $netwire->getOppositeContact($data['ID']), $FK_process); PluginFusioninventorySnmphistory::addLogConnection("remove", $data['ID'], $FK_process); if ($nn->getFromDBForNetworkPort($data['ID'])) { $nn->delete($data); } $np->delete($data); $query_delete = "DELETE FROM `glpi_plugin_fusioninventory_networking_ports`\n WHERE `FK_networking_ports`='" . $data["ID"] . "';"; $DB->query($query_delete); } return $oidList; }
/** @file * @brief * @since version 0.84 */ include '../inc/includes.php'; Session::checkCentralAccess(); $cost = new TicketCost(); if (isset($_POST["add"])) { $cost->check(-1, CREATE, $_POST); if ($newID = $cost->add($_POST)) { Event::log($_POST['tickets_id'], "tickets", 4, "tracking", sprintf(__('%s adds a cost'), $_SESSION["glpiname"])); } Html::back(); } else { if (isset($_POST["purge"])) { $cost->check($_POST["id"], PURGE); if ($cost->delete($_POST, 1)) { Event::log($cost->fields['tickets_id'], "tickets", 4, "tracking", sprintf(__('%s purges a cost'), $_SESSION["glpiname"])); } Html::redirect(Toolbox::getItemTypeFormURL('Ticket') . '?id=' . $cost->fields['tickets_id']); } else { if (isset($_POST["update"])) { $cost->check($_POST["id"], UPDATE); if ($cost->update($_POST)) { Event::log($cost->fields['tickets_id'], "tickets", 4, "tracking", sprintf(__('%s updates a cost'), $_SESSION["glpiname"])); } Html::back(); } } } Html::displayErrorAndDie('Lost');
if ($budget->restore($_POST)) { Event::log($_POST["id"], "budget", 4, "financial", sprintf(__('%s restores an item'), $_SESSION["glpiname"])); } $budget->redirectToList(); } else { if (isset($_POST["purge"])) { $budget->check($_POST["id"], PURGE); if ($budget->delete($_POST, 1)) { Event::log($_POST["id"], "budget", 4, "financial", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); } $budget->redirectToList(); } else { if (isset($_POST["update"])) { $budget->check($_POST["id"], UPDATE); if ($budget->update($_POST)) { Event::log($_POST["id"], "budget", 4, "financial", sprintf(__('%s updates an item'), $_SESSION["glpiname"])); } Html::back(); } else { if (isset($_GET['_in_modal'])) { Html::popHeader(Budget::getTypeName(1), $_SERVER['PHP_SELF']); $budget->showForm($_GET["id"], array('withtemplate' => $_GET["withtemplate"])); Html::popFooter(); } else { Html::header(Budget::getTypeName(1), $_SERVER['PHP_SELF'], "management", "budget"); $budget->display(array('id' => $_GET["id"], 'withtemplate' => $_GET["withtemplate"])); Html::footer(); } } } }
} else { $_POST['users_id'] = $_SESSION['glpiID']; } } if (isset($_POST["add"])) { $pmDisplayview->add($_POST); Html::back(); } else { if (isset($_POST["update"])) { $pmDisplayview->update($_POST); Html::back(); } else { if (isset($_POST["purge"])) { $pmDisplayview->delete($_POST); $pmDisplayview->redirectToList(); } else { if (isset($_POST["update"])) { $remind->check($_POST["id"], UPDATE); // Right to update the reminder $remind->update($_POST); Event::log($_POST["id"], "reminder", 4, "tools", sprintf(__('%s updates an item'), $_SESSION["glpiname"])); Html::back(); } } } } if (!isset($_GET["id"])) { $_GET["id"] = ""; } $pmDisplayview->display(array('id' => $_GET["id"])); Html::footer();
$language = new NotificationTemplateTranslation(); if (isset($_POST["add"])) { $language->check(-1, CREATE, $_POST); $newID = $language->add($_POST); Event::log($newID, "notificationtemplatetranslations", 4, "notification", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["language"])); Html::back(); } else { if (isset($_POST["purge"])) { $language->check($_POST["id"], PURGE); $language->delete($_POST, 1); Event::log($_POST["id"], "notificationtemplatetranslations", 4, "notification", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); $language->redirectToList(); } else { if (isset($_POST["update"])) { $language->check($_POST["id"], UPDATE); $language->update($_POST); Event::log($_POST["id"], "notificationtemplatetranslations", 4, "notification", sprintf(__('%s updates an item'), $_SESSION["glpiname"])); Html::back(); } else { Html::header(NotificationTemplate::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "config", "notification", "notificationtemplate"); if ($_GET["id"] == '') { $options = array("notificationtemplates_id" => $_GET["notificationtemplates_id"]); } else { $options = array(); } $options['id'] = $_GET["id"]; $language->display($options); Html::footer(); } } }
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: Julien Dombre // Purpose of file: // ---------------------------------------------------------------------- define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; if (empty($_GET["id"])) { $_GET["id"] = ""; } $link = new Link(); $link_itemtype = new Link_ItemType(); if (isset($_POST["add"])) { $link->check($_GET["id"], 'w'); if ($link_itemtype->add($_POST)) { Event::log($_POST["links_id"], "links", 4, "setup", $_SESSION["glpiname"] . " " . $LANG['log'][32]); } glpi_header($CFG_GLPI["root_doc"] . "/front/link.form.php?id=" . $_POST["links_id"]); } else { if (isset($_GET["delete"])) { $link->check($_GET["links_id"], 'w'); $link_itemtype->delete($_GET); Event::log($_GET["links_id"], "links", 4, "setup", $_SESSION["glpiname"] . " " . $LANG['log'][33]); glpi_header($_SERVER['HTTP_REFERER']); } }
$ri->delete($_POST); Event::log($_POST['id'], "reservationitem", 4, "inventory", sprintf(__('%s deletes an item'), $_SESSION["glpiname"])); Html::back(); } else { if (isset($_POST["purge"])) { $ri->check($_POST["id"], 'd'); $ri->delete($_POST, 1); Event::log($_POST['id'], "reservationitem", 4, "inventory", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); Html::back(); } else { if (isset($_POST["restore"])) { $ri->check($_POST["id"], 'd'); $ri->restore($_POST); Event::log($_POST['id'], "reservationitem", 4, "inventory", sprintf(__('%s restores an item'), $_SESSION["glpiname"])); Html::back(); } else { if (isset($_POST["update"])) { $ri->check($_POST["id"], 'w'); $ri->update($_POST); Event::log($_POST['id'], "reservationitem", 4, "inventory", sprintf(__('%s updates an item'), $_SESSION["glpiname"])); Html::back(); } else { $ri->check($_GET["id"], 'r'); Html::header(Reservation::getTypeName(2), $_SERVER['PHP_SELF'], "utils", "reservation"); $ri->showForm($_GET["id"]); } } } } } Html::footer();