Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add make default option for authmails #16221

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?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/>.
*
* ---------------------------------------------------------------------
*/

/**
* @var \Migration $migration
*/

$migration->addField("glpi_authmails", "is_default", "TINYINT NOT NULL DEFAULT 0");
1 change: 1 addition & 0 deletions install/mysql/glpi-empty.sql
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ CREATE TABLE `glpi_authmails` (
`date_creation` timestamp NULL DEFAULT NULL,
`comment` text,
`is_active` tinyint NOT NULL DEFAULT '0',
`is_default` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `name` (`name`),
KEY `date_mod` (`date_mod`),
Expand Down
3 changes: 3 additions & 0 deletions src/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,9 @@ public static function getLoginAuthMethods()
]);
foreach ($iterator as $data) {
$elements['mail-' . $data['id']] = $data['name'];
if ($data['is_default'] == 1) {
$elements['_default'] = 'mail-' . $data['id'];
}
}

return $elements;
Expand Down
15 changes: 15 additions & 0 deletions src/AuthMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ public function rawSearchOptions()
'datatype' => 'bool'
];

$tab[] = [
'id' => '7',
'table' => $this->getTable(),
'field' => 'is_default',
'name' => __('Default server'),
'datatype' => 'bool',
'massiveaction' => false
];

$tab[] = [
'id' => '19',
'table' => $this->getTable(),
Expand Down Expand Up @@ -192,6 +201,12 @@ public function showForm($ID, array $options = [])
Dropdown::showYesNo('is_active', $this->fields['is_active']);
echo "</td></tr>";

$defaultrand = mt_rand();
echo "<tr class='tab_bg_1'><td><label for='dropdown_is_default$defaultrand'>" . __('Default server') . "</label></td>";
echo "<td>";
Dropdown::showYesNo('is_default', $this->fields['is_default'], -1, ['rand' => $defaultrand]);
echo "</td>";

echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Email domain Name (users email will be login@domain)') . "</td>";
echo "<td><input class='form-control' type='text' name='host' value='" . $this->fields["host"] . "'>";
Expand Down