3 * @copyright Copyright (C) 2010-2023, the Friendica project
5 * @license GNU AGPL version 3 or any later version
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.
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.
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/>.
22 namespace Friendica\Module;
25 use Friendica\BaseModule;
26 use Friendica\Content\Feature;
27 use Friendica\Core\Hook;
28 use Friendica\Core\Renderer;
30 use Friendica\Model\User;
32 class BaseProfile extends BaseModule
35 * Returns the HTML for the profile pages tabs
37 * @param string $current
38 * @param bool $is_owner
39 * @param string $nickname
41 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
43 public static function getTabsHTML(string $current, bool $is_owner, string $nickname, bool $hide_friends)
45 $baseProfileUrl = DI::baseUrl() . '/profile/' . $nickname;
49 'label' => DI::l10n()->t('Profile'),
50 'url' => $baseProfileUrl . '/profile',
51 'sel' => $current == 'profile' ? 'active' : '',
52 'title' => DI::l10n()->t('Profile Details'),
53 'id' => 'profile-tab',
57 'label' => DI::l10n()->t('Conversations'),
58 'url' => $baseProfileUrl . '/conversations',
59 'sel' => $current == 'status' ? 'active' : '',
60 'title' => DI::l10n()->t('Conversations started'),
65 'label' => DI::l10n()->t('Photos'),
66 'url' => $baseProfileUrl . '/photos',
67 'sel' => $current == 'photos' ? 'active' : '',
68 'title' => DI::l10n()->t('Photo Albums'),
73 'label' => DI::l10n()->t('Media'),
74 'url' => $baseProfileUrl . '/media',
75 'sel' => $current == 'media' ? 'active' : '',
76 'title' => DI::l10n()->t('Media'),
82 // the calendar link for the full-featured events calendar
85 'label' => DI::l10n()->t('Calendar'),
86 'url' => DI::baseUrl() . '/calendar',
87 'sel' => $current == 'calendar' ? 'active' : '',
88 'title' => DI::l10n()->t('Calendar'),
89 'id' => 'calendar-tab',
93 $owner = User::getByNickname($nickname, ['uid']);
94 if(DI::userSession()->isAuthenticated() || $owner && Feature::isEnabled($owner['uid'], 'public_calendar')) {
96 'label' => DI::l10n()->t('Calendar'),
97 'url' => DI::baseUrl() . '/calendar/show/' . $nickname,
98 'sel' => $current == 'calendar' ? 'active' : '',
99 'title' => DI::l10n()->t('Calendar'),
100 'id' => 'calendar-tab',
108 'label' => DI::l10n()->t('Personal Notes'),
109 'url' => DI::baseUrl() . '/notes',
110 'sel' => $current == 'notes' ? 'active' : '',
111 'title' => DI::l10n()->t('Only You Can See This'),
116 'label' => DI::l10n()->t('Scheduled Posts'),
117 'url' => $baseProfileUrl . '/schedule',
118 'sel' => $current == 'schedule' ? 'active' : '',
119 'title' => DI::l10n()->t('Posts that are scheduled for publishing'),
120 'id' => 'schedule-tab',
125 if (!$hide_friends) {
127 'label' => DI::l10n()->t('Contacts'),
128 'url' => $baseProfileUrl . '/contacts',
129 'sel' => $current == 'contacts' ? 'active' : '',
130 'title' => DI::l10n()->t('Contacts'),
131 'id' => 'viewcontacts-tab',
136 if (DI::session()->get('new_member') && $is_owner) {
138 'label' => DI::l10n()->t('Tips for New Members'),
139 'url' => DI::baseUrl() . '/newmember',
141 'title' => DI::l10n()->t('Tips for New Members'),
142 'id' => 'newmember-tab',
146 $arr = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $current, 'tabs' => $tabs];
148 Hook::callAll('profile_tabs', $arr);
150 $tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
152 return Renderer::replaceMacros($tpl, ['$tabs' => $arr['tabs']]);