3 * @file mod/profiles.php
6 use Friendica\Content\ContactSelector;
7 use Friendica\Content\Feature;
8 use Friendica\Content\Nav;
9 use Friendica\Core\Addon;
10 use Friendica\Core\Config;
11 use Friendica\Core\L10n;
12 use Friendica\Core\PConfig;
13 use Friendica\Core\System;
14 use Friendica\Core\Worker;
15 use Friendica\Database\DBM;
16 use Friendica\Model\GContact;
17 use Friendica\Model\Profile;
18 use Friendica\Model\Item;
19 use Friendica\Network\Probe;
21 function profiles_init(App $a) {
23 Nav::setSelected('profiles');
29 if (($a->argc > 2) && ($a->argv[1] === "drop") && intval($a->argv[2])) {
30 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
34 if (! DBM::is_result($r)) {
35 notice(L10n::t('Profile not found.') . EOL);
40 check_form_security_token_redirectOnErr('/profiles', 'profile_drop', 't');
42 // move every contact using this profile as their default to the user default
44 $r = 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 ",
49 $r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d",
53 if (DBM::is_result($r)) {
54 info(L10n::t('Profile deleted.').EOL);
61 if (($a->argc > 1) && ($a->argv[1] === 'new')) {
63 check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't');
65 $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
66 intval(local_user()));
68 $num_profiles = (DBM::is_result($r0) ? count($r0) : 0);
70 $name = L10n::t('Profile-') . ($num_profiles + 1);
72 $r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
73 intval(local_user()));
75 $r2 = q("INSERT INTO `profile` (`uid` , `profile-name` , `name`, `photo`, `thumb`)
76 VALUES ( %d, '%s', '%s', '%s', '%s' )",
79 dbesc($r1[0]['name']),
80 dbesc($r1[0]['photo']),
81 dbesc($r1[0]['thumb'])
84 $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1",
89 info(L10n::t('New profile created.') . EOL);
90 if (DBM::is_result($r3) && count($r3) == 1) {
91 goaway('profiles/' . $r3[0]['id']);
97 if (($a->argc > 2) && ($a->argv[1] === 'clone')) {
99 check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't');
101 $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
102 intval(local_user()));
104 $num_profiles = (DBM::is_result($r0) ? count($r0) : 0);
106 $name = L10n::t('Profile-') . ($num_profiles + 1);
107 $r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 1",
108 intval(local_user()),
111 if(! DBM::is_result($r1)) {
112 notice(L10n::t('Profile unavailable to clone.') . EOL);
117 $r1[0]['is-default'] = 0;
118 $r1[0]['publish'] = 0;
119 $r1[0]['net-publish'] = 0;
120 $r1[0]['profile-name'] = dbesc($name);
122 dba::insert('profile', $r1[0]);
124 $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1",
125 intval(local_user()),
128 info(L10n::t('New profile created.') . EOL);
129 if ((DBM::is_result($r3)) && (count($r3) == 1)) {
130 goaway('profiles/'.$r3[0]['id']);
135 return; // NOTREACHED
139 if (($a->argc > 1) && (intval($a->argv[1]))) {
140 $r = q("SELECT id FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
144 if (! DBM::is_result($r)) {
145 notice(L10n::t('Profile not found.') . EOL);
150 Profile::load($a, $a->user['nickname'], $r[0]['id']);
157 function profile_clean_keywords($keywords) {
158 $keywords = str_replace(",", " ", $keywords);
159 $keywords = explode(" ", $keywords);
162 foreach ($keywords as $keyword) {
163 $keyword = trim(strtolower($keyword));
164 $keyword = trim($keyword, "#");
165 if ($keyword != "") {
166 $cleaned[] = $keyword;
170 $keywords = implode(", ", $cleaned);
175 function profiles_post(App $a) {
177 if (! local_user()) {
178 notice(L10n::t('Permission denied.') . EOL);
182 $namechanged = false;
184 Addon::callHooks('profile_post', $_POST);
186 if (($a->argc > 1) && ($a->argv[1] !== "new") && intval($a->argv[1])) {
187 $orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
191 if (! DBM::is_result($orig)) {
192 notice(L10n::t('Profile not found.') . EOL);
196 check_form_security_token_redirectOnErr('/profiles', 'profile_edit');
198 $is_default = (($orig[0]['is-default']) ? 1 : 0);
200 $profile_name = notags(trim($_POST['profile_name']));
201 if (! strlen($profile_name)) {
202 notice(L10n::t('Profile Name is required.') . EOL);
206 $dob = $_POST['dob'] ? escape_tags(trim($_POST['dob'])) : '0000-00-00';
208 $y = substr($dob, 0, 4);
209 if ((! ctype_digit($y)) || ($y < 1900)) {
212 $ignore_year = false;
214 if (!in_array($dob, ['0000-00-00', '0001-01-01'])) {
215 if (strpos($dob, '0000-') === 0 || strpos($dob, '0001-') === 0) {
217 $dob = substr($dob, 5);
219 $dob = datetime_convert('UTC', 'UTC', (($ignore_year) ? '1900-' . $dob : $dob), (($ignore_year) ? 'm-d' : 'Y-m-d'));
222 $dob = '0000-' . $dob;
226 $name = notags(trim($_POST['name']));
228 if (! strlen($name)) {
232 if ($orig[0]['name'] != $name) {
236 $pdesc = notags(trim($_POST['pdesc']));
237 $gender = notags(trim($_POST['gender']));
238 $address = notags(trim($_POST['address']));
239 $locality = notags(trim($_POST['locality']));
240 $region = notags(trim($_POST['region']));
241 $postal_code = notags(trim($_POST['postal_code']));
242 $country_name = notags(trim($_POST['country_name']));
243 $pub_keywords = profile_clean_keywords(notags(trim($_POST['pub_keywords'])));
244 $prv_keywords = profile_clean_keywords(notags(trim($_POST['prv_keywords'])));
245 $marital = notags(trim($_POST['marital']));
246 $howlong = notags(trim($_POST['howlong']));
248 $with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : '');
250 if (! strlen($howlong)) {
251 $howlong = NULL_DATE;
253 $howlong = datetime_convert(date_default_timezone_get(), 'UTC', $howlong);
255 // linkify the relationship target if applicable
257 $withchanged = false;
260 if ($with != strip_tags($orig[0]['with'])) {
264 if (strpos($lookup, '@') === 0) {
265 $lookup = substr($lookup, 1);
267 $lookup = str_replace('_',' ', $lookup);
268 if (strpos($lookup, '@') || (strpos($lookup, 'http://'))) {
270 $links = @Probe::lrdd($lookup);
272 foreach ($links as $link) {
273 if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
274 $prf = $link['@attributes']['href'];
281 $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
285 if (! DBM::is_result($r)) {
286 $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
291 if (DBM::is_result($r)) {
293 $newname = $r[0]['name'];
298 $with = str_replace($lookup, '<a href="' . $prf . '">' . $newname . '</a>', $with);
299 if (strpos($with, '@') === 0) {
300 $with = substr($with, 1);
304 $with = $orig[0]['with'];
308 /// @TODO Not flexible enough for later expansion, let's have more OOP here
309 $sexual = notags(trim($_POST['sexual']));
310 $xmpp = notags(trim($_POST['xmpp']));
311 $homepage = notags(trim($_POST['homepage']));
312 if ((strpos($homepage, 'http') !== 0) && (strlen($homepage))) {
313 // neither http nor https in URL, add them
314 $homepage = 'http://'.$homepage;
316 $hometown = notags(trim($_POST['hometown']));
317 $politic = notags(trim($_POST['politic']));
318 $religion = notags(trim($_POST['religion']));
320 $likes = escape_tags(trim($_POST['likes']));
321 $dislikes = escape_tags(trim($_POST['dislikes']));
323 $about = escape_tags(trim($_POST['about']));
324 $interest = escape_tags(trim($_POST['interest']));
325 $contact = escape_tags(trim($_POST['contact']));
326 $music = escape_tags(trim($_POST['music']));
327 $book = escape_tags(trim($_POST['book']));
328 $tv = escape_tags(trim($_POST['tv']));
329 $film = escape_tags(trim($_POST['film']));
330 $romance = escape_tags(trim($_POST['romance']));
331 $work = escape_tags(trim($_POST['work']));
332 $education = escape_tags(trim($_POST['education']));
334 $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0);
336 PConfig::set(local_user(), 'system', 'detailled_profile', (($_POST['detailled_profile'] == 1) ? 1: 0));
341 if ($marital != $orig[0]['marital']) {
342 $changes[] = '[color=#ff0000]♥[/color] ' . L10n::t('Marital Status');
346 $changes[] = '[color=#ff0000]♥[/color] ' . L10n::t('Romantic Partner');
347 $value = strip_tags($with);
349 if ($likes != $orig[0]['likes']) {
350 $changes[] = L10n::t('Likes');
353 if ($dislikes != $orig[0]['dislikes']) {
354 $changes[] = L10n::t('Dislikes');
357 if ($work != $orig[0]['work']) {
358 $changes[] = L10n::t('Work/Employment');
360 if ($religion != $orig[0]['religion']) {
361 $changes[] = L10n::t('Religion');
364 if ($politic != $orig[0]['politic']) {
365 $changes[] = L10n::t('Political Views');
368 if ($gender != $orig[0]['gender']) {
369 $changes[] = L10n::t('Gender');
372 if ($sexual != $orig[0]['sexual']) {
373 $changes[] = L10n::t('Sexual Preference');
376 if ($xmpp != $orig[0]['xmpp']) {
377 $changes[] = L10n::t('XMPP');
380 if ($homepage != $orig[0]['homepage']) {
381 $changes[] = L10n::t('Homepage');
384 if ($interest != $orig[0]['interest']) {
385 $changes[] = L10n::t('Interests');
388 if ($address != $orig[0]['address']) {
389 $changes[] = L10n::t('Address');
390 // New address not sent in notifications, potential privacy issues
391 // in case this leaks to unintended recipients. Yes, it's in the public
392 // profile but that doesn't mean we have to broadcast it to everybody.
394 if ($locality != $orig[0]['locality'] || $region != $orig[0]['region']
395 || $country_name != $orig[0]['country-name']) {
396 $changes[] = L10n::t('Location');
397 $comma1 = ((($locality) && ($region || $country_name)) ? ', ' : ' ');
398 $comma2 = (($region && $country_name) ? ', ' : '');
399 $value = $locality . $comma1 . $region . $comma2 . $country_name;
402 profile_activity($changes,$value);
406 $r = q("UPDATE `profile`
407 SET `profile-name` = '%s',
415 `postal-code` = '%s',
416 `country-name` = '%s',
426 `pub_keywords` = '%s',
427 `prv_keywords` = '%s',
441 WHERE `id` = %d AND `uid` = %d",
442 dbesc($profile_name),
451 dbesc($country_name),
461 dbesc($pub_keywords),
462 dbesc($prv_keywords),
475 intval($hide_friends),
481 info(L10n::t('Profile updated.') . EOL);
485 if ($namechanged && $is_default) {
486 $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
488 dbesc(datetime_convert()),
491 $r = q("UPDATE `user` set `username` = '%s' where `uid` = %d",
498 $location = Profile::formatLocation(["locality" => $locality, "region" => $region, "country-name" => $country_name]);
500 q("UPDATE `contact` SET `about` = '%s', `location` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `self` AND `uid` = %d",
503 dbesc($pub_keywords),
508 // Update global directory in background
509 $url = $_SESSION['my_url'];
510 if ($url && strlen(Config::get('system', 'directory'))) {
511 Worker::add(PRIORITY_LOW, "Directory", $url);
514 Worker::add(PRIORITY_LOW, 'ProfileUpdate', local_user());
516 // Update the global contact for the user
517 GContact::updateForUser(local_user());
523 function profile_activity($changed, $value) {
526 if (! local_user() || ! is_array($changed) || ! count($changed)) {
530 if ($a->user['hidewall'] || Config::get('system', 'block_public')) {
534 if (! PConfig::get(local_user(), 'system', 'post_profilechange')) {
538 require_once 'include/items.php';
540 $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
544 if (! DBM::is_result($self)) {
550 $arr['guid'] = get_guid(32);
551 $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), local_user());
552 $arr['uid'] = local_user();
553 $arr['contact-id'] = $self[0]['id'];
555 $arr['type'] = 'wall';
558 $arr['author-name'] = $arr['owner-name'] = $self[0]['name'];
559 $arr['author-link'] = $arr['owner-link'] = $self[0]['url'];
560 $arr['author-avatar'] = $arr['owner-avatar'] = $self[0]['thumb'];
561 $arr['verb'] = ACTIVITY_UPDATE;
562 $arr['object-type'] = ACTIVITY_OBJ_PROFILE;
564 $A = '[url=' . $self[0]['url'] . ']' . $self[0]['name'] . '[/url]';
568 $t = count($changed);
570 foreach ($changed as $ch) {
571 if (strlen($changes)) {
572 if ($z == ($t - 1)) {
573 $changes .= L10n::t(' and ');
582 $prof = '[url=' . $self[0]['url'] . '?tab=profile' . ']' . L10n::t('public profile') . '[/url]';
584 if ($t == 1 && strlen($value)) {
585 $message = L10n::t('%1$s changed %2$s to “%3$s”', $A, $changes, $value);
586 $message .= "\n\n" . L10n::t(' - Visit %1$s\'s %2$s', $A, $prof);
588 $message = L10n::t('%1$s has an updated %2$s, changing %3$s.', $A, $prof, $changes);
592 $arr['body'] = $message;
594 $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PROFILE . '</type><title>' . $self[0]['name'] . '</title>'
595 . '<id>' . $self[0]['url'] . '/' . $self[0]['name'] . '</id>';
596 $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $self[0]['url'] . '?tab=profile' . '" />' . "\n");
597 $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $self[0]['thumb'] . '" />' . "\n");
598 $arr['object'] .= '</link></object>' . "\n";
600 $arr['allow_cid'] = $a->user['allow_cid'];
601 $arr['allow_gid'] = $a->user['allow_gid'];
602 $arr['deny_cid'] = $a->user['deny_cid'];
603 $arr['deny_gid'] = $a->user['deny_gid'];
605 $i = Item::insert($arr);
607 Worker::add(PRIORITY_HIGH, "Notifier", "activity", $i);
612 function profiles_content(App $a) {
614 if (! local_user()) {
615 notice(L10n::t('Permission denied.') . EOL);
621 if (($a->argc > 1) && (intval($a->argv[1]))) {
622 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
626 if (! DBM::is_result($r)) {
627 notice(L10n::t('Profile not found.') . EOL);
631 $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), [
632 '$baseurl' => System::baseUrl(true),
634 $a->page['end'] .= replace_macros(get_markup_template('profed_end.tpl'), [
635 '$baseurl' => System::baseUrl(true),
638 $opt_tpl = get_markup_template("profile-hide-friends.tpl");
639 $hide_friends = replace_macros($opt_tpl,[
641 'hide-friends', //Name
642 L10n::t('Hide contacts and friends:'), //Label
643 !!$r[0]['hide-friends'], //Value
645 [L10n::t('No'), L10n::t('Yes')] //Off - On strings
647 '$desc' => L10n::t('Hide your contact/friend list from viewers of this profile?'),
648 '$yes_str' => L10n::t('Yes'),
649 '$no_str' => L10n::t('No'),
650 '$yes_selected' => (($r[0]['hide-friends']) ? " checked=\"checked\" " : ""),
651 '$no_selected' => (($r[0]['hide-friends'] == 0) ? " checked=\"checked\" " : "")
654 $personal_account = !(in_array($a->user["page-flags"],
655 [PAGE_COMMUNITY, PAGE_PRVGROUP]));
657 $detailled_profile = (PConfig::get(local_user(), 'system', 'detailled_profile') AND $personal_account);
659 $is_default = (($r[0]['is-default']) ? 1 : 0);
660 $tpl = get_markup_template("profile_edit.tpl");
661 $o .= replace_macros($tpl, [
662 '$personal_account' => $personal_account,
663 '$detailled_profile' => $detailled_profile,
666 'detailled_profile', //Name
667 L10n::t('Show more profile fields:'), //Label
668 $detailled_profile, //Value
670 [L10n::t('No'), L10n::t('Yes')] //Off - On strings
673 '$multi_profiles' => Feature::isEnabled(local_user(), 'multi_profiles'),
674 '$form_security_token' => get_form_security_token("profile_edit"),
675 '$form_security_token_photo' => get_form_security_token("profile_photo"),
676 '$profile_clone_link' => ((Feature::isEnabled(local_user(), 'multi_profiles')) ? 'profiles/clone/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_clone") : ""),
677 '$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_drop"),
679 '$profile_action' => L10n::t('Profile Actions'),
680 '$banner' => L10n::t('Edit Profile Details'),
681 '$submit' => L10n::t('Submit'),
682 '$profpic' => L10n::t('Change Profile Photo'),
683 '$viewprof' => L10n::t('View this profile'),
684 '$editvis' => L10n::t('Edit visibility'),
685 '$cr_prof' => L10n::t('Create a new profile using these settings'),
686 '$cl_prof' => L10n::t('Clone this profile'),
687 '$del_prof' => L10n::t('Delete this profile'),
689 '$lbl_basic_section' => L10n::t('Basic information'),
690 '$lbl_picture_section' => L10n::t('Profile picture'),
691 '$lbl_location_section' => L10n::t('Location'),
692 '$lbl_preferences_section' => L10n::t('Preferences'),
693 '$lbl_status_section' => L10n::t('Status information'),
694 '$lbl_about_section' => L10n::t('Additional information'),
695 '$lbl_interests_section' => L10n::t('Interests'),
696 '$lbl_personal_section' => L10n::t('Personal'),
697 '$lbl_relation_section' => L10n::t('Relation'),
698 '$lbl_miscellaneous_section' => L10n::t('Miscellaneous'),
700 '$lbl_profile_photo' => L10n::t('Upload Profile Photo'),
701 '$lbl_gender' => L10n::t('Your Gender:'),
702 '$lbl_marital' => L10n::t('<span class="heart">♥</span> Marital Status:'),
703 '$lbl_sexual' => L10n::t('Sexual Preference:'),
704 '$lbl_ex2' => L10n::t('Example: fishing photography software'),
706 '$disabled' => (($is_default) ? 'onclick="return false;" style="color: #BBBBFF;"' : ''),
707 '$baseurl' => System::baseUrl(true),
708 '$profile_id' => $r[0]['id'],
709 '$profile_name' => ['profile_name', L10n::t('Profile Name:'), $r[0]['profile-name'], L10n::t('Required'), '*'],
710 '$is_default' => $is_default,
711 '$default' => (($is_default) ? '<p id="profile-edit-default-desc">' . L10n::t('This is your <strong>public</strong> profile.<br />It <strong>may</strong> be visible to anybody using the internet.') . '</p>' : ""),
712 '$name' => ['name', L10n::t('Your Full Name:'), $r[0]['name']],
713 '$pdesc' => ['pdesc', L10n::t('Title/Description:'), $r[0]['pdesc']],
714 '$dob' => dob($r[0]['dob']),
715 '$hide_friends' => $hide_friends,
716 '$address' => ['address', L10n::t('Street Address:'), $r[0]['address']],
717 '$locality' => ['locality', L10n::t('Locality/City:'), $r[0]['locality']],
718 '$region' => ['region', L10n::t('Region/State:'), $r[0]['region']],
719 '$postal_code' => ['postal_code', L10n::t('Postal/Zip Code:'), $r[0]['postal-code']],
720 '$country_name' => ['country_name', L10n::t('Country:'), $r[0]['country-name']],
721 '$age' => ((intval($r[0]['dob'])) ? '(' . L10n::t('Age: ') . age($r[0]['dob'],$a->user['timezone'],$a->user['timezone']) . ')' : ''),
722 '$gender' => ContactSelector::gender($r[0]['gender']),
723 '$marital' => ContactSelector::maritalStatus($r[0]['marital']),
724 '$with' => ['with', L10n::t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), L10n::t('Examples: cathy123, Cathy Williams, cathy@example.com')],
725 '$howlong' => ['howlong', L10n::t('Since [date]:'), ($r[0]['howlong'] <= NULL_DATE ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong']))],
726 '$sexual' => ContactSelector::sexualPreference($r[0]['sexual']),
727 '$about' => ['about', L10n::t('Tell us about yourself...'), $r[0]['about']],
728 '$xmpp' => ['xmpp', L10n::t("XMPP \x28Jabber\x29 address:"), $r[0]['xmpp'], L10n::t("The XMPP address will be propagated to your contacts so that they can follow you.")],
729 '$homepage' => ['homepage', L10n::t('Homepage URL:'), $r[0]['homepage']],
730 '$hometown' => ['hometown', L10n::t('Hometown:'), $r[0]['hometown']],
731 '$politic' => ['politic', L10n::t('Political Views:'), $r[0]['politic']],
732 '$religion' => ['religion', L10n::t('Religious Views:'), $r[0]['religion']],
733 '$pub_keywords' => ['pub_keywords', L10n::t('Public Keywords:'), $r[0]['pub_keywords'], L10n::t("\x28Used for suggesting potential friends, can be seen by others\x29")],
734 '$prv_keywords' => ['prv_keywords', L10n::t('Private Keywords:'), $r[0]['prv_keywords'], L10n::t("\x28Used for searching profiles, never shown to others\x29")],
735 '$likes' => ['likes', L10n::t('Likes:'), $r[0]['likes']],
736 '$dislikes' => ['dislikes', L10n::t('Dislikes:'), $r[0]['dislikes']],
737 '$music' => ['music', L10n::t('Musical interests'), $r[0]['music']],
738 '$book' => ['book', L10n::t('Books, literature'), $r[0]['book']],
739 '$tv' => ['tv', L10n::t('Television'), $r[0]['tv']],
740 '$film' => ['film', L10n::t('Film/dance/culture/entertainment'), $r[0]['film']],
741 '$interest' => ['interest', L10n::t('Hobbies/Interests'), $r[0]['interest']],
742 '$romance' => ['romance', L10n::t('Love/romance'), $r[0]['romance']],
743 '$work' => ['work', L10n::t('Work/employment'), $r[0]['work']],
744 '$education' => ['education', L10n::t('School/education'), $r[0]['education']],
745 '$contact' => ['contact', L10n::t('Contact information and Social Networks'), $r[0]['contact']],
748 $arr = ['profile' => $r[0], 'entry' => $o];
749 Addon::callHooks('profile_edit', $arr);
753 // If we don't support multi profiles, don't display this list.
754 if (!Feature::isEnabled(local_user(), 'multi_profiles')) {
755 $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1",
758 if (DBM::is_result($r)) {
759 //Go to the default profile.
760 goaway('profiles/' . $r[0]['id']);
764 $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
767 if (DBM::is_result($r)) {
769 $tpl = get_markup_template('profile_entry.tpl');
772 foreach ($r as $rr) {
773 $profiles .= replace_macros($tpl, [
774 '$photo' => $a->remove_baseurl($rr['thumb']),
776 '$alt' => L10n::t('Profile Image'),
777 '$profile_name' => $rr['profile-name'],
778 '$visible' => (($rr['is-default']) ? '<strong>' . L10n::t('visible to everybody') . '</strong>'
779 : '<a href="'.'profperm/'.$rr['id'].'" />' . L10n::t('Edit visibility') . '</a>')
783 $tpl_header = get_markup_template('profile_listing_header.tpl');
784 $o .= replace_macros($tpl_header,[
785 '$header' => L10n::t('Edit/Manage Profiles'),
786 '$chg_photo' => L10n::t('Change profile photo'),
787 '$cr_new' => L10n::t('Create New Profile'),
788 '$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new"),
789 '$profiles' => $profiles