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\Network\Probe;
20 function profiles_init(App $a) {
22 Nav::setSelected('profiles');
28 if (($a->argc > 2) && ($a->argv[1] === "drop") && intval($a->argv[2])) {
29 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
33 if (! DBM::is_result($r)) {
34 notice(L10n::t('Profile not found.') . EOL);
39 check_form_security_token_redirectOnErr('/profiles', 'profile_drop', 't');
41 // move every contact using this profile as their default to the user default
43 $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 ",
48 $r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d",
52 if (DBM::is_result($r)) {
53 info(L10n::t('Profile deleted.').EOL);
60 if (($a->argc > 1) && ($a->argv[1] === 'new')) {
62 check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't');
64 $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
65 intval(local_user()));
67 $num_profiles = (DBM::is_result($r0) ? count($r0) : 0);
69 $name = L10n::t('Profile-') . ($num_profiles + 1);
71 $r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
72 intval(local_user()));
74 $r2 = q("INSERT INTO `profile` (`uid` , `profile-name` , `name`, `photo`, `thumb`)
75 VALUES ( %d, '%s', '%s', '%s', '%s' )",
78 dbesc($r1[0]['name']),
79 dbesc($r1[0]['photo']),
80 dbesc($r1[0]['thumb'])
83 $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1",
88 info(L10n::t('New profile created.') . EOL);
89 if (DBM::is_result($r3) && count($r3) == 1) {
90 goaway('profiles/' . $r3[0]['id']);
96 if (($a->argc > 2) && ($a->argv[1] === 'clone')) {
98 check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't');
100 $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
101 intval(local_user()));
103 $num_profiles = (DBM::is_result($r0) ? count($r0) : 0);
105 $name = L10n::t('Profile-') . ($num_profiles + 1);
106 $r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 1",
107 intval(local_user()),
110 if(! DBM::is_result($r1)) {
111 notice(L10n::t('Profile unavailable to clone.') . EOL);
116 $r1[0]['is-default'] = 0;
117 $r1[0]['publish'] = 0;
118 $r1[0]['net-publish'] = 0;
119 $r1[0]['profile-name'] = dbesc($name);
121 dba::insert('profile', $r1[0]);
123 $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1",
124 intval(local_user()),
127 info(L10n::t('New profile created.') . EOL);
128 if ((DBM::is_result($r3)) && (count($r3) == 1)) {
129 goaway('profiles/'.$r3[0]['id']);
134 return; // NOTREACHED
138 if (($a->argc > 1) && (intval($a->argv[1]))) {
139 $r = q("SELECT id FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
143 if (! DBM::is_result($r)) {
144 notice(L10n::t('Profile not found.') . EOL);
149 Profile::load($a, $a->user['nickname'], $r[0]['id']);
156 function profile_clean_keywords($keywords) {
157 $keywords = str_replace(",", " ", $keywords);
158 $keywords = explode(" ", $keywords);
161 foreach ($keywords as $keyword) {
162 $keyword = trim(strtolower($keyword));
163 $keyword = trim($keyword, "#");
164 if ($keyword != "") {
165 $cleaned[] = $keyword;
169 $keywords = implode(", ", $cleaned);
174 function profiles_post(App $a) {
176 if (! local_user()) {
177 notice(L10n::t('Permission denied.') . EOL);
181 $namechanged = false;
183 Addon::callHooks('profile_post', $_POST);
185 if (($a->argc > 1) && ($a->argv[1] !== "new") && intval($a->argv[1])) {
186 $orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
190 if (! DBM::is_result($orig)) {
191 notice(L10n::t('Profile not found.') . EOL);
195 check_form_security_token_redirectOnErr('/profiles', 'profile_edit');
197 $is_default = (($orig[0]['is-default']) ? 1 : 0);
199 $profile_name = notags(trim($_POST['profile_name']));
200 if (! strlen($profile_name)) {
201 notice(L10n::t('Profile Name is required.') . EOL);
205 $dob = $_POST['dob'] ? escape_tags(trim($_POST['dob'])) : '0001-01-01'; // FIXME: Needs to be validated?
207 $y = substr($dob, 0, 4);
208 if ((! ctype_digit($y)) || ($y < 1900)) {
211 $ignore_year = false;
213 if (!in_array($dob, ['0000-00-00', '0001-01-01'])) {
214 if (strpos($dob, '0000-') === 0 || strpos($dob, '0001-') === 0) {
216 $dob = substr($dob, 5);
218 $dob = datetime_convert('UTC', 'UTC', (($ignore_year) ? '1900-' . $dob : $dob), (($ignore_year) ? 'm-d' : 'Y-m-d'));
221 $dob = '0001-' . $dob;
225 $name = notags(trim($_POST['name']));
227 if (! strlen($name)) {
231 if ($orig[0]['name'] != $name) {
235 $pdesc = notags(trim($_POST['pdesc']));
236 $gender = notags(trim($_POST['gender']));
237 $address = notags(trim($_POST['address']));
238 $locality = notags(trim($_POST['locality']));
239 $region = notags(trim($_POST['region']));
240 $postal_code = notags(trim($_POST['postal_code']));
241 $country_name = notags(trim($_POST['country_name']));
242 $pub_keywords = profile_clean_keywords(notags(trim($_POST['pub_keywords'])));
243 $prv_keywords = profile_clean_keywords(notags(trim($_POST['prv_keywords'])));
244 $marital = notags(trim($_POST['marital']));
245 $howlong = notags(trim($_POST['howlong']));
247 $with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : '');
249 if (! strlen($howlong)) {
250 $howlong = NULL_DATE;
252 $howlong = datetime_convert(date_default_timezone_get(), 'UTC', $howlong);
254 // linkify the relationship target if applicable
256 $withchanged = false;
259 if ($with != strip_tags($orig[0]['with'])) {
263 if (strpos($lookup, '@') === 0) {
264 $lookup = substr($lookup, 1);
266 $lookup = str_replace('_',' ', $lookup);
267 if (strpos($lookup, '@') || (strpos($lookup, 'http://'))) {
269 $links = @Probe::lrdd($lookup);
271 foreach ($links as $link) {
272 if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
273 $prf = $link['@attributes']['href'];
280 $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
284 if (! DBM::is_result($r)) {
285 $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
290 if (DBM::is_result($r)) {
292 $newname = $r[0]['name'];
297 $with = str_replace($lookup, '<a href="' . $prf . '">' . $newname . '</a>', $with);
298 if (strpos($with, '@') === 0) {
299 $with = substr($with, 1);
303 $with = $orig[0]['with'];
307 /// @TODO Not flexible enough for later expansion, let's have more OOP here
308 $sexual = notags(trim($_POST['sexual']));
309 $xmpp = notags(trim($_POST['xmpp']));
310 $homepage = notags(trim($_POST['homepage']));
311 if ((strpos($homepage, 'http') !== 0) && (strlen($homepage))) {
312 // neither http nor https in URL, add them
313 $homepage = 'http://'.$homepage;
315 $hometown = notags(trim($_POST['hometown']));
316 $politic = notags(trim($_POST['politic']));
317 $religion = notags(trim($_POST['religion']));
319 $likes = escape_tags(trim($_POST['likes']));
320 $dislikes = escape_tags(trim($_POST['dislikes']));
322 $about = escape_tags(trim($_POST['about']));
323 $interest = escape_tags(trim($_POST['interest']));
324 $contact = escape_tags(trim($_POST['contact']));
325 $music = escape_tags(trim($_POST['music']));
326 $book = escape_tags(trim($_POST['book']));
327 $tv = escape_tags(trim($_POST['tv']));
328 $film = escape_tags(trim($_POST['film']));
329 $romance = escape_tags(trim($_POST['romance']));
330 $work = escape_tags(trim($_POST['work']));
331 $education = escape_tags(trim($_POST['education']));
333 $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0);
335 PConfig::set(local_user(), 'system', 'detailled_profile', (($_POST['detailled_profile'] == 1) ? 1: 0));
340 if ($marital != $orig[0]['marital']) {
341 $changes[] = '[color=#ff0000]♥[/color] ' . L10n::t('Marital Status');
345 $changes[] = '[color=#ff0000]♥[/color] ' . L10n::t('Romantic Partner');
346 $value = strip_tags($with);
348 if ($likes != $orig[0]['likes']) {
349 $changes[] = L10n::t('Likes');
352 if ($dislikes != $orig[0]['dislikes']) {
353 $changes[] = L10n::t('Dislikes');
356 if ($work != $orig[0]['work']) {
357 $changes[] = L10n::t('Work/Employment');
359 if ($religion != $orig[0]['religion']) {
360 $changes[] = L10n::t('Religion');
363 if ($politic != $orig[0]['politic']) {
364 $changes[] = L10n::t('Political Views');
367 if ($gender != $orig[0]['gender']) {
368 $changes[] = L10n::t('Gender');
371 if ($sexual != $orig[0]['sexual']) {
372 $changes[] = L10n::t('Sexual Preference');
375 if ($xmpp != $orig[0]['xmpp']) {
376 $changes[] = L10n::t('XMPP');
379 if ($homepage != $orig[0]['homepage']) {
380 $changes[] = L10n::t('Homepage');
383 if ($interest != $orig[0]['interest']) {
384 $changes[] = L10n::t('Interests');
387 if ($address != $orig[0]['address']) {
388 $changes[] = L10n::t('Address');
389 // New address not sent in notifications, potential privacy issues
390 // in case this leaks to unintended recipients. Yes, it's in the public
391 // profile but that doesn't mean we have to broadcast it to everybody.
393 if ($locality != $orig[0]['locality'] || $region != $orig[0]['region']
394 || $country_name != $orig[0]['country-name']) {
395 $changes[] = L10n::t('Location');
396 $comma1 = ((($locality) && ($region || $country_name)) ? ', ' : ' ');
397 $comma2 = (($region && $country_name) ? ', ' : '');
398 $value = $locality . $comma1 . $region . $comma2 . $country_name;
401 profile_activity($changes,$value);
405 $r = q("UPDATE `profile`
406 SET `profile-name` = '%s',
414 `postal-code` = '%s',
415 `country-name` = '%s',
425 `pub_keywords` = '%s',
426 `prv_keywords` = '%s',
440 WHERE `id` = %d AND `uid` = %d",
441 dbesc($profile_name),
450 dbesc($country_name),
460 dbesc($pub_keywords),
461 dbesc($prv_keywords),
474 intval($hide_friends),
480 info(L10n::t('Profile updated.') . EOL);
484 if ($namechanged && $is_default) {
485 $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
487 dbesc(datetime_convert()),
490 $r = q("UPDATE `user` set `username` = '%s' where `uid` = %d",
497 $location = Profile::formatLocation(["locality" => $locality, "region" => $region, "country-name" => $country_name]);
499 q("UPDATE `contact` SET `about` = '%s', `location` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `self` AND `uid` = %d",
502 dbesc($pub_keywords),
507 // Update global directory in background
508 $url = $_SESSION['my_url'];
509 if ($url && strlen(Config::get('system', 'directory'))) {
510 Worker::add(PRIORITY_LOW, "Directory", $url);
513 Worker::add(PRIORITY_LOW, 'ProfileUpdate', local_user());
515 // Update the global contact for the user
516 GContact::updateForUser(local_user());
522 function profile_activity($changed, $value) {
525 if (! local_user() || ! is_array($changed) || ! count($changed)) {
529 if ($a->user['hidewall'] || Config::get('system', 'block_public')) {
533 if (! PConfig::get(local_user(), 'system', 'post_profilechange')) {
537 require_once 'include/items.php';
539 $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
543 if (! DBM::is_result($self)) {
549 $arr['guid'] = get_guid(32);
550 $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), local_user());
551 $arr['uid'] = local_user();
552 $arr['contact-id'] = $self[0]['id'];
554 $arr['type'] = 'wall';
557 $arr['author-name'] = $arr['owner-name'] = $self[0]['name'];
558 $arr['author-link'] = $arr['owner-link'] = $self[0]['url'];
559 $arr['author-avatar'] = $arr['owner-avatar'] = $self[0]['thumb'];
560 $arr['verb'] = ACTIVITY_UPDATE;
561 $arr['object-type'] = ACTIVITY_OBJ_PROFILE;
563 $A = '[url=' . $self[0]['url'] . ']' . $self[0]['name'] . '[/url]';
567 $t = count($changed);
569 foreach ($changed as $ch) {
570 if (strlen($changes)) {
571 if ($z == ($t - 1)) {
572 $changes .= L10n::t(' and ');
581 $prof = '[url=' . $self[0]['url'] . '?tab=profile' . ']' . L10n::t('public profile') . '[/url]';
583 if ($t == 1 && strlen($value)) {
584 $message = sprintf(L10n::t('%1$s changed %2$s to “%3$s”'), $A, $changes, $value);
585 $message .= "\n\n" . sprintf(L10n::t(' - Visit %1$s\'s %2$s'), $A, $prof);
587 $message = sprintf(L10n::t('%1$s has an updated %2$s, changing %3$s.'), $A, $prof, $changes);
591 $arr['body'] = $message;
593 $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PROFILE . '</type><title>' . $self[0]['name'] . '</title>'
594 . '<id>' . $self[0]['url'] . '/' . $self[0]['name'] . '</id>';
595 $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $self[0]['url'] . '?tab=profile' . '" />' . "\n");
596 $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $self[0]['thumb'] . '" />' . "\n");
597 $arr['object'] .= '</link></object>' . "\n";
599 $arr['allow_cid'] = $a->user['allow_cid'];
600 $arr['allow_gid'] = $a->user['allow_gid'];
601 $arr['deny_cid'] = $a->user['deny_cid'];
602 $arr['deny_gid'] = $a->user['deny_gid'];
604 $i = item_store($arr);
606 Worker::add(PRIORITY_HIGH, "Notifier", "activity", $i);
611 function profiles_content(App $a) {
613 if (! local_user()) {
614 notice(L10n::t('Permission denied.') . EOL);
620 if (($a->argc > 1) && (intval($a->argv[1]))) {
621 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
625 if (! DBM::is_result($r)) {
626 notice(L10n::t('Profile not found.') . EOL);
630 $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), [
631 '$baseurl' => System::baseUrl(true),
633 $a->page['end'] .= replace_macros(get_markup_template('profed_end.tpl'), [
634 '$baseurl' => System::baseUrl(true),
637 $opt_tpl = get_markup_template("profile-hide-friends.tpl");
638 $hide_friends = replace_macros($opt_tpl,[
640 'hide-friends', //Name
641 L10n::t('Hide contacts and friends:'), //Label
642 !!$r[0]['hide-friends'], //Value
644 [L10n::t('No'), L10n::t('Yes')] //Off - On strings
646 '$desc' => L10n::t('Hide your contact/friend list from viewers of this profile?'),
647 '$yes_str' => L10n::t('Yes'),
648 '$no_str' => L10n::t('No'),
649 '$yes_selected' => (($r[0]['hide-friends']) ? " checked=\"checked\" " : ""),
650 '$no_selected' => (($r[0]['hide-friends'] == 0) ? " checked=\"checked\" " : "")
653 $personal_account = !(in_array($a->user["page-flags"],
654 [PAGE_COMMUNITY, PAGE_PRVGROUP]));
656 $detailled_profile = (PConfig::get(local_user(), 'system', 'detailled_profile') AND $personal_account);
658 $is_default = (($r[0]['is-default']) ? 1 : 0);
659 $tpl = get_markup_template("profile_edit.tpl");
660 $o .= replace_macros($tpl, [
661 '$personal_account' => $personal_account,
662 '$detailled_profile' => $detailled_profile,
665 'detailled_profile', //Name
666 L10n::t('Show more profile fields:'), //Label
667 $detailled_profile, //Value
669 [L10n::t('No'), L10n::t('Yes')] //Off - On strings
672 '$multi_profiles' => Feature::isEnabled(local_user(), 'multi_profiles'),
673 '$form_security_token' => get_form_security_token("profile_edit"),
674 '$form_security_token_photo' => get_form_security_token("profile_photo"),
675 '$profile_clone_link' => ((Feature::isEnabled(local_user(), 'multi_profiles')) ? 'profiles/clone/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_clone") : ""),
676 '$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_drop"),
678 '$profile_action' => L10n::t('Profile Actions'),
679 '$banner' => L10n::t('Edit Profile Details'),
680 '$submit' => L10n::t('Submit'),
681 '$profpic' => L10n::t('Change Profile Photo'),
682 '$viewprof' => L10n::t('View this profile'),
683 '$editvis' => L10n::t('Edit visibility'),
684 '$cr_prof' => L10n::t('Create a new profile using these settings'),
685 '$cl_prof' => L10n::t('Clone this profile'),
686 '$del_prof' => L10n::t('Delete this profile'),
688 '$lbl_basic_section' => L10n::t('Basic information'),
689 '$lbl_picture_section' => L10n::t('Profile picture'),
690 '$lbl_location_section' => L10n::t('Location'),
691 '$lbl_preferences_section' => L10n::t('Preferences'),
692 '$lbl_status_section' => L10n::t('Status information'),
693 '$lbl_about_section' => L10n::t('Additional information'),
694 '$lbl_interests_section' => L10n::t('Interests'),
695 '$lbl_personal_section' => L10n::t('Personal'),
696 '$lbl_relation_section' => L10n::t('Relation'),
697 '$lbl_miscellaneous_section' => L10n::t('Miscellaneous'),
699 '$lbl_profile_photo' => L10n::t('Upload Profile Photo'),
700 '$lbl_gender' => L10n::t('Your Gender:'),
701 '$lbl_marital' => L10n::t('<span class="heart">♥</span> Marital Status:'),
702 '$lbl_sexual' => L10n::t('Sexual Preference:'),
703 '$lbl_ex2' => L10n::t('Example: fishing photography software'),
705 '$disabled' => (($is_default) ? 'onclick="return false;" style="color: #BBBBFF;"' : ''),
706 '$baseurl' => System::baseUrl(true),
707 '$profile_id' => $r[0]['id'],
708 '$profile_name' => ['profile_name', L10n::t('Profile Name:'), $r[0]['profile-name'], L10n::t('Required'), '*'],
709 '$is_default' => $is_default,
710 '$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>' : ""),
711 '$name' => ['name', L10n::t('Your Full Name:'), $r[0]['name']],
712 '$pdesc' => ['pdesc', L10n::t('Title/Description:'), $r[0]['pdesc']],
713 '$dob' => dob($r[0]['dob']),
714 '$hide_friends' => $hide_friends,
715 '$address' => ['address', L10n::t('Street Address:'), $r[0]['address']],
716 '$locality' => ['locality', L10n::t('Locality/City:'), $r[0]['locality']],
717 '$region' => ['region', L10n::t('Region/State:'), $r[0]['region']],
718 '$postal_code' => ['postal_code', L10n::t('Postal/Zip Code:'), $r[0]['postal-code']],
719 '$country_name' => ['country_name', L10n::t('Country:'), $r[0]['country-name']],
720 '$age' => ((intval($r[0]['dob'])) ? '(' . L10n::t('Age: ') . age($r[0]['dob'],$a->user['timezone'],$a->user['timezone']) . ')' : ''),
721 '$gender' => ContactSelector::gender($r[0]['gender']),
722 '$marital' => ContactSelector::maritalStatus($r[0]['marital']),
723 '$with' => ['with', L10n::t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), L10n::t('Examples: cathy123, Cathy Williams, cathy@example.com')],
724 '$howlong' => ['howlong', L10n::t('Since [date]:'), ($r[0]['howlong'] <= NULL_DATE ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong']))],
725 '$sexual' => ContactSelector::sexualPreference($r[0]['sexual']),
726 '$about' => ['about', L10n::t('Tell us about yourself...'), $r[0]['about']],
727 '$xmpp' => ['xmpp', L10n::t('XMPP (Jabber) address:'), $r[0]['xmpp'], L10n::t("The XMPP address will be propagated to your contacts so that they can follow you.")],
728 '$homepage' => ['homepage', L10n::t('Homepage URL:'), $r[0]['homepage']],
729 '$hometown' => ['hometown', L10n::t('Hometown:'), $r[0]['hometown']],
730 '$politic' => ['politic', L10n::t('Political Views:'), $r[0]['politic']],
731 '$religion' => ['religion', L10n::t('Religious Views:'), $r[0]['religion']],
732 '$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")],
733 '$prv_keywords' => ['prv_keywords', L10n::t('Private Keywords:'), $r[0]['prv_keywords'], L10n::t("\x28Used for searching profiles, never shown to others\x29")],
734 '$likes' => ['likes', L10n::t('Likes:'), $r[0]['likes']],
735 '$dislikes' => ['dislikes', L10n::t('Dislikes:'), $r[0]['dislikes']],
736 '$music' => ['music', L10n::t('Musical interests'), $r[0]['music']],
737 '$book' => ['book', L10n::t('Books, literature'), $r[0]['book']],
738 '$tv' => ['tv', L10n::t('Television'), $r[0]['tv']],
739 '$film' => ['film', L10n::t('Film/dance/culture/entertainment'), $r[0]['film']],
740 '$interest' => ['interest', L10n::t('Hobbies/Interests'), $r[0]['interest']],
741 '$romance' => ['romance', L10n::t('Love/romance'), $r[0]['romance']],
742 '$work' => ['work', L10n::t('Work/employment'), $r[0]['work']],
743 '$education' => ['education', L10n::t('School/education'), $r[0]['education']],
744 '$contact' => ['contact', L10n::t('Contact information and Social Networks'), $r[0]['contact']],
747 $arr = ['profile' => $r[0], 'entry' => $o];
748 Addon::callHooks('profile_edit', $arr);
752 // If we don't support multi profiles, don't display this list.
753 if (!Feature::isEnabled(local_user(), 'multi_profiles')) {
754 $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1",
757 if (DBM::is_result($r)) {
758 //Go to the default profile.
759 goaway('profiles/' . $r[0]['id']);
763 $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
766 if (DBM::is_result($r)) {
768 $tpl = get_markup_template('profile_entry.tpl');
771 foreach ($r as $rr) {
772 $profiles .= replace_macros($tpl, [
773 '$photo' => $a->remove_baseurl($rr['thumb']),
775 '$alt' => L10n::t('Profile Image'),
776 '$profile_name' => $rr['profile-name'],
777 '$visible' => (($rr['is-default']) ? '<strong>' . L10n::t('visible to everybody') . '</strong>'
778 : '<a href="'.'profperm/'.$rr['id'].'" />' . L10n::t('Edit visibility') . '</a>')
782 $tpl_header = get_markup_template('profile_listing_header.tpl');
783 $o .= replace_macros($tpl_header,[
784 '$header' => L10n::t('Edit/Manage Profiles'),
785 '$chg_photo' => L10n::t('Change profile photo'),
786 '$cr_new' => L10n::t('Create New Profile'),
787 '$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new"),
788 '$profiles' => $profiles