Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4d8778
commit 7c7dfa6
Showing
38 changed files
with
4,210 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
/** | ||
* --------------------------------------------------------------------- | ||
* | ||
* GLPI - Gestionnaire Libre de Parc Informatique | ||
* | ||
* http://glpi-project.org | ||
* | ||
* @copyright 2015-2024 Teclib' and contributors. | ||
* @copyright 2003-2014 by the INDEPNET Development Team. | ||
* @licence https://www.gnu.org/licenses/gpl-3.0.html | ||
* | ||
* --------------------------------------------------------------------- | ||
* | ||
* LICENSE | ||
* | ||
* This file is part of GLPI. | ||
* | ||
* This program 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 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* --------------------------------------------------------------------- | ||
*/ | ||
|
||
include('../../inc/includes.php'); | ||
|
||
use Glpi\Form\AccessControl\FormAccessControl; | ||
|
||
/** | ||
* Ajax endpoint to update an access control item. | ||
* | ||
* This endpoint is called once per possible access control stategies when | ||
* submitting the access control config page for a form. | ||
*/ | ||
|
||
try { | ||
$access_control = new FormAccessControl(); | ||
|
||
if (isset($_POST["update"])) { | ||
// ID is mandatory | ||
$id = $_POST['id'] ?? null; | ||
if ($id === null) { | ||
// Invalid request | ||
throw new InvalidArgumentException("Missing id"); | ||
} | ||
|
||
// Right check | ||
$access_control->check($id, UPDATE, $_POST); | ||
|
||
// Format user supplied config | ||
$access_control->getFromDB($id); | ||
$_POST['_config'] = $access_control->createConfigFromUserInput($_POST); | ||
|
||
// Update access control item | ||
if (!$access_control->update($_POST, true)) { | ||
throw new RuntimeException("Failed to create destination item"); | ||
} | ||
} else { | ||
// Unknown request | ||
throw new InvalidArgumentException("Unknown action"); | ||
} | ||
} catch (\Throwable $e) { | ||
// Log error | ||
trigger_error( | ||
// Insert POST data into logs to ease debugging | ||
$e->getMessage() . ": " . json_encode($_POST), | ||
E_USER_WARNING | ||
); | ||
|
||
Session::addMessageAfterRedirect(__('An unexpected error occured.'), false, ERROR); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/** | ||
* --------------------------------------------------------------------- | ||
* | ||
* GLPI - Gestionnaire Libre de Parc Informatique | ||
* | ||
* http://glpi-project.org | ||
* | ||
* @copyright 2015-2024 Teclib' and contributors. | ||
* @copyright 2003-2014 by the INDEPNET Development Team. | ||
* @licence https://www.gnu.org/licenses/gpl-3.0.html | ||
* | ||
* --------------------------------------------------------------------- | ||
* | ||
* LICENSE | ||
* | ||
* This file is part of GLPI. | ||
* | ||
* This program 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 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* --------------------------------------------------------------------- | ||
*/ | ||
|
||
include(__DIR__ . '../../getAbstractRightDropdownValue.php'); | ||
|
||
use Glpi\Form\AccessControl\ControlType\AllowListDropdown; | ||
use Glpi\Form\Form; | ||
|
||
// This dropdown is used to configure form's access controls. | ||
// It should only be visible to users with the right to view form's access controls. | ||
Session::checkRight(Form::$rightname, READ); | ||
show_rights_dropdown(AllowListDropdown::class); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
/** | ||
* --------------------------------------------------------------------- | ||
* | ||
* GLPI - Gestionnaire Libre de Parc Informatique | ||
* | ||
* http://glpi-project.org | ||
* | ||
* @copyright 2015-2024 Teclib' and contributors. | ||
* @copyright 2003-2014 by the INDEPNET Development Team. | ||
* @licence https://www.gnu.org/licenses/gpl-3.0.html | ||
* | ||
* --------------------------------------------------------------------- | ||
* | ||
* LICENSE | ||
* | ||
* This file is part of GLPI. | ||
* | ||
* This program 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 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
* --------------------------------------------------------------------- | ||
*/ | ||
|
||
include('../../inc/includes.php'); | ||
|
||
use Glpi\Form\AccessControl\ControlType\AllowListDropdown; | ||
use Glpi\Form\Form; | ||
|
||
Session::checkRight(Form::$rightname, READ); | ||
|
||
/** | ||
* Special endpoint to preview the results of the AllowListDropdown. | ||
* | ||
* It will count the number ofusers that match the supplied restrictions. | ||
* A link to the search results will also be provided if the user can read the user list. | ||
*/ | ||
|
||
|
||
if (isset($_POST['values'])) { | ||
$users = AllowListDropdown::getPostedIds($_POST['values'], User::class); | ||
$groups = AllowListDropdown::getPostedIds($_POST['values'], Group::class); | ||
$profiles = AllowListDropdown::getPostedIds($_POST['values'], Profile::class); | ||
$empty_criteria = false; | ||
} else { | ||
// If the dropdown has no selected value, $_POST['values'] is not defined at all. | ||
// This mean there are no criteria and no users should be found. | ||
$users = [-1]; | ||
$groups = [-1]; | ||
$profiles = [-1]; | ||
$empty_criteria = true; | ||
} | ||
|
||
$data = AllowListDropdown::countUsersForCriteria( | ||
$users, | ||
$groups, | ||
$profiles | ||
); | ||
|
||
// Do not display the link if there are no criteria, as the search would be confusing | ||
// with the '-1' criteria. | ||
if ($empty_criteria) { | ||
unset($data['link']); | ||
} | ||
|
||
// Do not display the link if the user does not have the right to read the user list | ||
if (!Session::haveRight(User::$rightname, READ)) { | ||
unset($data['link']); | ||
} | ||
|
||
// Content will be rendered as JSON to allow the calling script to render it as it wishes. | ||
header('Content-Type: application/json'); | ||
echo json_encode($data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.