-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Not yested covered with testing. Changes database columns for more presentable names and for future use to connect additional model types. For #4316
- Loading branch information
1 parent
dd251d9
commit 3946158
Showing
10 changed files
with
165 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace BookStack\Activity\Controllers; | ||
|
||
use BookStack\Activity\Models\Activity; | ||
use BookStack\Http\ApiController; | ||
|
||
class AuditLogApiController extends ApiController | ||
{ | ||
/** | ||
* Get a listing of audit log events in the system. | ||
* The loggable relation fields currently only relates to core | ||
* content types (page, book, bookshelf, chapter) but this may be | ||
* used more in the future across other types. | ||
* Requires permission to manage both users and system settings. | ||
*/ | ||
public function list() | ||
{ | ||
$this->checkPermission('settings-manage'); | ||
$this->checkPermission('users-manage'); | ||
|
||
$query = Activity::query()->with(['user']); | ||
|
||
return $this->apiListingResponse($query, [ | ||
'id', 'type', 'detail', 'user_id', 'loggable_id', 'loggable_type', 'ip', 'created_at', | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
database/migrations/2024_05_04_154409_rename_activity_relation_columns.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('activities', function (Blueprint $table) { | ||
$table->renameColumn('entity_id', 'loggable_id'); | ||
$table->renameColumn('entity_type', 'loggable_type'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('activities', function (Blueprint $table) { | ||
$table->renameColumn('loggable_id', 'entity_id'); | ||
$table->renameColumn('loggable_type', 'entity_type'); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"id": 1, | ||
"type": "bookshelf_create", | ||
"detail": "", | ||
"user_id": 1, | ||
"loggable_id": 1, | ||
"loggable_type": "bookshelf", | ||
"ip": "124.4.x.x", | ||
"created_at": "2021-09-29T12:32:02.000000Z", | ||
"user": { | ||
"id": 1, | ||
"name": "Admins", | ||
"slug": "admins" | ||
} | ||
}, | ||
{ | ||
"id": 2, | ||
"type": "auth_login", | ||
"detail": "standard; (1) Admin", | ||
"user_id": 1, | ||
"loggable_id": null, | ||
"loggable_type": null, | ||
"ip": "127.0.x.x", | ||
"created_at": "2021-09-29T12:32:04.000000Z", | ||
"user": { | ||
"id": 1, | ||
"name": "Admins", | ||
"slug": "admins" | ||
} | ||
}, | ||
{ | ||
"id": 3, | ||
"type": "bookshelf_update", | ||
"detail": "", | ||
"user_id": 1, | ||
"loggable_id": 1, | ||
"loggable_type": "bookshelf", | ||
"ip": "127.0.x.x", | ||
"created_at": "2021-09-29T12:32:07.000000Z", | ||
"user": { | ||
"id": 1, | ||
"name": "Admins", | ||
"slug": "admins" | ||
} | ||
}, | ||
{ | ||
"id": 4, | ||
"type": "page_create", | ||
"detail": "", | ||
"user_id": 1, | ||
"loggable_id": 1, | ||
"loggable_type": "page", | ||
"ip": "127.0.x.x", | ||
"created_at": "2021-09-29T12:32:13.000000Z", | ||
"user": { | ||
"id": 1, | ||
"name": "Admins", | ||
"slug": "admins" | ||
} | ||
}, | ||
{ | ||
"id": 5, | ||
"type": "page_update", | ||
"detail": "", | ||
"user_id": 1, | ||
"loggable_id": 1, | ||
"loggable_type": "page", | ||
"ip": "127.0.x.x", | ||
"created_at": "2021-09-29T12:37:27.000000Z", | ||
"user": { | ||
"id": 1, | ||
"name": "Admins", | ||
"slug": "admins" | ||
} | ||
} | ||
], | ||
"total": 6088 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters