]> git.mxchange.org Git - friendica.git/blob - mod/contacts.php
Send notifications for each new post of a contact, option for creating a summary...
[friendica.git] / mod / contacts.php
1 <?php
2
3 require_once('include/Contact.php');
4 require_once('include/socgraph.php');
5 require_once('include/contact_selectors.php');
6
7 function contacts_init(&$a) {
8         if(! local_user())
9                 return;
10
11         $contact_id = 0;
12
13         if(($a->argc == 2) && intval($a->argv[1])) {
14                 $contact_id = intval($a->argv[1]);
15                 $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
16                         intval(local_user()),
17                         intval($contact_id)
18                 );
19                 if(! count($r)) {
20                         $contact_id = 0;
21                 }
22         }
23
24         require_once('include/group.php');
25         require_once('include/contact_widgets.php');
26
27         if(! x($a->page,'aside'))
28                 $a->page['aside'] = '';
29
30         if($contact_id) {
31                         $a->data['contact'] = $r[0];
32                         $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"),array(
33                                 '$name' => $a->data['contact']['name'],
34                                 '$photo' => $a->data['contact']['photo']
35                         ));
36                         $follow_widget = '';
37         }
38         else {
39                 $vcard_widget = '';
40                 $follow_widget = follow_widget();
41         }
42
43         $groups_widget .= group_side('contacts','group',false,0,$contact_id);
44         $findpeople_widget .= findpeople_widget();
45         $networks_widget .= networks_widget('contacts',$_GET['nets']);
46         $a->page['aside'] .= replace_macros(get_markup_template("contacts-widget-sidebar.tpl"),array(
47                 '$vcard_widget' => $vcard_widget,
48                 '$follow_widget' => $follow_widget,
49                 '$groups_widget' => $groups_widget,
50                 '$findpeople_widget' => $findpeople_widget,
51                 '$networks_widget' => $networks_widget
52         ));
53
54         $base = $a->get_baseurl();
55         $tpl = get_markup_template("contacts-head.tpl");
56         $a->page['htmlhead'] .= replace_macros($tpl,array(
57                 '$baseurl' => $a->get_baseurl(true),
58                 '$base' => $base
59         ));
60
61         $tpl = get_markup_template("contacts-end.tpl");
62         $a->page['end'] .= replace_macros($tpl,array(
63                 '$baseurl' => $a->get_baseurl(true),
64                 '$base' => $base
65         ));
66
67
68 }
69
70 function contacts_post(&$a) {
71
72         if(! local_user())
73                 return;
74
75         $contact_id = intval($a->argv[1]);
76         if(! $contact_id)
77                 return;
78
79         $orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
80                 intval($contact_id),
81                 intval(local_user())
82         );
83
84         if(! count($orig_record)) {
85                 notice( t('Could not access contact record.') . EOL);
86                 goaway($a->get_baseurl(true) . '/contacts');
87                 return; // NOTREACHED
88         }
89
90         call_hooks('contact_edit_post', $_POST);
91
92         $profile_id = intval($_POST['profile-assign']);
93         if($profile_id) {
94                 $r = q("SELECT `id` FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
95                         intval($profile_id),
96                         intval(local_user())
97                 );
98                 if(! count($r)) {
99                         notice( t('Could not locate selected profile.') . EOL);
100                         return;
101                 }
102         }
103
104         $hidden = intval($_POST['hidden']);
105
106         $notify = intval($_POST['notify']);
107
108         $fetch_further_information = intval($_POST['fetch_further_information']);
109
110         $priority = intval($_POST['poll']);
111         if($priority > 5 || $priority < 0)
112                 $priority = 0;
113
114         $info = fix_mce_lf(escape_tags(trim($_POST['info'])));
115
116         $r = q("UPDATE `contact` SET `profile-id` = %d, `priority` = %d , `info` = '%s',
117                 `hidden` = %d, `notify_new_posts` = %d, `fetch_further_information` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
118                 intval($profile_id),
119                 intval($priority),
120                 dbesc($info),
121                 intval($hidden),
122                 intval($notify),
123                 intval($fetch_further_information),
124                 intval($contact_id),
125                 intval(local_user())
126         );
127         if($r)
128                 info( t('Contact updated.') . EOL);
129         else
130                 notice( t('Failed to update contact record.') . EOL);
131
132         $r = q("select * from contact where id = %d and uid = %d limit 1",
133                 intval($contact_id),
134                 intval(local_user())
135         );
136         if($r && count($r))
137                 $a->data['contact'] = $r[0];
138
139         return;
140
141 }
142
143
144
145 function contacts_content(&$a) {
146
147         $sort_type = 0;
148         $o = '';
149         nav_set_selected('contacts');
150
151
152         if(! local_user()) {
153                 notice( t('Permission denied.') . EOL);
154                 return;
155         }
156
157         if($a->argc == 3) {
158
159                 $contact_id = intval($a->argv[1]);
160                 if(! $contact_id)
161                         return;
162
163                 $cmd = $a->argv[2];
164
165                 $orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d AND `self` = 0 LIMIT 1",
166                         intval($contact_id),
167                         intval(local_user())
168                 );
169
170                 if(! count($orig_record)) {
171                         notice( t('Could not access contact record.') . EOL);
172                         goaway($a->get_baseurl(true) . '/contacts');
173                         return; // NOTREACHED
174                 }
175                 
176                 if($cmd === 'update') {
177
178                         // pull feed and consume it, which should subscribe to the hub.
179                         proc_run('php',"include/poller.php","$contact_id");
180                         goaway($a->get_baseurl(true) . '/contacts/' . $contact_id);
181                         // NOTREACHED
182                 }
183
184                 if($cmd === 'block') {
185                         $blocked = (($orig_record[0]['blocked']) ? 0 : 1);
186                         $r = q("UPDATE `contact` SET `blocked` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
187                                 intval($blocked),
188                                 intval($contact_id),
189                                 intval(local_user())
190                         );
191                         if($r) {
192                                 //notice( t('Contact has been ') . (($blocked) ? t('blocked') : t('unblocked')) . EOL );
193                                 info( (($blocked) ? t('Contact has been blocked') : t('Contact has been unblocked')) . EOL );
194                         }
195                         goaway($a->get_baseurl(true) . '/contacts/' . $contact_id);
196                         return; // NOTREACHED
197                 }
198
199                 if($cmd === 'ignore') {
200                         $readonly = (($orig_record[0]['readonly']) ? 0 : 1);
201                         $r = q("UPDATE `contact` SET `readonly` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
202                                 intval($readonly),
203                                 intval($contact_id),
204                                 intval(local_user())
205                         );
206                         if($r) {
207                                 info( (($readonly) ? t('Contact has been ignored') : t('Contact has been unignored')) . EOL );
208                         }
209                         goaway($a->get_baseurl(true) . '/contacts/' . $contact_id);
210                         return; // NOTREACHED
211                 }
212
213
214                 if($cmd === 'archive') {
215                         $archived = (($orig_record[0]['archive']) ? 0 : 1);
216                         $r = q("UPDATE `contact` SET `archive` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
217                                 intval($archived),
218                                 intval($contact_id),
219                                 intval(local_user())
220                         );
221                         if ($archived) {
222                                 q("UPDATE `item` SET `private` = 2 WHERE `contact-id` = %d AND `uid` = %d", intval($contact_id), intval(local_user()));
223                         }
224                         if($r) {
225                                 //notice( t('Contact has been ') . (($archived) ? t('archived') : t('unarchived')) . EOL );
226                                 info( (($archived) ? t('Contact has been archived') : t('Contact has been unarchived')) . EOL );
227                         }
228                         goaway($a->get_baseurl(true) . '/contacts/' . $contact_id);
229                         return; // NOTREACHED
230                 }
231
232                 if($cmd === 'drop') {
233
234                         // Check if we should do HTML-based delete confirmation
235                         if($_REQUEST['confirm']) {
236                                 // <form> can't take arguments in its "action" parameter
237                                 // so add any arguments as hidden inputs
238                                 $query = explode_querystring($a->query_string);
239                                 $inputs = array();
240                                 foreach($query['args'] as $arg) {
241                                         if(strpos($arg, 'confirm=') === false) {
242                                                 $arg_parts = explode('=', $arg);
243                                                 $inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]);
244                                         }
245                                 }
246
247                                 $a->page['aside'] = '';
248                                 return replace_macros(get_markup_template('confirm.tpl'), array(
249                                         '$method' => 'get',
250                                         '$message' => t('Do you really want to delete this contact?'),
251                                         '$extra_inputs' => $inputs,
252                                         '$confirm' => t('Yes'),
253                                         '$confirm_url' => $query['base'],
254                                         '$confirm_name' => 'confirmed',
255                                         '$cancel' => t('Cancel'),
256                                 ));
257                         }
258                         // Now check how the user responded to the confirmation query
259                         if($_REQUEST['canceled']) {
260                                 goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']);
261
262                         }
263
264                         require_once('include/Contact.php');
265
266                         terminate_friendship($a->user,$a->contact,$orig_record[0]);
267
268                         contact_remove($orig_record[0]['id']);
269                         info( t('Contact has been removed.') . EOL );
270                         if(x($_SESSION,'return_url'))
271                                 goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']);
272                         else
273                                 goaway($a->get_baseurl(true) . '/contacts');
274                         return; // NOTREACHED
275                 }
276         }
277
278
279
280         $_SESSION['return_url'] = $a->query_string;
281
282         if((x($a->data,'contact')) && (is_array($a->data['contact']))) {
283
284                 $contact_id = $a->data['contact']['id'];
285                 $contact = $a->data['contact'];
286
287                 $editselect = 'none';
288                 if( feature_enabled(local_user(),'richtext') )
289                         $editselect = 'exact';
290
291                 $a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), array(
292                         '$baseurl' => $a->get_baseurl(true),
293                         '$editselect' => $editselect,
294                 ));
295                 $a->page['end'] .= replace_macros(get_markup_template('contact_end.tpl'), array(
296                         '$baseurl' => $a->get_baseurl(true),
297                         '$editselect' => $editselect,
298                 ));
299
300                 require_once('include/contact_selectors.php');
301
302                 $tpl = get_markup_template("contact_edit.tpl");
303
304                 switch($contact['rel']) {
305                         case CONTACT_IS_FRIEND:
306                                 $dir_icon = 'images/lrarrow.gif';
307                                 $relation_text = t('You are mutual friends with %s');
308                                 break;
309                         case CONTACT_IS_FOLLOWER;
310                                 $dir_icon = 'images/larrow.gif';
311                                 $relation_text = t('You are sharing with %s');
312                                 break;
313         
314                         case CONTACT_IS_SHARING;
315                                 $dir_icon = 'images/rarrow.gif';
316                                 $relation_text = t('%s is sharing with you');
317                                 break;
318                         default:
319                                 break;
320                 }
321
322                 $relation_text = sprintf($relation_text,$contact['name']);
323
324                 if(($contact['network'] === NETWORK_DFRN) && ($contact['rel'])) {
325                         $url = "redir/{$contact['id']}";
326                         $sparkle = ' class="sparkle" ';
327                 }
328                 else { 
329                         $url = $contact['url'];
330                         $sparkle = '';
331                 }
332
333                 $insecure = t('Private communications are not available for this contact.');
334
335                 $last_update = (($contact['last-update'] == '0000-00-00 00:00:00') 
336                                 ? t('Never') 
337                                 : datetime_convert('UTC',date_default_timezone_get(),$contact['last-update'],'D, j M Y, g:i A'));
338
339                 if($contact['last-update'] !== '0000-00-00 00:00:00')
340                         $last_update .= ' ' . (($contact['last-update'] == $contact['success_update']) ? t("\x28Update was successful\x29") : t("\x28Update was not successful\x29"));
341
342                 $lblsuggest = (($contact['network'] === NETWORK_DFRN) ? t('Suggest friends') : '');
343
344                 $poll_enabled = (($contact['network'] !== NETWORK_DIASPORA) ? true : false);
345
346                 $nettype = sprintf( t('Network type: %s'),network_to_name($contact['network']));
347
348                 $common = count_common_friends(local_user(),$contact['id']);
349                 $common_text = (($common) ? sprintf( tt('%d contact in common','%d contacts in common', $common),$common) : '');
350
351                 $polling = (($contact['network'] === NETWORK_MAIL | $contact['network'] === NETWORK_FEED) ? 'polling' : ''); 
352
353                 $x = count_all_friends(local_user(), $contact['id']);
354                 $all_friends = (($x) ? t('View all contacts') : '');
355
356                 // tabs
357                 $tabs = array(
358                         array(
359                                 'label' => (($contact['blocked']) ? t('Unblock') : t('Block') ),
360                                 'url'   => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/block',
361                                 'sel'   => '',
362                                 'title' => t('Toggle Blocked status'),
363                         ),
364                         array(
365                                 'label' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ),
366                                 'url'   => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/ignore',
367                                 'sel'   => '',
368                                 'title' => t('Toggle Ignored status'),
369                         ),
370
371                         array(
372                                 'label' => (($contact['archive']) ? t('Unarchive') : t('Archive') ),
373                                 'url'   => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/archive',
374                                 'sel'   => '',
375                                 'title' => t('Toggle Archive status'),
376                         ),
377                         array(
378                                 'label' => t('Repair'),
379                                 'url'   => $a->get_baseurl(true) . '/crepair/' . $contact_id,
380                                 'sel'   => '',
381                                 'title' => t('Advanced Contact Settings'),
382                         )
383                 );
384                 $tab_tpl = get_markup_template('common_tabs.tpl');
385                 $tab_str = replace_macros($tab_tpl, array('$tabs' => $tabs));
386
387                 $lost_contact = (($contact['archive'] && $contact['term-date'] != '0000-00-00 00:00:00' && $contact['term-date'] < datetime_convert('','','now')) ? t('Communications lost with this contact!') : '');
388
389                 $o .= replace_macros($tpl, array(
390                         '$header' => t('Contact Editor'),
391                         '$tab_str' => $tab_str,
392                         '$submit' => t('Submit'),
393                         '$lbl_vis1' => t('Profile Visibility'),
394                         '$lbl_vis2' => sprintf( t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['name']),
395                         '$lbl_info1' => t('Contact Information / Notes'),
396                         '$infedit' => t('Edit contact notes'),
397                         '$common_text' => $common_text,
398                         '$common_link' => $a->get_baseurl(true) . '/common/loc/' . local_user() . '/' . $contact['id'],
399                         '$all_friends' => $all_friends,
400                         '$relation_text' => $relation_text,
401                         '$visit' => sprintf( t('Visit %s\'s profile [%s]'),$contact['name'],$contact['url']),
402                         '$blockunblock' => t('Block/Unblock contact'),
403                         '$ignorecont' => t('Ignore contact'),
404                         '$lblcrepair' => t("Repair URL settings"),
405                         '$lblrecent' => t('View conversations'),
406                         '$lblsuggest' => $lblsuggest,
407                         '$delete' => t('Delete contact'),
408                         '$nettype' => $nettype,
409                         '$poll_interval' => contact_poll_interval($contact['priority'],(! $poll_enabled)),
410                         '$poll_enabled' => $poll_enabled,
411                         '$lastupdtext' => t('Last update:'),
412                         '$lost_contact' => $lost_contact,
413                         '$updpub' => t('Update public posts'),
414                         '$last_update' => $last_update,
415                         '$udnow' => t('Update now'),
416                         '$profile_select' => contact_profile_assign($contact['profile-id'],(($contact['network'] !== NETWORK_DFRN) ? true : false)),
417                         '$contact_id' => $contact['id'],
418                         '$block_text' => (($contact['blocked']) ? t('Unblock') : t('Block') ),
419                         '$ignore_text' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ),
420                         '$insecure' => (($contact['network'] !== NETWORK_DFRN && $contact['network'] !== NETWORK_MAIL && $contact['network'] !== NETWORK_FACEBOOK && $contact['network'] !== NETWORK_DIASPORA) ? $insecure : ''),
421                         '$info' => $contact['info'],
422                         '$blocked' => (($contact['blocked']) ? t('Currently blocked') : ''),
423                         '$ignored' => (($contact['readonly']) ? t('Currently ignored') : ''),
424                         '$archived' => (($contact['archive']) ? t('Currently archived') : ''),
425                         '$hidden' => array('hidden', t('Hide this contact from others'), ($contact['hidden'] == 1), t('Replies/likes to your public posts <strong>may</strong> still be visible')),
426                         '$notify' => array('notify', t('Notification for new posts'), ($contact['notify_new_posts'] == 1), t('Send a notification of every new post of this contact')),
427                         '$fetch_further_information' => array('fetch_further_information', t('Fetch further information for feeds'), ($contact['fetch_further_information'] == 1), t('Fetch further information for feeds')),
428                         '$photo' => $contact['photo'],
429                         '$name' => $contact['name'],
430                         '$dir_icon' => $dir_icon,
431                         '$alt_text' => $alt_text,
432                         '$sparkle' => $sparkle,
433                         '$url' => $url,
434
435                 ));
436
437                 $arr = array('contact' => $contact,'output' => $o);
438
439                 call_hooks('contact_edit', $arr);
440
441                 return $arr['output'];
442
443         }
444
445         $blocked = false;
446         $hidden = false;
447         $ignored = false;
448         $all = false;
449
450         if(($a->argc == 2) && ($a->argv[1] === 'all')) {
451                 $sql_extra = '';
452                 $all = true;
453         }
454         elseif(($a->argc == 2) && ($a->argv[1] === 'blocked')) {
455                 $sql_extra = " AND `blocked` = 1 ";
456                 $blocked = true;
457         }
458         elseif(($a->argc == 2) && ($a->argv[1] === 'hidden')) {
459                 $sql_extra = " AND `hidden` = 1 ";
460                 $hidden = true;
461         }
462         elseif(($a->argc == 2) && ($a->argv[1] === 'ignored')) {
463                 $sql_extra = " AND `readonly` = 1 ";
464                 $ignored = true;
465         }
466         elseif(($a->argc == 2) && ($a->argv[1] === 'archived')) {
467                 $sql_extra = " AND `archive` = 1 ";
468                 $archived = true;
469         }
470         else
471                 $sql_extra = " AND `blocked` = 0 ";
472
473         $search = ((x($_GET,'search')) ? notags(trim($_GET['search'])) : '');
474         $nets = ((x($_GET,'nets')) ? notags(trim($_GET['nets'])) : '');
475
476         $tabs = array(
477                 array(
478                         'label' => t('Suggestions'),
479                         'url'   => $a->get_baseurl(true) . '/suggest', 
480                         'sel'   => '',
481                         'title' => t('Suggest potential friends'),
482                 ),
483                 array(
484                         'label' => t('All Contacts'),
485                         'url'   => $a->get_baseurl(true) . '/contacts/all', 
486                         'sel'   => ($all) ? 'active' : '',
487                         'title' => t('Show all contacts'),
488                 ),
489                 array(
490                         'label' => t('Unblocked'),
491                         'url'   => $a->get_baseurl(true) . '/contacts',
492                         'sel'   => ((! $all) && (! $blocked) && (! $hidden) && (! $search) && (! $nets) && (! $ignored) && (! $archived)) ? 'active' : '',
493                         'title' => t('Only show unblocked contacts'),
494                 ),
495
496                 array(
497                         'label' => t('Blocked'),
498                         'url'   => $a->get_baseurl(true) . '/contacts/blocked',
499                         'sel'   => ($blocked) ? 'active' : '',
500                         'title' => t('Only show blocked contacts'),
501                 ),
502
503                 array(
504                         'label' => t('Ignored'),
505                         'url'   => $a->get_baseurl(true) . '/contacts/ignored',
506                         'sel'   => ($ignored) ? 'active' : '',
507                         'title' => t('Only show ignored contacts'),
508                 ),
509
510                 array(
511                         'label' => t('Archived'),
512                         'url'   => $a->get_baseurl(true) . '/contacts/archived',
513                         'sel'   => ($archived) ? 'active' : '',
514                         'title' => t('Only show archived contacts'),
515                 ),
516
517                 array(
518                         'label' => t('Hidden'),
519                         'url'   => $a->get_baseurl(true) . '/contacts/hidden',
520                         'sel'   => ($hidden) ? 'active' : '',
521                         'title' => t('Only show hidden contacts'),
522                 ),
523
524         );
525
526         $tab_tpl = get_markup_template('common_tabs.tpl');
527         $t = replace_macros($tab_tpl, array('$tabs'=>$tabs));
528
529
530
531         $searching = false;
532         if($search) {
533                 $search_hdr = $search;
534                 $search_txt = dbesc(protect_sprintf(preg_quote($search)));
535                 $searching = true;
536         }
537         $sql_extra .= (($searching) ? " AND `name` REGEXP '$search_txt' " : "");
538
539         if($nets)
540                 $sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets));
541  
542         $sql_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ",intval($sort_type)) : ''); 
543
544         
545         $r = q("SELECT COUNT(*) AS `total` FROM `contact` 
546                 WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ",
547                 intval($_SESSION['uid']));
548         if(count($r)) {
549                 $a->set_pager_total($r[0]['total']);
550                 $total = $r[0]['total'];
551         }
552
553
554         $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ORDER BY `name` ASC LIMIT %d , %d ",
555                 intval($_SESSION['uid']),
556                 intval($a->pager['start']),
557                 intval($a->pager['itemspage'])
558         );
559
560         $contacts = array();
561
562         if(count($r)) {
563
564                 foreach($r as $rr) {
565
566                         switch($rr['rel']) {
567                                 case CONTACT_IS_FRIEND:
568                                         $dir_icon = 'images/lrarrow.gif';
569                                         $alt_text = t('Mutual Friendship');
570                                         break;
571                                 case  CONTACT_IS_FOLLOWER;
572                                         $dir_icon = 'images/larrow.gif';
573                                         $alt_text = t('is a fan of yours');
574                                         break;
575                                 case CONTACT_IS_SHARING;
576                                         $dir_icon = 'images/rarrow.gif';
577                                         $alt_text = t('you are a fan of');
578                                         break;
579                                 default:
580                                         break;
581                         }
582                         if(($rr['network'] === 'dfrn') && ($rr['rel'])) {
583                                 $url = "redir/{$rr['id']}";
584                                 $sparkle = ' class="sparkle" ';
585                         }
586                         else { 
587                                 $url = $rr['url'];
588                                 $sparkle = '';
589                         }
590
591
592                         $contacts[] = array(
593                                 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'),$rr['name'],$rr['url']),
594                                 'edit_hover' => t('Edit contact'),
595                                 'photo_menu' => contact_photo_menu($rr),
596                                 'id' => $rr['id'],
597                                 'alt_text' => $alt_text,
598                                 'dir_icon' => $dir_icon,
599                                 'thumb' => $rr['thumb'], 
600                                 'name' => $rr['name'],
601                                 'username' => $rr['name'],
602                                 'sparkle' => $sparkle,
603                                 'itemurl' => $rr['url'],
604                                 'url' => $url,
605                                 'network' => network_to_name($rr['network']),
606                         );
607                 }
608
609                 
610
611         }
612         
613         $tpl = get_markup_template("contacts-template.tpl");
614         $o .= replace_macros($tpl, array(
615                 '$header' => t('Contacts') . (($nets) ? ' - ' . network_to_name($nets) : ''),
616                 '$tabs' => $t,
617                 '$total' => $total,
618                 '$search' => $search_hdr,
619                 '$desc' => t('Search your contacts'),
620                 '$finding' => (($searching) ? t('Finding: ') . "'" . $search . "'" : ""),
621                 '$submit' => t('Find'),
622                 '$cmd' => $a->cmd,
623                 '$contacts' => $contacts,
624                 '$paginate' => paginate($a),
625
626         )); 
627         
628         return $o;
629 }