fix - profile in install
This commit is contained in:
+16
-1
@@ -74,6 +74,21 @@ class Profile extends \Profile
|
||||
|
||||
if ($profiles_id > 0) {
|
||||
self::setProfileRights($profiles_id, READ | UPDATE | CREATE | DELETE);
|
||||
} else {
|
||||
// CLI installation: no session available.
|
||||
// Assign full rights to the Super-Admin profile.
|
||||
global $DB;
|
||||
$sa_iterator = $DB->request([
|
||||
'FROM' => 'glpi_profiles',
|
||||
'WHERE' => [
|
||||
'name' => 'Super-Admin',
|
||||
],
|
||||
'LIMIT' => 1,
|
||||
]);
|
||||
foreach ($sa_iterator as $sa_profile) {
|
||||
$profiles_id = (int) $sa_profile['id'];
|
||||
self::setProfileRights($profiles_id, READ | UPDATE | CREATE | DELETE);
|
||||
}
|
||||
}
|
||||
|
||||
global $DB;
|
||||
@@ -83,7 +98,7 @@ class Profile extends \Profile
|
||||
]);
|
||||
|
||||
foreach ($all_profiles as $profile) {
|
||||
if ($profile['id'] !== $profiles_id) {
|
||||
if ((int) $profile['id'] !== $profiles_id) {
|
||||
$existing = $DB->request([
|
||||
'FROM' => 'glpi_profilerights',
|
||||
'WHERE' => [
|
||||
|
||||
+16
-6
@@ -433,12 +433,14 @@ class Server extends CommonDBTM
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
|
||||
$canUpdate = Session::haveRight(self::$rightname, UPDATE);
|
||||
$canEdit = $ID > 0
|
||||
? Session::haveRight(self::$rightname, UPDATE)
|
||||
: Session::haveRight(self::$rightname, CREATE);
|
||||
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td>" . htmlspecialchars(__('API username', 'urbackup')) . "</td>";
|
||||
echo "<td>";
|
||||
if ($canUpdate) {
|
||||
if ($canEdit) {
|
||||
echo Html::input('api_username', [
|
||||
'value' => $this->fields['api_username'] ?? '',
|
||||
'size' => 40,
|
||||
@@ -451,7 +453,7 @@ class Server extends CommonDBTM
|
||||
|
||||
echo "<td>" . htmlspecialchars(__('API password', 'urbackup')) . "</td>";
|
||||
echo "<td>";
|
||||
if ($canUpdate) {
|
||||
if ($canEdit) {
|
||||
echo "<input type='password' name='api_password' value='" .
|
||||
htmlspecialchars((string) ($this->fields['api_password'] ?? '')) .
|
||||
"' autocomplete='new-password'>";
|
||||
@@ -1126,6 +1128,7 @@ class Server extends CommonDBTM
|
||||
$itemtypes = Config::getEnabledItemtypes();
|
||||
$missingAssets = [];
|
||||
$candidatesByType = [];
|
||||
$totalAssets = 0;
|
||||
|
||||
foreach ($itemtypes as $itemtype) {
|
||||
if (!class_exists($itemtype)) {
|
||||
@@ -1148,6 +1151,7 @@ class Server extends CommonDBTM
|
||||
]);
|
||||
|
||||
foreach ($iterator as $assetRow) {
|
||||
$totalAssets++;
|
||||
$name = (string) ($assetRow['name'] ?? '');
|
||||
if ($name === '') {
|
||||
continue;
|
||||
@@ -1204,9 +1208,15 @@ class Server extends CommonDBTM
|
||||
unset($asset);
|
||||
|
||||
if (count($missingAssets) === 0) {
|
||||
echo '<div class="alert alert-success">';
|
||||
echo htmlspecialchars(__('All assets in this location are linked or already on the UrBackup server.', 'urbackup'));
|
||||
echo '</div>';
|
||||
if ($totalAssets === 0) {
|
||||
echo '<div class="alert alert-info">';
|
||||
echo htmlspecialchars(__('No assets', 'urbackup'));
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<div class="alert alert-success">';
|
||||
echo htmlspecialchars(__('All assets in this location are linked or already on the UrBackup server.', 'urbackup'));
|
||||
echo '</div>';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user