-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.php
298 lines (271 loc) · 8.51 KB
/
home.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<?php
// This file is part of Music Match.
// Copyright (C) 2022 David P. Anderson
//
// Music Match is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Music Match 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Music Match. If not, see <http://www.gnu.org/licenses/>.
// --------------------------------------------------------------------
require_once("../inc/util.inc");
require_once("../inc/forum_db.inc");
require_once("../inc/mm.inc");
require_once("../inc/cp_profile.inc");
require_once("../inc/teacher.inc");
require_once("../inc/tech.inc");
require_once("../inc/ensemble.inc");
require_once("../inc/notification.inc");
$show_home_link = false;
// user home page
function left() {
show_search();
echo "<hr>";
show_profiles();
echo "<hr>";
show_ens();
}
function show_profiles() {
global $user;
echo "<font size=+3>My profiles</font>
<h3>Composer</h3>
";
start_table();
if (profile_exists($user->id, COMPOSER)) {
$profile = read_profile($user->id, COMPOSER);
echo cp_profile_summary_table($user, $profile, COMPOSER);
row2('',
mm_button_text(
sprintf("cp_profile_edit.php?role=%d", COMPOSER),
"Edit composer profile", BUTTON_SMALL
)
);
} else {
row2('',
mm_button_text(
sprintf("cp_profile_edit.php?role=%d", COMPOSER),
"Create composer profile", BUTTON_SMALL
)
);
}
end_table();
echo "<h3>Performer</h3>";
start_table();
if (profile_exists($user->id, PERFORMER)) {
$profile = read_profile($user->id, PERFORMER);
echo cp_profile_summary_table($user, $profile, PERFORMER);
row2('',
mm_button_text(
sprintf("cp_profile_edit.php?role=%d", PERFORMER),
"Edit performer profile", BUTTON_SMALL
)
);
} else {
row2('',
mm_button_text(
sprintf("cp_profile_edit.php?role=%d", PERFORMER),
"Create performer profile", BUTTON_SMALL
)
);
}
end_table();
echo "<h3>Technician</h3>";
start_table();
if (profile_exists($user->id, TECHNICIAN)) {
$profile = read_profile($user->id, TECHNICIAN);
echo tech_profile_summary_table($user, $profile);
row2('',
mm_button_text(
sprintf("tech_profile_edit.php", PERFORMER),
"Edit technician profile", BUTTON_SMALL
)
);
} else {
row2('',
mm_button_text(
"tech_profile_edit.php",
"Create technician profile"
)
);
}
end_table();
echo "<h3>Teacher</h3>";
start_table();
if (profile_exists($user->id, TEACHER)) {
$profile = read_profile($user->id, TEACHER);
echo teacher_profile_summary_table($user, $profile);
row2('',
mm_button_text(
sprintf("teacher_edit.php"),
"Edit teacher profile", BUTTON_SMALL
)
);
} else {
row2('',
mm_button_text(
"teacher_edit.php",
"Create teacher profile", BUTTON_SMALL
)
);
}
end_table();
}
function show_ens() {
global $user;
echo "<h3>My ensembles</h3>";
start_table();
show_ensembles($user);
row2('',
mm_button_text(
"ensemble_edit.php", "Add ensemble", BUTTON_SMALL
)
);
end_table();
}
function show_search() {
echo "<h3>Search for</h3>";
echo "<table><tr><td align=center width=18%>";
$url = sprintf("cp_search.php?role=%d", COMPOSER);
echo sprintf(
'<p><a href=%s><img width=80%% src=comp.png alt="%s"></a><p>',
$url, 'Picture of a musical score'
);
mm_show_button($url, "Composers", BUTTON_SMALL);
echo "</td><td align=center width=18%>";
$url = sprintf("cp_search.php?role=%d", PERFORMER);
echo sprintf(
'<p><a href=%s><img width=80%% src=perf.png alt="%s"></a><p>',
$url, 'Picture of a violinist'
);
mm_show_button($url, "Performers", BUTTON_SMALL);
echo "</td><td align=center width=18%>";
$url = 'tech_search.php';
echo sprintf(
'<p><a href=%s><img width=80%% src=tech.png alt="%s"></a><p>',
$url, 'Picture of a mixing board'
);
mm_show_button($url, "Technicians", BUTTON_SMALL);
echo "</td><td align=center width=18%>";
$url = 'ensemble_search.php';
echo sprintf(
'<p><a href=%s><img width=80%% src=ens.png alt="%s"></a><p>',
$url, 'Picture of an orchestra'
);
mm_show_button($url, "Ensembles", BUTTON_SMALL);
echo "</td><td align=center width=18%>";
$url = 'teacher_search.php';
echo sprintf(
'<p><a href=%s><img width=80%% src=teach.png alt="%s"></a><p>',
$url, 'Picture of cello student and teacher'
);
mm_show_button($url, "Teachers", BUTTON_SMALL);
echo "
</td></tr></table>
";
global $user;
$searches = Search::enum("user_id = $user->id");
$n = count($searches);
$nnew = 0;
foreach ($searches as $s) {
if ($s->rerun_nnew) {
$nnew++;
}
}
if ($n) {
echo "<p><p>Your previous searches:
<a href=search_list.php>View all $n</a>
";
if ($nnew) {
echo " · <a href=search_list.php?new=1>View $nnew with new results</a>";
}
}
}
function right() {
global $user;
echo "<h3>Community</h3>";
start_table();
$tot = total_posts($user);
if ($tot) {
row2("Message boards",
sprintf('<a href=%s>%d posts</a>',
"forum_user_posts.php?userid=$user->id",
$tot
)
);
}
row2("Private messages",
sprintf(
'<a href=%s>Inbox</a> <small>(%d messages, %d unread)</small><br><a href=%s>Sent</a>',
'pm.php?action=inbox',
pm_total($user),
pm_unread($user),
'pm.php?action=outbox'
)
);
$following = BoincFriend::enum("user_src=$user->id");
$x = [];
foreach ($following as $friend) {
$fuser = BoincUser::lookup_id($friend->user_dest);
if (!$fuser) continue;
$x[] = "<a href=user.php?user_id=$fuser->id>$fuser->name</a>";
}
if ($x) {
row2("I'm following", implode('<br>', $x));
}
$followers = BoincFriend::enum("user_dest=$user->id");
$x = [];
foreach ($followers as $friend) {
$fuser = BoincUser::lookup_id($friend->user_src);
if (!$fuser) continue;
$x[] = "<a href=user.php?user_id=$fuser->id>$fuser->name</a>";
}
if ($x) {
row2('My followers', implode('<br>', $x));
}
if (has_picture($user)) {
row2('My picture<br><a href=picture.php><font size=-1>edit</font></a>',
sprintf('<img src=%s width=100>', picture_path($user))
);
} else {
row2('My picture', '<a href=picture.php>Add</a>');
}
end_table();
echo "<h3>Notifications</h3>";
start_table();
show_notifications($user);
end_table();
echo "<h3>Spread the word</h3>
<p>
Help us grow!
<a href=email.php>Tell your musical friends and colleagues</a>
about Music Match.
<p>
";
echo '<table><tr><td><a href="https://twitter.com/music_match_org?ref_src=twsrc%5Etfw" class="twitter-follow-button" data-show-screen-name="false" data-show-count="false">Follow @music_match_org</a><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></td>';
echo "
<td> </td>
<td><a href=https://www.facebook.com/Music-matchorg-113556814665297>
<img style=\"vertical-align:baseline\" height=20 src=fb.png></a>
</td></tr></table>
";
}
function top() {
}
function home_page($user) {
page_head("Home");
echo "<hr>";
grid('top', 'left', 'right', 6);
page_tail();
}
$user = mm_get_logged_in_user();
update_visit_time($user);
BoincForumPrefs::lookup($user);
home_page($user);
?>