]> git.mxchange.org Git - friendica.git/blob - src/Module/Moderation/Summary.php
Merge pull request #12325 from annando/blurhash
[friendica.git] / src / Module / Moderation / Summary.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2022, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Module\Moderation;
23
24 use Friendica\App;
25 use Friendica\Core\L10n;
26 use Friendica\Core\Renderer;
27 use Friendica\Core\Session\Capability\IHandleUserSessions;
28 use Friendica\Database\Database;
29 use Friendica\Model\Register;
30 use Friendica\Module\BaseModeration;
31 use Friendica\Module\Response;
32 use Friendica\Navigation\SystemMessages;
33 use Friendica\Util\Profiler;
34 use Psr\Log\LoggerInterface;
35
36 class Summary extends BaseModeration
37 {
38         /** @var Database */
39         private $database;
40
41         public function __construct(Database $database, App\Page $page, App $app, SystemMessages $systemMessages, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
42         {
43                 parent::__construct($page, $app, $systemMessages, $session, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
44
45                 $this->database = $database;
46         }
47
48         protected function content(array $request = []): string
49         {
50                 parent::content();
51
52                 $accounts = [
53                         [$this->t('Normal Account'), 0],
54                         [$this->t('Automatic Follower Account'), 0],
55                         [$this->t('Public Forum Account'), 0],
56                         [$this->t('Automatic Friend Account'), 0],
57                         [$this->t('Blog Account'), 0],
58                         [$this->t('Private Forum Account'), 0]
59                 ];
60
61                 $users = 0;
62
63                 $pageFlagsCountStmt = $this->database->p('SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` WHERE `uid` != ? GROUP BY `page-flags`', 0);
64                 while ($pageFlagsCount = $this->database->fetch($pageFlagsCountStmt)) {
65                         $accounts[$pageFlagsCount['page-flags']][1] = $pageFlagsCount['count'];
66                         $users += $pageFlagsCount['count'];
67                 }
68                 $this->database->close($pageFlagsCountStmt);
69
70                 $this->logger->debug('accounts', ['accounts' => $accounts]);
71
72                 $pending = Register::getPendingCount();
73
74                 $t = Renderer::getMarkupTemplate('moderation/summary.tpl');
75                 return Renderer::replaceMacros($t, [
76                         '$title'       => $this->t('Moderation'),
77                         '$page'        => $this->t('Summary'),
78                         '$users'       => [$this->t('Registered users'), $users],
79                         '$accounts'    => $accounts,
80                         '$pending'     => [$this->t('Pending registrations'), $pending],
81                         '$warningtext' => [],
82                 ]);
83         }
84 }