]> git.mxchange.org Git - friendica.git/blob - src/Module/BaseProfile.php
spelling: group
[friendica.git] / src / Module / BaseProfile.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2023, 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;
23
24 use Friendica\App;
25 use Friendica\BaseModule;
26 use Friendica\Content\Feature;
27 use Friendica\Core\Hook;
28 use Friendica\Core\Renderer;
29 use Friendica\DI;
30 use Friendica\Model\User;
31
32 class BaseProfile extends BaseModule
33 {
34         /**
35          * Returns the HTML for the profile pages tabs
36          *
37          * @param string $current
38          * @param bool   $is_owner
39          * @param string $nickname
40          * @return string
41          * @throws \Friendica\Network\HTTPException\InternalServerErrorException
42          */
43         public static function getTabsHTML(string $current, bool $is_owner, string $nickname, bool $hide_friends)
44         {
45                 $baseProfileUrl = DI::baseUrl() . '/profile/' . $nickname;
46
47                 $tabs = [
48                         [
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',
54                                 'accesskey' => 'r',
55                         ],
56                         [
57                                 'label' => DI::l10n()->t('Conversations'),
58                                 'url'   => $baseProfileUrl . '/conversations',
59                                 'sel'   => $current == 'status' ? 'active' : '',
60                                 'title' => DI::l10n()->t('Conversations started'),
61                                 'id'    => 'status-tab',
62                                 'accesskey' => 'm',
63                         ],
64                         [
65                                 'label' => DI::l10n()->t('Photos'),
66                                 'url'   => $baseProfileUrl . '/photos',
67                                 'sel'   => $current == 'photos' ? 'active' : '',
68                                 'title' => DI::l10n()->t('Photo Albums'),
69                                 'id'    => 'photo-tab',
70                                 'accesskey' => 'h',
71                         ],
72                         [
73                                 'label' => DI::l10n()->t('Media'),
74                                 'url'   => $baseProfileUrl . '/media',
75                                 'sel'   => $current == 'media' ? 'active' : '',
76                                 'title' => DI::l10n()->t('Media'),
77                                 'id'    => 'media-tab',
78                                 'accesskey' => 'd',
79                         ],
80                 ];
81
82                 // the calendar link for the full-featured events calendar
83                 if ($is_owner) {
84                         $tabs[] = [
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',
90                                 'accesskey' => 'c',
91                         ];
92                 } else {
93                         $owner = User::getByNickname($nickname, ['uid']);
94                         if(DI::userSession()->isAuthenticated() || $owner && Feature::isEnabled($owner['uid'], 'public_calendar')) {
95                                 $tabs[] = [
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',
101                                         'accesskey' => 'c',
102                                 ];
103                         }
104                 }
105
106                 if ($is_owner) {
107                         $tabs[] = [
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'),
112                                 'id'    => 'notes-tab',
113                                 'accesskey' => 't',
114                         ];
115                         $tabs[] = [
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',
121                                 'accesskey' => 'o',
122                         ];
123                 }
124
125                 if (!$hide_friends) {
126                         $tabs[] = [
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',
132                                 'accesskey' => 'k',
133                         ];
134                 }
135
136                 if (DI::session()->get('new_member') && $is_owner) {
137                         $tabs[] = [
138                                 'label' => DI::l10n()->t('Tips for New Members'),
139                                 'url'   => DI::baseUrl() . '/newmember',
140                                 'sel'   => false,
141                                 'title' => DI::l10n()->t('Tips for New Members'),
142                                 'id'    => 'newmember-tab',
143                         ];
144                 }
145
146                 $arr = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $current, 'tabs' => $tabs];
147
148                 Hook::callAll('profile_tabs', $arr);
149
150                 $tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
151
152                 return Renderer::replaceMacros($tpl, ['$tabs' => $arr['tabs']]);
153         }
154 }