refactor model event again

This commit is contained in:
xiaomlove
2024-04-26 03:21:35 +08:00
parent ae29693549
commit 8a44a0a269
12 changed files with 136 additions and 31 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ if ($action == 'add')
if (mysql_affected_rows() != 1) {
stderr($lang_news['std_error'], $lang_news['std_something_weird_happened']);
}
fire_event("news_created", mysql_insert_id());
fire_event("news_created", \App\Models\News::query()->find(mysql_insert_id()));
header("Location: " . get_protocol_prefix() . "$BASEURL/index.php");
}
+2 -2
View File
@@ -30,7 +30,7 @@ $row = mysql_fetch_array($res);
$torrentAddedTimeString = $row['added'];
if (!$row)
die();
$torrentOld = \App\Models\Torrent::query()->find($id);
if ($CURUSER["id"] != $row["owner"] && !user_can('torrentmanage'))
bark($lang_takeedit['std_not_owner']);
$oldcatmode = get_single_value("categories","mode","WHERE id=".sqlesc($row['category']));
@@ -232,7 +232,7 @@ if (user_can('torrent-set-price') && $paidTorrentEnabled) {
$sql = "UPDATE torrents SET " . join(",", $updateset) . " WHERE id = $id";
do_log("[UPDATE_TORRENT]: $sql");
$affectedRows = sql_query($sql) or sqlerr(__FILE__, __LINE__);
fire_event("torrent_updated", $id);
fire_event("torrent_updated", \App\Models\Torrent::query()->find($id), $torrentOld);
$dateTimeStringNow = date("Y-m-d H:i:s");
/**
+1 -1
View File
@@ -448,7 +448,7 @@ $meiliSearch = new \App\Repositories\MeiliSearchRepository();
$meiliSearch->doImportFromDatabase($id);
//trigger event
fire_event("torrent_created", $id);
fire_event("torrent_created", \App\Models\Torrent::query()->find($id));
//===notify people who voted on offer thanks CoLdFuSiOn :)
if ($is_offer)