mirror of
https://github.com/OPSnet/Gazelle.git
synced 2026-01-16 18:04:34 -05:00
remove obsolete request_update report
This commit is contained in:
@@ -6,7 +6,7 @@ class Report extends \Gazelle\BaseManager {
|
||||
protected const ID_KEY = 'zz_r_%d';
|
||||
|
||||
public function __construct(
|
||||
protected \Gazelle\Manager\User $userMan,
|
||||
protected User $userMan = new User(),
|
||||
) {}
|
||||
|
||||
public function create(\Gazelle\User $user, int $id, string $type, string $reason): \Gazelle\Report {
|
||||
@@ -17,9 +17,6 @@ class Report extends \Gazelle\BaseManager {
|
||||
", $user->id, $id, $type, $reason
|
||||
);
|
||||
$id = self::$db->inserted_id();
|
||||
if ($type == 'request_update') {
|
||||
self::$cache->decrement('num_update_reports');
|
||||
}
|
||||
self::$cache->delete_value('num_other_reports');
|
||||
return $this->findById($id);
|
||||
}
|
||||
@@ -37,7 +34,7 @@ class Report extends \Gazelle\BaseManager {
|
||||
}
|
||||
}
|
||||
return $reportId
|
||||
? (new \Gazelle\Report($reportId))->setUserManager($this->userMan)
|
||||
? new \Gazelle\Report($reportId)
|
||||
: null;
|
||||
}
|
||||
|
||||
@@ -56,11 +53,11 @@ class Report extends \Gazelle\BaseManager {
|
||||
|
||||
public function decorate(
|
||||
array $idList,
|
||||
\Gazelle\Manager\Collage $collageMan,
|
||||
\Gazelle\Manager\Comment $commentMan,
|
||||
\Gazelle\Manager\ForumThread $threadMan,
|
||||
\Gazelle\Manager\ForumPost $postMan,
|
||||
\Gazelle\Manager\Request $requestMan,
|
||||
Collage $collageMan = new Collage(),
|
||||
Comment $commentMan = new Comment(),
|
||||
ForumThread $threadMan = new ForumThread(),
|
||||
ForumPost $postMan = new ForumPost(),
|
||||
Request $requestMan = new Request(),
|
||||
): array {
|
||||
$list = [];
|
||||
foreach ($idList as $id) {
|
||||
@@ -79,7 +76,6 @@ class Report extends \Gazelle\BaseManager {
|
||||
];
|
||||
break;
|
||||
case 'request':
|
||||
case 'request_update':
|
||||
$context = [
|
||||
'label' => 'request',
|
||||
'subject' => $requestMan->findById($report->subjectId()),
|
||||
|
||||
@@ -5,7 +5,12 @@ namespace Gazelle;
|
||||
class Report extends BaseObject {
|
||||
final public const tableName = 'reports';
|
||||
|
||||
protected Manager\User $userMan;
|
||||
public function __construct(
|
||||
int $id,
|
||||
protected Manager\User $userMan = new Manager\User(),
|
||||
) {
|
||||
parent::__construct($id);
|
||||
}
|
||||
|
||||
public function flush(): static {
|
||||
$this->info = [];
|
||||
@@ -13,18 +18,13 @@ class Report extends BaseObject {
|
||||
}
|
||||
|
||||
public function link(): string {
|
||||
return sprintf('<a href="%s">Report #%d</a>', $this->url(), $this->id());
|
||||
return sprintf('<a href="%s">Report #%d</a>', $this->url(), $this->id);
|
||||
}
|
||||
|
||||
public function location(): string {
|
||||
return "reports.php?id={$this->id}#report{$this->id}";
|
||||
}
|
||||
|
||||
public function setUserManager(Manager\User $userMan): static {
|
||||
$this->userMan = $userMan;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function info(): array {
|
||||
if (isset($this->info) && !empty($this->info)) {
|
||||
return $this->info;
|
||||
@@ -96,7 +96,7 @@ class Report extends BaseObject {
|
||||
*/
|
||||
public function claim(?User $user): int {
|
||||
return (int)$this
|
||||
->setField('ClaimerID', (int)$user?->id())
|
||||
->setField('ClaimerID', (int)$user?->id)
|
||||
->setField('Status', 'InProgress')
|
||||
->modify();
|
||||
}
|
||||
@@ -107,20 +107,17 @@ class Report extends BaseObject {
|
||||
}
|
||||
|
||||
public function resolve(User $user): int {
|
||||
$affected = $this
|
||||
$affected = (int)$this
|
||||
->setField('Status', 'Resolved')
|
||||
->setField('ResolverID', $user->id)
|
||||
->setFieldNow('ResolvedTime')
|
||||
->modify();
|
||||
|
||||
self::$cache->delete_value('num_other_reports');
|
||||
if ($this->subjectType() == 'request_update') {
|
||||
self::$cache->decrement('num_update_reports');
|
||||
} elseif (in_array($this->subjectType(), ['comment', 'post', 'thread'])) {
|
||||
if (in_array($this->subjectType(), ['comment', 'post', 'thread'])) {
|
||||
self::$cache->decrement('num_forum_reports');
|
||||
}
|
||||
|
||||
return (int)$affected;
|
||||
return $affected;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,15 +3,13 @@
|
||||
namespace Gazelle\Report;
|
||||
|
||||
class Request extends AbstractReport {
|
||||
protected bool $isUpdate = false;
|
||||
|
||||
public function __construct(
|
||||
protected readonly int $reportId,
|
||||
protected readonly \Gazelle\Request $subject,
|
||||
) {}
|
||||
|
||||
public function template(): string {
|
||||
return $this->isUpdate ? 'report/request-update.twig' : 'report/request.twig';
|
||||
return 'report/request.twig';
|
||||
}
|
||||
|
||||
public function bbLink(): string {
|
||||
@@ -26,13 +24,7 @@ class Request extends AbstractReport {
|
||||
return $this->subject->title();
|
||||
}
|
||||
|
||||
public function isUpdate(bool $isUpdate): static {
|
||||
$this->isUpdate = $isUpdate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function needReason(): bool {
|
||||
/* Don't need to show the report reason for request updates */
|
||||
return !$this->isUpdate;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Gazelle;
|
||||
if (!$Viewer->permitted('site_moderate_forums')) {
|
||||
json_error('forbidden');
|
||||
}
|
||||
$report = (new Manager\Report(new Manager\User()))->findById((int)($_POST['id'] ?? 0));
|
||||
$report = new Manager\Report()->findById((int)($_POST['id'] ?? 0));
|
||||
if (is_null($report)) {
|
||||
json_error('bad post id');
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ if (!$Viewer->permittedAny('admin_reports', 'site_moderate_forums')) {
|
||||
json_error('bad parameters');
|
||||
}
|
||||
|
||||
$report = (new Manager\Report(new Manager\User()))->findById((int)($_POST['id'] ?? 0));
|
||||
$report = new Manager\Report()->findById((int)($_POST['id'] ?? 0));
|
||||
if (is_null($report)) {
|
||||
json_error('no report id');
|
||||
}
|
||||
|
||||
@@ -10,11 +10,15 @@ if (!$Viewer->permittedAny('admin_reports', 'site_moderate_forums')) {
|
||||
}
|
||||
authorize();
|
||||
|
||||
$report = (new Manager\Report(new Manager\User()))->findById((int)($_POST['reportid'] ?? 0));
|
||||
$report = new Manager\Report()->findById((int)($_POST['reportid'] ?? 0));
|
||||
if (is_null($report)) {
|
||||
json_error('no report id');
|
||||
}
|
||||
if (!$Viewer->permitted('admin_reports') && !in_array($report->subjectType(), ['comment', 'post', 'thread'])) {
|
||||
if (
|
||||
!$Viewer->permitted('admin_reports')
|
||||
&&
|
||||
!in_array($report->subjectType(), ['comment', 'post', 'thread'])
|
||||
) {
|
||||
json_error('forbidden ' . $report->subjectType());
|
||||
}
|
||||
$report->resolve($Viewer);
|
||||
|
||||
@@ -9,7 +9,7 @@ if (!$Viewer->permitted('site_moderate_forums') || empty($_POST['remove'])) {
|
||||
json_error('bad parameters');
|
||||
}
|
||||
|
||||
$report = (new Manager\Report(new Manager\User()))->findById((int)($_POST['id'] ?? 0));
|
||||
$report = new Manager\Report()->findById((int)($_POST['id'] ?? 0));
|
||||
if (is_null($report)) {
|
||||
json_error('no report id');
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ $reportId = (int)($_GET['reportid'] ?? 0);
|
||||
$id = (int)($_GET['thingid'] ?? 0);
|
||||
$type = $_GET['type'] ?? null;
|
||||
if (!$reportId || !$id || is_null($type)) {
|
||||
Error403::error();
|
||||
Error400::error();
|
||||
}
|
||||
|
||||
require_once 'array.php';
|
||||
@@ -23,18 +23,18 @@ $reportType = $Types[$type];
|
||||
|
||||
$user = null;
|
||||
if (!isset($Return)) {
|
||||
$user = (new Manager\User())->findById((int)($_GET['toid'] ?? 0));
|
||||
$user = new Manager\User()->findById((int)($_GET['toid'] ?? 0));
|
||||
if (is_null($user)) {
|
||||
Error404::error();
|
||||
}
|
||||
if ($user->id === $Viewer->id()) {
|
||||
if ($user->id === $Viewer->id) {
|
||||
Error400::error("You cannot start a conversation with yourself!");
|
||||
}
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'user':
|
||||
$reported = (new Manager\User())->findById($id);
|
||||
$reported = new Manager\User()->findById($id);
|
||||
if (is_null($reported)) {
|
||||
Error404::error();
|
||||
}
|
||||
@@ -42,8 +42,7 @@ switch ($type) {
|
||||
break;
|
||||
|
||||
case 'request':
|
||||
case 'request_update':
|
||||
$request = (new Manager\Request())->findById($id);
|
||||
$request = new Manager\Request()->findById($id);
|
||||
if (is_null($request)) {
|
||||
Error404::error();
|
||||
}
|
||||
@@ -51,7 +50,7 @@ switch ($type) {
|
||||
break;
|
||||
|
||||
case 'collage':
|
||||
$collage = (new Manager\Collage())->findById($id);
|
||||
$collage = new Manager\Collage()->findById($id);
|
||||
if (is_null($collage)) {
|
||||
Error404::error();
|
||||
}
|
||||
@@ -59,7 +58,7 @@ switch ($type) {
|
||||
break;
|
||||
|
||||
case 'thread':
|
||||
$thread = (new Manager\ForumThread())->findById($id);
|
||||
$thread = new Manager\ForumThread()->findById($id);
|
||||
if (is_null($thread)) {
|
||||
Error404::error();
|
||||
}
|
||||
@@ -70,7 +69,7 @@ switch ($type) {
|
||||
break;
|
||||
|
||||
case 'post':
|
||||
$post = (new Manager\ForumPost())->findById($id);
|
||||
$post = new Manager\ForumPost()->findById($id);
|
||||
if (is_null($post)) {
|
||||
Error404::error();
|
||||
}
|
||||
@@ -81,11 +80,11 @@ switch ($type) {
|
||||
break;
|
||||
|
||||
case 'comment':
|
||||
$comment = (new Manager\Comment())->findById($id);
|
||||
$comment = new Manager\Comment()->findById($id);
|
||||
if (is_null($comment)) {
|
||||
Error404::error();
|
||||
}
|
||||
$report = (new Report\Comment($reportId, $comment))->setContext($reportType['title']);
|
||||
$report = new Report\Comment($reportId, $comment)->setContext($reportType['title']);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -7,8 +7,7 @@ namespace Gazelle;
|
||||
|
||||
authorize();
|
||||
|
||||
$userMan = new Manager\User();
|
||||
$recipient = $userMan->findById((int)($_POST['toid'] ?? 0));
|
||||
$recipient = new Manager\User()->findById((int)($_POST['toid'] ?? 0));
|
||||
if (is_null($recipient)) {
|
||||
Error404::error("No such recipient!");
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ $reportType = $Types[$type];
|
||||
|
||||
switch ($type) {
|
||||
case 'user':
|
||||
$user = (new Manager\User())->findById($id);
|
||||
$user = new Manager\User()->findById($id);
|
||||
if (is_null($user)) {
|
||||
Error404::error();
|
||||
}
|
||||
@@ -28,26 +28,15 @@ switch ($type) {
|
||||
break;
|
||||
|
||||
case 'request':
|
||||
$request = (new Manager\Request())->findById($id);
|
||||
$request = new Manager\Request()->findById($id);
|
||||
if (is_null($request)) {
|
||||
Error404::error();
|
||||
}
|
||||
$report = new Report\Request($id, $request);
|
||||
break;
|
||||
|
||||
case 'request_update':
|
||||
$request = (new Manager\Request())->findById($id);
|
||||
if (is_null($request)) {
|
||||
Error404::error();
|
||||
}
|
||||
if ($request->isFilled() || $request->categoryName() != 'Music' || $request->year() != 0) {
|
||||
Error403::error();
|
||||
}
|
||||
$report = (new Report\Request($id, $request))->isUpdate(true);
|
||||
break;
|
||||
|
||||
case 'collage':
|
||||
$collage = (new Manager\Collage())->findById($id);
|
||||
$collage = new Manager\Collage()->findById($id);
|
||||
if (is_null($collage)) {
|
||||
Error404::error();
|
||||
}
|
||||
@@ -55,7 +44,7 @@ switch ($type) {
|
||||
break;
|
||||
|
||||
case 'thread':
|
||||
$thread = (new Manager\ForumThread())->findById($id);
|
||||
$thread = new Manager\ForumThread()->findById($id);
|
||||
if (is_null($thread)) {
|
||||
Error404::error();
|
||||
}
|
||||
@@ -66,7 +55,7 @@ switch ($type) {
|
||||
break;
|
||||
|
||||
case 'post':
|
||||
$post = (new Manager\ForumPost())->findById($id);
|
||||
$post = new Manager\ForumPost()->findById($id);
|
||||
if (is_null($post)) {
|
||||
Error404::error();
|
||||
}
|
||||
@@ -77,11 +66,11 @@ switch ($type) {
|
||||
break;
|
||||
|
||||
case 'comment':
|
||||
$comment = (new Manager\Comment())->findById($id);
|
||||
$comment = new Manager\Comment()->findById($id);
|
||||
if (is_null($comment)) {
|
||||
Error404::error();
|
||||
}
|
||||
$report = (new Report\Comment($id, $comment))->setContext($reportType['title']);
|
||||
$report = new Report\Comment($id, $comment)->setContext($reportType['title']);
|
||||
break;
|
||||
default:
|
||||
Error400::error('Unknown report target');
|
||||
@@ -89,7 +78,7 @@ switch ($type) {
|
||||
|
||||
echo $Twig->render('report/create.twig', [
|
||||
'id' => $id,
|
||||
'release' => (new ReleaseType())->list(),
|
||||
'release' => new ReleaseType()->list(),
|
||||
'report' => $report,
|
||||
'report_type' => $reportType,
|
||||
'type' => $type,
|
||||
|
||||
@@ -10,46 +10,31 @@ use Gazelle\Util\Irc;
|
||||
authorize();
|
||||
|
||||
$subjectId = (int)$_POST['id'];
|
||||
if (!$subjectId || empty($_POST['type']) || ($_POST['type'] !== 'request_update' && empty($_POST['reason']))) {
|
||||
Error404::error();
|
||||
if (!$subjectId || empty($_POST['type'])) {
|
||||
Error400::error();
|
||||
}
|
||||
|
||||
require_once 'array.php';
|
||||
/** @var array $Types */
|
||||
if (!array_key_exists($_POST['type'], $Types)) {
|
||||
Error403::error();
|
||||
Error400::error();
|
||||
}
|
||||
$subjectType = (string)$_POST['type'];
|
||||
|
||||
if ($subjectType !== 'request_update') {
|
||||
$reason = $_POST['reason'];
|
||||
} else {
|
||||
$year = trim($_POST['year']);
|
||||
if (empty($year) || !is_number($year)) {
|
||||
Error400::error('Year must be specified.');
|
||||
}
|
||||
$reason = "[b]Year[/b]: {$year}.\n\n";
|
||||
// If the release type is somehow invalid, return "Not given"; otherwise, return the release type.
|
||||
$reason .= '[b]Release type[/b]: ' . ((empty($_POST['releasetype']) || !is_number($_POST['releasetype']) || $_POST['releasetype'] == '0')
|
||||
? 'Not given' : (new ReleaseType())->findNameById((int)$_POST['releasetype'])) . " . \n\n";
|
||||
$reason .= '[b]Additional comments[/b]: ' . $_POST['comment'];
|
||||
}
|
||||
|
||||
$location = match ($subjectType) {
|
||||
'collage' => "collages.php?id=$subjectId",
|
||||
'comment' => "comments.php?action=jump&postid=$subjectId",
|
||||
'post' => (new Manager\ForumPost())->findById($subjectId)?->location(), // could be null
|
||||
'request',
|
||||
'request_update' => "requests.php?action=view&id=$subjectId",
|
||||
'thread' => "forums.php?action=viewthread&threadid=$subjectId",
|
||||
'user' => "user.php?id=$subjectId",
|
||||
default => null, // definitely a problem
|
||||
'collage' => "collages.php?id=$subjectId",
|
||||
'comment' => "comments.php?action=jump&postid=$subjectId",
|
||||
'post' => new Manager\ForumPost()->findById($subjectId)?->location(), // could be null
|
||||
'request' => "requests.php?action=view&id=$subjectId",
|
||||
'thread' => "forums.php?action=viewthread&threadid=$subjectId",
|
||||
'user' => "user.php?id=$subjectId",
|
||||
default => null, // definitely a problem
|
||||
};
|
||||
if (is_null($location)) {
|
||||
Error400::error("Cannot generate a link to the reported item '$subjectType'");
|
||||
}
|
||||
|
||||
$report = (new Manager\Report(new Manager\User()))->create($Viewer, $subjectId, $subjectType, $reason);
|
||||
$reason = "[b]comments[/b]: {$_POST['reason']}";
|
||||
$report = new Manager\Report()->create($Viewer, $subjectId, $subjectType, $reason);
|
||||
if (in_array($report->subjectType(), ['user', 'comment'])) {
|
||||
Irc::sendMessage(
|
||||
IRC_CHAN_MOD,
|
||||
|
||||
@@ -6,8 +6,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Gazelle;
|
||||
|
||||
use Gazelle\Enum\SearchReportOrder;
|
||||
|
||||
if (!$Viewer->permittedAny('admin_reports', 'site_moderate_forums')) {
|
||||
Error403::error();
|
||||
}
|
||||
@@ -53,10 +51,10 @@ if (isset($_REQUEST['id'])) {
|
||||
$paginator->setParam('view', 'old');
|
||||
$paginator->setParam("order", $_REQUEST['order']);
|
||||
$search->setOrder(match ($_REQUEST['order']) {
|
||||
'resolved-asc' => SearchReportOrder::resolvedAsc,
|
||||
'resolved-desc' => SearchReportOrder::resolvedDesc,
|
||||
'created-asc' => SearchReportOrder::createdAsc,
|
||||
default => SearchReportOrder::createdDesc,
|
||||
'resolved-asc' => Enum\SearchReportOrder::resolvedAsc,
|
||||
'resolved-desc' => Enum\SearchReportOrder::resolvedDesc,
|
||||
'created-asc' => Enum\SearchReportOrder::createdAsc,
|
||||
default => Enum\SearchReportOrder::createdDesc,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -64,13 +62,8 @@ if (isset($_REQUEST['id'])) {
|
||||
$paginator->setTotal($search->total());
|
||||
|
||||
echo $Twig->render('report/index.twig', [
|
||||
'list' => (new Manager\Report(new Manager\User()))->decorate(
|
||||
'list' => new Manager\Report()->decorate(
|
||||
$search->page($paginator->limit(), $paginator->offset()),
|
||||
new Manager\Collage(),
|
||||
new Manager\Comment(),
|
||||
new Manager\ForumThread(),
|
||||
new Manager\ForumPost(),
|
||||
new Manager\Request(),
|
||||
),
|
||||
'paginator' => $paginator,
|
||||
'type' => $Types,
|
||||
|
||||
@@ -10,11 +10,15 @@ if (!$Viewer->permittedAny('admin_reports', 'site_moderate_forums')) {
|
||||
}
|
||||
authorize();
|
||||
|
||||
$report = (new Manager\Report(new Manager\User()))->findById((int)($_POST['id'] ?? 0));
|
||||
$report = new Manager\Report()->findById((int)($_POST['id'] ?? 0));
|
||||
if (is_null($report)) {
|
||||
json_error('no report id');
|
||||
}
|
||||
if (!$Viewer->permitted('admin_reports') && !in_array($report->subjectType(), ['comment', 'post', 'thread'])) {
|
||||
if (
|
||||
!$Viewer->permitted('admin_reports')
|
||||
&&
|
||||
!in_array($report->subjectType(), ['comment', 'post', 'thread'])
|
||||
) {
|
||||
Error403::error('forbidden ' . $report->subjectType());
|
||||
}
|
||||
$report->resolve($Viewer);
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
{% from 'macro/form.twig' import selected %}
|
||||
<p>You are reporting the request:</p>
|
||||
<table>
|
||||
<tr class="colhead">
|
||||
<td>Title</td>
|
||||
<td>Description</td>
|
||||
<td>Filled?</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{ subject.title }}</td>
|
||||
<td>{{ subject.description|bb_format }}</td>
|
||||
<td><strong>{% if subject.isFilled %}Yes{% else %}No{% endif %}</strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<div class="box pad center">
|
||||
<p><strong>It will greatly increase the turnover rate of the updates if you can fill in as much of the following details as possible.</strong></p>
|
||||
<form class="create_form" id="report_form" name="report" action="" method="post">
|
||||
<input type="hidden" name="action" value="takereport" />
|
||||
<input type="hidden" name="auth" value="{{ viewer.auth }}" />
|
||||
<input type="hidden" name="id" value="{{ subject.id }}" />
|
||||
<input type="hidden" name="type" value="{{ type }}" />
|
||||
<table class="layout">
|
||||
<tr>
|
||||
<td class="label">Year (required)</td>
|
||||
<td>
|
||||
<input type="text" size="4" name="year" class="required" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Release type</td>
|
||||
<td>
|
||||
<select id="releasetype" name="releasetype">
|
||||
<option value="0">---</option>
|
||||
{% for id, name in release %}
|
||||
<option value="{{ id }}"{{ selected(id == subject.releaseType) }}>{{ name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Comment</td>
|
||||
<td>
|
||||
<textarea rows="8" cols="80" name="comment" class="required"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<br />
|
||||
<input type="submit" value="Create report" />
|
||||
</form>
|
||||
</div>
|
||||
@@ -24,11 +24,7 @@
|
||||
<a href="reports.php?action=report&type=request&id={{ request.id }}" class="brackets">Report request</a>
|
||||
{% if not request.isFilled %}
|
||||
<a href="upload.php?requestid={{ request.id }}{% if request.tgroupId %}&groupid={{ request.tgroupId }}{% endif %}" class="brackets">Upload request</a>
|
||||
{% if request.categoryName == 'Music' and request.year == 0 %}
|
||||
<a href="reports.php?action=report&type=request_update&id={{ request.id }}" class="brackets">Request update</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if request.categoryName == 'Music' %}
|
||||
<a href="https://www.worldcat.org/search?qt=worldcat_org_all&q={{ request.urlencodeArtist }}%20{{ request.urlencodeTitle }}" class="brackets">Find in library</a>
|
||||
<a href="https://www.discogs.com/search/?q={{ request.urlencodeArtist }}+{{ request.urlencodeTitle }}&type=release" class="brackets">Find on Discogs</a>
|
||||
|
||||
@@ -211,7 +211,7 @@ class RequestTest extends TestCase {
|
||||
$this->request = $requestMan->create(
|
||||
user: $admin,
|
||||
bounty: $bounty,
|
||||
categoryId: (new Manager\Category())->findIdByName('Music'),
|
||||
categoryId: new Manager\Category()->findIdByName('Music'),
|
||||
year: 2018,
|
||||
title: $title,
|
||||
image: '',
|
||||
@@ -295,7 +295,7 @@ class RequestTest extends TestCase {
|
||||
title: 'Deluxe Edition',
|
||||
);
|
||||
$torrentId = current($this->tgroup->torrentIdList());
|
||||
$torrent = (new Manager\Torrent())->findById($torrentId);
|
||||
$torrent = new Manager\Torrent()->findById($torrentId);
|
||||
$this->assertInstanceOf(Torrent::class, $torrent, 'request-torrent-filler');
|
||||
|
||||
$this->assertEquals(1, $this->request->fill($user, $torrent), 'request-fill');
|
||||
@@ -453,7 +453,7 @@ class RequestTest extends TestCase {
|
||||
$this->request = $requestMan->create(
|
||||
user: $user,
|
||||
bounty: $bounty,
|
||||
categoryId: (new Manager\Category())->findIdByName('Music'),
|
||||
categoryId: new Manager\Category()->findIdByName('Music'),
|
||||
year: 2018,
|
||||
title: $title,
|
||||
image: '',
|
||||
@@ -490,7 +490,7 @@ class RequestTest extends TestCase {
|
||||
$this->request = $manager->create(
|
||||
user: $this->userList['admin'],
|
||||
bounty: 1024 ** 2 * REQUEST_MIN,
|
||||
categoryId: (new Manager\Category())->findIdByName('Music'),
|
||||
categoryId: new Manager\Category()->findIdByName('Music'),
|
||||
year: (int)date('Y'),
|
||||
title: 'phpunit request bookmark',
|
||||
image: '',
|
||||
@@ -510,9 +510,9 @@ class RequestTest extends TestCase {
|
||||
$this->userList['user'],
|
||||
new Manager\Artist(),
|
||||
);
|
||||
(new Manager\Tag())->softCreate('classical.era', $this->userList['admin'])->addRequest($this->request);
|
||||
new Manager\Tag()->softCreate('classical.era', $this->userList['admin'])->addRequest($this->request);
|
||||
$this->assertTrue(
|
||||
(new User\Bookmark($this->userList['user']))->create('request', $this->request->id),
|
||||
new User\Bookmark($this->userList['user'])->create('request', $this->request->id),
|
||||
'request-bookmark-add'
|
||||
);
|
||||
$this->assertEquals(1, $this->request->updateBookmarkStats(), 'request-bookmark-update');
|
||||
@@ -530,12 +530,13 @@ class RequestTest extends TestCase {
|
||||
$this->userList['user'],
|
||||
new Manager\Artist(),
|
||||
);
|
||||
(new Manager\Tag())
|
||||
new Manager\Tag()
|
||||
->create('phpunit.' . randomString(6), $this->userList['admin'])
|
||||
->addRequest($this->request);
|
||||
|
||||
$title = 'phpunit request report';
|
||||
$report = (new Manager\Report(new Manager\User()))->create(
|
||||
$reportMan = new Manager\Report();
|
||||
$report = $reportMan->create(
|
||||
$this->userList['user'], $this->request->id, 'request', $title
|
||||
);
|
||||
$this->assertEquals('phpunit request report', $report->reason(), 'request-report-reason');
|
||||
@@ -547,6 +548,24 @@ class RequestTest extends TestCase {
|
||||
$requestReport->bbLink(),
|
||||
'request-report-bb-link'
|
||||
);
|
||||
|
||||
$detail = $reportMan->decorate([$report->id])[0];
|
||||
$this->assertEquals(
|
||||
["label", "subject", "report"],
|
||||
array_keys($detail),
|
||||
'request-report-decorate-keys',
|
||||
);
|
||||
$this->assertEquals(
|
||||
$this->request->id,
|
||||
$detail['subject']->id,
|
||||
'request-report-decorate-subject'
|
||||
);
|
||||
$this->assertEquals(
|
||||
$report->id,
|
||||
$detail['report']->id,
|
||||
'request-report-decorate-report'
|
||||
);
|
||||
|
||||
$report->remove();
|
||||
}
|
||||
|
||||
@@ -559,7 +578,7 @@ class RequestTest extends TestCase {
|
||||
$this->userList['user'],
|
||||
$artistMan,
|
||||
);
|
||||
(new Manager\Tag())
|
||||
new Manager\Tag()
|
||||
->create('phpunit.' . randomString(6), $this->userList['admin'])
|
||||
->addRequest($this->request);
|
||||
$this->assertInstanceOf(Request::class, $this->request, 'request-json-create');
|
||||
@@ -718,7 +737,7 @@ class RequestTest extends TestCase {
|
||||
$this->assertStringContainsString(
|
||||
"<span style=\"font-weight: bold;\">Requests (1)</span>",
|
||||
Util\Twig::factory(new Manager\User())->render('request/torrent.twig', [
|
||||
'list' => (new Manager\Request())->findByTGroup($this->tgroup),
|
||||
'list' => new Manager\Request()->findByTGroup($this->tgroup),
|
||||
]),
|
||||
'render-tgroup-request-list',
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user