3 require_once('include/Contact.php');
4 require_once('include/socgraph.php');
5 require_once('include/contact_selectors.php');
6 require_once('include/Scrape.php');
7 require_once('mod/proxy.php');
8 require_once('include/Photo.php');
10 function contacts_init(&$a) {
16 if(($a->argc == 2) && intval($a->argv[1])) {
17 $contact_id = intval($a->argv[1]);
18 $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1",
27 require_once('include/group.php');
28 require_once('include/contact_widgets.php');
30 if ($_GET['nets'] == "all")
33 if(! x($a->page,'aside'))
34 $a->page['aside'] = '';
37 $a->data['contact'] = $r[0];
38 $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"),array(
39 '$name' => htmlentities($a->data['contact']['name']),
40 '$photo' => $a->data['contact']['photo'],
41 '$url' => ($a->data['contact']['network'] == NETWORK_DFRN) ? $a->get_baseurl()."/redir/".$a->data['contact']['id'] : $a->data['contact']['url']
43 $finpeople_widget = '';
45 $networks_widget = '';
49 $networks_widget .= networks_widget('contacts',$_GET['nets']);
50 if (isset($_GET['add']))
51 $follow_widget = follow_widget($_GET['add']);
53 $follow_widget = follow_widget();
55 $findpeople_widget .= findpeople_widget();
58 $groups_widget .= group_side('contacts','group',false,0,$contact_id);
60 $a->page['aside'] .= replace_macros(get_markup_template("contacts-widget-sidebar.tpl"),array(
61 '$vcard_widget' => $vcard_widget,
62 '$findpeople_widget' => $findpeople_widget,
63 '$follow_widget' => $follow_widget,
64 '$groups_widget' => $groups_widget,
65 '$networks_widget' => $networks_widget
68 $base = $a->get_baseurl();
69 $tpl = get_markup_template("contacts-head.tpl");
70 $a->page['htmlhead'] .= replace_macros($tpl,array(
71 '$baseurl' => $a->get_baseurl(true),
75 $tpl = get_markup_template("contacts-end.tpl");
76 $a->page['end'] .= replace_macros($tpl,array(
77 '$baseurl' => $a->get_baseurl(true),
84 function contacts_batch_actions(&$a){
85 $contacts_id = $_POST['contact_batch'];
86 if (!is_array($contacts_id)) return;
88 $orig_records = q("SELECT * FROM `contact` WHERE `id` IN (%s) AND `uid` = %d AND `self` = 0",
89 implode(",", $contacts_id),
94 foreach($orig_records as $orig_record) {
95 $contact_id = $orig_record['id'];
96 if (x($_POST, 'contacts_batch_update')) {
97 _contact_update($contact_id);
100 if (x($_POST, 'contacts_batch_block')) {
101 $r = _contact_block($contact_id, $orig_record);
102 if ($r) $count_actions++;
104 if (x($_POST, 'contacts_batch_ignore')) {
105 $r = _contact_ignore($contact_id, $orig_record);
106 if ($r) $count_actions++;
108 if (x($_POST, 'contacts_batch_archive')) {
109 $r = _contact_archive($contact_id, $orig_record);
110 if ($r) $count_actions++;
112 if (x($_POST, 'contacts_batch_drop')) {
113 _contact_drop($contact_id, $orig_record);
117 if ($count_actions>0) {
118 info ( sprintf( tt("%d contact edited.", "%d contacts edited", $count_actions), $count_actions) );
121 if(x($_SESSION,'return_url'))
122 goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']);
124 goaway($a->get_baseurl(true) . '/contacts');
129 function contacts_post(&$a) {
134 if ($a->argv[1]==="batch") {
135 contacts_batch_actions($a);
139 $contact_id = intval($a->argv[1]);
143 $orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
148 if(! count($orig_record)) {
149 notice( t('Could not access contact record.') . EOL);
150 goaway($a->get_baseurl(true) . '/contacts');
151 return; // NOTREACHED
154 call_hooks('contact_edit_post', $_POST);
156 $profile_id = intval($_POST['profile-assign']);
158 $r = q("SELECT `id` FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
163 notice( t('Could not locate selected profile.') . EOL);
168 $hidden = intval($_POST['hidden']);
170 $notify = intval($_POST['notify']);
172 $fetch_further_information = intval($_POST['fetch_further_information']);
174 $ffi_keyword_blacklist = fix_mce_lf(escape_tags(trim($_POST['ffi_keyword_blacklist'])));
176 $priority = intval($_POST['poll']);
177 if($priority > 5 || $priority < 0)
180 $info = fix_mce_lf(escape_tags(trim($_POST['info'])));
182 $r = q("UPDATE `contact` SET `profile-id` = %d, `priority` = %d , `info` = '%s',
183 `hidden` = %d, `notify_new_posts` = %d, `fetch_further_information` = %d,
184 `ffi_keyword_blacklist` = '%s' WHERE `id` = %d AND `uid` = %d",
190 intval($fetch_further_information),
191 dbesc($ffi_keyword_blacklist),
196 info( t('Contact updated.') . EOL);
198 notice( t('Failed to update contact record.') . EOL);
200 $r = q("select * from contact where id = %d and uid = %d limit 1",
205 $a->data['contact'] = $r[0];
212 function _contact_update($contact_id) {
213 $r = q("SELECT `uid`, `url`, `network` FROM `contact` WHERE `id` = %d", intval($contact_id));
219 if ($uid != local_user())
222 if ($r[0]["network"] == NETWORK_OSTATUS) {
223 $result = new_contact($uid, $r[0]["url"], false);
225 if ($result['success'])
226 $r = q("UPDATE `contact` SET `subhub` = 1 WHERE `id` = %d",
227 intval($contact_id));
229 // pull feed and consume it, which should subscribe to the hub.
230 proc_run('php',"include/onepoll.php","$contact_id", "force");
233 function _contact_update_profile($contact_id) {
234 $r = q("SELECT `uid`, `url`, `network` FROM `contact` WHERE `id` = %d", intval($contact_id));
240 if ($uid != local_user())
243 $data = probe_url($r[0]["url"]);
245 // "Feed" or "Unknown" is mostly a sign of communication problems
246 if ((in_array($data["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) AND ($data["network"] != $r[0]["network"]))
249 $updatefields = array("name", "nick", "url", "addr", "batch", "notify", "poll", "request", "confirm",
250 "poco", "network", "alias");
253 if ($data["network"] == NETWORK_OSTATUS) {
254 $result = new_contact($uid, $data["url"], false);
256 if ($result['success'])
257 $update["subhub"] = true;
260 foreach($updatefields AS $field)
261 if (isset($data[$field]) AND ($data[$field] != ""))
262 $update[$field] = $data[$field];
264 $update["nurl"] = normalise_link($data["url"]);
268 if (isset($data["priority"]) AND ($data["priority"] != 0))
269 $query = "`priority` = ".intval($data["priority"]);
271 foreach($update AS $key => $value) {
275 $query .= "`".$key."` = '".dbesc($value)."'";
281 $r = q("UPDATE `contact` SET $query WHERE `id` = %d AND `uid` = %d",
286 $photos = import_profile_photo($data['photo'], local_user(), $contact_id);
288 $r = q("UPDATE `contact` SET `photo` = '%s',
298 dbesc(datetime_convert()),
299 dbesc(datetime_convert()),
300 dbesc(datetime_convert()),
306 function _contact_block($contact_id, $orig_record) {
307 $blocked = (($orig_record['blocked']) ? 0 : 1);
308 $r = q("UPDATE `contact` SET `blocked` = %d WHERE `id` = %d AND `uid` = %d",
316 function _contact_ignore($contact_id, $orig_record) {
317 $readonly = (($orig_record['readonly']) ? 0 : 1);
318 $r = q("UPDATE `contact` SET `readonly` = %d WHERE `id` = %d AND `uid` = %d",
325 function _contact_archive($contact_id, $orig_record) {
326 $archived = (($orig_record['archive']) ? 0 : 1);
327 $r = q("UPDATE `contact` SET `archive` = %d WHERE `id` = %d AND `uid` = %d",
333 q("UPDATE `item` SET `private` = 2 WHERE `contact-id` = %d AND `uid` = %d", intval($contact_id), intval(local_user()));
337 function _contact_drop($contact_id, $orig_record) {
338 require_once('include/Contact.php');
341 terminate_friendship($a->user,$a->contact,$orig_record);
342 contact_remove($orig_record['id']);
346 function contacts_content(&$a) {
350 nav_set_selected('contacts');
354 notice( t('Permission denied.') . EOL);
360 $contact_id = intval($a->argv[1]);
366 $orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d AND `self` = 0 LIMIT 1",
371 if(! count($orig_record)) {
372 notice( t('Could not access contact record.') . EOL);
373 goaway($a->get_baseurl(true) . '/contacts');
374 return; // NOTREACHED
377 if($cmd === 'update') {
378 _contact_update($contact_id);
379 goaway($a->get_baseurl(true) . '/contacts/' . $contact_id);
383 if($cmd === 'updateprofile') {
384 _contact_update_profile($contact_id);
385 goaway($a->get_baseurl(true) . '/crepair/' . $contact_id);
389 if($cmd === 'block') {
390 $r = _contact_block($contact_id, $orig_record[0]);
392 $blocked = (($orig_record[0]['blocked']) ? 0 : 1);
393 info((($blocked) ? t('Contact has been blocked') : t('Contact has been unblocked')).EOL);
396 goaway($a->get_baseurl(true) . '/contacts/' . $contact_id);
397 return; // NOTREACHED
400 if($cmd === 'ignore') {
401 $r = _contact_ignore($contact_id, $orig_record[0]);
403 $readonly = (($orig_record[0]['readonly']) ? 0 : 1);
404 info((($readonly) ? t('Contact has been ignored') : t('Contact has been unignored')).EOL);
407 goaway($a->get_baseurl(true) . '/contacts/' . $contact_id);
408 return; // NOTREACHED
412 if($cmd === 'archive') {
413 $r = _contact_archive($contact_id, $orig_record[0]);
415 $archived = (($orig_record[0]['archive']) ? 0 : 1);
416 info((($archived) ? t('Contact has been archived') : t('Contact has been unarchived')).EOL);
419 goaway($a->get_baseurl(true) . '/contacts/' . $contact_id);
420 return; // NOTREACHED
423 if($cmd === 'drop') {
425 // Check if we should do HTML-based delete confirmation
426 if($_REQUEST['confirm']) {
427 // <form> can't take arguments in its "action" parameter
428 // so add any arguments as hidden inputs
429 $query = explode_querystring($a->query_string);
431 foreach($query['args'] as $arg) {
432 if(strpos($arg, 'confirm=') === false) {
433 $arg_parts = explode('=', $arg);
434 $inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]);
438 $a->page['aside'] = '';
440 return replace_macros(get_markup_template('contact_drop_confirm.tpl'), array(
441 '$contact' => _contact_detail_for_template($orig_record[0]),
443 '$message' => t('Do you really want to delete this contact?'),
444 '$extra_inputs' => $inputs,
445 '$confirm' => t('Yes'),
446 '$confirm_url' => $query['base'],
447 '$confirm_name' => 'confirmed',
448 '$cancel' => t('Cancel'),
451 // Now check how the user responded to the confirmation query
452 if($_REQUEST['canceled']) {
453 if(x($_SESSION,'return_url'))
454 goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']);
456 goaway($a->get_baseurl(true) . '/contacts');
459 _contact_drop($contact_id, $orig_record[0]);
460 info( t('Contact has been removed.') . EOL );
461 if(x($_SESSION,'return_url'))
462 goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']);
464 goaway($a->get_baseurl(true) . '/contacts');
465 return; // NOTREACHED
471 $_SESSION['return_url'] = $a->query_string;
473 if((x($a->data,'contact')) && (is_array($a->data['contact']))) {
475 $contact_id = $a->data['contact']['id'];
476 $contact = $a->data['contact'];
478 $editselect = 'none';
479 if( feature_enabled(local_user(),'richtext') )
480 $editselect = 'exact';
482 $a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), array(
483 '$baseurl' => $a->get_baseurl(true),
484 '$editselect' => $editselect,
486 $a->page['end'] .= replace_macros(get_markup_template('contact_end.tpl'), array(
487 '$baseurl' => $a->get_baseurl(true),
488 '$editselect' => $editselect,
491 require_once('include/contact_selectors.php');
493 $tpl = get_markup_template("contact_edit.tpl");
495 switch($contact['rel']) {
496 case CONTACT_IS_FRIEND:
497 $dir_icon = 'images/lrarrow.gif';
498 $relation_text = t('You are mutual friends with %s');
500 case CONTACT_IS_FOLLOWER;
501 $dir_icon = 'images/larrow.gif';
502 $relation_text = t('You are sharing with %s');
505 case CONTACT_IS_SHARING;
506 $dir_icon = 'images/rarrow.gif';
507 $relation_text = t('%s is sharing with you');
513 if(!in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA)))
516 $relation_text = sprintf($relation_text,htmlentities($contact['name']));
518 if(($contact['network'] === NETWORK_DFRN) && ($contact['rel'])) {
519 $url = "redir/{$contact['id']}";
520 $sparkle = ' class="sparkle" ';
523 $url = $contact['url'];
527 $insecure = t('Private communications are not available for this contact.');
529 $last_update = (($contact['last-update'] == '0000-00-00 00:00:00')
531 : datetime_convert('UTC',date_default_timezone_get(),$contact['last-update'],'D, j M Y, g:i A'));
533 if($contact['last-update'] !== '0000-00-00 00:00:00')
534 $last_update .= ' ' . (($contact['last-update'] <= $contact['success_update']) ? t("\x28Update was successful\x29") : t("\x28Update was not successful\x29"));
536 $lblsuggest = (($contact['network'] === NETWORK_DFRN) ? t('Suggest friends') : '');
538 $poll_enabled = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2));
540 $nettype = sprintf( t('Network type: %s'),network_to_name($contact['network'], $contact["url"]));
542 $common = count_common_friends(local_user(),$contact['id']);
543 $common_text = (($common) ? sprintf( tt('%d contact in common','%d contacts in common', $common),$common) : '');
545 $polling = (($contact['network'] === NETWORK_MAIL | $contact['network'] === NETWORK_FEED) ? 'polling' : '');
547 $x = count_all_friends(local_user(), $contact['id']);
548 $all_friends = (($x) ? t('View all contacts') : '');
553 'label' => (($contact['blocked']) ? t('Unblock') : t('Block') ),
554 'url' => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/block',
556 'title' => t('Toggle Blocked status'),
557 'id' => 'toggle-block-tab',
561 'label' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ),
562 'url' => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/ignore',
564 'title' => t('Toggle Ignored status'),
565 'id' => 'toggle-ignore-tab',
570 'label' => (($contact['archive']) ? t('Unarchive') : t('Archive') ),
571 'url' => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/archive',
573 'title' => t('Toggle Archive status'),
574 'id' => 'toggle-archive-tab',
578 'label' => t('Repair'),
579 'url' => $a->get_baseurl(true) . '/crepair/' . $contact_id,
581 'title' => t('Advanced Contact Settings'),
582 'id' => 'repair-tab',
586 $tab_tpl = get_markup_template('common_tabs.tpl');
587 $tab_str = replace_macros($tab_tpl, array('$tabs' => $tabs));
589 $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!') : '');
591 if ($contact['network'] == NETWORK_FEED)
592 $fetch_further_information = array('fetch_further_information', t('Fetch further information for feeds'), $contact['fetch_further_information'], t('Fetch further information for feeds'),
593 array('0'=>t('Disabled'), '1'=>t('Fetch information'), '2'=>t('Fetch information and keywords')));
595 if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2)))
596 $poll_interval = contact_poll_interval($contact['priority'],(! $poll_enabled));
598 if ($contact['network'] == NETWORK_DFRN)
599 $profile_select = contact_profile_assign($contact['profile-id'],(($contact['network'] !== NETWORK_DFRN) ? true : false));
601 if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS)) AND
602 ($contact['rel'] == CONTACT_IS_FOLLOWER))
603 $follow = $a->get_baseurl(true)."/follow?url=".urlencode($contact["url"]);
605 $o .= replace_macros($tpl, array(
606 '$header' => t('Contact Editor'),
607 '$tab_str' => $tab_str,
608 '$submit' => t('Submit'),
609 '$lbl_vis1' => t('Profile Visibility'),
610 '$lbl_vis2' => sprintf( t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['name']),
611 '$lbl_info1' => t('Contact Information / Notes'),
612 '$infedit' => t('Edit contact notes'),
613 '$common_text' => $common_text,
614 '$common_link' => $a->get_baseurl(true) . '/common/loc/' . local_user() . '/' . $contact['id'],
615 '$all_friends' => $all_friends,
616 '$relation_text' => $relation_text,
617 '$visit' => sprintf( t('Visit %s\'s profile [%s]'),$contact['name'],$contact['url']),
618 '$blockunblock' => t('Block/Unblock contact'),
619 '$ignorecont' => t('Ignore contact'),
620 '$lblcrepair' => t("Repair URL settings"),
621 '$lblrecent' => t('View conversations'),
622 '$lblsuggest' => $lblsuggest,
623 '$delete' => t('Delete contact'),
624 '$nettype' => $nettype,
625 '$poll_interval' => $poll_interval,
626 '$poll_enabled' => $poll_enabled,
627 '$lastupdtext' => t('Last update:'),
628 '$lost_contact' => $lost_contact,
629 '$updpub' => t('Update public posts'),
630 '$last_update' => $last_update,
631 '$udnow' => t('Update now'),
632 '$follow' => $follow,
633 '$follow_text' => t("Connect/Follow"),
634 '$profile_select' => $profile_select,
635 '$contact_id' => $contact['id'],
636 '$block_text' => (($contact['blocked']) ? t('Unblock') : t('Block') ),
637 '$ignore_text' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ),
638 '$insecure' => (($contact['network'] !== NETWORK_DFRN && $contact['network'] !== NETWORK_MAIL && $contact['network'] !== NETWORK_FACEBOOK && $contact['network'] !== NETWORK_DIASPORA) ? $insecure : ''),
639 '$info' => $contact['info'],
640 '$blocked' => (($contact['blocked']) ? t('Currently blocked') : ''),
641 '$ignored' => (($contact['readonly']) ? t('Currently ignored') : ''),
642 '$archived' => (($contact['archive']) ? t('Currently archived') : ''),
643 '$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')),
644 '$notify' => array('notify', t('Notification for new posts'), ($contact['notify_new_posts'] == 1), t('Send a notification of every new post of this contact')),
645 '$fetch_further_information' => $fetch_further_information,
646 '$ffi_keyword_blacklist' => $contact['ffi_keyword_blacklist'],
647 '$ffi_keyword_blacklist' => array('ffi_keyword_blacklist', t('Blacklisted keywords'), $contact['ffi_keyword_blacklist'], t('Comma separated list of keywords that should not be converted to hashtags, when "Fetch information and keywords" is selected')),
648 '$photo' => $contact['photo'],
649 '$name' => htmlentities($contact['name']),
650 '$dir_icon' => $dir_icon,
651 '$alt_text' => $alt_text,
652 '$sparkle' => $sparkle,
654 '$profileurllabel' => t('Profile URL'),
655 '$profileurl' => $contact['url'],
659 $arr = array('contact' => $contact,'output' => $o);
661 call_hooks('contact_edit', $arr);
663 return $arr['output'];
672 if(($a->argc == 2) && ($a->argv[1] === 'all')) {
676 elseif(($a->argc == 2) && ($a->argv[1] === 'blocked')) {
677 $sql_extra = " AND `blocked` = 1 ";
680 elseif(($a->argc == 2) && ($a->argv[1] === 'hidden')) {
681 $sql_extra = " AND `hidden` = 1 ";
684 elseif(($a->argc == 2) && ($a->argv[1] === 'ignored')) {
685 $sql_extra = " AND `readonly` = 1 ";
688 elseif(($a->argc == 2) && ($a->argv[1] === 'archived')) {
689 $sql_extra = " AND `archive` = 1 ";
693 $sql_extra = " AND `blocked` = 0 ";
695 $search = ((x($_GET,'search')) ? notags(trim($_GET['search'])) : '');
696 $nets = ((x($_GET,'nets')) ? notags(trim($_GET['nets'])) : '');
700 'label' => t('Suggestions'),
701 'url' => $a->get_baseurl(true) . '/suggest',
703 'title' => t('Suggest potential friends'),
704 'id' => 'suggestions-tab',
708 'label' => t('All Contacts'),
709 'url' => $a->get_baseurl(true) . '/contacts/all',
710 'sel' => ($all) ? 'active' : '',
711 'title' => t('Show all contacts'),
712 'id' => 'showall-tab',
716 'label' => t('Unblocked'),
717 'url' => $a->get_baseurl(true) . '/contacts',
718 'sel' => ((! $all) && (! $blocked) && (! $hidden) && (! $search) && (! $nets) && (! $ignored) && (! $archived)) ? 'active' : '',
719 'title' => t('Only show unblocked contacts'),
720 'id' => 'showunblocked-tab',
725 'label' => t('Blocked'),
726 'url' => $a->get_baseurl(true) . '/contacts/blocked',
727 'sel' => ($blocked) ? 'active' : '',
728 'title' => t('Only show blocked contacts'),
729 'id' => 'showblocked-tab',
734 'label' => t('Ignored'),
735 'url' => $a->get_baseurl(true) . '/contacts/ignored',
736 'sel' => ($ignored) ? 'active' : '',
737 'title' => t('Only show ignored contacts'),
738 'id' => 'showignored-tab',
743 'label' => t('Archived'),
744 'url' => $a->get_baseurl(true) . '/contacts/archived',
745 'sel' => ($archived) ? 'active' : '',
746 'title' => t('Only show archived contacts'),
747 'id' => 'showarchived-tab',
752 'label' => t('Hidden'),
753 'url' => $a->get_baseurl(true) . '/contacts/hidden',
754 'sel' => ($hidden) ? 'active' : '',
755 'title' => t('Only show hidden contacts'),
756 'id' => 'showhidden-tab',
762 $tab_tpl = get_markup_template('common_tabs.tpl');
763 $t = replace_macros($tab_tpl, array('$tabs'=>$tabs));
769 $search_hdr = $search;
770 $search_txt = dbesc(protect_sprintf(preg_quote($search)));
773 $sql_extra .= (($searching) ? " AND (name REGEXP '$search_txt' OR url REGEXP '$search_txt' OR nick REGEXP '$search_txt') " : "");
776 $sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets));
778 $sql_extra2 = ((($sort_type > 0) && ($sort_type <= CONTACT_IS_FRIEND)) ? sprintf(" AND `rel` = %d ",intval($sort_type)) : '');
781 $r = q("SELECT COUNT(*) AS `total` FROM `contact`
782 WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 ",
783 intval($_SESSION['uid']));
785 $a->set_pager_total($r[0]['total']);
786 $total = $r[0]['total'];
790 $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 ",
791 intval($_SESSION['uid']),
792 intval($a->pager['start']),
793 intval($a->pager['itemspage'])
800 $contacts[] = _contact_detail_for_template($rr);
804 $tpl = get_markup_template("contacts-template.tpl");
805 $o .= replace_macros($tpl, array(
806 '$baseurl' => $a->get_baseurl(),
807 '$header' => t('Contacts') . (($nets) ? ' - ' . network_to_name($nets) : ''),
810 '$search' => $search_hdr,
811 '$desc' => t('Search your contacts'),
812 '$finding' => (($searching) ? t('Finding: ') . "'" . $search . "'" : ""),
813 '$submit' => t('Find'),
815 '$contacts' => $contacts,
816 '$contact_drop_confirm' => t('Do you really want to delete this contact?'),
818 '$batch_actions' => array(
819 'contacts_batch_update' => t('Update'),
820 'contacts_batch_block' => t('Block')."/".t("Unblock"),
821 "contacts_batch_ignore" => t('Ignore')."/".t("Unignore"),
822 "contacts_batch_archive" => t('Archive')."/".t("Unarchive"),
823 "contacts_batch_drop" => t('Delete'),
825 '$paginate' => paginate($a),
832 function _contact_detail_for_template($rr){
834 case CONTACT_IS_FRIEND:
835 $dir_icon = 'images/lrarrow.gif';
836 $alt_text = t('Mutual Friendship');
838 case CONTACT_IS_FOLLOWER;
839 $dir_icon = 'images/larrow.gif';
840 $alt_text = t('is a fan of yours');
842 case CONTACT_IS_SHARING;
843 $dir_icon = 'images/rarrow.gif';
844 $alt_text = t('you are a fan of');
849 if(($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
850 $url = "redir/{$rr['id']}";
851 $sparkle = ' class="sparkle" ';
860 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'),$rr['name'],$rr['url']),
861 'edit_hover' => t('Edit contact'),
862 'photo_menu' => contact_photo_menu($rr),
864 'alt_text' => $alt_text,
865 'dir_icon' => $dir_icon,
866 'thumb' => proxy_url($rr['thumb'], false, PROXY_SIZE_THUMB),
867 'name' => htmlentities($rr['name']),
868 'username' => htmlentities($rr['name']),
869 'sparkle' => $sparkle,
870 'itemurl' => (($rr['addr'] != "") ? $rr['addr'] : $rr['url']),
872 'network' => network_to_name($rr['network'], $rr['url']),