From c268263e9cf9960150ef84c9ceb45cdb4f508611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Fri, 19 Mar 2021 12:49:52 +0100 Subject: [PATCH 1/3] Add ability to update 'user' field of SASL XOAUTH2 authentication --- front/authorization.form.php | 22 ++++++++++++-- inc/authorization.class.php | 47 ++++++++++++++++++++++++++++-- inc/mailcollectorfeature.class.php | 31 ++++++++++++++++++++ 3 files changed, 96 insertions(+), 4 deletions(-) diff --git a/front/authorization.form.php b/front/authorization.form.php index 2d05e82..75796e9 100644 --- a/front/authorization.form.php +++ b/front/authorization.form.php @@ -27,12 +27,30 @@ include ('../../../inc/includes.php'); $authorization = new PluginOauthimapAuthorization(); +$application = new PluginOauthimapApplication(); if (isset($_POST['id']) && isset($_POST['delete'])) { $authorization->check($_POST['id'], DELETE); $authorization->delete($_POST); Html::back(); -} +} else if (isset($_POST['id']) && isset($_POST['update'])) { + $authorization->check($_POST['id'], UPDATE); + if ($authorization->update($_POST) + && $application->getFromDB($authorization->fields[$application->getForeignKeyField()])) { + Html::redirect($application->getLinkURL()); + } -Html::displayErrorAndDie('lost'); + Html::back(); +} else if (isset($_GET['id'])) { + $application = new PluginOauthimapApplication(); + $application->displayHeader(); + $authorization->display( + [ + 'id' => $_GET['id'], + ] + ); + Html::footer(); +} else { + Html::displayErrorAndDie('lost'); +} diff --git a/inc/authorization.class.php b/inc/authorization.class.php index 313ce21..b70a075 100644 --- a/inc/authorization.class.php +++ b/inc/authorization.class.php @@ -34,6 +34,9 @@ class PluginOauthimapAuthorization extends CommonDBChild { + // From CommonGlpi + protected $displaylist = false; + // From CommonDBTM public $dohistory = true; @@ -100,7 +103,7 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem echo '' . __('No authorizations.', 'oauthimap') . ''; } else { echo ''; - echo '' . __('Email') . ''; + echo '' . __('Email', 'oauthimap') . ''; echo ''; echo ''; @@ -110,7 +113,11 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtem echo '' . $row['email'] . ''; echo ''; - echo '
'; + echo ''; + echo __('Update', 'oauthimap'); + echo ''; + echo ' '; + echo ''; echo Html::hidden('_glpi_csrf_token', ['value' => Session::getNewCSRFToken()]); echo Html::hidden('id', ['value' => $row['id']]); echo '