3 * @file mod/profiles.php
7 use Friendica\BaseModule;
8 use Friendica\Content\ContactSelector;
9 use Friendica\Content\Feature;
10 use Friendica\Content\Nav;
11 use Friendica\Core\Config;
12 use Friendica\Core\Hook;
13 use Friendica\Core\L10n;
14 use Friendica\Core\Renderer;
15 use Friendica\Core\Worker;
16 use Friendica\Database\DBA;
18 use Friendica\Model\Contact;
19 use Friendica\Model\GContact;
20 use Friendica\Model\Profile;
21 use Friendica\Model\User;
22 use Friendica\Module\Security\Login;
23 use Friendica\Network\Probe;
24 use Friendica\Util\DateTimeFormat;
25 use Friendica\Util\Strings;
26 use Friendica\Util\Temporal;
28 function profiles_init(App $a) {
30 Nav::setSelected('profiles');
36 if (($a->argc > 2) && ($a->argv[1] === "drop") && intval($a->argv[2])) {
37 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
41 if (! DBA::isResult($r)) {
42 notice(DI::l10n()->t('Profile not found.') . EOL);
43 DI::baseUrl()->redirect('profiles');
47 BaseModule::checkFormSecurityTokenRedirectOnError('/profiles', 'profile_drop', 't');
49 // move every contact using this profile as their default to the user default
51 q("UPDATE `contact` SET `profile-id` = (SELECT `profile`.`id` AS `profile-id` FROM `profile` WHERE `profile`.`is-default` = 1 AND `profile`.`uid` = %d LIMIT 1) WHERE `profile-id` = %d AND `uid` = %d ",
56 q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d",
60 if (DBA::isResult($r)) {
61 info(DI::l10n()->t('Profile deleted.').EOL);
64 DI::baseUrl()->redirect('profiles');
68 if (($a->argc > 1) && ($a->argv[1] === 'new')) {
70 BaseModule::checkFormSecurityTokenRedirectOnError('/profiles', 'profile_new', 't');
72 $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
73 intval(local_user()));
75 $num_profiles = (DBA::isResult($r0) ? count($r0) : 0);
77 $name = DI::l10n()->t('Profile-') . ($num_profiles + 1);
79 $r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
80 intval(local_user()));
82 q("INSERT INTO `profile` (`uid` , `profile-name` , `name`, `photo`, `thumb`)
83 VALUES ( %d, '%s', '%s', '%s', '%s' )",
86 DBA::escape($r1[0]['name']),
87 DBA::escape($r1[0]['photo']),
88 DBA::escape($r1[0]['thumb'])
91 $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1",
96 info(DI::l10n()->t('New profile created.') . EOL);
97 if (DBA::isResult($r3) && count($r3) == 1) {
98 DI::baseUrl()->redirect('profiles/' . $r3[0]['id']);
101 DI::baseUrl()->redirect('profiles');
104 if (($a->argc > 2) && ($a->argv[1] === 'clone')) {
106 BaseModule::checkFormSecurityTokenRedirectOnError('/profiles', 'profile_clone', 't');
108 $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
109 intval(local_user()));
111 $num_profiles = (DBA::isResult($r0) ? count($r0) : 0);
113 $name = DI::l10n()->t('Profile-') . ($num_profiles + 1);
114 $r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 1",
115 intval(local_user()),
118 if(! DBA::isResult($r1)) {
119 notice(DI::l10n()->t('Profile unavailable to clone.') . EOL);
123 $r1[0]['is-default'] = 0;
124 $r1[0]['publish'] = 0;
125 $r1[0]['net-publish'] = 0;
126 $r1[0]['profile-name'] = DBA::escape($name);
128 DBA::insert('profile', $r1[0]);
130 $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1",
131 intval(local_user()),
134 info(DI::l10n()->t('New profile created.') . EOL);
135 if ((DBA::isResult($r3)) && (count($r3) == 1)) {
136 DI::baseUrl()->redirect('profiles/'.$r3[0]['id']);
139 DI::baseUrl()->redirect('profiles');
141 return; // NOTREACHED
145 if (($a->argc > 1) && (intval($a->argv[1]))) {
146 $r = q("SELECT id FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
150 if (! DBA::isResult($r)) {
151 notice(DI::l10n()->t('Profile not found.') . EOL);
155 Profile::load($a, $a->user['nickname'], $r[0]['id']);
159 function profile_clean_keywords($keywords)
161 $keywords = str_replace(",", " ", $keywords);
162 $keywords = explode(" ", $keywords);
165 foreach ($keywords as $keyword) {
166 $keyword = trim(strtolower($keyword));
167 $keyword = trim($keyword, "#");
168 if ($keyword != "") {
169 $cleaned[] = $keyword;
173 $keywords = implode(", ", $cleaned);
178 function profiles_post(App $a) {
180 if (! local_user()) {
181 notice(DI::l10n()->t('Permission denied.') . EOL);
185 $namechanged = false;
187 Hook::callAll('profile_post', $_POST);
189 if (($a->argc > 1) && ($a->argv[1] !== "new") && intval($a->argv[1])) {
190 $orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
194 if (! DBA::isResult($orig)) {
195 notice(DI::l10n()->t('Profile not found.') . EOL);
199 BaseModule::checkFormSecurityTokenRedirectOnError('/profiles', 'profile_edit');
201 $is_default = (($orig[0]['is-default']) ? 1 : 0);
203 $profile_name = Strings::escapeTags(trim($_POST['profile_name']));
204 if (! strlen($profile_name)) {
205 notice(DI::l10n()->t('Profile Name is required.') . EOL);
209 $dob = !empty($_POST['dob']) ? Strings::escapeHtml(trim($_POST['dob'])) : '0000-00-00';
211 $y = substr($dob, 0, 4);
212 if ((! ctype_digit($y)) || ($y < 1900)) {
215 $ignore_year = false;
217 if (!in_array($dob, ['0000-00-00', DBA::NULL_DATE])) {
218 if (strpos($dob, '0000-') === 0 || strpos($dob, '0001-') === 0) {
220 $dob = substr($dob, 5);
224 $dob = '0000-' . DateTimeFormat::utc('1900-' . $dob, 'm-d');
226 $dob = DateTimeFormat::utc($dob, 'Y-m-d');
230 $name = Strings::escapeTags(trim($_POST['name']));
232 if (! strlen($name)) {
236 if ($orig[0]['name'] != $name) {
240 $pdesc = Strings::escapeTags(trim($_POST['pdesc'] ?? ''));
241 $gender = Strings::escapeTags(trim($_POST['gender'] ?? ''));
242 $address = Strings::escapeTags(trim($_POST['address'] ?? ''));
243 $locality = Strings::escapeTags(trim($_POST['locality'] ?? ''));
244 $region = Strings::escapeTags(trim($_POST['region'] ?? ''));
245 $postal_code = Strings::escapeTags(trim($_POST['postal_code'] ?? ''));
246 $country_name = Strings::escapeTags(trim($_POST['country_name'] ?? ''));
247 $pub_keywords = profile_clean_keywords(Strings::escapeTags(trim($_POST['pub_keywords'] ?? '')));
248 $prv_keywords = profile_clean_keywords(Strings::escapeTags(trim($_POST['prv_keywords'] ?? '')));
249 $marital = Strings::escapeTags(trim($_POST['marital'] ?? ''));
250 $howlong = Strings::escapeTags(trim($_POST['howlong'] ?? ''));
252 $with = (!empty($_POST['with']) ? Strings::escapeTags(trim($_POST['with'])) : '');
254 if (! strlen($howlong)) {
255 $howlong = DBA::NULL_DATETIME;
257 $howlong = DateTimeFormat::convert($howlong, 'UTC', date_default_timezone_get());
259 // linkify the relationship target if applicable
261 $withchanged = false;
264 if ($with != strip_tags($orig[0]['with'])) {
268 if (strpos($lookup, '@') === 0) {
269 $lookup = substr($lookup, 1);
271 $lookup = str_replace('_',' ', $lookup);
272 if (strpos($lookup, '@') || (strpos($lookup, 'http://'))) {
274 $links = @Probe::lrdd($lookup);
276 foreach ($links as $link) {
277 if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
278 $prf = $link['@attributes']['href'];
285 $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
286 DBA::escape($newname),
289 if (! DBA::isResult($r)) {
290 $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
291 DBA::escape($lookup),
295 if (DBA::isResult($r)) {
297 $newname = $r[0]['name'];
302 $with = str_replace($lookup, '<a href="' . $prf . '">' . $newname . '</a>', $with);
303 if (strpos($with, '@') === 0) {
304 $with = substr($with, 1);
308 $with = $orig[0]['with'];
312 /// @TODO Not flexible enough for later expansion, let's have more OOP here
313 $sexual = Strings::escapeTags(trim($_POST['sexual']));
314 $xmpp = Strings::escapeTags(trim($_POST['xmpp']));
315 $homepage = Strings::escapeTags(trim($_POST['homepage']));
316 if ((strpos($homepage, 'http') !== 0) && (strlen($homepage))) {
317 // neither http nor https in URL, add them
318 $homepage = 'http://'.$homepage;
320 $hometown = Strings::escapeTags(trim($_POST['hometown']));
321 $politic = Strings::escapeTags(trim($_POST['politic']));
322 $religion = Strings::escapeTags(trim($_POST['religion']));
324 $likes = Strings::escapeHtml(trim($_POST['likes']));
325 $dislikes = Strings::escapeHtml(trim($_POST['dislikes']));
327 $about = Strings::escapeHtml(trim($_POST['about']));
328 $interest = Strings::escapeHtml(trim($_POST['interest']));
329 $contact = Strings::escapeHtml(trim($_POST['contact']));
330 $music = Strings::escapeHtml(trim($_POST['music']));
331 $book = Strings::escapeHtml(trim($_POST['book']));
332 $tv = Strings::escapeHtml(trim($_POST['tv']));
333 $film = Strings::escapeHtml(trim($_POST['film']));
334 $romance = Strings::escapeHtml(trim($_POST['romance']));
335 $work = Strings::escapeHtml(trim($_POST['work']));
336 $education = Strings::escapeHtml(trim($_POST['education']));
338 $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0);
340 DI::pConfig()->set(local_user(), 'system', 'detailled_profile', !empty($_POST['detailed_profile']) ? 1: 0);
344 if ($marital != $orig[0]['marital']) {
345 $changes[] = '[color=#ff0000]♥[/color] ' . DI::l10n()->t('Marital Status');
348 $changes[] = '[color=#ff0000]♥[/color] ' . DI::l10n()->t('Romantic Partner');
350 if ($likes != $orig[0]['likes']) {
351 $changes[] = DI::l10n()->t('Likes');
353 if ($dislikes != $orig[0]['dislikes']) {
354 $changes[] = DI::l10n()->t('Dislikes');
356 if ($work != $orig[0]['work']) {
357 $changes[] = DI::l10n()->t('Work/Employment');
359 if ($religion != $orig[0]['religion']) {
360 $changes[] = DI::l10n()->t('Religion');
362 if ($politic != $orig[0]['politic']) {
363 $changes[] = DI::l10n()->t('Political Views');
365 if ($gender != $orig[0]['gender']) {
366 $changes[] = DI::l10n()->t('Gender');
368 if ($sexual != $orig[0]['sexual']) {
369 $changes[] = DI::l10n()->t('Sexual Preference');
371 if ($xmpp != $orig[0]['xmpp']) {
372 $changes[] = DI::l10n()->t('XMPP');
374 if ($homepage != $orig[0]['homepage']) {
375 $changes[] = DI::l10n()->t('Homepage');
377 if ($interest != $orig[0]['interest']) {
378 $changes[] = DI::l10n()->t('Interests');
380 if ($address != $orig[0]['address']) {
381 $changes[] = DI::l10n()->t('Address');
382 // New address not sent in notifications, potential privacy issues
383 // in case this leaks to unintended recipients. Yes, it's in the public
384 // profile but that doesn't mean we have to broadcast it to everybody.
386 if ($locality != $orig[0]['locality'] || $region != $orig[0]['region']
387 || $country_name != $orig[0]['country-name']) {
388 $changes[] = DI::l10n()->t('Location');
392 $r = q("UPDATE `profile`
393 SET `profile-name` = '%s',
401 `postal-code` = '%s',
402 `country-name` = '%s',
412 `pub_keywords` = '%s',
413 `prv_keywords` = '%s',
427 WHERE `id` = %d AND `uid` = %d",
428 DBA::escape($profile_name),
431 DBA::escape($gender),
433 DBA::escape($address),
434 DBA::escape($locality),
435 DBA::escape($region),
436 DBA::escape($postal_code),
437 DBA::escape($country_name),
438 DBA::escape($marital),
440 DBA::escape($howlong),
441 DBA::escape($sexual),
443 DBA::escape($homepage),
444 DBA::escape($hometown),
445 DBA::escape($politic),
446 DBA::escape($religion),
447 DBA::escape($pub_keywords),
448 DBA::escape($prv_keywords),
450 DBA::escape($dislikes),
452 DBA::escape($interest),
453 DBA::escape($contact),
458 DBA::escape($romance),
460 DBA::escape($education),
461 intval($hide_friends),
466 /// @TODO decide to use DBA::isResult() here and check $r
468 info(DI::l10n()->t('Profile updated.') . EOL);
473 q("UPDATE `user` set `username` = '%s' where `uid` = %d",
479 Contact::updateSelfFromUserID(local_user());
481 // Update global directory in background
482 $url = $_SESSION['my_url'];
483 if ($url && strlen(Config::get('system', 'directory'))) {
484 Worker::add(PRIORITY_LOW, "Directory", $url);
487 Worker::add(PRIORITY_LOW, 'ProfileUpdate', local_user());
489 // Update the global contact for the user
490 GContact::updateForUser(local_user());
495 function profiles_content(App $a) {
497 if (! local_user()) {
498 notice(DI::l10n()->t('Permission denied.') . EOL);
499 return Login::form();
504 if (($a->argc > 1) && (intval($a->argv[1]))) {
505 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
509 if (! DBA::isResult($r)) {
510 notice(DI::l10n()->t('Profile not found.') . EOL);
514 DI::page()['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('profed_head.tpl'), [
515 '$baseurl' => DI::baseUrl()->get(true),
518 $opt_tpl = Renderer::getMarkupTemplate("profile-hide-friends.tpl");
519 $hide_friends = Renderer::replaceMacros($opt_tpl,[
521 'hide-friends', //Name
522 DI::l10n()->t('Hide contacts and friends:'), //Label
523 !!$r[0]['hide-friends'], //Value
525 [DI::l10n()->t('No'), DI::l10n()->t('Yes')] //Off - On strings
527 '$desc' => DI::l10n()->t('Hide your contact/friend list from viewers of this profile?'),
528 '$yes_str' => DI::l10n()->t('Yes'),
529 '$no_str' => DI::l10n()->t('No'),
530 '$yes_selected' => (($r[0]['hide-friends']) ? " checked=\"checked\" " : ""),
531 '$no_selected' => (($r[0]['hide-friends'] == 0) ? " checked=\"checked\" " : "")
534 $personal_account = !(in_array($a->user["page-flags"],
535 [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP]));
537 $detailed_profile = (DI::pConfig()->get(local_user(), 'system', 'detailled_profile') AND $personal_account);
539 $is_default = (($r[0]['is-default']) ? 1 : 0);
540 $tpl = Renderer::getMarkupTemplate("profile_edit.tpl");
541 $o .= Renderer::replaceMacros($tpl, [
542 '$personal_account' => $personal_account,
543 '$detailled_profile' => $detailed_profile,
546 'detailed_profile', //Name
547 DI::l10n()->t('Show more profile fields:'), //Label
548 $detailed_profile, //Value
550 [DI::l10n()->t('No'), DI::l10n()->t('Yes')] //Off - On strings
553 '$multi_profiles' => Feature::isEnabled(local_user(), 'multi_profiles'),
554 '$form_security_token' => BaseModule::getFormSecurityToken("profile_edit"),
555 '$form_security_token_photo' => BaseModule::getFormSecurityToken("profile_photo"),
556 '$profile_clone_link' => ((Feature::isEnabled(local_user(), 'multi_profiles')) ? 'profiles/clone/' . $r[0]['id'] . '?t=' . BaseModule::getFormSecurityToken("profile_clone") : ""),
557 '$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . BaseModule::getFormSecurityToken("profile_drop"),
559 '$profile_action' => DI::l10n()->t('Profile Actions'),
560 '$banner' => DI::l10n()->t('Edit Profile Details'),
561 '$submit' => DI::l10n()->t('Submit'),
562 '$profpic' => DI::l10n()->t('Change Profile Photo'),
563 '$profpiclink' => '/photos/' . $a->user['nickname'],
564 '$viewprof' => DI::l10n()->t('View this profile'),
565 '$viewallprof' => DI::l10n()->t('View all profiles'),
566 '$editvis' => DI::l10n()->t('Edit visibility'),
567 '$cr_prof' => DI::l10n()->t('Create a new profile using these settings'),
568 '$cl_prof' => DI::l10n()->t('Clone this profile'),
569 '$del_prof' => DI::l10n()->t('Delete this profile'),
571 '$lbl_basic_section' => DI::l10n()->t('Basic information'),
572 '$lbl_picture_section' => DI::l10n()->t('Profile picture'),
573 '$lbl_location_section' => DI::l10n()->t('Location'),
574 '$lbl_preferences_section' => DI::l10n()->t('Preferences'),
575 '$lbl_status_section' => DI::l10n()->t('Status information'),
576 '$lbl_about_section' => DI::l10n()->t('Additional information'),
577 '$lbl_interests_section' => DI::l10n()->t('Interests'),
578 '$lbl_personal_section' => DI::l10n()->t('Personal'),
579 '$lbl_relation_section' => DI::l10n()->t('Relation'),
580 '$lbl_miscellaneous_section' => DI::l10n()->t('Miscellaneous'),
582 '$lbl_profile_photo' => DI::l10n()->t('Upload Profile Photo'),
583 '$lbl_gender' => DI::l10n()->t('Your Gender:'),
584 '$lbl_marital' => DI::l10n()->t('<span class="heart">♥</span> Marital Status:'),
585 '$lbl_sexual' => DI::l10n()->t('Sexual Preference:'),
586 '$lbl_ex2' => DI::l10n()->t('Example: fishing photography software'),
588 '$disabled' => (($is_default) ? 'onclick="return false;" style="color: #BBBBFF;"' : ''),
589 '$baseurl' => DI::baseUrl()->get(true),
590 '$profile_id' => $r[0]['id'],
591 '$profile_name' => ['profile_name', DI::l10n()->t('Profile Name:'), $r[0]['profile-name'], DI::l10n()->t('Required'), '*'],
592 '$is_default' => $is_default,
593 '$default' => (($is_default) ? '<p id="profile-edit-default-desc">' . DI::l10n()->t('This is your <strong>public</strong> profile.<br />It <strong>may</strong> be visible to anybody using the internet.') . '</p>' : ""),
594 '$name' => ['name', DI::l10n()->t('Your Full Name:'), $r[0]['name']],
595 '$pdesc' => ['pdesc', DI::l10n()->t('Title/Description:'), $r[0]['pdesc']],
596 '$dob' => Temporal::getDateofBirthField($r[0]['dob'], $a->user['timezone']),
597 '$hide_friends' => $hide_friends,
598 '$address' => ['address', DI::l10n()->t('Street Address:'), $r[0]['address']],
599 '$locality' => ['locality', DI::l10n()->t('Locality/City:'), $r[0]['locality']],
600 '$region' => ['region', DI::l10n()->t('Region/State:'), $r[0]['region']],
601 '$postal_code' => ['postal_code', DI::l10n()->t('Postal/Zip Code:'), $r[0]['postal-code']],
602 '$country_name' => ['country_name', DI::l10n()->t('Country:'), $r[0]['country-name']],
603 '$age' => ((intval($r[0]['dob'])) ? '(' . DI::l10n()->t('Age: ') . Temporal::getAgeByTimezone($r[0]['dob'],$a->user['timezone'],$a->user['timezone']) . ')' : ''),
604 '$gender' => DI::l10n()->t(ContactSelector::gender($r[0]['gender'])),
605 '$marital' => ['selector' => ContactSelector::maritalStatus($r[0]['marital']), 'value' => DI::l10n()->t($r[0]['marital'])],
606 '$with' => ['with', DI::l10n()->t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), DI::l10n()->t('Examples: cathy123, Cathy Williams, cathy@example.com')],
607 '$howlong' => ['howlong', DI::l10n()->t('Since [date]:'), ($r[0]['howlong'] <= DBA::NULL_DATETIME ? '' : DateTimeFormat::local($r[0]['howlong']))],
608 '$sexual' => ['selector' => ContactSelector::sexualPreference($r[0]['sexual']), 'value' => DI::l10n()->t($r[0]['sexual'])],
609 '$about' => ['about', DI::l10n()->t('Tell us about yourself...'), $r[0]['about']],
610 '$xmpp' => ['xmpp', DI::l10n()->t("XMPP \x28Jabber\x29 address:"), $r[0]['xmpp'], DI::l10n()->t("The XMPP address will be propagated to your contacts so that they can follow you.")],
611 '$homepage' => ['homepage', DI::l10n()->t('Homepage URL:'), $r[0]['homepage']],
612 '$hometown' => ['hometown', DI::l10n()->t('Hometown:'), $r[0]['hometown']],
613 '$politic' => ['politic', DI::l10n()->t('Political Views:'), $r[0]['politic']],
614 '$religion' => ['religion', DI::l10n()->t('Religious Views:'), $r[0]['religion']],
615 '$pub_keywords' => ['pub_keywords', DI::l10n()->t('Public Keywords:'), $r[0]['pub_keywords'], DI::l10n()->t("\x28Used for suggesting potential friends, can be seen by others\x29")],
616 '$prv_keywords' => ['prv_keywords', DI::l10n()->t('Private Keywords:'), $r[0]['prv_keywords'], DI::l10n()->t("\x28Used for searching profiles, never shown to others\x29")],
617 '$likes' => ['likes', DI::l10n()->t('Likes:'), $r[0]['likes']],
618 '$dislikes' => ['dislikes', DI::l10n()->t('Dislikes:'), $r[0]['dislikes']],
619 '$music' => ['music', DI::l10n()->t('Musical interests'), $r[0]['music']],
620 '$book' => ['book', DI::l10n()->t('Books, literature'), $r[0]['book']],
621 '$tv' => ['tv', DI::l10n()->t('Television'), $r[0]['tv']],
622 '$film' => ['film', DI::l10n()->t('Film/dance/culture/entertainment'), $r[0]['film']],
623 '$interest' => ['interest', DI::l10n()->t('Hobbies/Interests'), $r[0]['interest']],
624 '$romance' => ['romance', DI::l10n()->t('Love/romance'), $r[0]['romance']],
625 '$work' => ['work', DI::l10n()->t('Work/employment'), $r[0]['work']],
626 '$education' => ['education', DI::l10n()->t('School/education'), $r[0]['education']],
627 '$contact' => ['contact', DI::l10n()->t('Contact information and Social Networks'), $r[0]['contact']],
630 $arr = ['profile' => $r[0], 'entry' => $o];
631 Hook::callAll('profile_edit', $arr);
635 // If we don't support multi profiles, don't display this list.
636 if (!Feature::isEnabled(local_user(), 'multi_profiles')) {
637 $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1",
640 if (DBA::isResult($r)) {
641 //Go to the default profile.
642 DI::baseUrl()->redirect('profiles/' . $r[0]['id']);
646 $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
649 if (DBA::isResult($r)) {
651 $tpl = Renderer::getMarkupTemplate('profile_entry.tpl');
654 foreach ($r as $rr) {
655 $profiles .= Renderer::replaceMacros($tpl, [
656 '$photo' => DI::baseUrl()->remove($rr['thumb']),
658 '$alt' => DI::l10n()->t('Profile Image'),
659 '$profile_name' => $rr['profile-name'],
660 '$visible' => (($rr['is-default']) ? '<strong>' . DI::l10n()->t('visible to everybody') . '</strong>'
661 : '<a href="'.'profperm/'.$rr['id'].'" />' . DI::l10n()->t('Edit visibility') . '</a>')
665 $tpl_header = Renderer::getMarkupTemplate('profile_listing_header.tpl');
666 $o .= Renderer::replaceMacros($tpl_header,[
667 '$header' => DI::l10n()->t('Edit/Manage Profiles'),
668 '$chg_photo' => DI::l10n()->t('Change profile photo'),
669 '$cr_new' => DI::l10n()->t('Create New Profile'),
670 '$cr_new_link' => 'profiles/new?t=' . BaseModule::getFormSecurityToken("profile_new"),
671 '$profiles' => $profiles