3 * @file mod/profiles.php
7 use Friendica\Content\ContactSelector;
8 use Friendica\Content\Feature;
9 use Friendica\Content\Nav;
10 use Friendica\Core\Addon;
11 use Friendica\Core\Config;
12 use Friendica\Core\L10n;
13 use Friendica\Core\PConfig;
14 use Friendica\Core\System;
15 use Friendica\Core\Worker;
16 use Friendica\Database\DBM;
17 use Friendica\Model\GContact;
18 use Friendica\Model\Profile;
19 use Friendica\Model\Item;
20 use Friendica\Network\Probe;
21 use Friendica\Util\Temporal;
23 function profiles_init(App $a) {
25 Nav::setSelected('profiles');
31 if (($a->argc > 2) && ($a->argv[1] === "drop") && intval($a->argv[2])) {
32 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
36 if (! DBM::is_result($r)) {
37 notice(L10n::t('Profile not found.') . EOL);
42 check_form_security_token_redirectOnErr('/profiles', 'profile_drop', 't');
44 // move every contact using this profile as their default to the user default
46 $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 ",
51 $r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d",
55 if (DBM::is_result($r)) {
56 info(L10n::t('Profile deleted.').EOL);
63 if (($a->argc > 1) && ($a->argv[1] === 'new')) {
65 check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't');
67 $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
68 intval(local_user()));
70 $num_profiles = (DBM::is_result($r0) ? count($r0) : 0);
72 $name = L10n::t('Profile-') . ($num_profiles + 1);
74 $r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
75 intval(local_user()));
77 $r2 = q("INSERT INTO `profile` (`uid` , `profile-name` , `name`, `photo`, `thumb`)
78 VALUES ( %d, '%s', '%s', '%s', '%s' )",
81 dbesc($r1[0]['name']),
82 dbesc($r1[0]['photo']),
83 dbesc($r1[0]['thumb'])
86 $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1",
91 info(L10n::t('New profile created.') . EOL);
92 if (DBM::is_result($r3) && count($r3) == 1) {
93 goaway('profiles/' . $r3[0]['id']);
99 if (($a->argc > 2) && ($a->argv[1] === 'clone')) {
101 check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't');
103 $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
104 intval(local_user()));
106 $num_profiles = (DBM::is_result($r0) ? count($r0) : 0);
108 $name = L10n::t('Profile-') . ($num_profiles + 1);
109 $r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 1",
110 intval(local_user()),
113 if(! DBM::is_result($r1)) {
114 notice(L10n::t('Profile unavailable to clone.') . EOL);
119 $r1[0]['is-default'] = 0;
120 $r1[0]['publish'] = 0;
121 $r1[0]['net-publish'] = 0;
122 $r1[0]['profile-name'] = dbesc($name);
124 dba::insert('profile', $r1[0]);
126 $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1",
127 intval(local_user()),
130 info(L10n::t('New profile created.') . EOL);
131 if ((DBM::is_result($r3)) && (count($r3) == 1)) {
132 goaway('profiles/'.$r3[0]['id']);
137 return; // NOTREACHED
141 if (($a->argc > 1) && (intval($a->argv[1]))) {
142 $r = q("SELECT id FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
146 if (! DBM::is_result($r)) {
147 notice(L10n::t('Profile not found.') . EOL);
152 Profile::load($a, $a->user['nickname'], $r[0]['id']);
159 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(L10n::t('Permission denied.') . EOL);
184 $namechanged = false;
186 Addon::callHooks('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 (! DBM::is_result($orig)) {
194 notice(L10n::t('Profile not found.') . EOL);
198 check_form_security_token_redirectOnErr('/profiles', 'profile_edit');
200 $is_default = (($orig[0]['is-default']) ? 1 : 0);
202 $profile_name = notags(trim($_POST['profile_name']));
203 if (! strlen($profile_name)) {
204 notice(L10n::t('Profile Name is required.') . EOL);
208 $dob = $_POST['dob'] ? escape_tags(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', '0001-01-01'])) {
217 if (strpos($dob, '0000-') === 0 || strpos($dob, '0001-') === 0) {
219 $dob = substr($dob, 5);
223 $dob = '0000-' . Temporal::utc('1900-' . $dob, 'm-d');
225 $dob = Temporal::utc($dob, 'Y-m-d');
229 $name = notags(trim($_POST['name']));
231 if (! strlen($name)) {
235 if ($orig[0]['name'] != $name) {
239 $pdesc = notags(trim($_POST['pdesc']));
240 $gender = notags(trim($_POST['gender']));
241 $address = notags(trim($_POST['address']));
242 $locality = notags(trim($_POST['locality']));
243 $region = notags(trim($_POST['region']));
244 $postal_code = notags(trim($_POST['postal_code']));
245 $country_name = notags(trim($_POST['country_name']));
246 $pub_keywords = profile_clean_keywords(notags(trim($_POST['pub_keywords'])));
247 $prv_keywords = profile_clean_keywords(notags(trim($_POST['prv_keywords'])));
248 $marital = notags(trim($_POST['marital']));
249 $howlong = notags(trim($_POST['howlong']));
251 $with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : '');
253 if (! strlen($howlong)) {
254 $howlong = NULL_DATE;
256 $howlong = Temporal::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",
288 if (! DBM::is_result($r)) {
289 $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
294 if (DBM::is_result($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 = notags(trim($_POST['sexual']));
313 $xmpp = notags(trim($_POST['xmpp']));
314 $homepage = notags(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 = notags(trim($_POST['hometown']));
320 $politic = notags(trim($_POST['politic']));
321 $religion = notags(trim($_POST['religion']));
323 $likes = escape_tags(trim($_POST['likes']));
324 $dislikes = escape_tags(trim($_POST['dislikes']));
326 $about = escape_tags(trim($_POST['about']));
327 $interest = escape_tags(trim($_POST['interest']));
328 $contact = escape_tags(trim($_POST['contact']));
329 $music = escape_tags(trim($_POST['music']));
330 $book = escape_tags(trim($_POST['book']));
331 $tv = escape_tags(trim($_POST['tv']));
332 $film = escape_tags(trim($_POST['film']));
333 $romance = escape_tags(trim($_POST['romance']));
334 $work = escape_tags(trim($_POST['work']));
335 $education = escape_tags(trim($_POST['education']));
337 $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0);
339 PConfig::set(local_user(), 'system', 'detailled_profile', (($_POST['detailled_profile'] == 1) ? 1: 0));
344 if ($marital != $orig[0]['marital']) {
345 $changes[] = '[color=#ff0000]♥[/color] ' . L10n::t('Marital Status');
349 $changes[] = '[color=#ff0000]♥[/color] ' . L10n::t('Romantic Partner');
350 $value = strip_tags($with);
352 if ($likes != $orig[0]['likes']) {
353 $changes[] = L10n::t('Likes');
356 if ($dislikes != $orig[0]['dislikes']) {
357 $changes[] = L10n::t('Dislikes');
360 if ($work != $orig[0]['work']) {
361 $changes[] = L10n::t('Work/Employment');
363 if ($religion != $orig[0]['religion']) {
364 $changes[] = L10n::t('Religion');
367 if ($politic != $orig[0]['politic']) {
368 $changes[] = L10n::t('Political Views');
371 if ($gender != $orig[0]['gender']) {
372 $changes[] = L10n::t('Gender');
375 if ($sexual != $orig[0]['sexual']) {
376 $changes[] = L10n::t('Sexual Preference');
379 if ($xmpp != $orig[0]['xmpp']) {
380 $changes[] = L10n::t('XMPP');
383 if ($homepage != $orig[0]['homepage']) {
384 $changes[] = L10n::t('Homepage');
387 if ($interest != $orig[0]['interest']) {
388 $changes[] = L10n::t('Interests');
391 if ($address != $orig[0]['address']) {
392 $changes[] = L10n::t('Address');
393 // New address not sent in notifications, potential privacy issues
394 // in case this leaks to unintended recipients. Yes, it's in the public
395 // profile but that doesn't mean we have to broadcast it to everybody.
397 if ($locality != $orig[0]['locality'] || $region != $orig[0]['region']
398 || $country_name != $orig[0]['country-name']) {
399 $changes[] = L10n::t('Location');
400 $comma1 = ((($locality) && ($region || $country_name)) ? ', ' : ' ');
401 $comma2 = (($region && $country_name) ? ', ' : '');
402 $value = $locality . $comma1 . $region . $comma2 . $country_name;
405 profile_activity($changes,$value);
409 $r = q("UPDATE `profile`
410 SET `profile-name` = '%s',
418 `postal-code` = '%s',
419 `country-name` = '%s',
429 `pub_keywords` = '%s',
430 `prv_keywords` = '%s',
444 WHERE `id` = %d AND `uid` = %d",
445 dbesc($profile_name),
454 dbesc($country_name),
464 dbesc($pub_keywords),
465 dbesc($prv_keywords),
478 intval($hide_friends),
484 info(L10n::t('Profile updated.') . EOL);
488 if ($namechanged && $is_default) {
489 $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d",
491 dbesc(Temporal::utcNow()),
494 $r = q("UPDATE `user` set `username` = '%s' where `uid` = %d",
501 $location = Profile::formatLocation(["locality" => $locality, "region" => $region, "country-name" => $country_name]);
503 q("UPDATE `contact` SET `about` = '%s', `location` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `self` AND `uid` = %d",
506 dbesc($pub_keywords),
511 // Update global directory in background
512 $url = $_SESSION['my_url'];
513 if ($url && strlen(Config::get('system', 'directory'))) {
514 Worker::add(PRIORITY_LOW, "Directory", $url);
517 Worker::add(PRIORITY_LOW, 'ProfileUpdate', local_user());
519 // Update the global contact for the user
520 GContact::updateForUser(local_user());
526 function profile_activity($changed, $value) {
529 if (! local_user() || ! is_array($changed) || ! count($changed)) {
533 if ($a->user['hidewall'] || Config::get('system', 'block_public')) {
537 if (! PConfig::get(local_user(), 'system', 'post_profilechange')) {
541 require_once 'include/items.php';
543 $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
547 if (! DBM::is_result($self)) {
553 $arr['guid'] = get_guid(32);
554 $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), local_user());
555 $arr['uid'] = local_user();
556 $arr['contact-id'] = $self[0]['id'];
558 $arr['type'] = 'wall';
561 $arr['author-name'] = $arr['owner-name'] = $self[0]['name'];
562 $arr['author-link'] = $arr['owner-link'] = $self[0]['url'];
563 $arr['author-avatar'] = $arr['owner-avatar'] = $self[0]['thumb'];
564 $arr['verb'] = ACTIVITY_UPDATE;
565 $arr['object-type'] = ACTIVITY_OBJ_PROFILE;
567 $A = '[url=' . $self[0]['url'] . ']' . $self[0]['name'] . '[/url]';
571 $t = count($changed);
573 foreach ($changed as $ch) {
574 if (strlen($changes)) {
575 if ($z == ($t - 1)) {
576 $changes .= L10n::t(' and ');
585 $prof = '[url=' . $self[0]['url'] . '?tab=profile' . ']' . L10n::t('public profile') . '[/url]';
587 if ($t == 1 && strlen($value)) {
588 $message = L10n::t('%1$s changed %2$s to “%3$s”', $A, $changes, $value);
589 $message .= "\n\n" . L10n::t(' - Visit %1$s\'s %2$s', $A, $prof);
591 $message = L10n::t('%1$s has an updated %2$s, changing %3$s.', $A, $prof, $changes);
595 $arr['body'] = $message;
597 $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PROFILE . '</type><title>' . $self[0]['name'] . '</title>'
598 . '<id>' . $self[0]['url'] . '/' . $self[0]['name'] . '</id>';
599 $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $self[0]['url'] . '?tab=profile' . '" />' . "\n");
600 $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $self[0]['thumb'] . '" />' . "\n");
601 $arr['object'] .= '</link></object>' . "\n";
603 $arr['allow_cid'] = $a->user['allow_cid'];
604 $arr['allow_gid'] = $a->user['allow_gid'];
605 $arr['deny_cid'] = $a->user['deny_cid'];
606 $arr['deny_gid'] = $a->user['deny_gid'];
608 $i = Item::insert($arr);
610 Worker::add(PRIORITY_HIGH, "Notifier", "activity", $i);
615 function profiles_content(App $a) {
617 if (! local_user()) {
618 notice(L10n::t('Permission denied.') . EOL);
624 if (($a->argc > 1) && (intval($a->argv[1]))) {
625 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
629 if (! DBM::is_result($r)) {
630 notice(L10n::t('Profile not found.') . EOL);
634 $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), [
635 '$baseurl' => System::baseUrl(true),
637 $a->page['end'] .= replace_macros(get_markup_template('profed_end.tpl'), [
638 '$baseurl' => System::baseUrl(true),
641 $opt_tpl = get_markup_template("profile-hide-friends.tpl");
642 $hide_friends = replace_macros($opt_tpl,[
644 'hide-friends', //Name
645 L10n::t('Hide contacts and friends:'), //Label
646 !!$r[0]['hide-friends'], //Value
648 [L10n::t('No'), L10n::t('Yes')] //Off - On strings
650 '$desc' => L10n::t('Hide your contact/friend list from viewers of this profile?'),
651 '$yes_str' => L10n::t('Yes'),
652 '$no_str' => L10n::t('No'),
653 '$yes_selected' => (($r[0]['hide-friends']) ? " checked=\"checked\" " : ""),
654 '$no_selected' => (($r[0]['hide-friends'] == 0) ? " checked=\"checked\" " : "")
657 $personal_account = !(in_array($a->user["page-flags"],
658 [PAGE_COMMUNITY, PAGE_PRVGROUP]));
660 $detailled_profile = (PConfig::get(local_user(), 'system', 'detailled_profile') AND $personal_account);
662 $is_default = (($r[0]['is-default']) ? 1 : 0);
663 $tpl = get_markup_template("profile_edit.tpl");
664 $o .= replace_macros($tpl, [
665 '$personal_account' => $personal_account,
666 '$detailled_profile' => $detailled_profile,
669 'detailled_profile', //Name
670 L10n::t('Show more profile fields:'), //Label
671 $detailled_profile, //Value
673 [L10n::t('No'), L10n::t('Yes')] //Off - On strings
676 '$multi_profiles' => Feature::isEnabled(local_user(), 'multi_profiles'),
677 '$form_security_token' => get_form_security_token("profile_edit"),
678 '$form_security_token_photo' => get_form_security_token("profile_photo"),
679 '$profile_clone_link' => ((Feature::isEnabled(local_user(), 'multi_profiles')) ? 'profiles/clone/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_clone") : ""),
680 '$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_drop"),
682 '$profile_action' => L10n::t('Profile Actions'),
683 '$banner' => L10n::t('Edit Profile Details'),
684 '$submit' => L10n::t('Submit'),
685 '$profpic' => L10n::t('Change Profile Photo'),
686 '$viewprof' => L10n::t('View this profile'),
687 '$editvis' => L10n::t('Edit visibility'),
688 '$cr_prof' => L10n::t('Create a new profile using these settings'),
689 '$cl_prof' => L10n::t('Clone this profile'),
690 '$del_prof' => L10n::t('Delete this profile'),
692 '$lbl_basic_section' => L10n::t('Basic information'),
693 '$lbl_picture_section' => L10n::t('Profile picture'),
694 '$lbl_location_section' => L10n::t('Location'),
695 '$lbl_preferences_section' => L10n::t('Preferences'),
696 '$lbl_status_section' => L10n::t('Status information'),
697 '$lbl_about_section' => L10n::t('Additional information'),
698 '$lbl_interests_section' => L10n::t('Interests'),
699 '$lbl_personal_section' => L10n::t('Personal'),
700 '$lbl_relation_section' => L10n::t('Relation'),
701 '$lbl_miscellaneous_section' => L10n::t('Miscellaneous'),
703 '$lbl_profile_photo' => L10n::t('Upload Profile Photo'),
704 '$lbl_gender' => L10n::t('Your Gender:'),
705 '$lbl_marital' => L10n::t('<span class="heart">♥</span> Marital Status:'),
706 '$lbl_sexual' => L10n::t('Sexual Preference:'),
707 '$lbl_ex2' => L10n::t('Example: fishing photography software'),
709 '$disabled' => (($is_default) ? 'onclick="return false;" style="color: #BBBBFF;"' : ''),
710 '$baseurl' => System::baseUrl(true),
711 '$profile_id' => $r[0]['id'],
712 '$profile_name' => ['profile_name', L10n::t('Profile Name:'), $r[0]['profile-name'], L10n::t('Required'), '*'],
713 '$is_default' => $is_default,
714 '$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>' : ""),
715 '$name' => ['name', L10n::t('Your Full Name:'), $r[0]['name']],
716 '$pdesc' => ['pdesc', L10n::t('Title/Description:'), $r[0]['pdesc']],
717 '$dob' => dob($r[0]['dob']),
718 '$hide_friends' => $hide_friends,
719 '$address' => ['address', L10n::t('Street Address:'), $r[0]['address']],
720 '$locality' => ['locality', L10n::t('Locality/City:'), $r[0]['locality']],
721 '$region' => ['region', L10n::t('Region/State:'), $r[0]['region']],
722 '$postal_code' => ['postal_code', L10n::t('Postal/Zip Code:'), $r[0]['postal-code']],
723 '$country_name' => ['country_name', L10n::t('Country:'), $r[0]['country-name']],
724 '$age' => ((intval($r[0]['dob'])) ? '(' . L10n::t('Age: ') . age($r[0]['dob'],$a->user['timezone'],$a->user['timezone']) . ')' : ''),
725 '$gender' => ContactSelector::gender($r[0]['gender']),
726 '$marital' => ContactSelector::maritalStatus($r[0]['marital']),
727 '$with' => ['with', L10n::t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), L10n::t('Examples: cathy123, Cathy Williams, cathy@example.com')],
728 '$howlong' => ['howlong', L10n::t('Since [date]:'), ($r[0]['howlong'] <= NULL_DATE ? '' : Temporal::local($r[0]['howlong']))],
729 '$sexual' => ContactSelector::sexualPreference($r[0]['sexual']),
730 '$about' => ['about', L10n::t('Tell us about yourself...'), $r[0]['about']],
731 '$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.")],
732 '$homepage' => ['homepage', L10n::t('Homepage URL:'), $r[0]['homepage']],
733 '$hometown' => ['hometown', L10n::t('Hometown:'), $r[0]['hometown']],
734 '$politic' => ['politic', L10n::t('Political Views:'), $r[0]['politic']],
735 '$religion' => ['religion', L10n::t('Religious Views:'), $r[0]['religion']],
736 '$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")],
737 '$prv_keywords' => ['prv_keywords', L10n::t('Private Keywords:'), $r[0]['prv_keywords'], L10n::t("\x28Used for searching profiles, never shown to others\x29")],
738 '$likes' => ['likes', L10n::t('Likes:'), $r[0]['likes']],
739 '$dislikes' => ['dislikes', L10n::t('Dislikes:'), $r[0]['dislikes']],
740 '$music' => ['music', L10n::t('Musical interests'), $r[0]['music']],
741 '$book' => ['book', L10n::t('Books, literature'), $r[0]['book']],
742 '$tv' => ['tv', L10n::t('Television'), $r[0]['tv']],
743 '$film' => ['film', L10n::t('Film/dance/culture/entertainment'), $r[0]['film']],
744 '$interest' => ['interest', L10n::t('Hobbies/Interests'), $r[0]['interest']],
745 '$romance' => ['romance', L10n::t('Love/romance'), $r[0]['romance']],
746 '$work' => ['work', L10n::t('Work/employment'), $r[0]['work']],
747 '$education' => ['education', L10n::t('School/education'), $r[0]['education']],
748 '$contact' => ['contact', L10n::t('Contact information and Social Networks'), $r[0]['contact']],
751 $arr = ['profile' => $r[0], 'entry' => $o];
752 Addon::callHooks('profile_edit', $arr);
756 // If we don't support multi profiles, don't display this list.
757 if (!Feature::isEnabled(local_user(), 'multi_profiles')) {
758 $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`=1",
761 if (DBM::is_result($r)) {
762 //Go to the default profile.
763 goaway('profiles/' . $r[0]['id']);
767 $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
770 if (DBM::is_result($r)) {
772 $tpl = get_markup_template('profile_entry.tpl');
775 foreach ($r as $rr) {
776 $profiles .= replace_macros($tpl, [
777 '$photo' => $a->remove_baseurl($rr['thumb']),
779 '$alt' => L10n::t('Profile Image'),
780 '$profile_name' => $rr['profile-name'],
781 '$visible' => (($rr['is-default']) ? '<strong>' . L10n::t('visible to everybody') . '</strong>'
782 : '<a href="'.'profperm/'.$rr['id'].'" />' . L10n::t('Edit visibility') . '</a>')
786 $tpl_header = get_markup_template('profile_listing_header.tpl');
787 $o .= replace_macros($tpl_header,[
788 '$header' => L10n::t('Edit/Manage Profiles'),
789 '$chg_photo' => L10n::t('Change profile photo'),
790 '$cr_new' => L10n::t('Create New Profile'),
791 '$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new"),
792 '$profiles' => $profiles