/
delete_all.php
54 lines (43 loc) · 1.62 KB
/
delete_all.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace Concrete\Controller\Dialog\Logs;
use Concrete\Controller\Backend\UserInterface as BackendInterfaceController;
use Concrete\Core\Database\Connection\Connection;
use Concrete\Core\Http\ResponseFactory;
use Concrete\Core\Page\EditResponse;
use Concrete\Core\Page\Page;
use Concrete\Core\Permission\Checker as Permissions;
use Concrete\Core\Permission\Key\Key;
use Concrete\Core\Support\Facade\Application;
use Concrete\Core\User\User;
class DeleteAll extends BackendInterfaceController
{
protected $viewPath = '/dialogs/logs/delete_all';
protected $controllerActionPath = '/ccm/system/dialogs/logs/delete_all';
protected function canAccess()
{
$key = Key::getByHandle("delete_log_entries");
return $key->validate();
}
public function view()
{
}
public function submit()
{
/** @var ResponseFactory $responseFactory */
$responseFactory = $this->app->make(ResponseFactory::class);
/** @var EditResponse $editResponse */
$editResponse = new EditResponse();
if ($this->canAccess()) {
/** @var Connection $db */
$db = $this->app->make(Connection::class);
/** @noinspection PhpUnhandledExceptionInspection */
/** @noinspection SqlDialectInspection */
/** @noinspection SqlNoDataSourceInspection */
$db->executeQuery("TRUNCATE TABLE Logs");
$editResponse->setMessage(t('Log cleared successfully.'));
} else {
$editResponse->setMessage(t('Access denied'));
}
return $responseFactory->json($editResponse->getJSONObject());
}
}