]> git.mxchange.org Git - friendica.git/blobdiff - view/theme/vier/theme.php
Update remote_friends_common.tpl
[friendica.git] / view / theme / vier / theme.php
index c6441652465982ce8ecd088dfd901ab52e885080..e264251624eab708b72b37988fc9cc497c5ddb09 100644 (file)
@@ -1,5 +1,22 @@
 <?php
 /**
+ * @copyright Copyright (C) 2010-2023, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
  * Name: Vier
  * Version: 1.2
  * Author: Fabio <http://kirgroup.com/profile/fabrixxm>
@@ -10,7 +27,7 @@
  */
 
 use Friendica\App;
-use Friendica\Content\ForumManager;
+use Friendica\Content\GroupManager;
 use Friendica\Core\Addon;
 use Friendica\Core\Renderer;
 use Friendica\Core\Search;
@@ -19,13 +36,23 @@ use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Util\Strings;
 
+/*
+ * This script can be included even when the app is in maintenance mode which requires us to avoid any config call
+ */
+
 function vier_init(App $a)
 {
-       $a->theme_events_in_profile = false;
-
        Renderer::setActiveTemplateEngine('smarty3');
 
-       if (!empty($a->argv[0]) && ($a->argv[0] . ($a->argv[1] ?? '')) === ('profile' . ($a->user['nickname'] ?? '')) || $a->argv[0] === 'network' && local_user()) {
+       $args = DI::args();
+
+       if (
+               DI::mode()->has(App\Mode::MAINTENANCEDISABLED)
+               && (
+                       $args->get(0) === 'profile' && $args->get(1) === ($a->getLoggedInUserNickname() ?? '')
+                       || $args->get(0) === 'network' && DI::userSession()->getLocalUserId()
+               )
+       ) {
                vier_community_info();
 
                DI::page()['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";
@@ -77,7 +104,7 @@ EOT;
 
        // Hide the left menu bar
        /// @TODO maybe move this static array out where it should belong?
-       if (empty(DI::page()['aside']) && in_array($a->argv[0], ["community", "events", "help", "delegation", "notifications",
+       if (empty(DI::page()['aside']) && in_array($args->get(0), ["community", "calendar", "help", "delegation", "notifications",
                        "probe", "webfinger", "login", "invite", "credits"])) {
                DI::page()['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
        }
@@ -85,8 +112,8 @@ EOT;
 
 function get_vier_config($key, $default = false, $admin = false)
 {
-       if (local_user() && !$admin) {
-               $result = DI::pConfig()->get(local_user(), "vier", $key);
+       if (DI::userSession()->getLocalUserId() && !$admin) {
+               $result = DI::pConfig()->get(DI::userSession()->getLocalUserId(), "vier", $key);
                if (!is_null($result)) {
                        return $result;
                }
@@ -102,8 +129,6 @@ function get_vier_config($key, $default = false, $admin = false)
 
 function vier_community_info()
 {
-       $a = DI::app();
-
        $show_pages      = get_vier_config("show_pages", 1);
        $show_profiles   = get_vier_config("show_profiles", 1);
        $show_helpers    = get_vier_config("show_helpers", 1);
@@ -112,26 +137,25 @@ function vier_community_info()
        $show_lastusers  = get_vier_config("show_lastusers", 1);
 
        // get_baseurl
-       $url = DI::baseUrl();
-       $aside['$url'] = $url;
+       $aside['$url'] = $url = (string)DI::baseUrl();
 
-       // comunity_profiles
+       // community_profiles
        if ($show_profiles) {
-               $contacts = Contact\Relation::getSuggestions(local_user(), 0, 9);
+               $contacts = Contact\Relation::getCachedSuggestions(DI::userSession()->getLocalUserId(), 0, 9);
 
                $tpl = Renderer::getMarkupTemplate('ch_directory_item.tpl');
                if (DBA::isResult($contacts)) {
-                       $aside['$comunity_profiles_title'] = DI::l10n()->t('Community Profiles');
-                       $aside['$comunity_profiles_items'] = [];
+                       $aside['$community_profiles_title'] = DI::l10n()->t('Community Profiles');
+                       $aside['$community_profiles_items'] = [];
 
                        foreach ($contacts as $contact) {
                                $entry = Renderer::replaceMacros($tpl, [
                                        '$id' => $contact['id'],
-                                       '$profile_link' => 'follow/?url='.urlencode($contact['url']),
+                                       '$profile_link' => 'contact/follow?url=' . urlencode($contact['url']),
                                        '$photo' => Contact::getMicro($contact),
                                        '$alt_text' => $contact['name'],
                                ]);
-                               $aside['$comunity_profiles_items'][] = $entry;
+                               $aside['$community_profiles_items'][] = $entry;
                        }
                }
        }
@@ -164,7 +188,7 @@ function vier_community_info()
        }
 
        //right_aside FIND FRIENDS
-       if ($show_friends && local_user()) {
+       if ($show_friends && DI::userSession()->getLocalUserId()) {
                $nv = [];
                $nv['findpeople'] = DI::l10n()->t('Find People');
                $nv['desc'] = DI::l10n()->t('Enter name or interest');
@@ -183,50 +207,8 @@ function vier_community_info()
        }
 
        //Community_Pages at right_aside
-       if ($show_pages && local_user()) {
-               $cid = $_GET['cid'] ?? null;
-
-               //sort by last updated item
-               $lastitem = true;
-
-               $contacts = ForumManager::getList($a->user['uid'], $lastitem, true, true);
-               $total = count($contacts);
-               $visible_forums = 10;
-
-               if (count($contacts)) {
-                       $id = 0;
-
-                       foreach ($contacts as $contact) {
-                               $selected = (($cid == $contact['id']) ? ' forum-selected' : '');
-
-                               $entry = [
-                                       'url'          => 'network?contactid=' . $contact['id'],
-                                       'external_url' => Contact::magicLink($contact['url']),
-                                       'name'         => $contact['name'],
-                                       'cid'          => $contact['id'],
-                                       'selected'     => $selected,
-                                       'micro'        => Contact::getMicro($contact),
-                                       'id'           => ++$id,
-                               ];
-                               $entries[] = $entry;
-                       }
-
-
-                       $tpl = Renderer::getMarkupTemplate('widget_forumlist_right.tpl');
-
-                       $page = Renderer::replaceMacros(
-                               $tpl,
-                               [
-                                       '$title'          => DI::l10n()->t('Forums'),
-                                       '$forums'         => $entries,
-                                       '$link_desc'      => DI::l10n()->t('External link to forum'),
-                                       '$total'          => $total,
-                                       '$visible_forums' => $visible_forums,
-                                       '$showmore'       => DI::l10n()->t('show more')]
-                       );
-
-                       $aside['$page'] = $page;
-               }
+       if ($show_pages && DI::userSession()->getLocalUserId()) {
+               $aside['$page'] = GroupManager::widget('network/group', DI::userSession()->getLocalUserId());;
        }
        // END Community Page
 
@@ -326,7 +308,7 @@ function vier_community_info()
                        $r[] = ["photo" => "images/wordpress.png", "name" => "Wordpress"];
                }
 
-               if (function_exists("imap_open") && !DI::config()->get("system", "imap_disabled") && !DI::config()->get("system", "dfrn_only")) {
+               if (function_exists("imap_open") && !DI::config()->get("system", "imap_disabled")) {
                        $r[] = ["photo" => "images/mail.png", "name" => "E-Mail"];
                }