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\Hook;
12 use Friendica\Core\Renderer;
13 use Friendica\Core\Worker;
14 use Friendica\Database\DBA;
16 use Friendica\Model\Contact;
17 use Friendica\Model\GContact;
18 use Friendica\Model\Profile;
19 use Friendica\Model\User;
20 use Friendica\Module\Security\Login;
21 use Friendica\Network\Probe;
22 use Friendica\Util\DateTimeFormat;
23 use Friendica\Util\Strings;
24 use Friendica\Util\Temporal;
26 function profiles_init(App $a) {
28 Nav::setSelected('profiles');
34 if (($a->argc > 2) && ($a->argv[1] === "drop") && intval($a->argv[2])) {
35 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
39 if (! DBA::isResult($r)) {
40 notice(DI::l10n()->t('Profile not found.') . EOL);
41 DI::baseUrl()->redirect('profiles');
45 BaseModule::checkFormSecurityTokenRedirectOnError('/profiles', 'profile_drop', 't');
47 // move every contact using this profile as their default to the user default
49 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 ",
54 q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d",
58 if (DBA::isResult($r)) {
59 info(DI::l10n()->t('Profile deleted.').EOL);
62 DI::baseUrl()->redirect('profiles');
66 if (($a->argc > 1) && ($a->argv[1] === 'new')) {
68 BaseModule::checkFormSecurityTokenRedirectOnError('/profiles', 'profile_new', 't');
70 $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
71 intval(local_user()));
73 $num_profiles = (DBA::isResult($r0) ? count($r0) : 0);
75 $name = DI::l10n()->t('Profile-') . ($num_profiles + 1);
77 $r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
78 intval(local_user()));
80 q("INSERT INTO `profile` (`uid` , `profile-name` , `name`, `photo`, `thumb`)
81 VALUES ( %d, '%s', '%s', '%s', '%s' )",
84 DBA::escape($r1[0]['name']),
85 DBA::escape($r1[0]['photo']),
86 DBA::escape($r1[0]['thumb'])
89 $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1",
94 info(DI::l10n()->t('New profile created.') . EOL);
95 if (DBA::isResult($r3) && count($r3) == 1) {
96 DI::baseUrl()->redirect('profiles/' . $r3[0]['id']);
99 DI::baseUrl()->redirect('profiles');
102 if (($a->argc > 2) && ($a->argv[1] === 'clone')) {
104 BaseModule::checkFormSecurityTokenRedirectOnError('/profiles', 'profile_clone', 't');
106 $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
107 intval(local_user()));
109 $num_profiles = (DBA::isResult($r0) ? count($r0) : 0);
111 $name = DI::l10n()->t('Profile-') . ($num_profiles + 1);
112 $r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 1",
113 intval(local_user()),
116 if(! DBA::isResult($r1)) {
117 notice(DI::l10n()->t('Profile unavailable to clone.') . EOL);
121 $r1[0]['is-default'] = 0;
122 $r1[0]['publish'] = 0;
123 $r1[0]['net-publish'] = 0;
124 $r1[0]['profile-name'] = DBA::escape($name);
126 DBA::insert('profile', $r1[0]);
128 $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1",
129 intval(local_user()),
132 info(DI::l10n()->t('New profile created.') . EOL);
133 if ((DBA::isResult($r3)) && (count($r3) == 1)) {
134 DI::baseUrl()->redirect('profiles/'.$r3[0]['id']);
137 DI::baseUrl()->redirect('profiles');
139 return; // NOTREACHED
143 if (($a->argc > 1) && (intval($a->argv[1]))) {
144 $r = q("SELECT id FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
148 if (! DBA::isResult($r)) {
149 notice(DI::l10n()->t('Profile not found.') . EOL);
153 Profile::load($a, $a->user['nickname'], $r[0]['id']);
157 function profile_clean_keywords($keywords)
159 $keywords = str_replace(",", " ", $keywords);
160 $keywords = explode(" ", $keywords);
163 foreach ($keywords as $keyword) {
164 $keyword = trim(strtolower($keyword));
165 $keyword = trim($keyword, "#");
166 if ($keyword != "") {
167 $cleaned[] = $keyword;
171 $keywords = implode(", ", $cleaned);
176 function profiles_post(App $a) {
178 if (! local_user()) {
179 notice(DI::l10n()->t('Permission denied.') . EOL);
183 $namechanged = false;
185 Hook::callAll('profile_post', $_POST);
187 if (($a->argc > 1) && ($a->argv[1] !== "new") && intval($a->argv[1])) {
188 $orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
192 if (! DBA::isResult($orig)) {
193 notice(DI::l10n()->t('Profile not found.') . EOL);
197 BaseModule::checkFormSecurityTokenRedirectOnError('/profiles', 'profile_edit');
199 $is_default = (($orig[0]['is-default']) ? 1 : 0);
201 $profile_name = Strings::escapeTags(trim($_POST['profile_name']));
202 if (! strlen($profile_name)) {
203 notice(DI::l10n()->t('Profile Name is required.') . EOL);
207 $dob = !empty($_POST['dob']) ? Strings::escapeHtml(trim($_POST['dob'])) : '0000-00-00';
209 $y = substr($dob, 0, 4);
210 if ((! ctype_digit($y)) || ($y < 1900)) {
213 $ignore_year = false;
215 if (!in_array($dob, ['0000-00-00', DBA::NULL_DATE])) {
216 if (strpos($dob, '0000-') === 0 || strpos($dob, '0001-') === 0) {
218 $dob = substr($dob, 5);
222 $dob = '0000-' . DateTimeFormat::utc('1900-' . $dob, 'm-d');
224 $dob = DateTimeFormat::utc($dob, 'Y-m-d');
228 $name = Strings::escapeTags(trim($_POST['name']));
230 if (! strlen($name)) {
234 if ($orig[0]['name'] != $name) {
238 $pdesc = Strings::escapeTags(trim($_POST['pdesc'] ?? ''));
239 $gender = Strings::escapeTags(trim($_POST['gender'] ?? ''));
240 $address = Strings::escapeTags(trim($_POST['address'] ?? ''));
241 $locality = Strings::escapeTags(trim($_POST['locality'] ?? ''));
242 $region = Strings::escapeTags(trim($_POST['region'] ?? ''));
243 $postal_code = Strings::escapeTags(trim($_POST['postal_code'] ?? ''));
244 $country_name = Strings::escapeTags(trim($_POST['country_name'] ?? ''));
245 $pub_keywords = profile_clean_keywords(Strings::escapeTags(trim($_POST['pub_keywords'] ?? '')));
246 $prv_keywords = profile_clean_keywords(Strings::escapeTags(trim($_POST['prv_keywords'] ?? '')));
247 $marital = Strings::escapeTags(trim($_POST['marital'] ?? ''));
248 $howlong = Strings::escapeTags(trim($_POST['howlong'] ?? ''));
250 $with = (!empty($_POST['with']) ? Strings::escapeTags(trim($_POST['with'])) : '');
252 if (! strlen($howlong)) {
253 $howlong = DBA::NULL_DATETIME;
255 $howlong = DateTimeFormat::convert($howlong, 'UTC', date_default_timezone_get());
257 // linkify the relationship target if applicable
259 $withchanged = false;
262 if ($with != strip_tags($orig[0]['with'])) {
266 if (strpos($lookup, '@') === 0) {
267 $lookup = substr($lookup, 1);
269 $lookup = str_replace('_',' ', $lookup);
270 if (strpos($lookup, '@') || (strpos($lookup, 'http://'))) {
272 $links = @Probe::lrdd($lookup);
274 foreach ($links as $link) {
275 if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
276 $prf = $link['@attributes']['href'];
283 $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
284 DBA::escape($newname),
287 if (! DBA::isResult($r)) {
288 $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
289 DBA::escape($lookup),
293 if (DBA::isResult($r)) {
295 $newname = $r[0]['name'];
300 $with = str_replace($lookup, '<a href="' . $prf . '">' . $newname . '</a>', $with);
301 if (strpos($with, '@') === 0) {
302 $with = substr($with, 1);
306 $with = $orig[0]['with'];
310 /// @TODO Not flexible enough for later expansion, let's have more OOP here
311 $sexual = Strings::escapeTags(trim($_POST['sexual']));
312 $xmpp = Strings::escapeTags(trim($_POST['xmpp']));
313 $homepage = Strings::escapeTags(trim($_POST['homepage']));
314 if ((strpos($homepage, 'http') !== 0) && (strlen($homepage))) {
315 // neither http nor https in URL, add them
316 $homepage = 'http://'.$homepage;
318 $hometown = Strings::escapeTags(trim($_POST['hometown']));
319 $politic = Strings::escapeTags(trim($_POST['politic']));
320 $religion = Strings::escapeTags(trim($_POST['religion']));
322 $likes = Strings::escapeHtml(trim($_POST['likes']));
323 $dislikes = Strings::escapeHtml(trim($_POST['dislikes']));
325 $about = Strings::escapeHtml(trim($_POST['about']));
326 $interest = Strings::escapeHtml(trim($_POST['interest']));
327 $contact = Strings::escapeHtml(trim($_POST['contact']));
328 $music = Strings::escapeHtml(trim($_POST['music']));
329 $book = Strings::escapeHtml(trim($_POST['book']));
330 $tv = Strings::escapeHtml(trim($_POST['tv']));
331 $film = Strings::escapeHtml(trim($_POST['film']));
332 $romance = Strings::escapeHtml(trim($_POST['romance']));
333 $work = Strings::escapeHtml(trim($_POST['work']));
334 $education = Strings::escapeHtml(trim($_POST['education']));
336 $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0);
338 DI::pConfig()->set(local_user(), 'system', 'detailled_profile', !empty($_POST['detailed_profile']) ? 1: 0);
342 if ($marital != $orig[0]['marital']) {
343 $changes[] = '[color=#ff0000]♥[/color] ' . DI::l10n()->t('Marital Status');
346 $changes[] = '[color=#ff0000]♥[/color] ' . DI::l10n()->t('Romantic Partner');
348 if ($likes != $orig[0]['likes']) {
349 $changes[] = DI::l10n()->t('Likes');
351 if ($dislikes != $orig[0]['dislikes']) {
352 $changes[] = DI::l10n()->t('Dislikes');
354 if ($work != $orig[0]['work']) {
355 $changes[] = DI::l10n()->t('Work/Employment');
357 if ($religion != $orig[0]['religion']) {
358 $changes[] = DI::l10n()->t('Religion');
360 if ($politic != $orig[0]['politic']) {
361 $changes[] = DI::l10n()->t('Political Views');
363 if ($gender != $orig[0]['gender']) {
364 $changes[] = DI::l10n()->t('Gender');
366 if ($sexual != $orig[0]['sexual']) {
367 $changes[] = DI::l10n()->t('Sexual Preference');
369 if ($xmpp != $orig[0]['xmpp']) {
370 $changes[] = DI::l10n()->t('XMPP');
372 if ($homepage != $orig[0]['homepage']) {
373 $changes[] = DI::l10n()->t('Homepage');
375 if ($interest != $orig[0]['interest']) {
376 $changes[] = DI::l10n()->t('Interests');
378 if ($address != $orig[0]['address']) {
379 $changes[] = DI::l10n()->t('Address');
380 // New address not sent in notifications, potential privacy issues
381 // in case this leaks to unintended recipients. Yes, it's in the public
382 // profile but that doesn't mean we have to broadcast it to everybody.
384 if ($locality != $orig[0]['locality'] || $region != $orig[0]['region']
385 || $country_name != $orig[0]['country-name']) {
386 $changes[] = DI::l10n()->t('Location');
390 $r = q("UPDATE `profile`
391 SET `profile-name` = '%s',
399 `postal-code` = '%s',
400 `country-name` = '%s',
410 `pub_keywords` = '%s',
411 `prv_keywords` = '%s',
425 WHERE `id` = %d AND `uid` = %d",
426 DBA::escape($profile_name),
429 DBA::escape($gender),
431 DBA::escape($address),
432 DBA::escape($locality),
433 DBA::escape($region),
434 DBA::escape($postal_code),
435 DBA::escape($country_name),
436 DBA::escape($marital),
438 DBA::escape($howlong),
439 DBA::escape($sexual),
441 DBA::escape($homepage),
442 DBA::escape($hometown),
443 DBA::escape($politic),
444 DBA::escape($religion),
445 DBA::escape($pub_keywords),
446 DBA::escape($prv_keywords),
448 DBA::escape($dislikes),
450 DBA::escape($interest),
451 DBA::escape($contact),
456 DBA::escape($romance),
458 DBA::escape($education),
459 intval($hide_friends),
464 /// @TODO decide to use DBA::isResult() here and check $r
466 info(DI::l10n()->t('Profile updated.') . EOL);
471 q("UPDATE `user` set `username` = '%s' where `uid` = %d",
477 Contact::updateSelfFromUserID(local_user());
479 // Update global directory in background
480 $url = $_SESSION['my_url'];
481 if ($url && strlen(DI::config()->get('system', 'directory'))) {
482 Worker::add(PRIORITY_LOW, "Directory", $url);
485 Worker::add(PRIORITY_LOW, 'ProfileUpdate', local_user());
487 // Update the global contact for the user
488 GContact::updateForUser(local_user());
493 function profiles_content(App $a) {
495 if (! local_user()) {
496 notice(DI::l10n()->t('Permission denied.') . EOL);
497 return Login::form();
502 if (($a->argc > 1) && (intval($a->argv[1]))) {
503 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
507 if (! DBA::isResult($r)) {
508 notice(DI::l10n()->t('Profile not found.') . EOL);
512 DI::page()['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('profed_head.tpl'), [
513 '$baseurl' => DI::baseUrl()->get(true),
516 $opt_tpl = Renderer::getMarkupTemplate("profile-hide-friends.tpl");
517 $hide_friends = Renderer::replaceMacros($opt_tpl,[
519 'hide-friends', //Name
520 DI::l10n()->t('Hide contacts and friends:'), //Label
521 !!$r[0]['hide-friends'], //Value
523 [DI::l10n()->t('No'), DI::l10n()->t('Yes')] //Off - On strings
525 '$desc' => DI::l10n()->t('Hide your contact/friend list from viewers of this profile?'),
526 '$yes_str' => DI::l10n()->t('Yes'),
527 '$no_str' => DI::l10n()->t('No'),
528 '$yes_selected' => (($r[0]['hide-friends']) ? " checked=\"checked\" " : ""),
529 '$no_selected' => (($r[0]['hide-friends'] == 0) ? " checked=\"checked\" " : "")
532 $personal_account = !(in_array($a->user["page-flags"],
533 [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP]));
535 $detailed_profile = (DI::pConfig()->get(local_user(), 'system', 'detailled_profile') AND $personal_account);
537 $is_default = (($r[0]['is-default']) ? 1 : 0);
538 $tpl = Renderer::getMarkupTemplate("profile_edit.tpl");
539 $o .= Renderer::replaceMacros($tpl, [
540 '$personal_account' => $personal_account,
541 '$detailled_profile' => $detailed_profile,
544 'detailed_profile', //Name
545 DI::l10n()->t('Show more profile fields:'), //Label
546 $detailed_profile, //Value
548 [DI::l10n()->t('No'), DI::l10n()->t('Yes')] //Off - On strings
551 '$multi_profiles' => Feature::isEnabled(local_user(), 'multi_profiles'),
552 '$form_security_token' => BaseModule::getFormSecurityToken("profile_edit"),
553 '$form_security_token_photo' => BaseModule::getFormSecurityToken("profile_photo"),
554 '$profile_clone_link' => ((Feature::isEnabled(local_user(), 'multi_profiles')) ? 'profiles/clone/' . $r[0]['id'] . '?t=' . BaseModule::getFormSecurityToken("profile_clone") : ""),
555 '$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . BaseModule::getFormSecurityToken("profile_drop"),
557 '$profile_action' => DI::l10n()->t('Profile Actions'),
558 '$banner' => DI::l10n()->t('Edit Profile Details'),
559 '$submit' => DI::l10n()->t('Submit'),
560 '$profpic' => DI::l10n()->t('Change Profile Photo'),
561 '$profpiclink' => '/photos/' . $a->user['nickname'],
562 '$viewprof' => DI::l10n()->t('View this profile'),
563 '$viewallprof' => DI::l10n()->t('View all profiles'),
564 '$editvis' => DI::l10n()->t('Edit visibility'),
565 '$cr_prof' => DI::l10n()->t('Create a new profile using these settings'),
566 '$cl_prof' => DI::l10n()->t('Clone this profile'),
567 '$del_prof' => DI::l10n()->t('Delete this profile'),
569 '$lbl_basic_section' => DI::l10n()->t('Basic information'),
570 '$lbl_picture_section' => DI::l10n()->t('Profile picture'),
571 '$lbl_location_section' => DI::l10n()->t('Location'),
572 '$lbl_preferences_section' => DI::l10n()->t('Preferences'),
573 '$lbl_status_section' => DI::l10n()->t('Status information'),
574 '$lbl_about_section' => DI::l10n()->t('Additional information'),
575 '$lbl_interests_section' => DI::l10n()->t('Interests'),
576 '$lbl_personal_section' => DI::l10n()->t('Personal'),
577 '$lbl_relation_section' => DI::l10n()->t('Relation'),
578 '$lbl_miscellaneous_section' => DI::l10n()->t('Miscellaneous'),
580 '$lbl_profile_photo' => DI::l10n()->t('Upload Profile Photo'),
581 '$lbl_gender' => DI::l10n()->t('Your Gender:'),
582 '$lbl_marital' => DI::l10n()->t('<span class="heart">♥</span> Marital Status:'),
583 '$lbl_sexual' => DI::l10n()->t('Sexual Preference:'),
584 '$lbl_ex2' => DI::l10n()->t('Example: fishing photography software'),
586 '$disabled' => (($is_default) ? 'onclick="return false;" style="color: #BBBBFF;"' : ''),
587 '$baseurl' => DI::baseUrl()->get(true),
588 '$profile_id' => $r[0]['id'],
589 '$profile_name' => ['profile_name', DI::l10n()->t('Profile Name:'), $r[0]['profile-name'], DI::l10n()->t('Required'), '*'],
590 '$is_default' => $is_default,
591 '$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>' : ""),
592 '$name' => ['name', DI::l10n()->t('Your Full Name:'), $r[0]['name']],
593 '$pdesc' => ['pdesc', DI::l10n()->t('Title/Description:'), $r[0]['pdesc']],
594 '$dob' => Temporal::getDateofBirthField($r[0]['dob'], $a->user['timezone']),
595 '$hide_friends' => $hide_friends,
596 '$address' => ['address', DI::l10n()->t('Street Address:'), $r[0]['address']],
597 '$locality' => ['locality', DI::l10n()->t('Locality/City:'), $r[0]['locality']],
598 '$region' => ['region', DI::l10n()->t('Region/State:'), $r[0]['region']],
599 '$postal_code' => ['postal_code', DI::l10n()->t('Postal/Zip Code:'), $r[0]['postal-code']],
600 '$country_name' => ['country_name', DI::l10n()->t('Country:'), $r[0]['country-name']],
601 '$age' => ((intval($r[0]['dob'])) ? '(' . DI::l10n()->t('Age: ') . DI::l10n()->tt('%d year old', '%d years old', Temporal::getAgeByTimezone($r[0]['dob'], $a->user['timezone'])) . ')' : ''),
602 '$gender' => DI::l10n()->t(ContactSelector::gender($r[0]['gender'])),
603 '$marital' => ['selector' => ContactSelector::maritalStatus($r[0]['marital']), 'value' => DI::l10n()->t($r[0]['marital'])],
604 '$with' => ['with', DI::l10n()->t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), DI::l10n()->t('Examples: cathy123, Cathy Williams, cathy@example.com')],
605 '$howlong' => ['howlong', DI::l10n()->t('Since [date]:'), ($r[0]['howlong'] <= DBA::NULL_DATETIME ? '' : DateTimeFormat::local($r[0]['howlong']))],
606 '$sexual' => ['selector' => ContactSelector::sexualPreference($r[0]['sexual']), 'value' => DI::l10n()->t($r[0]['sexual'])],
607 '$about' => ['about', DI::l10n()->t('Tell us about yourself...'), $r[0]['about']],
608 '$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.")],
609 '$homepage' => ['homepage', DI::l10n()->t('Homepage URL:'), $r[0]['homepage']],
610 '$hometown' => ['hometown', DI::l10n()->t('Hometown:'), $r[0]['hometown']],
611 '$politic' => ['politic', DI::l10n()->t('Political Views:'), $r[0]['politic']],
612 '$religion' => ['religion', DI::l10n()->t('Religious Views:'), $r[0]['religion']],
613 '$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")],
614 '$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")],
615 '$likes' => ['likes', DI::l10n()->t('Likes:'), $r[0]['likes']],
616 '$dislikes' => ['dislikes', DI::l10n()->t('Dislikes:'), $r[0]['dislikes']],
617 '$music' => ['music', DI::l10n()->t('Musical interests'), $r[0]['music']],
618 '$book' => ['book', DI::l10n()->t('Books, literature'), $r[0]['book']],
619 '$tv' => ['tv', DI::l10n()->t('Television'), $r[0]['tv']],
620 '$film' => ['film', DI::l10n()->t('Film/dance/culture/entertainment'), $r[0]['film']],
621 '$interest' => ['interest', DI::l10n()->t('Hobbies/Interests'), $r[0]['interest']],
622 '$romance' => ['romance', DI::l10n()->t('Love/romance'), $r[0]['romance']],
623 '$work' => ['work', DI::l10n()->t('Work/employment'), $r[0]['work']],
624 '$education' => ['education', DI::l10n()->t('School/education'), $r[0]['education']],
625 '$contact' => ['contact', DI::l10n()->t('Contact information and Social Networks'), $r[0]['contact']],
628 $arr = ['profile' => $r[0], 'entry' => $o];
629 Hook::callAll('profile_edit', $arr);
633 // If we don't support multi profiles, don't display this list.
634 if (!Feature::isEnabled(local_user(), 'multi_profiles')) {
635 $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1",
638 if (DBA::isResult($r)) {
639 //Go to the default profile.
640 DI::baseUrl()->redirect('profiles/' . $r[0]['id']);
644 $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
647 if (DBA::isResult($r)) {
649 $tpl = Renderer::getMarkupTemplate('profile_entry.tpl');
652 foreach ($r as $rr) {
653 $profiles .= Renderer::replaceMacros($tpl, [
654 '$photo' => DI::baseUrl()->remove($rr['thumb']),
656 '$alt' => DI::l10n()->t('Profile Image'),
657 '$profile_name' => $rr['profile-name'],
658 '$visible' => (($rr['is-default']) ? '<strong>' . DI::l10n()->t('visible to everybody') . '</strong>'
659 : '<a href="'.'profperm/'.$rr['id'].'" />' . DI::l10n()->t('Edit visibility') . '</a>')
663 $tpl_header = Renderer::getMarkupTemplate('profile_listing_header.tpl');
664 $o .= Renderer::replaceMacros($tpl_header,[
665 '$header' => DI::l10n()->t('Edit/Manage Profiles'),
666 '$chg_photo' => DI::l10n()->t('Change profile photo'),
667 '$cr_new' => DI::l10n()->t('Create New Profile'),
668 '$cr_new_link' => 'profiles/new?t=' . BaseModule::getFormSecurityToken("profile_new"),
669 '$profiles' => $profiles