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