/** * @param $input **/ function updateForgottenPassword($input) { global $CFG_GLPI; echo "<div class='center'>"; if ($this->getFromDBbyEmail($input['email'], "`glpi_users`.`is_active` AND NOT `glpi_users`.`is_deleted`")) { if ($this->fields["authtype"] == Auth::DB_GLPI || !Auth::useAuthExt()) { if ($input['password_forget_token'] == $this->fields['password_forget_token'] && abs(strtotime($_SESSION["glpi_currenttime"]) - strtotime($this->fields['password_forget_token_date'])) < DAY_TIMESTAMP) { $input['id'] = $this->fields['id']; if (Config::validatePassword($input["password"]) && $this->update($input)) { _e('Reset password successful.'); // $input2['password_forget_token'] = ''; $input2['password_forget_token_date'] = NULL; $input2['id'] = $this->fields['id']; $this->update($input2); } else { // Force display on error Html::displayMessageAfterRedirect(); } } else { _e('Your password reset request has expired or is invalid. Please renew it.'); } } else { _e("The authentication method configuration doesn't allow you to change your password."); } } else { _e('Email address not found.'); } echo "<br>"; echo "<a href='" . $CFG_GLPI['root_doc'] . "'>" . __('Back') . "</a>"; echo "</div>"; }
$_SESSION['valid_id'] = session_id(); $_SESSION['glpiactiveentities'] = $form->fields['entities_id']; $subentities = getSonsOf('glpi_entities', $form->fields['entities_id']); $_SESSION['glpiactiveentities_string'] = !empty($subentities) ? "'" . implode("', '", $subentities) . "'" : "'" . $form->fields['entities_id'] . "'"; } } if (isset($_SESSION['glpiactiveprofile']['interface']) && $_SESSION['glpiactiveprofile']['interface'] == 'helpdesk') { Html::helpHeader(__('Form list', 'formcreator'), $_SERVER['PHP_SELF']); $form->displayUserForm($form); Html::helpFooter(); } elseif (!empty($_SESSION['glpiactiveprofile'])) { Html::header(__('Form Creator', 'formcreator'), $_SERVER['PHP_SELF'], 'helpdesk', 'PluginFormcreatorFormlist'); $form->displayUserForm($form); Html::footer(); } else { Html::nullHeader(__('Form Creator', 'formcreator'), $_SERVER['PHP_SELF']); Html::displayMessageAfterRedirect(); $form->displayUserForm($form); Html::nullFooter(); } } else { Html::displayNotFoundError(); } // If user was not authenticated, remove temporary user if ($_SESSION['glpiname'] == 'formcreator_temp_user') { unset($_SESSION['glpiname']); } // Or display a "Not found" error } else { Html::displayNotFoundError(); }
static function displayOrderTypeForm($order_type, $packages_id, $package) { global $CFG_GLPI; $subtypes = array('check' => __("Audits", 'fusioninventory'), 'file' => __("Files", 'fusioninventory'), 'action' => __("Actions", 'fusioninventory')); $json_subtypes = array('check' => 'checks', 'file' => 'associatedFiles', 'action' => 'actions'); $rand = mt_rand(); $order = new PluginFusioninventoryDeployOrder($order_type, $packages_id); $datas = json_decode($order->fields['json'], TRUE); $orders_id = $order->fields['id']; $order_type_label = PluginFusioninventoryDeployOrder::getOrderTypeLabel($order->fields['type']); /** * Display an error if the package modification is not possible **/ $error_msg = $package->getEditErrorMessage($order_type_label); if (!empty($error_msg)) { Session::addMessageAfterRedirect($error_msg); Html::displayMessageAfterRedirect(); echo "<div id='package_order_" . $orders_id . "_span'>"; } echo "<table class='tab_cadre_fixe' id='package_order_" . $orders_id . "'>"; /** * Display the lists of each subtypes of a package **/ foreach ($subtypes as $subtype => $label) { echo "<tr>"; echo "<th id='th_title_{$subtype}_{$rand}'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/pics/{$subtype}.png' />"; echo " " . __($label, 'fusioninventory'); $package->plusButtonSubtype($package->getID(), $orders_id, $subtype, $rand); echo "</th>"; echo "</tr>"; /** * File's form must be encoded as multipart/form-data **/ $multipart = ""; if ($subtype == "file") { $multipart = "enctype='multipart/form-data'"; } echo "<tr>"; echo "<td style='vertical-align:top'>"; /** * Display subtype form **/ echo "<form name='addition{$subtype}' method='post' " . $multipart . " action='deploypackage.form.php'>"; echo "<input type='hidden' name='orders_id' value='{$orders_id}' />"; echo "<input type='hidden' name='itemtype' value='PluginFusioninventoryDeploy" . ucfirst($subtype) . "' />"; $classname = "PluginFusioninventoryDeploy" . ucfirst($subtype); $classname::displayForm($order, $datas, $rand, "init"); Html::closeForm(); $json_subtype = $json_subtypes[$subtype]; /** * Display stored actions datas **/ if (isset($datas['jobs'][$json_subtype]) && !empty($datas['jobs'][$json_subtype])) { echo "<div id='drag_" . $order_type_label . "_" . $subtype . "s'>"; echo "<form name='remove" . $subtype . "s' " . "method='post' action='deploypackage.form.php' " . "id='" . $subtype . "sList" . $rand . "'>"; echo "<input type='hidden' name='remove_item' />"; echo "<input type='hidden' name='itemtype' value='" . $classname . "' />"; echo "<input type='hidden' name='orders_id' value='" . $order->fields['id'] . "' />"; $classname::displayList($order, $datas, $rand); Html::closeForm(); echo "</div>"; } /** * Initialize drag and drop on subtype lists **/ echo "<script type='text/javascript'>"; echo "redipsInit('{$order_type_label}', '{$subtype}', {$orders_id});"; echo "</script>"; echo "</td>"; echo "</tr>"; } if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) { // === debug === echo "<tr><td>"; echo "<span id='package_json_debug'>"; self::display_json_debug($order); echo "</sp3an>"; echo "</td></tr>"; } echo "</table>"; if (!empty($error_msg)) { echo "</div>"; echo "<script type='text/javascript'>\n Ext.onReady(function() {\n Ext.select('#package_order_" . $orders_id . "_span').mask();\n });\n </script>"; } }
/** * @covers Session::addMessageAfterRedirect * @covers Html::displayMessageAfterRedirect */ public function testAddMessageAfterRedirect() { session_start(); $err_msg = 'Something is broken. Weird.'; $warn_msg = 'There was a warning. Be carefull.'; $info_msg = 'All goes well. Or not... Who knows ;)'; $this->assertEquals(false, isset($_SESSION['MESSAGE_AFTER_REDIRECT'])); //test add message in cron mode $_SESSION['glpicronuserrunning'] = 'phpunit_cron'; Session::addMessageAfterRedirect($err_msg, false, ERROR); //adding a message in "cron mode" does not add anything in the session $this->assertEquals(false, isset($_SESSION['MESSAGE_AFTER_REDIRECT'])); //set not running from cron unset($_SESSION['glpicronuserrunning']); //test all messages types Session::addMessageAfterRedirect($err_msg, false, ERROR); Session::addMessageAfterRedirect($warn_msg, false, WARNING); Session::addMessageAfterRedirect($info_msg, false, INFO); $expected = [ERROR => [$err_msg], WARNING => [$warn_msg], INFO => [$info_msg]]; $this->assertEquals($expected, $_SESSION['MESSAGE_AFTER_REDIRECT']); $this->expectOutputRegex('/' . str_replace('.', '\\.', $err_msg) . '/'); $this->expectOutputRegex('/' . str_replace('.', '\\.', $warn_msg) . '/'); $this->expectOutputRegex('/' . str_replace(['.', ')'], ['\\.', '\\)'], $info_msg) . '/'); Html::displayMessageAfterRedirect(); $this->assertEquals([], $_SESSION['MESSAGE_AFTER_REDIRECT']); //test multiple messages of same type Session::addMessageAfterRedirect($err_msg, false, ERROR); Session::addMessageAfterRedirect($err_msg, false, ERROR); Session::addMessageAfterRedirect($err_msg, false, ERROR); $expected = [ERROR => [$err_msg, $err_msg, $err_msg]]; $this->assertEquals($expected, $_SESSION['MESSAGE_AFTER_REDIRECT']); $this->expectOutputRegex('/' . str_replace('.', '\\.', $err_msg) . '/'); Html::displayMessageAfterRedirect(); $this->assertEquals([], $_SESSION['MESSAGE_AFTER_REDIRECT']); //test message deduplication $err_msg_bis = $err_msg . ' not the same'; Session::addMessageAfterRedirect($err_msg, true, ERROR); Session::addMessageAfterRedirect($err_msg_bis, true, ERROR); Session::addMessageAfterRedirect($err_msg, true, ERROR); Session::addMessageAfterRedirect($err_msg, true, ERROR); $expected = [ERROR => [$err_msg, $err_msg_bis]]; $this->assertEquals($expected, $_SESSION['MESSAGE_AFTER_REDIRECT']); $this->expectOutputRegex('/' . str_replace('.', '\\.', $err_msg) . '/'); $this->expectOutputRegex('/' . str_replace('.', '\\.', $err_msg_bis) . '/'); Html::displayMessageAfterRedirect(); $this->assertEquals([], $_SESSION['MESSAGE_AFTER_REDIRECT']); //test with reset Session::addMessageAfterRedirect($err_msg, false, ERROR); Session::addMessageAfterRedirect($warn_msg, false, WARNING); Session::addMessageAfterRedirect($info_msg, false, INFO, true); $expected = [INFO => [$info_msg]]; $this->assertEquals($expected, $_SESSION['MESSAGE_AFTER_REDIRECT']); $this->expectOutputRegex('/' . str_replace(['.', ')'], ['\\.', '\\)'], $info_msg) . '/'); Html::displayMessageAfterRedirect(); $this->assertEquals([], $_SESSION['MESSAGE_AFTER_REDIRECT']); }
/** * Process the massive actions for all passed items. This a switch between different methods: * new system, old one and plugins ... * * @return an array of results (ok, ko, noright counts, redirect ...) **/ function process() { if (!empty($this->remainings)) { $this->updateProgressBars(); if (isset($this->messaget_after_redirect)) { $_SESSION["MESSAGE_AFTER_REDIRECT"] = $this->messaget_after_redirect; Html::displayMessageAfterRedirect(); unset($this->messaget_after_redirect); } $processor = $this->processor; $this->processForSeveralItemtypes(); } $this->results['redirect'] = $this->redirect; // unset $this->identifier to ensure the action won't register in $_SESSION unset($this->identifier); return $this->results; }