]> git.mxchange.org Git - friendica.git/blobdiff - mod/admin.php
Merge pull request #4510 from tobiasd/20180227-zhcn
[friendica.git] / mod / admin.php
index a420a77d0f88b01862b1fae1e704ada9e1889a9e..1fa8cb2c021b56bb3a94777518b6ac2d4868efb4 100644 (file)
@@ -17,9 +17,11 @@ use Friendica\Core\Worker;
 use Friendica\Database\DBM;
 use Friendica\Database\DBStructure;
 use Friendica\Model\Contact;
-use Friendica\Model\User;
 use Friendica\Model\Item;
+use Friendica\Model\User;
 use Friendica\Module\Login;
+use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Temporal;
 
 require_once 'include/enotify.php';
 require_once 'include/text.php';
@@ -171,17 +173,31 @@ function admin_content(App $a)
        // array(url, name, extra css classes)
        // not part of $aside to make the template more adjustable
        $aside_sub = [
-               'site'         => ["admin/site/"        , L10n::t("Site")                 , "site"],
-               'users'        => ["admin/users/"       , L10n::t("Users")                , "users"],
-               'addons'       => ["admin/addons/"      , L10n::t("Addons")               , "addons"],
-               'themes'       => ["admin/themes/"      , L10n::t("Themes")               , "themes"],
-               'features'     => ["admin/features/"    , L10n::t("Additional features")  , "features"],
-               'dbsync'       => ["admin/dbsync/"      , L10n::t('DB updates')           , "dbsync"],
-               'queue'        => ["admin/queue/"       , L10n::t('Inspect Queue')        , "queue"],
-               'contactblock' => ["admin/contactblock/", L10n::t('Contact Blocklist')    , "contactblock"],
-               'blocklist'    => ["admin/blocklist/"   , L10n::t('Server Blocklist')     , "blocklist"],
-               'federation'   => ["admin/federation/"  , L10n::t('Federation Statistics'), "federation"],
-               'deleteitem'   => ["admin/deleteitem/"  , L10n::t('Delete Item')          , 'deleteitem'],
+               'information' => [ L10n::t('Information'), [
+                       "overview" => ["admin/", L10n::t("Overview"), "overview" ],
+                       'federation'   => ["admin/federation/"  , L10n::t('Federation Statistics'), "federation"] ]],
+               'configuration' => [ L10n::t('Configuration'), [
+                       'site'         => ["admin/site/"        , L10n::t("Site")                 , "site"],
+                       'users'        => ["admin/users/"       , L10n::t("Users")                , "users"],
+                       'addons'       => ["admin/addons/"      , L10n::t("Addons")               , "addons"],
+                       'themes'       => ["admin/themes/"      , L10n::t("Themes")               , "themes"],
+                       'features'     => ["admin/features/"    , L10n::t("Additional features")  , "features"] ]],
+               'database' => [ L10n::t('Database'), [
+                       'dbsync'       => ["admin/dbsync/"      , L10n::t('DB updates')           , "dbsync"],
+                       'queue'        => ["admin/queue/"       , L10n::t('Inspect Queue')        , "queue"], ]],
+               'tools' => [ L10n::t('Tools'), [
+                       'contactblock' => ["admin/contactblock/", L10n::t('Contact Blocklist')    , "contactblock"],
+                       'blocklist'    => ["admin/blocklist/"   , L10n::t('Server Blocklist')     , "blocklist"],
+                       'deleteitem'   => ["admin/deleteitem/"  , L10n::t('Delete Item')          , 'deleteitem'], ]],
+               "logs" => [ L10n::t("Logs"), [
+                       "logsconfig" => ["admin/logs/", L10n::t("Logs"), "logs"],
+                       "logsview" => ["admin/viewlogs/", L10n::t("View Logs"), 'viewlogs']
+               ]],
+               "diagnostics" => [ L10n::t("Diagnostics"), [
+                       "phpinfo" => ['phpinfo/', L10n::t('PHP Info'), 'phpinfo'],
+                       "probe" => ['probe/', L10n::t('probe address'), 'probe'],
+                       "webfinger" =>['webfinger/', L10n::t('check webfinger'), 'webfinger']
+               ]]
        ];
 
        /* get addons admin page */
@@ -195,19 +211,12 @@ function admin_content(App $a)
                $a->addons_admin[] = $addon;
        }
 
