Skip to content
Merged
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
35 changes: 0 additions & 35 deletions app/Http/Controllers/SubscribeProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@

use App\Models\User;
use CDash\Database;
use CDash\Model\Label;
use CDash\Model\LabelEmail;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\View\View;

final class SubscribeProjectController extends AbstractProjectController
Expand Down Expand Up @@ -81,12 +78,6 @@ public function subscribeProject(): View|RedirectResponse
$EmailSuccess = $_POST['emailsuccess'];
}

// Deals with label email
$LabelEmail = new LabelEmail();
$Label = new Label();
$LabelEmail->ProjectId = $this->project->Id;
$LabelEmail->UserId = $user->id;

if ($UpdateSubscription) {
$emailcategory_update = intval($_POST['emailcategory_update'] ?? 0);
$emailcategory_configure = intval($_POST['emailcategory_configure'] ?? 0);
Expand Down Expand Up @@ -117,11 +108,6 @@ public function subscribeProject(): View|RedirectResponse
]);
}

if (isset($_POST['emaillabels'])) {
$LabelEmail->UpdateLabels($_POST['emaillabels']);
} else {
$LabelEmail->UpdateLabels(null);
}
// Redirect
return redirect('/user');
}
Expand All @@ -131,27 +117,6 @@ public function subscribeProject(): View|RedirectResponse
$xml .= add_XML_value('name', $this->project->Name);
$xml .= add_XML_value('emailbrokensubmission', $this->project->EmailBrokenSubmission);

$labelavailableids = $this->project->GetLabels(7); // Get the labels for the last 7 days
$labelids = $LabelEmail->GetLabels();

$labelavailableids = array_diff($labelavailableids, $labelids);

foreach ($labelavailableids as $labelid) {
$xml .= '<label>';
$xml .= add_XML_value('id', $labelid);
$Label->Id = $labelid;
$xml .= add_XML_value('text', $Label->GetText());
$xml .= '</label>';
}

foreach ($labelids as $labelid) {
$xml .= '<labelemail>';
$xml .= add_XML_value('id', $labelid);
$Label->Id = $labelid;
$xml .= add_XML_value('text', $Label->GetText());
$xml .= '</labelemail>';
}

$xml .= '</project>';

$sql = 'SELECT id, name FROM project';
Expand Down
147 changes: 0 additions & 147 deletions app/cdash/app/Model/LabelEmail.php

This file was deleted.

77 changes: 1 addition & 76 deletions app/cdash/app/Model/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -698,78 +698,6 @@ public function GetNumberOfNotRunTests(string $startUTCdate, string $endUTCdate)
', [(int) $this->Id, $startUTCdate, $endUTCdate])[0]->s;
}

/**
* Get the labels ids for a given project
*
* @return array<int>|false
*/
public function GetLabels($days): array|false
{
$todaytime = time();
$todaytime -= 3600 * 24 * $days;
$today = date(FMT_DATETIMESTD, $todaytime);

$labels = DB::select('
(
SELECT labelid AS id
FROM label2build, build
WHERE
label2build.buildid=build.id
AND build.projectid=?
AND build.starttime>?
) UNION (
SELECT labelid AS id
FROM label2test, build, build2test
WHERE
build2test.buildid=build.id
AND build2test.id=label2test.testid
AND build.projectid=?
AND build.starttime>?
) UNION (
SELECT labelid AS id
FROM build, label2coverage, coverage
WHERE
label2coverage.coverageid=coverage.id
AND coverage.buildid=build.id
AND build.projectid=?
AND build.starttime>?
) UNION (
SELECT labelid AS id
FROM build, buildfailure, label2buildfailure
WHERE
label2buildfailure.buildfailureid=buildfailure.id
AND buildfailure.buildid=build.id
AND build.projectid=?
AND build.starttime>?
) UNION (
SELECT labelid AS id
FROM build, dynamicanalysis, label2dynamicanalysis
WHERE
label2dynamicanalysis.dynamicanalysisid=dynamicanalysis.id
AND dynamicanalysis.buildid=build.id
AND build.projectid=?
AND build.starttime>?
)
', [
intval($this->Id),
$today,
intval($this->Id),
$today,
intval($this->Id),
$today,
intval($this->Id),
$today,
intval($this->Id),
$today,
]);

$labelids = [];
foreach ($labels as $label_array) {
$labelids[] = (int) $label_array->id;
}
return array_unique($labelids);
}

/**
* Return the list of subproject groups that belong to this project.
*
Expand Down Expand Up @@ -965,11 +893,9 @@ public function GetProjectSubscribers(): SubscriberCollection
$sql = '
SELECT
u2p.*,
u.email email,
labelid haslabels
u.email email
FROM user2project u2p
JOIN users u ON u.id = u2p.userid
LEFT JOIN labelemail ON labelemail.userid = u2p.userid
WHERE u2p.projectid = :id
ORDER BY u.email;
';
Expand All @@ -991,7 +917,6 @@ public function GetProjectSubscribers(): SubscriberCollection
$preferences->set(NotifyOn::FIXED, $row->emailsuccess);
$preferences->set(NotifyOn::SITE_MISSING, $row->emailmissingsites);
$preferences->set(NotifyOn::REDUNDANT, $this->EmailRedundantFailures);
$preferences->set(NotifyOn::LABELED, (bool) $row->haslabels);

/** @var Subscriber $subscriber */
$subscriber = $service->make(Subscriber::class, ['preferences' => $preferences]);
Expand Down
31 changes: 0 additions & 31 deletions app/cdash/app/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

use CDash\Database;
use Illuminate\Support\Collection;
use PDO;

/**
* @deprecated 04/22/2025 Used only in the legacy notification system. Use Eloquent for new work.
Expand All @@ -28,24 +27,12 @@ class User
{
public $Id;
public $Email;
public $Password;
public $FirstName;
public $LastName;
public $Institution;
public $Admin;
private $PDO;
private Collection $LabelCollection;

public function __construct()
{
$this->Id = null;
$this->Email = '';
$this->Password = '';
$this->FirstName = '';
$this->LastName = '';
$this->Institution = '';
$this->Admin = 0;
$this->PDO = Database::getInstance();
$this->LabelCollection = collect();
}

Expand All @@ -56,24 +43,6 @@ public function __construct()
*/
public function GetLabelCollection(): Collection
{
if ($this->LabelCollection->isEmpty()) {
$sql = '
SELECT label.id, label.text
FROM labelemail
JOIN label ON label.id = labelemail.labelid
WHERE userid=:user';

$stmt = $this->PDO->prepare($sql);
$stmt->bindParam(':user', $this->Id);
if ($this->PDO->execute($stmt)) {
foreach ($stmt->fetchAll(PDO::FETCH_OBJ) as $row) {
$label = new Label();
$label->Id = $row->id;
$label->Text = $row->text;
$this->AddLabel($label);
}
}
}
return $this->LabelCollection;
}

Expand Down
Loading