]> git.mxchange.org Git - friendica.git/blob - mod/profiles.php
013e8e82002617ac88b23940909567c29d6bf106
[friendica.git] / mod / profiles.php
1 <?php
2
3
4 function profiles_post(&$a) {
5
6         if(! local_user()) {
7                 notice( t('Permission denied.') . EOL);
8                 return;
9         }
10
11         $namechanged = false;
12
13         call_hooks('profile_post', $_POST);
14
15         if(($a->argc > 1) && ($a->argv[1] !== "new") && intval($a->argv[1])) {
16                 $orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
17                         intval($a->argv[1]),
18                         intval(local_user())
19                 );
20                 if(! count($orig)) {
21                         notice( t('Profile not found.') . EOL);
22                         return;
23                 }
24                 
25                 check_form_security_token_redirectOnErr('/profiles', 'profile_edit');
26                 
27                 $is_default = (($orig[0]['is-default']) ? 1 : 0);
28
29                 $profile_name = notags(trim($_POST['profile_name']));
30                 if(! strlen($profile_name)) {
31                         notify( t('Profile Name is required.') . EOL);
32                         return;
33                 }
34         
35                 $year = intval($_POST['year']);
36                 if($year < 1900 || $year > 2100 || $year < 0)
37                         $year = 0;
38                 $month = intval($_POST['month']);
39                         if(($month > 12) || ($month < 0))
40                                 $month = 0;
41                 $mtab = array(0,31,29,31,30,31,30,31,31,30,31,30,31);
42                 $day = intval($_POST['day']);
43                         if(($day > $mtab[$month]) || ($day < 0))
44                                 $day = 0;
45                 $dob = '0000-00-00';
46                 $dob = sprintf('%04d-%02d-%02d',$year,$month,$day);
47
48                         
49                 $name = notags(trim($_POST['name']));
50
51                 if(! strlen($name)) {
52                         $name = '[No Name]';
53                 }
54
55                 if($orig[0]['name'] != $name)
56                         $namechanged = true;
57
58
59
60                 $pdesc = notags(trim($_POST['pdesc']));
61                 $gender = notags(trim($_POST['gender']));
62                 $address = notags(trim($_POST['address']));
63                 $locality = notags(trim($_POST['locality']));
64                 $region = notags(trim($_POST['region']));
65                 $postal_code = notags(trim($_POST['postal_code']));
66                 $country_name = notags(trim($_POST['country_name']));
67                 $pub_keywords = notags(trim($_POST['pub_keywords']));
68                 $prv_keywords = notags(trim($_POST['prv_keywords']));
69                 $marital = notags(trim($_POST['marital']));
70                 $howlong = notags(trim($_POST['howlong']));
71
72                 $with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : '');
73
74                 if(! strlen($howlong))
75                         $howlong = '0000-00-00 00:00:00';
76                 else
77                         $howlong = datetime_convert(date_default_timezone_get(),'UTC',$howlong);
78  
79                 // linkify the relationship target if applicable
80
81                 $withchanged = false;
82
83                 if(strlen($with)) {
84                         if($with != strip_tags($orig[0]['with'])) {
85                                 $withchanged = true;
86                                 $prf = '';
87                                 $lookup = $with;
88                                 if(strpos($lookup,'@') === 0)
89                                         $lookup = substr($lookup,1);
90                                 $lookup = str_replace('_',' ', $lookup);
91                                 if(strpos($lookup,'@') || (strpos($lookup,'http://'))) {
92                                         $newname = $lookup;
93                                         $links = @lrdd($lookup);
94                                         if(count($links)) {
95                                                 foreach($links as $link) {
96                                                         if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') {
97                                         $prf = $link['@attributes']['href'];
98                                                         }
99                                                 }
100                                         }
101                                 }
102                                 else {
103                                         $newname = $lookup;
104 /*                                      if(strstr($lookup,' ')) {
105                                                 $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
106                                                         dbesc($newname),
107                                                         intval(local_user())
108                                                 );
109                                         }
110                                         else {
111                                                 $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
112                                                         dbesc($lookup),
113                                                         intval(local_user())
114                                                 );
115                                         }*/
116                                         
117                                         $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
118                                                 dbesc($newname),
119                                                 intval(local_user())
120                                         );
121                                         if(! $r) {
122                                                 $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
123                                                         dbesc($lookup),
124                                                         intval(local_user())
125                                                 );
126                                         }
127                                         if(count($r)) {
128                                                 $prf = $r[0]['url'];
129                                                 $newname = $r[0]['name'];
130                                         }
131                                 }
132         
133                                 if($prf) {
134                                         $with = str_replace($lookup,'<a href="' . $prf . '">' . $newname        . '</a>', $with);
135                                         if(strpos($with,'@') === 0)
136                                                 $with = substr($with,1);
137                                 }
138                         }
139                         else
140                                 $with = $orig[0]['with'];
141                 }
142
143                 $sexual = notags(trim($_POST['sexual']));
144                 $homepage = notags(trim($_POST['homepage']));
145                 $hometown = notags(trim($_POST['hometown']));
146                 $politic = notags(trim($_POST['politic']));
147                 $religion = notags(trim($_POST['religion']));
148
149                 $likes = fix_mce_lf(escape_tags(trim($_POST['likes'])));
150                 $dislikes = fix_mce_lf(escape_tags(trim($_POST['dislikes'])));
151
152                 $about = fix_mce_lf(escape_tags(trim($_POST['about'])));
153                 $interest = fix_mce_lf(escape_tags(trim($_POST['interest'])));
154                 $contact = fix_mce_lf(escape_tags(trim($_POST['contact'])));
155                 $music = fix_mce_lf(escape_tags(trim($_POST['music'])));
156                 $book = fix_mce_lf(escape_tags(trim($_POST['book'])));
157                 $tv = fix_mce_lf(escape_tags(trim($_POST['tv'])));
158                 $film = fix_mce_lf(escape_tags(trim($_POST['film'])));
159                 $romance = fix_mce_lf(escape_tags(trim($_POST['romance'])));
160                 $work = fix_mce_lf(escape_tags(trim($_POST['work'])));
161                 $education = fix_mce_lf(escape_tags(trim($_POST['education'])));
162
163                 $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0);
164
165
166
167                 $changes = array();
168                 $value = '';
169                 if($is_default) {
170                         if($marital != $orig[0]['marital']) {
171                                 $changes[] = '[color=#ff0000]&hearts;[/color] ' . t('Marital Status');
172                                 $value = $marital;
173                         }
174                         if($withchanged) {
175                                 $changes[] = '[color=#ff0000]&hearts;[/color] ' . t('Romantic Partner');
176                                 $value = strip_tags($with);
177                         }
178                         if($likes != $orig[0]['likes']) {
179                                 $changes[] = t('Likes');
180                                 $value = $likes;
181                         }
182                         if($dislikes != $orig[0]['dislikes']) {
183                                 $changes[] = t('Dislikes');
184                                 $value = $dislikes;
185                         }
186                         if($work != $orig[0]['work']) {
187                                 $changes[] = t('Work/Employment');
188                         }
189                         if($religion != $orig[0]['religion']) {
190                                 $changes[] = t('Religion');
191                                 $value = $religion;
192                         }
193                         if($politic != $orig[0]['politic']) {
194                                 $changes[] = t('Political Views');
195                                 $value = $politic;
196                         }
197                         if($gender != $orig[0]['gender']) {
198                                 $changes[] = t('Gender');
199                                 $value = $gender;
200                         }
201                         if($sexual != $orig[0]['sexual']) {
202                                 $changes[] = t('Sexual Preference');
203                                 $value = $sexual;
204                         }
205                         if($homepage != $orig[0]['homepage']) {
206                                 $changes[] = t('Homepage');
207                                 $value = $homepage;
208                         }
209                         if($interest != $orig[0]['interest']) {
210                                 $changes[] = t('Interests');
211                                 $value = $interest;
212                         }
213                         if($address != $orig[0]['address']) {
214                                 $changes[] = t('Address');
215                                 // New address not sent in notifications, potential privacy issues
216                                 // in case this leaks to unintended recipients. Yes, it's in the public
217                                 // profile but that doesn't mean we have to broadcast it to everybody.
218                         }
219                         if($locality != $orig[0]['locality'] || $region != $orig[0]['region']
220                                 || $country_name != $orig[0]['country-name']) {
221                                 $changes[] = t('Location');
222                                 $comma1 = ((($locality) && ($region || $country_name)) ? ', ' : ' ');
223                                 $comma2 = (($region && $country_name) ? ', ' : '');
224                                 $value = $locality . $comma1 . $region . $comma2 . $country_name;
225                         }
226
227                         profile_activity($changes,$value);
228
229                 }                       
230                         
231                 $r = q("UPDATE `profile` 
232                         SET `profile-name` = '%s',
233                         `name` = '%s',
234                         `pdesc` = '%s',
235                         `gender` = '%s',
236                         `dob` = '%s',
237                         `address` = '%s',
238                         `locality` = '%s',
239                         `region` = '%s',
240                         `postal-code` = '%s',
241                         `country-name` = '%s',
242                         `marital` = '%s',
243                         `with` = '%s',
244                         `howlong` = '%s',
245                         `sexual` = '%s',
246                         `homepage` = '%s',
247                         `hometown` = '%s',
248                         `politic` = '%s',
249                         `religion` = '%s',
250                         `pub_keywords` = '%s',
251                         `prv_keywords` = '%s',
252                         `likes` = '%s',
253                         `dislikes` = '%s',
254                         `about` = '%s',
255                         `interest` = '%s',
256                         `contact` = '%s',
257                         `music` = '%s',
258                         `book` = '%s',
259                         `tv` = '%s',
260                         `film` = '%s',
261                         `romance` = '%s',
262                         `work` = '%s',
263                         `education` = '%s',
264                         `hide-friends` = %d
265                         WHERE `id` = %d AND `uid` = %d LIMIT 1",
266                         dbesc($profile_name),
267                         dbesc($name),
268                         dbesc($pdesc),
269                         dbesc($gender),
270                         dbesc($dob),
271                         dbesc($address),
272                         dbesc($locality),
273                         dbesc($region),
274                         dbesc($postal_code),
275                         dbesc($country_name),
276                         dbesc($marital),
277                         dbesc($with),
278                         dbesc($howlong),
279                         dbesc($sexual),
280                         dbesc($homepage),
281                         dbesc($hometown),
282                         dbesc($politic),
283                         dbesc($religion),
284                         dbesc($pub_keywords),
285                         dbesc($prv_keywords),
286                         dbesc($likes),
287                         dbesc($dislikes),
288                         dbesc($about),
289                         dbesc($interest),
290                         dbesc($contact),
291                         dbesc($music),
292                         dbesc($book),
293                         dbesc($tv),
294                         dbesc($film),
295                         dbesc($romance),
296                         dbesc($work),
297                         dbesc($education),
298                         intval($hide_friends),
299                         intval($a->argv[1]),
300                         intval(local_user())
301                 );
302
303                 if($r)
304                         info( t('Profile updated.') . EOL);
305
306
307                 if($namechanged && $is_default) {
308                         $r = q("UPDATE `contact` SET `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d LIMIT 1",
309                                 dbesc(datetime_convert()),
310                                 intval(local_user())
311                         );
312                 }
313
314                 if($is_default) {
315                         // Update global directory in background
316                         $url = $_SESSION['my_url'];
317                         if($url && strlen(get_config('system','directory_submit_url')))
318                                 proc_run('php',"include/directory.php","$url");
319
320                         require_once('include/profile_update.php');
321                         profile_change();
322                 }
323         }
324 }
325
326
327 function profile_activity($changed, $value) {
328         $a = get_app();
329
330         if(! local_user() || ! is_array($changed) || ! count($changed))
331                 return;
332
333         if($a->user['hidewall'] || get_config('system','block_public'))
334                 return;
335
336         if(! get_pconfig(local_user(),'system','post_profilechange'))
337                 return;
338
339         require_once('include/items.php');
340
341         $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
342                 intval(local_user())
343         );
344
345         if(! count($self))
346                 return;
347
348         $arr = array();
349         $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), local_user()); 
350         $arr['uid'] = local_user();
351         $arr['contact-id'] = $self[0]['id'];
352         $arr['wall'] = 1;
353         $arr['type'] = 'wall';
354         $arr['gravity'] = 0;
355         $arr['origin'] = 1;
356         $arr['author-name'] = $arr['owner-name'] = $self[0]['name'];
357         $arr['author-link'] = $arr['owner-link'] = $self[0]['url'];
358         $arr['author-avatar'] = $arr['owner-avatar'] = $self[0]['thumb'];
359         $arr['verb'] = ACTIVITY_UPDATE;
360         $arr['object-type'] = ACTIVITY_OBJ_PROFILE;
361                                 
362         $A = '[url=' . $self[0]['url'] . ']' . $self[0]['name'] . '[/url]';
363
364
365         $changes = '';
366         $t = count($changed);
367         $z = 0;
368         foreach($changed as $ch) {
369                 if(strlen($changes)) {
370                         if ($z == ($t - 1))
371                                 $changes .= t(' and ');
372                         else
373                                 $changes .= ', ';
374                 }
375                 $z ++;
376                 $changes .= $ch;
377         }
378
379         $prof = '[url=' . $self[0]['url'] . '?tab=profile' . ']' . t('public profile') . '[/url]';      
380
381         if($t == 1 && strlen($value)) {
382                 $message = sprintf( t('%1$s changed %2$s to &ldquo;%3$s&rdquo;'), $A, $changes, $value);
383                 $message .= "\n\n" . sprintf( t(' - Visit %1$s\'s %2$s'), $A, $prof);
384         }
385         else
386                 $message =      sprintf( t('%1$s has an updated %2$s, changing %3$s.'), $A, $prof, $changes);
387  
388
389         $arr['body'] = $message;  
390
391         $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PROFILE . '</type><title>' . $self[0]['name'] . '</title>'
392         . '<id>' . $self[0]['url'] . '/' . $self[0]['name'] . '</id>';
393         $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $self[0]['url'] . '?tab=profile' . '" />' . "\n");
394         $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $self[0]['thumb'] . '" />' . "\n");
395         $arr['object'] .= '</link></object>' . "\n";
396         $arr['last-child'] = 1;
397
398         $arr['allow_cid'] = $a->user['allow_cid'];
399         $arr['allow_gid'] = $a->user['allow_gid'];
400         $arr['deny_cid']  = $a->user['deny_cid'];
401         $arr['deny_gid']  = $a->user['deny_gid'];
402
403         $i = item_store($arr);
404         if($i) {
405
406                 // give it a permanent link
407                 q("update item set plink = '%s' where id = %d limit 1",
408                         dbesc($a->get_baseurl() . '/display/' . $a->user['nickname'] . '/' . $i),
409                         intval($i)
410                 );
411
412                 proc_run('php',"include/notifier.php","activity","$i");
413
414         }
415 }
416
417
418 function profiles_content(&$a) {
419
420         $o = '';
421         nav_set_selected('profiles');
422
423         if(! local_user()) {
424                 notice( t('Permission denied.') . EOL);
425                 return;
426         }
427
428         if(($a->argc > 2) && ($a->argv[1] === "drop") && intval($a->argv[2])) {
429                 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
430                         intval($a->argv[2]),
431                         intval(local_user())
432                 );
433                 if(! count($r)) {
434                         notice( t('Profile not found.') . EOL);
435                         goaway($a->get_baseurl(true) . '/profiles');
436                         return; // NOTREACHED
437                 }
438                 
439                 check_form_security_token_redirectOnErr('/profiles', 'profile_drop', 't');
440
441                 // move every contact using this profile as their default to the user default
442
443                 $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 ",
444                         intval(local_user()),
445                         intval($a->argv[2]),
446                         intval(local_user())
447                 );
448                 $r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
449                         intval($a->argv[2]),
450                         intval(local_user())
451                 );
452                 if($r)
453                         info( t('Profile deleted.') . EOL);
454
455                 goaway($a->get_baseurl(true) . '/profiles');
456                 return; // NOTREACHED
457         }
458
459
460
461
462
463         if(($a->argc > 1) && ($a->argv[1] === 'new')) {
464                 
465                 check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't');
466
467                 $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
468                         intval(local_user()));
469                 $num_profiles = count($r0);
470
471                 $name = t('Profile-') . ($num_profiles + 1);
472
473                 $r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
474                         intval(local_user()));
475                 
476                 $r2 = q("INSERT INTO `profile` (`uid` , `profile-name` , `name`, `photo`, `thumb`)
477                         VALUES ( %d, '%s', '%s', '%s', '%s' )",
478                         intval(local_user()),
479                         dbesc($name),
480                         dbesc($r1[0]['name']),
481                         dbesc($r1[0]['photo']),
482                         dbesc($r1[0]['thumb'])
483                 );
484
485                 $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1",
486                         intval(local_user()),
487                         dbesc($name)
488                 );
489
490                 info( t('New profile created.') . EOL);
491                 if(count($r3) == 1)
492                         goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']);
493                 
494                 goaway($a->get_baseurl(true) . '/profiles');
495         } 
496
497         if(($a->argc > 2) && ($a->argv[1] === 'clone')) {
498                 
499                 check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't');
500
501                 $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
502                         intval(local_user()));
503                 $num_profiles = count($r0);
504
505                 $name = t('Profile-') . ($num_profiles + 1);
506                 $r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 1",
507                         intval(local_user()),
508                         intval($a->argv[2])
509                 );
510                 if(! count($r1)) {
511                         notice( t('Profile unavailable to clone.') . EOL);
512                         return;
513                 }
514                 unset($r1[0]['id']);
515                 $r1[0]['is-default'] = 0;
516                 $r1[0]['publish'] = 0;  
517                 $r1[0]['net-publish'] = 0;      
518                 $r1[0]['profile-name'] = dbesc($name);
519
520                 dbesc_array($r1[0]);
521
522                 $r2 = dbq("INSERT INTO `profile` (`" 
523                         . implode("`, `", array_keys($r1[0])) 
524                         . "`) VALUES ('" 
525                         . implode("', '", array_values($r1[0])) 
526                         . "')" );
527
528                 $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile-name` = '%s' LIMIT 1",
529                         intval(local_user()),
530                         dbesc($name)
531                 );
532                 info( t('New profile created.') . EOL);
533                 if(count($r3) == 1)
534                         goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']);
535                 
536                 goaway($a->get_baseurl(true) . '/profiles');
537                 
538                 return; // NOTREACHED
539         }
540
541
542         if(($a->argc > 1) && (intval($a->argv[1]))) {
543                 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
544                         intval($a->argv[1]),
545                         intval(local_user())
546                 );
547                 if(! count($r)) {
548                         notice( t('Profile not found.') . EOL);
549                         return;
550                 }
551
552                 profile_load($a,$a->user['nickname'],$r[0]['id']);
553
554                 require_once('include/profile_selectors.php');
555
556
557                 $editselect = 'textareas';
558                 if(intval(get_pconfig(local_user(),'system','plaintext')))
559                         $editselect = 'none';
560
561                 $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array(
562                         '$baseurl' => $a->get_baseurl(true),
563                         '$editselect' => $editselect,
564                 ));
565                 $a->page['end'] .= replace_macros(get_markup_template('profed_end.tpl'), array(
566                         '$baseurl' => $a->get_baseurl(true),
567                         '$editselect' => $editselect,
568                 ));
569
570
571                 $opt_tpl = get_markup_template("profile-hide-friends.tpl");
572                 $hide_friends = replace_macros($opt_tpl,array(
573                         '$desc' => t('Hide your contact/friend list from viewers of this profile?'),
574                         '$yes_str' => t('Yes'),
575                         '$no_str' => t('No'),
576                         '$yes_selected' => (($r[0]['hide-friends']) ? " checked=\"checked\" " : ""),
577                         '$no_selected' => (($r[0]['hide-friends'] == 0) ? " checked=\"checked\" " : "")
578                 ));
579
580
581
582
583                 $f = get_config('system','birthday_input_format');
584                 if(! $f)
585                         $f = 'ymd';
586
587                 $is_default = (($r[0]['is-default']) ? 1 : 0);
588                 $tpl = get_markup_template("profile_edit.tpl");
589                 $o .= replace_macros($tpl,array(
590                         '$form_security_token' => get_form_security_token("profile_edit"),
591                         '$profile_clone_link' => 'profiles/clone/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_clone"),
592                         '$profile_drop_link' => 'profiles/drop/' . $r[0]['id'] . '?t=' . get_form_security_token("profile_drop"),
593                         '$banner' => t('Edit Profile Details'),
594                         '$submit' => t('Submit'),
595                         '$viewprof' => t('View this profile'),
596                         '$cr_prof' => t('Create a new profile using these settings'),
597                         '$cl_prof' => t('Clone this profile'),
598                         '$del_prof' => t('Delete this profile'),
599                         '$lbl_profname' => t('Profile Name:'),
600                         '$lbl_fullname' => t('Your Full Name:'),
601                         '$lbl_title' => t('Title/Description:'),
602                         '$lbl_gender' => t('Your Gender:'),
603                         '$lbl_bd' => sprintf( t("Birthday \x28%s\x29:"),datesel_format($f)),
604                         '$lbl_address' => t('Street Address:'),
605                         '$lbl_city' => t('Locality/City:'),
606                         '$lbl_zip' => t('Postal/Zip Code:'),
607                         '$lbl_country' => t('Country:'),
608                         '$lbl_region' => t('Region/State:'),
609                         '$lbl_marital' => t('<span class="heart">&hearts;</span> Marital Status:'),
610                         '$lbl_with' => t("Who: \x28if applicable\x29"),
611                         '$lbl_ex1' => t('Examples: cathy123, Cathy Williams, cathy@example.com'),
612                         '$lbl_howlong' => t('Since [date]:'),
613                         '$lbl_sexual' => t('Sexual Preference:'),
614                         '$lbl_homepage' => t('Homepage URL:'),
615                         '$lbl_hometown' => t('Hometown:'),
616                         '$lbl_politic' => t('Political Views:'),
617                         '$lbl_religion' => t('Religious Views:'),
618                         '$lbl_pubkey' => t('Public Keywords:'),
619                         '$lbl_prvkey' => t('Private Keywords:'),
620                         '$lbl_likes' => t('Likes:'),
621                         '$lbl_dislikes' => t('Dislikes:'),
622                         '$lbl_ex2' => t('Example: fishing photography software'),
623                         '$lbl_pubdsc' => t("\x28Used for suggesting potential friends, can be seen by others\x29"),
624                         '$lbl_prvdsc' => t("\x28Used for searching profiles, never shown to others\x29"),
625                         '$lbl_about' => t('Tell us about yourself...'),
626                         '$lbl_hobbies' => t('Hobbies/Interests'),
627                         '$lbl_social' => t('Contact information and Social Networks'),
628                         '$lbl_music' => t('Musical interests'),
629                         '$lbl_book' => t('Books, literature'),
630                         '$lbl_tv' => t('Television'),
631                         '$lbl_film' => t('Film/dance/culture/entertainment'),
632                         '$lbl_love' => t('Love/romance'),
633                         '$lbl_work' => t('Work/employment'),
634                         '$lbl_school' => t('School/education'),
635                         '$disabled' => (($is_default) ? 'onclick="return false;" style="color: #BBBBFF;"' : ''),
636                         '$baseurl' => $a->get_baseurl(true),
637                         '$profile_id' => $r[0]['id'],
638                         '$profile_name' => $r[0]['profile-name'],
639                         '$default' => (($is_default) ? '<p id="profile-edit-default-desc">' . t('This is your <strong>public</strong> profile.<br />It <strong>may</strong> be visible to anybody using the internet.') . '</p>' : ""),
640                         '$name' => $r[0]['name'],
641                         '$pdesc' => $r[0]['pdesc'],
642                         '$dob' => dob($r[0]['dob']),
643                         '$hide_friends' => $hide_friends,
644                         '$address' => $r[0]['address'],
645                         '$locality' => $r[0]['locality'],
646                         '$region' => $r[0]['region'],
647                         '$postal_code' => $r[0]['postal-code'],
648                         '$country_name' => $r[0]['country-name'],
649                         '$age' => ((intval($r[0]['dob'])) ? '(' . t('Age: ') . age($r[0]['dob'],$a->user['timezone'],$a->user['timezone']) . ')' : ''),
650                         '$gender' => gender_selector($r[0]['gender']),
651                         '$marital' => marital_selector($r[0]['marital']),
652                         '$with' => strip_tags($r[0]['with']),
653                         '$howlong' => ($r[0]['howlong'] === '0000-00-00 00:00:00' ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong'])),
654                         '$sexual' => sexpref_selector($r[0]['sexual']),
655                         '$about' => $r[0]['about'],
656                         '$homepage' => $r[0]['homepage'],
657                         '$hometown' => $r[0]['hometown'],
658                         '$politic' => $r[0]['politic'],
659                         '$religion' => $r[0]['religion'],
660                         '$pub_keywords' => $r[0]['pub_keywords'],
661                         '$prv_keywords' => $r[0]['prv_keywords'],
662                         '$likes' => $r[0]['likes'],
663                         '$dislikes' => $r[0]['dislikes'],
664                         '$music' => $r[0]['music'],
665                         '$book' => $r[0]['book'],
666                         '$tv' => $r[0]['tv'],
667                         '$film' => $r[0]['film'],
668                         '$interest' => $r[0]['interest'],
669                         '$romance' => $r[0]['romance'],
670                         '$work' => $r[0]['work'],
671                         '$education' => $r[0]['education'],
672                         '$contact' => $r[0]['contact']
673                 ));
674
675                 $arr = array('profile' => $r[0], 'entry' => $o);
676                 call_hooks('profile_edit', $arr);
677
678                 return $o;
679         }
680         else {
681
682                 $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
683                         local_user());
684                 if(count($r)) {
685
686                         $tpl_header = get_markup_template('profile_listing_header.tpl');
687                         $o .= replace_macros($tpl_header,array(
688                                 '$header' => t('Edit/Manage Profiles'),
689                                 '$chg_photo' => t('Change profile photo'),
690                                 '$cr_new' => t('Create New Profile'),
691                                 '$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new")
692                         ));
693
694
695                         $tpl = get_markup_template('profile_entry.tpl');
696
697                         foreach($r as $rr) {
698                                 $o .= replace_macros($tpl, array(
699                                         '$photo' => $a->get_cached_avatar_image($rr['thumb']),
700                                         '$id' => $rr['id'],
701                                         '$alt' => t('Profile Image'),
702                                         '$profile_name' => $rr['profile-name'],
703                                         '$visible' => (($rr['is-default']) ? '<strong>' . t('visible to everybody') . '</strong>' 
704                                                 : '<a href="' . $a->get_baseurl(true) . '/profperm/' . $rr['id'] . '" />' . t('Edit visibility') . '</a>')
705                                 ));
706                         }
707                 }
708                 return $o;
709         }
710
711 }