-       $aside_tools['logs'] = ["admin/logs/", L10n::t("Logs"), "logs"];
-       $aside_tools['viewlogs'] = ["admin/viewlogs/", L10n::t("View Logs"), 'viewlogs'];
-       $aside_tools['diagnostics_probe'] = ['probe/', L10n::t('probe address'), 'probe'];
-       $aside_tools['diagnostics_webfinger'] = ['webfinger/', L10n::t('check webfinger'), 'webfinger'];
-
        $t = get_markup_template('admin/aside.tpl');
        $a->page['aside'] .= replace_macros($t, [
                '$admin' => $aside_tools,
                '$subpages' => $aside_sub,
                '$admtxt' => L10n::t('Admin'),
                '$plugadmtxt' => L10n::t('Addon Features'),
-               '$logtxt' => L10n::t('Logs'),
-               '$diagnosticstxt' => L10n::t('diagnostics'),
                '$h_pending' => L10n::t('User registrations waiting for confirmation'),
                '$admurl' => "admin/"
        ]);
@@ -496,7 +505,7 @@ function admin_page_deleteitem_post(App $a)
                // associated threads.
                $r = dba::select('item', ['id'], ['guid' => $guid]);
                while ($row = dba::fetch($r)) {
-                       Item::delete($row['id']);
+                       Item::deleteById($row['id']);
                }
                dba::close($r);
        }
@@ -530,7 +539,7 @@ function admin_page_federation(App $a)
        // off one % two of them are needed in the query
        // Add more platforms if you like, when one returns 0 known nodes it is not
        // displayed on the stats page.
-       $platforms = ['Friendi%%a', 'Diaspora', '%%red%%', 'Hubzilla', 'BlaBlaNet', 'GNU Social', 'StatusNet', 'Mastodon', 'Pleroma', 'socialhome'];
+       $platforms = ['Friendi%%a', 'Diaspora', '%%red%%', 'Hubzilla', 'BlaBlaNet', 'GNU Social', 'StatusNet', 'Mastodon', 'Pleroma', 'socialhome', 'ganggo'];
        $colors = [
                'Friendi%%a' => '#ffc018', // orange from the logo
                'Diaspora'   => '#a1a1a1', // logo is black and white, makes a gray
@@ -541,7 +550,8 @@ function admin_page_federation(App $a)
                'StatusNet'  => '#789240', // the green from the logo (red and blue have already others
                'Mastodon'   => '#1a9df9', // blue from the Mastodon logo
                'Pleroma'    => '#E46F0F', // Orange from the text that is used on Pleroma instances
-               'socialhome' => '#52056b'  // lilac from the Django Image used at the Socialhome homepage
+               'socialhome' => '#52056b' , // lilac from the Django Image used at the Socialhome homepage
+               'ganggo'     => '#69d7e2' // from the favicon
        ];
        $counts = [];
        $total = 0;
@@ -732,7 +742,7 @@ function admin_page_summary(App $a)
        if (!$last_worker_call) {
                $showwarning = true;
                $warningtext[] = L10n::t('The worker was never executed. Please check your database structure!');
-       } elseif ((strtotime(datetime_convert()) - strtotime($last_worker_call)) > 60 * 60) {
+       } elseif ((strtotime(DateTimeFormat::utcNow()) - strtotime($last_worker_call)) > 60 * 60) {
                $showwarning = true;
                $warningtext[] = L10n::t('The last worker execution was on %s UTC. This is older than one hour. Please check your crontab settings.', $last_worker_call);
        }
@@ -1640,13 +1650,13 @@ function admin_page_users(App $a)
                        L10n::t('Automatic Friend Account')
                ];
                $e['page-flags'] = $accounts[$e['page-flags']];
-               $e['register_date'] = relative_date($e['register_date']);
-               $e['login_date'] = relative_date($e['login_date']);
-               $e['lastitem_date'] = relative_date($e['lastitem_date']);
+               $e['register_date'] = Temporal::getRelativeDate($e['register_date']);
+               $e['login_date'] = Temporal::getRelativeDate($e['login_date']);
+               $e['lastitem_date'] = Temporal::getRelativeDate($e['lastitem_date']);
                //$e['is_admin'] = ($e['email'] === $a->config['admin_email']);
                $e['is_admin'] = in_array($e['email'], $adminlist);
                $e['is_deletable'] = (intval($e['uid']) != local_user());
-               $e['deleted'] = ($e['account_removed'] ? relative_date($e['account_expires_on']) : False);
+               $e['deleted'] = ($e['account_removed'] ? Temporal::getRelativeDate($e['account_expires_on']) : False);
                return $e;
        };
        $users = array_map($_setup_users, $users);