mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-18 15:50:50 +08:00
add event news_created
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Events\NewsCreated;
|
||||
use App\Events\TorrentCreated;
|
||||
use App\Events\UserDestroyed;
|
||||
use App\Events\UserDisabled;
|
||||
@@ -29,6 +30,7 @@ class FireEvent extends Command
|
||||
"user_destroyed" => UserDestroyed::class,
|
||||
"user_disabled" => UserDisabled::class,
|
||||
"user_enabled" => UserEnabled::class,
|
||||
"news_created" => NewsCreated::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
38
app/Events/NewsCreated.php
Normal file
38
app/Events/NewsCreated.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class NewsCreated
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public int $id;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(int $id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new PrivateChannel('channel-name');
|
||||
}
|
||||
}
|
||||
@@ -799,7 +799,7 @@ HTML;
|
||||
if (is_array($arr) && isset($arr['torrent_id'], $arr['pieces_hash'])) {
|
||||
$out[$arr['pieces_hash']] = $arr['torrent_id'];
|
||||
} else {
|
||||
do_log(sprintf("%s, invalid item: %s(%s)", $logPrefix, var_export($item, true), gettype($item)), 'error');
|
||||
do_log(sprintf("%s, invalid item: %s(%s)", $logPrefix, var_export($item, true), gettype($item)));
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.12');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2024-04-01');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2024-04-03');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
@@ -48,8 +48,10 @@ if ($action == 'add')
|
||||
$notify = 'no';
|
||||
sql_query("INSERT INTO news (userid, added, body, title, notify) VALUES (".sqlesc($CURUSER['id']) . ", $added, " . sqlesc($body) . ", " . sqlesc($title) . ", " . sqlesc($notify).")") or sqlerr(__FILE__, __LINE__);
|
||||
$Cache->delete_value('recent_news',true);
|
||||
if (mysql_affected_rows() != 1)
|
||||
stderr($lang_news['std_error'], $lang_news['std_something_weird_happened']);
|
||||
if (mysql_affected_rows() != 1) {
|
||||
stderr($lang_news['std_error'], $lang_news['std_something_weird_happened']);
|
||||
}
|
||||
fire_event("news_created", mysql_insert_id());
|
||||
header("Location: " . get_protocol_prefix() . "$BASEURL/index.php");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user