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\Renderer;
14 use Friendica\Core\Worker;
15 use Friendica\Database\DBA;
17 use Friendica\Model\Contact;
18 use Friendica\Model\GContact;
19 use Friendica\Model\Profile;
20 use Friendica\Model\User;
21 use Friendica\Module\Security\Login;
22 use Friendica\Network\Probe;
23 use Friendica\Util\DateTimeFormat;
24 use Friendica\Util\Strings;
25 use Friendica\Util\Temporal;
27 function profiles_init(App $a) {
29 Nav::setSelected('profiles');
35 if (($a->argc > 2) && ($a->argv[1] === "drop") && intval($a->argv[2])) {
36 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
40 if (! DBA::isResult($r)) {
41 notice(DI::l10n()->t('Profile not found.') . EOL);
42 DI::baseUrl()->redirect('profiles');
46 BaseModule::checkFormSecurityTokenRedirectOnError('/profiles', 'profile_drop', 't');
48 // move every contact using this profile as their default to the user default
50 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 ",
55 q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d",
59 if (DBA::isResult($r)) {
60 info(DI::l10n()->t('Profile deleted.').EOL);
63 DI::baseUrl()->redirect('profiles');
67 if (($a->argc > 1) && ($a->argv[1] === 'new')) {
69 BaseModule::checkFormSecurityTokenRedirectOnError('/profiles', 'profile_new', 't');
71 $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
72 intval(local_user()));
74 $num_profiles = (DBA::isResult($r0) ? count($r0) : 0);
76 $name = DI::l10n()->t('Profile-') . ($num_profiles + 1);
78 $r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
79 intval(local_user()));
81 q("INSERT INTO `profile` (`uid` , `profile-name` , `name`, `photo`, `thumb`)
82 VALUES ( %d, '%s', '%s', '%s', '%s' )",
85 DBA::escape($r1[0]['name']),
86 DBA::escape($r1[0]['photo']),
87 DBA::escape($r1[0]['thumb'])
90 $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1",
95 info(DI::l10n()->t('New profile created.') . EOL);
96 if (DBA::isResult($r3) && count($r3) == 1) {
97 DI::baseUrl()->redirect('profiles/' . $r3[0]['id']);
100 DI::baseUrl()->redirect('profiles');
103 if (($a->argc > 2) && ($a->argv[1] === 'clone')) {
105 BaseModule::checkFormSecurityTokenRedirectOnError('/profiles', 'profile_clone', 't');
107 $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
108 intval(local_user()));
110 $num_profiles = (DBA::isResult($r0) ? count($r0) : 0);
112 $name = DI::l10n()->t('Profile-') . ($num_profiles + 1);
113 $r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 1",
114 intval(local_user()),
117 if(! DBA::isResult($r1)) {
118 notice(DI::l10n()->t('Profile unavailable to clone.') . EOL);
122 $r1[0]['is-default'] = 0;
123 $r1[0]['publish'] = 0;
124 $r1[0]['net-publish'] = 0;
125 $r1[0]['profile-name'] = DBA::escape($name);
127 DBA::insert('profile', $r1[0]);
129 $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1",
130 intval(local_user()),
133 info(DI::l10n()->t('New profile created.') . EOL);
134 if ((DBA::isResult($r3)) && (count($r3) == 1)) {
135 DI::baseUrl()->redirect('profiles/'.$r3[0]['id']);
138 DI::baseUrl()->redirect('profiles');
140 return; // NOTREACHED
144 if (($a->argc > 1) && (intval($a->argv[1]))) {
145 $r = q("SELECT id FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
149 if (! DBA::isResult($r)) {
150 notice(DI::l10n()->t('Profile not found.') . EOL);
154 Profile::load($a, $a->user['nickname'], $r[0]['id']);
158 function profile_clean_keywords($keywords)
160 $keywords = str_replace(",", " ", $keywords);
161 $keywords = explode(" ", $keywords);
164 foreach ($keywords as $keyword) {
165 $keyword = trim(strtolower($keyword));
166 $keyword = trim($keyword, "#");
167 if ($keyword != "") {
168 $cleaned[] = $keyword;
172 $keywords = implode(", ", $cleaned);
177 function profiles_post(App $a) {
179 if (! local_user()) {
180 notice(DI::l10n()->t('Permission denied.') . EOL);
184 $namechanged = false;
186 Hook::callAll('profile_post', $_POST);
188 if (($a->argc > 1) && ($a->argv[1] !== "new") && intval($a->argv[1])) {
189 $orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
193 if (! DBA::isResult($orig)) {
194 notice(DI::l10n()->t('Profile not found.') . EOL);
198 BaseModule::checkFormSecurityTokenRedirectOnError('/profiles', 'profile_edit');
200 $is_default = (($orig[0]['is-default']) ? 1 : 0);
202 $profile_name = Strings::escapeTags(trim($_POST['profile_name']));
203 if (! strlen($profile_name)) {
204 notice(DI::l10n()->t('Profile Name is required.') . EOL);
208 $dob = !empty($_POST['dob']) ? Strings::escapeHtml(trim($_POST['dob'])) : '0000-00-00';
210 $y = substr($dob, 0, 4);
211 if ((! ctype_digit($y)) || ($y < 1900)) {
214 $ignore_year = false;
216 if (!in_array($dob, ['0000-00-00', DBA::NULL_DATE])) {
217 if (strpos($dob, '0000-') === 0 || strpos($dob, '0001-') === 0) {
219 $dob = substr($dob, 5);
223 $dob = '0000-' . DateTimeFormat::utc('1900-' . $dob, 'm-d');
225 $dob = DateTimeFormat::utc($dob, 'Y-m-d');
229 $name = Strings::escapeTags(trim($_POST['name']));
231 if (! strlen($name)) {
235 if ($orig[0]['name'] != $name) {
239 $pdesc = Strings::escapeTags(trim($_POST['pdesc'] ?? ''));
240 $gender = Strings::escapeTags(trim($_POST['gender'] ?? ''));
241 $address = Strings::escapeTags(trim($_POST['address'] ?? ''));
242 $locality = Strings::escapeTags(trim($_POST['locality'] ?? ''));
243 $region = Strings::escapeTags(trim($_POST['region'] ?? ''));
244 $postal_code = Strings::escapeTags(trim($_POST['postal_code'] ?? ''));
245 $country_name = Strings::escapeTags(trim($_POST['country_name'] ?? ''));
246 $pub_keywords = profile_clean_keywords(Strings::escapeTags(trim($_POST['pub_keywords'] ?? '')));
247 $prv_keywords = profile_clean_keywords(Strings::escapeTags(trim($_POST['prv_keywords'] ?? '')));
248 $marital = Strings::escapeTags(trim($_POST['marital'] ?? ''));
249 $howlong = Strings::escapeTags(trim($_POST['howlong'] ?? ''));
251 $with = (!empty($_POST['with']) ? Strings::escapeTags(trim($_POST['with'])) : '');
253 if (! strlen($howlong)) {
254 $howlong = DBA::NULL_DATETIME;
256 $howlong = DateTimeFormat::convert($howlong, 'UTC', date_default_timezone_get());
258 // linkify the relationship target if applicable
260 $withchanged = false;
263 if ($with != strip_tags($orig[0]['with'])) {
267 if (strpos($lookup, '@') === 0) {
268 $lookup = substr($lookup, 1);
270 $lookup = str_replace('_',' ', $lookup);
271 if (strpos($lookup, '@') || (strpos($lookup, 'http://'))) {
273 $links = @Probe::lrdd($lookup);
275 foreach ($links as $link) {
276 if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
277 $prf = $link['@attributes']['href'];
284 $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
285 DBA::escape($newname),
288 if (! DBA::isResult($r)) {
289 $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
290 DBA::escape($lookup),
294 if (DBA::isResult($r)) {
296 $newname = $r[0]['name'];
301 $with = str_replace($lookup, '<a href="' . $prf . '">' . $newname . '</a>', $with);
302 if (strpos($with, '@') === 0) {
303 $with = substr($with, 1);
307 $with = $orig[0]['with'];
311 /// @TODO Not flexible enough for later expansion, let's have more OOP here
312 $sexual = Strings::escapeTags(trim($_POST['sexual']));
313 $xmpp = Strings::escapeTags(trim($_POST['xmpp']));
314 $homepage = Strings::escapeTags(trim($_POST['homepage']));
315 if ((strpos($homepage, 'http') !== 0) && (strlen($homepage))) {
316 // neither http nor https in URL, add them
317 $homepage = 'http://'.$homepage;
319 $hometown = Strings::escapeTags(trim($_POST['hometown']));
320 $politic = Strings::escapeTags(trim($_POST['politic']));
321 $religion = Strings::escapeTags(trim($_POST['religion']));
323 $likes = Strings::escapeHtml(trim($_POST['likes']));
324 $dislikes = Strings::escapeHtml(trim($_POST['dislikes']));
326 $about = Strings::escapeHtml(trim($_POST['about']));
327 $interest = Strings::escapeHtml(trim($_POST['interest']));
328 $contact = Strings::escapeHtml(trim($_POST['contact']));
329 $music = Strings::escapeHtml(trim($_POST['music']));
330 $book = Strings::escapeHtml(trim($_POST['book']));
331 $tv = Strings::escapeHtml(trim($_POST['tv']));
332 $film = Strings::escapeHtml(trim($_POST['film']));
333 $romance = Strings::escapeHtml(trim($_POST['romance']));
334 $work = Strings::escapeHtml(trim($_POST['work']));
335 $education = Strings::escapeHtml(trim($_POST['education']));
337 $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0);
339 DI::pConfig()->set(local_user(), 'system', 'detailled_profile', !empty($_POST['detailed_profile']) ? 1: 0);
343 if ($marital != $orig[0]['marital']) {
344 $changes[] = '[color=#ff0000]♥[/color] ' . DI::l10n()->t('Marital Status');
347 $changes[] = '[color=#ff0000]♥[/color] ' . DI::l10n()->t('Romantic Partner');
349 if ($likes != $orig[0]['likes']) {
350 $changes[] = DI::l10n()->t('Likes');
352 if ($dislikes != $orig[0]['dislikes']) {
353 $changes[] = DI::l10n()->t('Dislikes');
355 if ($work != $orig[0]['work']) {
356 $changes[] = DI::l10n()->t('Work/Employment');
358 if ($religion != $orig[0]['religion']) {
359 $changes[] = DI::l10n()->t('Religion');
361 if ($politic != $orig[0]['politic']) {
362 $changes[] = DI::l10n()->t('Political Views');
364 if ($gender != $orig[0]['gender']) {
365 $changes[] = DI::l10n()->t('Gender');
367 if ($sexual != $orig[0]['sexual']) {
368 $changes[] = DI::l10n()->t('Sexual Preference');
370 if ($xmpp != $orig[0]['xmpp']) {
371 $changes[] = DI::l10n()->t('XMPP');
373 if ($homepage != $orig[0]['homepage']) {
374 $changes[] = DI::l10n()->t('Homepage');
376 if ($interest != $orig[0]['interest']) {
377 $changes[] = DI::l10n()->t('Interests');
379 if ($address != $orig[0]['address']) {
380 $changes[] = DI::l10n()->t('Address');
381 // New address not sent in notifications, potential privacy issues
382 // in case this leaks to unintended recipients. Yes, it's in the public
383 // profile but that doesn't mean we have to broadcast it to everybody.
385 if ($locality != $orig[0]['locality'] || $region != $orig[0]['region']
386 || $country_name != $orig[0]['country-name']) {
387 $changes[] = DI::l10n()->t('Location');
391 $r = q("UPDATE `profile`
392 SET `profile-name` = '%s',
400 `postal-code` = '%s',
401 `country-name` = '%s',
411 `pub_keywords` = '%s',
412 `prv_keywords` = '%s',
426 WHERE `id` = %d AND `uid` = %d",
427 DBA::escape($profile_name),
430 DBA::escape($gender),
432 DBA::escape($address),
433 DBA::escape($locality),
434 DBA::escape($region),
435 DBA::escape($postal_code),
436 DBA::escape($country_name),
437 DBA::escape($marital),
439 DBA::escape($howlong),
440 DBA::escape($sexual),
442 DBA::escape($homepage),
443 DBA::escape($hometown),
444 DBA::escape($politic),
445 DBA::escape($religion),
446 DBA::escape($pub_keywords),
447 DBA::escape($prv_keywords),
449 DBA::escape($dislikes),
451 DBA::escape($interest),
452 DBA::escape($contact),
457 DBA::escape($romance),
459 DBA::escape($education),
460 intval($hide_friends),
465 /// @TODO decide to use DBA::isResult() here and check $r
467 info(DI::l10n()->t('Profile updated.') . EOL);
472 q("UPDATE `user` set `username` = '%s' where `uid` = %d",
478 Contact::updateSelfFromUserID(local_user());
480 // Update global directory in background
481 $url = $_SESSION['my_url'];
482 if ($url && strlen(Config::get('system', 'directory'))) {
483 Worker::add(PRIORITY_LOW, "Directory", $url);
486 Worker::add(PRIORITY_LOW, 'ProfileUpdate', local_user());
488 // Update the global contact for the user
489 GContact::updateForUser(local_user());
494 function profiles_content(App $a) {
496 if (! local_user()) {
497 notice(DI::l10n()->t('Permission denied.') . EOL);
498 return Login::form();
503 if (($a->argc > 1) && (intval($a->argv[1]))) {
504 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
508 if (! DBA::isResult($r)) {
509 notice(DI::l10n()->t('Profile not found.') . EOL);
513 DI::page()['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('profed_head.tpl'), [
514 '$baseurl' => DI::baseUrl()->get(true),
517 $opt_tpl = Renderer::getMarkupTemplate("profile-hide-friends.tpl");
518 $hide_friends = Renderer::replaceMacros($opt_tpl,[
520 'hide-friends', //Name
521 DI::l10n()->t('Hide contacts and friends:'), //Label
522 !!$r[0]['hide-friends'], //Value
524 [DI::l10n()->t('No'), DI::l10n()->t('Yes')] //Off - On strings
526 '$desc' => DI::l10n()->t('Hide your contact/friend list from viewers of this profile?'),
527 '$yes_str' => DI::l10n()->t('Yes'),
528 '$no_str' => DI::l10n()->t('No'),
529 '$yes_selected' => (($r[0]['hide-friends']) ? " checked=\"checked\" " : ""),
530 '$no_selected' => (($r[0]['hide-friends'] == 0) ? " checked=\"checked\" " : "")
533 $personal_account = !(in_array($a->user["page-flags"],
534 [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_PRVGROUP]));
536 $detailed_profile = (DI::pConfig()->get(local_user(), 'system', 'detailled_profile') AND $personal_account);
538 $is_default = (($r[0]['is-default']) ? 1 : 0);
539 $tpl = Renderer::getMarkupTemplate("profile_edit.tpl");
540 $o .= Renderer::replaceMacros($tpl, [
541 '$personal_account' => $personal_account,
542 '$detailled_profile' => $detailed_profile,
545 'detailed_profile', //Name
546 DI::l10n()->t('Show more profile fields:'), //Label
547 $detailed_profile, //Value
549 [DI::l10n()->t('No'), DI::l10n()->t('Yes')] //Off - On strings
552 '$multi_profiles' => Feature::isEnabled(local_user(), 'multi_profiles'),
553 '$form_security_token' => BaseModule::getFormSecurityToken("profile_edit"),
554 '$form_security_token_photo' => BaseModule::getFormSecurityToken("profile_photo"),
555 '$profile_clone_link' => ((Feature::isEnabled(local_user(), 'multi_profiles')) ? 'profiles/clone/' . $r[0]['id'] . '?t=' . BaseModule::getFormSecurityToken("profile_clone") : ""),
556 '$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . BaseModule::getFormSecurityToken("profile_drop"),
558 '$profile_action' => DI::l10n()->t('Profile Actions'),
559 '$banner' => DI::l10n()->t('Edit Profile Details'),
560 '$submit' => DI::l10n()->t('Submit'),
561 '$profpic' => DI::l10n()->t('Change Profile Photo'),
562 '$profpiclink' => '/photos/' . $a->user['nickname'],
563 '$viewprof' => DI::l10n()->t('View this profile'),
564 '$viewallprof' => DI::l10n()->t('View all profiles'),
565 '$editvis' => DI::l10n()->t('Edit visibility'),
566 '$cr_prof' => DI::l10n()->t('Create a new profile using these settings'),
567 '$cl_prof' => DI::l10n()->t('Clone this profile'),
568 '$del_prof' => DI::l10n()->t('Delete this profile'),
570 '$lbl_basic_section' => DI::l10n()->t('Basic information'),
571 '$lbl_picture_section' => DI::l10n()->t('Profile picture'),
572 '$lbl_location_section' => DI::l10n()->t('Location'),
573 '$lbl_preferences_section' => DI::l10n()->t('Preferences'),
574 '$lbl_status_section' => DI::l10n()->t('Status information'),
575 '$lbl_about_section' => DI::l10n()->t('Additional information'),
576 '$lbl_interests_section' => DI::l10n()->t('Interests'),
577 '$lbl_personal_section' => DI::l10n()->t('Personal'),
578 '$lbl_relation_section' => DI::l10n()->t('Relation'),
579 '$lbl_miscellaneous_section' => DI::l10n()->t('Miscellaneous'),
581 '$lbl_profile_photo' => DI::l10n()->t('Upload Profile Photo'),
582 '$lbl_gender' => DI::l10n()->t('Your Gender:'),
583 '$lbl_marital' => DI::l10n()->t('<span class="heart">♥</span> Marital Status:'),
584 '$lbl_sexual' => DI::l10n()->t('Sexual Preference:'),
585 '$lbl_ex2' => DI::l10n()->t('Example: fishing photography software'),
587 '$disabled' => (($is_default) ? 'onclick="return false;" style="color: #BBBBFF;"' : ''),
588 '$baseurl' => DI::baseUrl()->get(true),
589 '$profile_id' => $r[0]['id'],
590 '$profile_name' => ['profile_name', DI::l10n()->t('Profile Name:'), $r[0]['profile-name'], DI::l10n()->t('Required'), '*'],
591 '$is_default' => $is_default,
592 '$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>' : ""),
593 '$name' => ['name', DI::l10n()->t('Your Full Name:'), $r[0]['name']],
594 '$pdesc' => ['pdesc', DI::l10n()->t('Title/Description:'), $r[0]['pdesc']],
595 '$dob' => Temporal::getDateofBirthField($r[0]['dob'], $a->user['timezone']),
596 '$hide_friends' => $hide_friends,
597 '$address' => ['address', DI::l10n()->t('Street Address:'), $r[0]['address']],
598 '$locality' => ['locality', DI::l10n()->t('Locality/City:'), $r[0]['locality']],
599 '$region' => ['region', DI::l10n()->t('Region/State:'), $r[0]['region']],
600 '$postal_code' => ['postal_code', DI::l10n()->t('Postal/Zip Code:'), $r[0]['postal-code']],
601 '$country_name' => ['country_name', DI::l10n()->t('Country:'), $r[0]['country-name']],
602 '$age' => ((intval($r[0]['dob'])) ? '(' . DI::l10n()->t('Age: ') . Temporal::getAgeByTimezone($r[0]['dob'],$a->user['timezone'],$a->user['timezone']) . ')' : ''),
603 '$gender' => DI::l10n()->t(ContactSelector::gender($r[0]['gender'])),
604 '$marital' => ['selector' => ContactSelector::maritalStatus($r[0]['marital']), 'value' => DI::l10n()->t($r[0]['marital'])],
605 '$with' => ['with', DI::l10n()->t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), DI::l10n()->t('Examples: cathy123, Cathy Williams, cathy@example.com')],
606 '$howlong' => ['howlong', DI::l10n()->t('Since [date]:'), ($r[0]['howlong'] <= DBA::NULL_DATETIME ? '' : DateTimeFormat::local($r[0]['howlong']))],
607 '$sexual' => ['selector' => ContactSelector::sexualPreference($r[0]['sexual']), 'value' => DI::l10n()->t($r[0]['sexual'])],
608 '$about' => ['about', DI::l10n()->t('Tell us about yourself...'), $r[0]['about']],
609 '$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.")],
610 '$homepage' => ['homepage', DI::l10n()->t('Homepage URL:'), $r[0]['homepage']],
611 '$hometown' => ['hometown', DI::l10n()->t('Hometown:'), $r[0]['hometown']],
612 '$politic' => ['politic', DI::l10n()->t('Political Views:'), $r[0]['politic']],
613 '$religion' => ['religion', DI::l10n()->t('Religious Views:'), $r[0]['religion']],
614 '$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")],
615 '$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")],
616 '$likes' => ['likes', DI::l10n()->t('Likes:'), $r[0]['likes']],
617 '$dislikes' => ['dislikes', DI::l10n()->t('Dislikes:'), $r[0]['dislikes']],
618 '$music' => ['music', DI::l10n()->t('Musical interests'), $r[0]['music']],
619 '$book' => ['book', DI::l10n()->t('Books, literature'), $r[0]['book']],
620 '$tv' => ['tv', DI::l10n()->t('Television'), $r[0]['tv']],
621 '$film' => ['film', DI::l10n()->t('Film/dance/culture/entertainment'), $r[0]['film']],
622 '$interest' => ['interest', DI::l10n()->t('Hobbies/Interests'), $r[0]['interest']],
623 '$romance' => ['romance', DI::l10n()->t('Love/romance'), $r[0]['romance']],
624 '$work' => ['work', DI::l10n()->t('Work/employment'), $r[0]['work']],
625 '$education' => ['education', DI::l10n()->t('School/education'), $r[0]['education']],
626 '$contact' => ['contact', DI::l10n()->t('Contact information and Social Networks'), $r[0]['contact']],
629 $arr = ['profile' => $r[0], 'entry' => $o];
630 Hook::callAll('profile_edit', $arr);
634 // If we don't support multi profiles, don't display this list.
635 if (!Feature::isEnabled(local_user(), 'multi_profiles')) {
636 $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1",
639 if (DBA::isResult($r)) {
640 //Go to the default profile.
641 DI::baseUrl()->redirect('profiles/' . $r[0]['id']);
645 $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
648 if (DBA::isResult($r)) {
650 $tpl = Renderer::getMarkupTemplate('profile_entry.tpl');
653 foreach ($r as $rr) {
654 $profiles .= Renderer::replaceMacros($tpl, [
655 '$photo' => DI::baseUrl()->remove($rr['thumb']),
657 '$alt' => DI::l10n()->t('Profile Image'),
658 '$profile_name' => $rr['profile-name'],
659 '$visible' => (($rr['is-default']) ? '<strong>' . DI::l10n()->t('visible to everybody') . '</strong>'
660 : '<a href="'.'profperm/'.$rr['id'].'" />' . DI::l10n()->t('Edit visibility') . '</a>')
664 $tpl_header = Renderer::getMarkupTemplate('profile_listing_header.tpl');
665 $o .= Renderer::replaceMacros($tpl_header,[
666 '$header' => DI::l10n()->t('Edit/Manage Profiles'),
667 '$chg_photo' => DI::l10n()->t('Change profile photo'),
668 '$cr_new' => DI::l10n()->t('Create New Profile'),
669 '$cr_new_link' => 'profiles/new?t=' . BaseModule::getFormSecurityToken("profile_new"),
670 '$profiles' => $profiles