Skip to content

Commit 663cc91

Browse files
Remove "site maintainer" project access level (#2834)
CDash previously allowed users to "claim" sites, in addition to a separate "site maintainer" access control level. That site maintainer role was associated with notification options, not an access level with its own designated permissions. Additionally, the difference between users who had claimed sites and users who had the site maintainer role was unclear to users. The site maintainer role is now obsolete and serves no purpose in CDash today.
1 parent 9ea7f25 commit 663cc91

4 files changed

Lines changed: 22 additions & 15 deletions

File tree

app/Models/Project.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ class Project extends Model
107107
];
108108

109109
public const PROJECT_ADMIN = 2;
110-
public const SITE_MAINTAINER = 1;
111110
public const PROJECT_USER = 0;
112111

113112
public const ACCESS_PRIVATE = 0;
@@ -148,17 +147,6 @@ public function administrators(): BelongsToMany
148147
->wherePivot('role', self::PROJECT_ADMIN);
149148
}
150149

151-
/**
152-
* Get the users who maintain a site for this project
153-
*
154-
* @return BelongsToMany<User>
155-
*/
156-
public function siteMaintainers(): BelongsToMany
157-
{
158-
return $this->belongsToMany(User::class, 'user2project', 'projectid', 'userid')
159-
->wherePivot('role', self::SITE_MAINTAINER);
160-
}
161-
162150
/**
163151
* Get the projects available to the specified user, or the current user if no user specified.
164152
* Available as a query builder function: Project::forUser(?User)->...

app/cdash/app/Model/Project.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
class Project
4646
{
4747
public const PROJECT_ADMIN = 2;
48-
public const SITE_MAINTAINER = 1;
4948
public const PROJECT_USER = 0;
5049

5150
public const ACCESS_PRIVATE = 0;

app/cdash/include/common.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,8 @@ function get_dashboard_JSON($projectname, $date, &$response)
661661
$userid = Auth::id();
662662
if ($userid) {
663663
$project = App\Models\Project::findOrFail((int) $project->Id);
664-
$response['projectrole'] = $project->users()->withPivot('role')->find((int) $userid)->pivot->role ?? 0;
665-
if ($response['projectrole'] > Project::SITE_MAINTAINER) {
664+
$response['projectrole'] = (int) ($project->users()->withPivot('role')->find((int) $userid)->pivot->role ?? 0);
665+
if ($response['projectrole'] === Project::PROJECT_ADMIN) {
666666
$response['user']['admin'] = 1;
667667
}
668668
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Support\Facades\DB;
5+
6+
return new class extends Migration {
7+
public function up(): void
8+
{
9+
DB::update('
10+
UPDATE user2project
11+
SET role=0
12+
WHERE role=1
13+
');
14+
}
15+
16+
public function down(): void
17+
{
18+
// This migration is irreversible
19+
}
20+
};

0 commit comments

Comments
 (0)