function allfriends_content(&$a) { $o = ''; if (!local_user()) { notice(t('Permission denied.') . EOL); return; } if ($a->argc > 1) { $cid = intval($a->argv[1]); } if (!$cid) { return; } $uid = $a->user[uid]; $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval(local_user())); if (!count($c)) { return; } $a->page['aside'] = ""; profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"])); $total = count_all_friends(local_user(), $cid); if (count($total)) { $a->set_pager_total($total); } $r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']); if (!count($r)) { $o .= t('No friends to display.'); return $o; } $id = 0; foreach ($r as $rr) { //get further details of the contact $contact_details = get_contact_details_by_url($rr['url'], $uid); $photo_menu = ''; // $rr[cid] is only available for common contacts. So if the contact is a common one, use contact_photo_menu to generate the photo_menu // If the contact is not common to the user, Connect/Follow' will be added to the photo menu if ($rr[cid]) { $rr[id] = $rr[cid]; $photo_menu = contact_photo_menu($rr); } else { $connlnk = $a->get_baseurl() . '/follow/?url=' . $rr['url']; $photo_menu = array(array(t("View Profile"), zrl($rr['url']))); $photo_menu[] = array(t("Connect/Follow"), $connlnk); } $entry = array('url' => $rr['url'], 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $rr['url'], 'name' => htmlentities($rr['name']), 'thumb' => proxy_url($rr['photo'], false, PROXY_SIZE_THUMB), 'img_hover' => htmlentities($rr['name']), 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'network' => network_to_name($contact_details['network'], $contact_details['url']), 'photo_menu' => $photo_menu, 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'id' => ++$id); $entries[] = $entry; } $tab_str = contacts_tab($a, $cid, 3); $tpl = get_markup_template('viewcontact_template.tpl'); $o .= replace_macros($tpl, array('$tab_str' => $tab_str, '$contacts' => $entries, '$paginate' => paginate($a))); return $o; }
function viewcontacts_content(&$a) { require_once "mod/proxy.php"; if (get_config('system', 'block_public') && !local_user() && !remote_user()) { notice(t('Public access denied.') . EOL); return; } if (!count($a->profile) || $a->profile['hide-friends']) { notice(t('Permission denied.') . EOL); return; } $o = ""; // tabs $o .= profile_tabs($a, $is_owner, $a->data['user']['nickname']); $r = q("SELECT COUNT(*) AS `total` FROM `contact`\n\t\tWHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0\n\t\t\tAND `network` IN ('%s', '%s', '%s')", intval($a->profile['uid']), dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS)); if (count($r)) { $a->set_pager_total($r[0]['total']); } $r = q("SELECT * FROM `contact`\n\t\tWHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0\n\t\t\tAND `network` IN ('%s', '%s', '%s')\n\t\tORDER BY `name` ASC LIMIT %d, %d", intval($a->profile['uid']), dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS), intval($a->pager['start']), intval($a->pager['itemspage'])); if (!count($r)) { info(t('No contacts.') . EOL); return $o; } $contacts = array(); foreach ($r as $rr) { if ($rr['self']) { continue; } $url = $rr['url']; // route DFRN profiles through the redirect $is_owner = local_user() && $a->profile['profile_uid'] == local_user() ? true : false; if ($is_owner && $rr['network'] === NETWORK_DFRN && $rr['rel']) { $url = 'redir/' . $rr['id']; } else { $url = zrl($url); } $contact_details = get_contact_details_by_url($rr['url'], $a->profile['uid']); $contacts[] = array('id' => $rr['id'], 'img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $rr['name'], $rr['url']), 'photo_menu' => contact_photo_menu($rr), 'thumb' => proxy_url($rr['thumb'], false, PROXY_SIZE_THUMB), 'name' => htmlentities(substr($rr['name'], 0, 20)), 'username' => htmlentities($rr['name']), 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'url' => $url, 'sparkle' => '', 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $rr['url'], 'network' => network_to_name($rr['network'], $rr['url'])); } $tpl = get_markup_template("viewcontact_template.tpl"); $o .= replace_macros($tpl, array('$title' => t('Contacts'), '$contacts' => $contacts, '$paginate' => paginate($a))); return $o; }
function nogroup_content(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); return ''; } require_once 'include/Contact.php'; $r = contacts_not_grouped(local_user()); if (count($r)) { $a->set_pager_total($r[0]['total']); } $r = contacts_not_grouped(local_user(), $a->pager['start'], $a->pager['itemspage']); if (count($r)) { foreach ($r as $rr) { $contacts[] = array('img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $rr['name'], $rr['url']), 'edit_hover' => t('Edit contact'), 'photo_menu' => contact_photo_menu($rr), 'id' => $rr['id'], 'alt_text' => $alt_text, 'dir_icon' => $dir_icon, 'thumb' => $rr['thumb'], 'name' => $rr['name'], 'username' => $rr['name'], 'sparkle' => $sparkle, 'itemurl' => $rr['url'], 'url' => $url, 'network' => network_to_name($rr['network'])); } } $tpl = get_markup_template("nogroup-template.tpl"); $o .= replace_macros($tpl, array('$header' => t('Contacts who are not members of a group'), '$contacts' => $contacts, '$paginate' => paginate($a))); return $o; }
function contacts_content(&$a) { $sort_type = 0; $o = ''; nav_set_selected('contacts'); if (!local_user()) { notice(t('Permission denied.') . EOL); return; } if ($a->argc == 3) { $contact_id = intval($a->argv[1]); if (!$contact_id) { return; } $cmd = $a->argv[2]; $orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d AND `self` = 0 LIMIT 1", intval($contact_id), intval(local_user())); if (!count($orig_record)) { notice(t('Could not access contact record.') . EOL); goaway($a->get_baseurl() . '/contacts'); return; // NOTREACHED } if ($cmd === 'update') { // pull feed and consume it, which should subscribe to the hub. proc_run('php', "include/poller.php", "{$contact_id}"); goaway($a->get_baseurl() . '/contacts/' . $contact_id); // NOTREACHED } if ($cmd === 'block') { $blocked = $orig_record[0]['blocked'] ? 0 : 1; $r = q("UPDATE `contact` SET `blocked` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($blocked), intval($contact_id), intval(local_user())); if ($r) { //notice( t('Contact has been ') . (($blocked) ? t('blocked') : t('unblocked')) . EOL ); info(($blocked ? t('Contact has been blocked') : t('Contact has been unblocked')) . EOL); } goaway($a->get_baseurl() . '/contacts/' . $contact_id); return; // NOTREACHED } if ($cmd === 'ignore') { $readonly = $orig_record[0]['readonly'] ? 0 : 1; $r = q("UPDATE `contact` SET `readonly` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($readonly), intval($contact_id), intval(local_user())); if ($r) { info(($readonly ? t('Contact has been ignored') : t('Contact has been unignored')) . EOL); } goaway($a->get_baseurl() . '/contacts/' . $contact_id); return; // NOTREACHED } if ($cmd === 'drop') { // create an unfollow slap if ($orig_record[0]['network'] === NETWORK_OSTATUS) { $tpl = get_markup_template('follow_slap.tpl'); $slap = replace_macros($tpl, array('$name' => $a->user['username'], '$profile_page' => $a->get_baseurl() . '/profile/' . $a->user['nickname'], '$photo' => $a->contact['photo'], '$thumb' => $a->contact['thumb'], '$published' => datetime_convert('UTC', 'UTC', 'now', ATOM_TIME), '$item_id' => 'urn:X-dfrn:' . $a->get_hostname() . ':unfollow:' . random_string(), '$title' => '', '$type' => 'text', '$content' => t('stopped following'), '$nick' => $a->user['nickname'], '$verb' => 'http://ostatus.org/schema/1.0/unfollow', '$ostat_follow' => '')); if (x($orig_record[0], 'notify') && strlen($orig_record[0]['notify'])) { require_once 'include/salmon.php'; slapper($a->user, $orig_record[0]['notify'], $slap); } } elseif ($orig_record[0]['network'] === NETWORK_DIASPORA) { require_once 'include/diaspora.php'; diaspora_unshare($a->user, $orig_record[0]); } elseif ($orig_record[0]['network'] === NETWORK_DFRN) { require_once 'include/items.php'; dfrn_deliver($a->user, $orig_record[0], 'placeholder', 1); } contact_remove($orig_record[0]['id']); info(t('Contact has been removed.') . EOL); if (x($_SESSION, 'return_url')) { goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); } else { goaway($a->get_baseurl() . '/contacts'); } return; // NOTREACHED } } if (x($a->data, 'contact') && is_array($a->data['contact'])) { $contact_id = $a->data['contact']['id']; $contact = $a->data['contact']; $tpl = get_markup_template('contact_head.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl())); require_once 'include/contact_selectors.php'; $tpl = get_markup_template("contact_edit.tpl"); switch ($contact['rel']) { case CONTACT_IS_FRIEND: $dir_icon = 'images/lrarrow.gif'; $relation_text = t('You are mutual friends with %s'); break; case CONTACT_IS_FOLLOWER: $dir_icon = 'images/larrow.gif'; $relation_text = t('You are sharing with %s'); break; case CONTACT_IS_SHARING: $dir_icon = 'images/rarrow.gif'; $relation_text = t('%s is sharing with you'); break; default: break; } $relation_text = sprintf($relation_text, $contact['name']); if ($contact['network'] === NETWORK_DFRN && $contact['rel']) { $url = "redir/{$contact['id']}"; $sparkle = ' class="sparkle" '; } else { $url = $contact['url']; $sparkle = ''; } $insecure = t('Private communications are not available for this contact.'); $last_update = $contact['last-update'] == '0000-00-00 00:00:00' ? t('Never') : datetime_convert('UTC', date_default_timezone_get(), $contact['last-update'], 'D, j M Y, g:i A'); if ($contact['last-update'] !== '0000-00-00 00:00:00') { $last_update .= ' ' . ($contact['last-update'] == $contact['success_update'] ? t("(Update was successful)") : t("(Update was not successful)")); } $lblsuggest = $contact['network'] === NETWORK_DFRN ? t('Suggest friends') : ''; $poll_enabled = $contact['network'] !== NETWORK_DIASPORA ? true : false; $nettype = sprintf(t('Network type: %s'), network_to_name($contact['network'])); $common = count_common_friends(local_user(), $contact['id']); $common_text = $common ? sprintf(tt('%d contact in common', '%d contacts in common', $common), $common) : ''; $polling = $contact['network'] === NETWORK_MAIL | $contact['network'] === NETWORK_FEED ? 'polling' : ''; $x = count_all_friends(local_user(), $contact['id']); $all_friends = $x ? t('View all contacts') : ''; // tabs $tabs = array(array('label' => $contact['blocked'] ? t('Unblock') : t('Block'), 'url' => $a->get_baseurl() . '/contacts/' . $contact_id . '/block', 'sel' => ''), array('label' => $contact['readonly'] ? t('Unignore') : t('Ignore'), 'url' => $a->get_baseurl() . '/contacts/' . $contact_id . '/ignore', 'sel' => ''), array('label' => t('Repair'), 'url' => $a->get_baseurl() . '/crepair/' . $contact_id, 'sel' => '')); $tab_tpl = get_markup_template('common_tabs.tpl'); $tab_str = replace_macros($tab_tpl, array('$tabs' => $tabs)); $o .= replace_macros($tpl, array('$header' => t('Contact Editor'), '$tab_str' => $tab_str, '$submit' => t('Submit'), '$lbl_vis1' => t('Profile Visibility'), '$lbl_vis2' => sprintf(t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['name']), '$lbl_info1' => t('Contact Information / Notes'), '$infedit' => t('Edit contact notes'), '$common_text' => $common_text, '$common_link' => $a->get_baseurl() . '/common/' . $contact['id'], '$all_friends' => $all_friends, '$relation_text' => $relation_text, '$visit' => sprintf(t('Visit %s\'s profile [%s]'), $contact['name'], $contact['url']), '$blockunblock' => t('Block/Unblock contact'), '$ignorecont' => t('Ignore contact'), '$lblcrepair' => t("Repair URL settings"), '$lblrecent' => t('View conversations'), '$lblsuggest' => $lblsuggest, '$delete' => t('Delete contact'), '$nettype' => $nettype, '$poll_interval' => contact_poll_interval($contact['priority'], !$poll_enabled), '$poll_enabled' => $poll_enabled, '$lastupdtext' => t('Last update:'), '$updpub' => t('Update public posts'), '$last_update' => $last_update, '$udnow' => t('Update now'), '$profile_select' => contact_profile_assign($contact['profile-id'], $contact['network'] !== NETWORK_DFRN ? true : false), '$contact_id' => $contact['id'], '$block_text' => $contact['blocked'] ? t('Unblock') : t('Block'), '$ignore_text' => $contact['readonly'] ? t('Unignore') : t('Ignore'), '$insecure' => $contact['network'] !== NETWORK_DFRN && $contact['network'] !== NETWORK_MAIL && $contact['network'] !== NETWORK_FACEBOOK && $contact['network'] !== NETWORK_DIASPORA ? $insecure : '', '$info' => $contact['info'], '$blocked' => $contact['blocked'] ? t('Currently blocked') : '', '$ignored' => $contact['readonly'] ? t('Currently ignored') : '', '$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')), '$photo' => $contact['photo'], '$name' => $contact['name'], '$dir_icon' => $dir_icon, '$alt_text' => $alt_text, '$sparkle' => $sparkle, '$url' => $url)); $arr = array('contact' => $contact, 'output' => $o); call_hooks('contact_edit', $arr); return $arr['output']; } $blocked = false; $hidden = false; $ignored = false; $all = false; $_SESSION['return_url'] = $a->query_string; if ($a->argc == 2 && $a->argv[1] === 'all') { $sql_extra = ''; $all = true; } elseif ($a->argc == 2 && $a->argv[1] === 'blocked') { $sql_extra = " AND `blocked` = 1 "; $blocked = true; } elseif ($a->argc == 2 && $a->argv[1] === 'hidden') { $sql_extra = " AND `hidden` = 1 "; $hidden = true; } elseif ($a->argc == 2 && $a->argv[1] === 'ignored') { $sql_extra = " AND `readonly` = 1 "; $ignored = true; } else { $sql_extra = " AND `blocked` = 0 "; } $search = x($_GET, 'search') ? notags(trim($_GET['search'])) : ''; $nets = x($_GET, 'nets') ? notags(trim($_GET['nets'])) : ''; $tabs = array(array('label' => t('All Contacts'), 'url' => $a->get_baseurl() . '/contacts/all', 'sel' => $all ? 'active' : ''), array('label' => t('Unblocked Contacts'), 'url' => $a->get_baseurl() . '/contacts', 'sel' => !$all && !$blocked && !$hidden && !$search && !$nets && !$ignored ? 'active' : ''), array('label' => t('Blocked Contacts'), 'url' => $a->get_baseurl() . '/contacts/blocked', 'sel' => $blocked ? 'active' : ''), array('label' => t('Ignored Contacts'), 'url' => $a->get_baseurl() . '/contacts/ignored', 'sel' => $ignored ? 'active' : ''), array('label' => t('Hidden Contacts'), 'url' => $a->get_baseurl() . '/contacts/hidden', 'sel' => $hidden ? 'active' : '')); $tab_tpl = get_markup_template('common_tabs.tpl'); $t = replace_macros($tab_tpl, array('$tabs' => $tabs)); if ($search) { $search_hdr = $search; $search = dbesc($search . '*'); } $sql_extra .= strlen($search) ? " AND MATCH `name` AGAINST ('{$search}' IN BOOLEAN MODE) " : ""; if ($nets) { $sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets)); } $sql_extra2 = $sort_type > 0 && $sort_type <= CONTACT_IS_FRIEND ? sprintf(" AND `rel` = %d ", intval($sort_type)) : ''; $r = q("SELECT COUNT(*) AS `total` FROM `contact` \n\t\tWHERE `uid` = %d AND `pending` = 0 {$sql_extra} {$sql_extra2} ", intval($_SESSION['uid'])); if (count($r)) { $a->set_pager_total($r[0]['total']); } $tpl = get_markup_template("contacts-top.tpl"); $o .= replace_macros($tpl, array('$header' => t('Contacts') . ($nets ? ' - ' . network_to_name($nets) : ''), '$tabs' => $t, '$total' => $r[0]['total'], '$search' => $search_hdr, '$desc' => t('Search your contacts'), '$finding' => strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : "", '$submit' => t('Find'), '$cmd' => $a->cmd)); $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `pending` = 0 {$sql_extra} {$sql_extra2} ORDER BY `name` ASC LIMIT %d , %d ", intval($_SESSION['uid']), intval($a->pager['start']), intval($a->pager['itemspage'])); if (count($r)) { $tpl = get_markup_template("contact_template.tpl"); foreach ($r as $rr) { if ($rr['self']) { continue; } switch ($rr['rel']) { case CONTACT_IS_FRIEND: $dir_icon = 'images/lrarrow.gif'; $alt_text = t('Mutual Friendship'); break; case CONTACT_IS_FOLLOWER: $dir_icon = 'images/larrow.gif'; $alt_text = t('is a fan of yours'); break; case CONTACT_IS_SHARING: $dir_icon = 'images/rarrow.gif'; $alt_text = t('you are a fan of'); break; default: break; } if ($rr['network'] === 'dfrn' && $rr['rel']) { $url = "redir/{$rr['id']}"; $sparkle = ' class="sparkle" '; } else { $url = $rr['url']; $sparkle = ''; } $o .= replace_macros($tpl, array('$img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $rr['name'], $rr['url']), '$edit_hover' => t('Edit contact'), '$contact_photo_menu' => contact_photo_menu($rr), '$id' => $rr['id'], '$alt_text' => $alt_text, '$dir_icon' => $dir_icon, '$thumb' => $rr['thumb'], '$name' => $rr['name'], '$username' => $rr['name'], '$sparkle' => $sparkle, '$url' => $url)); } $o .= '<div id="contact-edit-end"></div>'; } $o .= paginate($a); return $o; }
function dirfind_content(&$a, $prefix = "") { $community = false; $discover_user = false; $local = get_config('system', 'poco_local_search'); $search = $prefix . notags(trim($_REQUEST['search'])); if (strpos($search, '@') === 0) { $search = substr($search, 1); if (valid_email($search) and validate_email($search) or substr(normalise_link($search), 0, 7) == "http://") { $user_data = probe_url($search); $discover_user = in_array($user_data["network"], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA)); } } if (strpos($search, '!') === 0) { $search = substr($search, 1); $community = true; } $o = ''; if ($search) { if ($discover_user) { $j = new stdClass(); $j->total = 1; $j->items_page = 1; $j->page = $a->pager['page']; $objresult = new stdClass(); $objresult->cid = 0; $objresult->name = $user_data["name"]; $objresult->addr = $user_data["addr"]; $objresult->url = $user_data["url"]; $objresult->photo = $user_data["photo"]; $objresult->tags = ""; $objresult->network = $user_data["network"]; $contact = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1", dbesc(normalise_link($user_data["url"])), intval(local_user())); if ($contact) { $objresult->cid = $contact[0]["id"]; } $j->results[] = $objresult; poco_check($user_data["url"], $user_data["name"], $user_data["network"], $user_data["photo"], "", "", "", "", "", datetime_convert(), 0); } elseif ($local) { if ($community) { $extra_sql = " AND `community`"; } else { $extra_sql = ""; } $perpage = 80; $startrec = $a->pager['page'] * $perpage - $perpage; if (get_config('system', 'diaspora_enabled')) { $diaspora = NETWORK_DIASPORA; } else { $diaspora = NETWORK_DFRN; } if (!get_config('system', 'ostatus_disabled')) { $ostatus = NETWORK_OSTATUS; } else { $ostatus = NETWORK_DFRN; } $count = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `network` IN ('%s', '%s', '%s') AND\n\t\t\t\t\t(`url` REGEXP '%s' OR `name` REGEXP '%s' OR `location` REGEXP '%s' OR\n\t\t\t\t\t\t`about` REGEXP '%s' OR `keywords` REGEXP '%s')" . $extra_sql, dbesc(NETWORK_DFRN), dbesc($ostatus), dbesc($diaspora), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search))); $results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`photo`, `gcontact`.`network`, `gcontact`.`keywords`, `gcontact`.`addr`\n\t\t\t\t\tFROM `gcontact`\n\t\t\t\t\tLEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl`\n\t\t\t\t\t\tAND `contact`.`uid` = %d AND NOT `contact`.`blocked`\n\t\t\t\t\t\tAND NOT `contact`.`pending` AND `contact`.`rel` IN ('%s', '%s')\n\t\t\t\t\tWHERE `gcontact`.`network` IN ('%s', '%s', '%s') AND\n\t\t\t\t\t((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)) AND\n\t\t\t\t\t(`gcontact`.`url` REGEXP '%s' OR `gcontact`.`name` REGEXP '%s' OR `gcontact`.`location` REGEXP '%s' OR\n\t\t\t\t\t\t`gcontact`.`about` REGEXP '%s' OR `gcontact`.`keywords` REGEXP '%s') {$extra_sql}\n\t\t\t\t\t\tGROUP BY `gcontact`.`nurl`\n\t\t\t\t\t\tORDER BY `gcontact`.`updated` DESC LIMIT %d, %d", intval(local_user()), dbesc(CONTACT_IS_SHARING), dbesc(CONTACT_IS_FRIEND), dbesc(NETWORK_DFRN), dbesc($ostatus), dbesc($diaspora), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), intval($startrec), intval($perpage)); $j = new stdClass(); $j->total = $count[0]["total"]; $j->items_page = $perpage; $j->page = $a->pager['page']; foreach ($results as $result) { if (poco_alternate_ostatus_url($result["url"])) { continue; } if ($result["name"] == "") { $urlparts = parse_url($result["url"]); $result["name"] = end(explode("/", $urlparts["path"])); } $objresult = new stdClass(); $objresult->cid = $result["cid"]; $objresult->name = $result["name"]; $objresult->addr = $result["addr"]; $objresult->url = $result["url"]; $objresult->photo = $result["photo"]; $objresult->tags = $result["keywords"]; $objresult->network = $result["network"]; $j->results[] = $objresult; } // Add found profiles from the global directory to the local directory proc_run('php', 'include/discover_poco.php', "dirsearch", urlencode($search)); } else { $p = $a->pager['page'] != 1 ? '&p=' . $a->pager['page'] : ''; if (strlen(get_config('system', 'directory'))) { $x = fetch_url(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search)); } $j = json_decode($x); } if ($j->total) { $a->set_pager_total($j->total); $a->set_pager_itemspage($j->items_page); } if (count($j->results)) { $id = 0; foreach ($j->results as $jj) { $alt_text = ""; $contact_details = get_contact_details_by_url($jj->url, local_user()); $itemurl = $contact_details["addr"] != "" ? $contact_details["addr"] : $jj->url; // If We already know this contact then don't show the "connect" button if ($jj->cid > 0) { $connlnk = ""; $conntxt = ""; $contact = q("SELECT * FROM `contact` WHERE `id` = %d", intval($jj->cid)); if ($contact) { $photo_menu = contact_photo_menu($contact[0]); $details = _contact_detail_for_template($contact[0]); $alt_text = $details['alt_text']; } else { $photo_menu = array(); } } else { $connlnk = $a->get_baseurl() . '/follow/?url=' . ($jj->connect ? $jj->connect : $jj->url); $conntxt = t('Connect'); $photo_menu = array(array(t("View Profile"), zrl($jj->url))); $photo_menu[] = array(t("Connect/Follow"), $connlnk); } $jj->photo = str_replace("http:///photo/", get_server() . "/photo/", $jj->photo); $entry = array('alt_text' => $alt_text, 'url' => zrl($jj->url), 'itemurl' => $itemurl, 'name' => htmlentities($jj->name), 'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB), 'img_hover' => $jj->tags, 'conntxt' => $conntxt, 'connlnk' => $connlnk, 'photo_menu' => $photo_menu, 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'network' => network_to_name($jj->network, $jj->url), 'id' => ++$id); $entries[] = $entry; } $tpl = get_markup_template('viewcontact_template.tpl'); $o .= replace_macros($tpl, array('title' => sprintf(t('People Search - %s'), $search), '$contacts' => $entries, '$paginate' => paginate($a))); } else { info(t('No matches') . EOL); } } return $o; }
function common_content(&$a) { $o = ''; $cmd = $a->argv[1]; $uid = intval($a->argv[2]); $cid = intval($a->argv[3]); $zcid = 0; if (!local_user()) { notice(t('Permission denied.') . EOL); return; } if ($cmd !== 'loc' && $cmd != 'rem') { return; } if (!$uid) { return; } if ($cmd === 'loc' && $cid) { $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval($uid)); $a->page['aside'] = ""; profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"])); } else { $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", intval($uid)); $vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"), array('$name' => htmlentities($c[0]['name']), '$photo' => $c[0]['photo'], 'url' => z_root() . '/contacts/' . $cid)); if (!x($a->page, 'aside')) { $a->page['aside'] = ''; } $a->page['aside'] .= $vcard_widget; } if (!count($c)) { return; } if (!$cid) { if (get_my_url()) { $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1", dbesc(normalise_link(get_my_url())), intval($profile_uid)); if (count($r)) { $cid = $r[0]['id']; } else { $r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1", dbesc(normalise_link(get_my_url()))); if (count($r)) { $zcid = $r[0]['id']; } } } } if ($cid == 0 && $zcid == 0) { return; } if ($cid) { $t = count_common_friends($uid, $cid); } else { $t = count_common_friends_zcid($uid, $zcid); } if (count($t)) { $a->set_pager_total($t); } else { notice(t('No contacts in common.') . EOL); return $o; } if ($cid) { $r = common_friends($uid, $cid, $a->pager['start'], $a->pager['itemspage']); } else { $r = common_friends_zcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']); } if (!count($r)) { return $o; } $id = 0; foreach ($r as $rr) { //get further details of the contact $contact_details = get_contact_details_by_url($rr['url'], $uid); // $rr[id] is needed to use contact_photo_menu() $rr[id] = $rr[cid]; $photo_menu = ''; $photo_menu = contact_photo_menu($rr); $entry = array('url' => $rr['url'], 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $rr['url'], 'name' => $rr['name'], 'thumb' => proxy_url($rr['photo'], false, PROXY_SIZE_THUMB), 'img_hover' => htmlentities($rr['name']), 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'network' => network_to_name($contact_details['network'], $contact_details['url']), 'photo_menu' => $photo_menu, 'id' => ++$id); $entries[] = $entry; } if ($cmd === 'loc' && $cid && $uid == local_user()) { $tab_str = contacts_tab($a, $cid, 4); } else { $title = t('Common Friends'); } $tpl = get_markup_template('viewcontact_template.tpl'); $o .= replace_macros($tpl, array('$title' => $title, '$tab_str' => $tab_str, '$contacts' => $entries, '$paginate' => paginate($a))); return $o; }
function _contact_detail_for_template($rr) { switch ($rr['rel']) { case CONTACT_IS_FRIEND: $dir_icon = 'images/lrarrow.gif'; $alt_text = t('Mutual Friendship'); break; case CONTACT_IS_FOLLOWER: $dir_icon = 'images/larrow.gif'; $alt_text = t('is a fan of yours'); break; case CONTACT_IS_SHARING: $dir_icon = 'images/rarrow.gif'; $alt_text = t('you are a fan of'); break; default: break; } if ($rr['network'] === NETWORK_DFRN && $rr['rel']) { $url = "redir/{$rr['id']}"; $sparkle = ' class="sparkle" '; } else { $url = $rr['url']; $sparkle = ''; } return array('img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $rr['name'], $rr['url']), 'edit_hover' => t('Edit contact'), 'photo_menu' => contact_photo_menu($rr), 'id' => $rr['id'], 'alt_text' => $alt_text, 'dir_icon' => $dir_icon, 'thumb' => proxy_url($rr['thumb']), 'name' => $rr['name'], 'username' => $rr['name'], 'sparkle' => $sparkle, 'itemurl' => $rr['url'], 'url' => $url, 'network' => network_to_name($rr['network'])); }
function contacts_content(&$a) { $sort_type = 0; $o = ''; nav_set_selected('contacts'); if (!local_user()) { notice(t('Permission denied.') . EOL); return; } if ($a->argc == 3) { $contact_id = intval($a->argv[1]); if (!$contact_id) { return; } $cmd = $a->argv[2]; $orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d AND `self` = 0 LIMIT 1", intval($contact_id), intval(local_user())); if (!count($orig_record)) { notice(t('Could not access contact record.') . EOL); goaway($a->get_baseurl(true) . '/contacts'); return; // NOTREACHED } if ($cmd === 'update') { _contact_update($contact_id); goaway($a->get_baseurl(true) . '/contacts/' . $contact_id); // NOTREACHED } if ($cmd === 'block') { $r = _contact_block($contact_id, $orig_record[0]); if ($r) { $blocked = $orig_record[0]['blocked'] ? 0 : 1; info(($blocked ? t('Contact has been blocked') : t('Contact has been unblocked')) . EOL); } goaway($a->get_baseurl(true) . '/contacts/' . $contact_id); return; // NOTREACHED } if ($cmd === 'ignore') { $r = _contact_ignore($contact_id, $orig_record[0]); if ($r) { $readonly = $orig_record[0]['readonly'] ? 0 : 1; info(($readonly ? t('Contact has been ignored') : t('Contact has been unignored')) . EOL); } goaway($a->get_baseurl(true) . '/contacts/' . $contact_id); return; // NOTREACHED } if ($cmd === 'archive') { $r = _contact_archive($contact_id, $orig_record[0]); if ($r) { $archived = $orig_record[0]['archive'] ? 0 : 1; info(($archived ? t('Contact has been archived') : t('Contact has been unarchived')) . EOL); } goaway($a->get_baseurl(true) . '/contacts/' . $contact_id); return; // NOTREACHED } if ($cmd === 'drop') { // Check if we should do HTML-based delete confirmation if ($_REQUEST['confirm']) { // <form> can't take arguments in its "action" parameter // so add any arguments as hidden inputs $query = explode_querystring($a->query_string); $inputs = array(); foreach ($query['args'] as $arg) { if (strpos($arg, 'confirm=') === false) { $arg_parts = explode('=', $arg); $inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]); } } $a->page['aside'] = ''; return replace_macros(get_markup_template('confirm.tpl'), array('$method' => 'get', '$message' => t('Do you really want to delete this contact?'), '$extra_inputs' => $inputs, '$confirm' => t('Yes'), '$confirm_url' => $query['base'], '$confirm_name' => 'confirmed', '$cancel' => t('Cancel'))); } // Now check how the user responded to the confirmation query if ($_REQUEST['canceled']) { if (x($_SESSION, 'return_url')) { goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']); } else { goaway($a->get_baseurl(true) . '/contacts'); } } _contact_drop($contact_id, $orig_record[0]); info(t('Contact has been removed.') . EOL); if (x($_SESSION, 'return_url')) { goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']); } else { goaway($a->get_baseurl(true) . '/contacts'); } return; // NOTREACHED } } $_SESSION['return_url'] = $a->query_string; if (x($a->data, 'contact') && is_array($a->data['contact'])) { $contact_id = $a->data['contact']['id']; $contact = $a->data['contact']; $editselect = 'none'; if (feature_enabled(local_user(), 'richtext')) { $editselect = 'exact'; } $a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), array('$baseurl' => $a->get_baseurl(true), '$editselect' => $editselect)); $a->page['end'] .= replace_macros(get_markup_template('contact_end.tpl'), array('$baseurl' => $a->get_baseurl(true), '$editselect' => $editselect)); require_once 'include/contact_selectors.php'; $tpl = get_markup_template("contact_edit.tpl"); switch ($contact['rel']) { case CONTACT_IS_FRIEND: $dir_icon = 'images/lrarrow.gif'; $relation_text = t('You are mutual friends with %s'); break; case CONTACT_IS_FOLLOWER: $dir_icon = 'images/larrow.gif'; $relation_text = t('You are sharing with %s'); break; case CONTACT_IS_SHARING: $dir_icon = 'images/rarrow.gif'; $relation_text = t('%s is sharing with you'); break; default: break; } $relation_text = sprintf($relation_text, $contact['name']); if ($contact['network'] === NETWORK_DFRN && $contact['rel']) { $url = "redir/{$contact['id']}"; $sparkle = ' class="sparkle" '; } else { $url = $contact['url']; $sparkle = ''; } $insecure = t('Private communications are not available for this contact.'); $last_update = $contact['last-update'] == '0000-00-00 00:00:00' ? t('Never') : datetime_convert('UTC', date_default_timezone_get(), $contact['last-update'], 'D, j M Y, g:i A'); if ($contact['last-update'] !== '0000-00-00 00:00:00') { $last_update .= ' ' . ($contact['last-update'] == $contact['success_update'] ? t("(Update was successful)") : t("(Update was not successful)")); } $lblsuggest = $contact['network'] === NETWORK_DFRN ? t('Suggest friends') : ''; $poll_enabled = $contact['network'] !== NETWORK_DIASPORA ? true : false; $nettype = sprintf(t('Network type: %s'), network_to_name($contact['network'])); $common = count_common_friends(local_user(), $contact['id']); $common_text = $common ? sprintf(tt('%d contact in common', '%d contacts in common', $common), $common) : ''; $polling = $contact['network'] === NETWORK_MAIL | $contact['network'] === NETWORK_FEED ? 'polling' : ''; $x = count_all_friends(local_user(), $contact['id']); $all_friends = $x ? t('View all contacts') : ''; // tabs $tabs = array(array('label' => $contact['blocked'] ? t('Unblock') : t('Block'), 'url' => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/block', 'sel' => '', 'title' => t('Toggle Blocked status')), array('label' => $contact['readonly'] ? t('Unignore') : t('Ignore'), 'url' => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/ignore', 'sel' => '', 'title' => t('Toggle Ignored status')), array('label' => $contact['archive'] ? t('Unarchive') : t('Archive'), 'url' => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/archive', 'sel' => '', 'title' => t('Toggle Archive status')), array('label' => t('Repair'), 'url' => $a->get_baseurl(true) . '/crepair/' . $contact_id, 'sel' => '', 'title' => t('Advanced Contact Settings'))); $tab_tpl = get_markup_template('common_tabs.tpl'); $tab_str = replace_macros($tab_tpl, array('$tabs' => $tabs)); $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!') : ''; $o .= replace_macros($tpl, array('$header' => t('Contact Editor'), '$tab_str' => $tab_str, '$submit' => t('Submit'), '$lbl_vis1' => t('Profile Visibility'), '$lbl_vis2' => sprintf(t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['name']), '$lbl_info1' => t('Contact Information / Notes'), '$infedit' => t('Edit contact notes'), '$common_text' => $common_text, '$common_link' => $a->get_baseurl(true) . '/common/loc/' . local_user() . '/' . $contact['id'], '$all_friends' => $all_friends, '$relation_text' => $relation_text, '$visit' => sprintf(t('Visit %s\'s profile [%s]'), $contact['name'], $contact['url']), '$blockunblock' => t('Block/Unblock contact'), '$ignorecont' => t('Ignore contact'), '$lblcrepair' => t("Repair URL settings"), '$lblrecent' => t('View conversations'), '$lblsuggest' => $lblsuggest, '$delete' => t('Delete contact'), '$nettype' => $nettype, '$poll_interval' => contact_poll_interval($contact['priority'], !$poll_enabled), '$poll_enabled' => $poll_enabled, '$lastupdtext' => t('Last update:'), '$lost_contact' => $lost_contact, '$updpub' => t('Update public posts'), '$last_update' => $last_update, '$udnow' => t('Update now'), '$profile_select' => contact_profile_assign($contact['profile-id'], $contact['network'] !== NETWORK_DFRN ? true : false), '$contact_id' => $contact['id'], '$block_text' => $contact['blocked'] ? t('Unblock') : t('Block'), '$ignore_text' => $contact['readonly'] ? t('Unignore') : t('Ignore'), '$insecure' => $contact['network'] !== NETWORK_DFRN && $contact['network'] !== NETWORK_MAIL && $contact['network'] !== NETWORK_FACEBOOK && $contact['network'] !== NETWORK_DIASPORA ? $insecure : '', '$info' => $contact['info'], '$blocked' => $contact['blocked'] ? t('Currently blocked') : '', '$ignored' => $contact['readonly'] ? t('Currently ignored') : '', '$archived' => $contact['archive'] ? t('Currently archived') : '', '$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')), '$notify' => array('notify', t('Notification for new posts'), $contact['notify_new_posts'] == 1, t('Send a notification of every new post of this contact')), '$fetch_further_information' => array('fetch_further_information', t('Fetch further information for feeds'), $contact['fetch_further_information'] == 1, t('Fetch further information for feeds')), '$photo' => $contact['photo'], '$name' => $contact['name'], '$dir_icon' => $dir_icon, '$alt_text' => $alt_text, '$sparkle' => $sparkle, '$url' => $url)); $arr = array('contact' => $contact, 'output' => $o); call_hooks('contact_edit', $arr); return $arr['output']; } $blocked = false; $hidden = false; $ignored = false; $all = false; if ($a->argc == 2 && $a->argv[1] === 'all') { $sql_extra = ''; $all = true; } elseif ($a->argc == 2 && $a->argv[1] === 'blocked') { $sql_extra = " AND `blocked` = 1 "; $blocked = true; } elseif ($a->argc == 2 && $a->argv[1] === 'hidden') { $sql_extra = " AND `hidden` = 1 "; $hidden = true; } elseif ($a->argc == 2 && $a->argv[1] === 'ignored') { $sql_extra = " AND `readonly` = 1 "; $ignored = true; } elseif ($a->argc == 2 && $a->argv[1] === 'archived') { $sql_extra = " AND `archive` = 1 "; $archived = true; } else { $sql_extra = " AND `blocked` = 0 "; } $search = x($_GET, 'search') ? notags(trim($_GET['search'])) : ''; $nets = x($_GET, 'nets') ? notags(trim($_GET['nets'])) : ''; $tabs = array(array('label' => t('Suggestions'), 'url' => $a->get_baseurl(true) . '/suggest', 'sel' => '', 'title' => t('Suggest potential friends')), array('label' => t('All Contacts'), 'url' => $a->get_baseurl(true) . '/contacts/all', 'sel' => $all ? 'active' : '', 'title' => t('Show all contacts')), array('label' => t('Unblocked'), 'url' => $a->get_baseurl(true) . '/contacts', 'sel' => !$all && !$blocked && !$hidden && !$search && !$nets && !$ignored && !$archived ? 'active' : '', 'title' => t('Only show unblocked contacts')), array('label' => t('Blocked'), 'url' => $a->get_baseurl(true) . '/contacts/blocked', 'sel' => $blocked ? 'active' : '', 'title' => t('Only show blocked contacts')), array('label' => t('Ignored'), 'url' => $a->get_baseurl(true) . '/contacts/ignored', 'sel' => $ignored ? 'active' : '', 'title' => t('Only show ignored contacts')), array('label' => t('Archived'), 'url' => $a->get_baseurl(true) . '/contacts/archived', 'sel' => $archived ? 'active' : '', 'title' => t('Only show archived contacts')), array('label' => t('Hidden'), 'url' => $a->get_baseurl(true) . '/contacts/hidden', 'sel' => $hidden ? 'active' : '', 'title' => t('Only show hidden contacts'))); $tab_tpl = get_markup_template('common_tabs.tpl'); $t = replace_macros($tab_tpl, array('$tabs' => $tabs)); $searching = false; if ($search) { $search_hdr = $search; $search_txt = dbesc(protect_sprintf(preg_quote($search))); $searching = true; } $sql_extra .= $searching ? " AND (name REGEXP '{$search_txt}' OR url REGEXP '{$search_txt}' OR nick REGEXP '{$search_txt}') " : ""; if ($nets) { $sql_extra .= sprintf(" AND network = '%s' ", dbesc($nets)); } $sql_extra2 = $sort_type > 0 && $sort_type <= CONTACT_IS_FRIEND ? sprintf(" AND `rel` = %d ", intval($sort_type)) : ''; $r = q("SELECT COUNT(*) AS `total` FROM `contact` \n\t\tWHERE `uid` = %d AND `self` = 0 AND `pending` = 0 {$sql_extra} {$sql_extra2} ", intval($_SESSION['uid'])); if (count($r)) { $a->set_pager_total($r[0]['total']); $total = $r[0]['total']; } $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 ", intval($_SESSION['uid']), intval($a->pager['start']), intval($a->pager['itemspage'])); $contacts = array(); if (count($r)) { foreach ($r as $rr) { switch ($rr['rel']) { case CONTACT_IS_FRIEND: $dir_icon = 'images/lrarrow.gif'; $alt_text = t('Mutual Friendship'); break; case CONTACT_IS_FOLLOWER: $dir_icon = 'images/larrow.gif'; $alt_text = t('is a fan of yours'); break; case CONTACT_IS_SHARING: $dir_icon = 'images/rarrow.gif'; $alt_text = t('you are a fan of'); break; default: break; } if ($rr['network'] === 'dfrn' && $rr['rel']) { $url = "redir/{$rr['id']}"; $sparkle = ' class="sparkle" '; } else { $url = $rr['url']; $sparkle = ''; } $contacts[] = array('img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $rr['name'], $rr['url']), 'edit_hover' => t('Edit contact'), 'photo_menu' => contact_photo_menu($rr), 'id' => $rr['id'], 'alt_text' => $alt_text, 'dir_icon' => $dir_icon, 'thumb' => $rr['thumb'], 'name' => $rr['name'], 'username' => $rr['name'], 'sparkle' => $sparkle, 'itemurl' => $rr['url'], 'url' => $url, 'network' => network_to_name($rr['network'])); } } $tpl = get_markup_template("contacts-template.tpl"); $o .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(), '$header' => t('Contacts') . ($nets ? ' - ' . network_to_name($nets) : ''), '$tabs' => $t, '$total' => $total, '$search' => $search_hdr, '$desc' => t('Search your contacts'), '$finding' => $searching ? t('Finding: ') . "'" . $search . "'" : "", '$submit' => t('Find'), '$cmd' => $a->cmd, '$contacts' => $contacts, '$contact_drop_confirm' => t('Do you really want to delete this contact?'), '$batch_actions' => array('contacts_batch_update' => t('Update'), 'contacts_batch_block' => t('Block') . "/" . t("Unblock"), "contacts_batch_ignore" => t('Ignore') . "/" . t("Unignore"), "contacts_batch_archive" => t('Archive') . "/" . t("Unarchive"), "contacts_batch_drop" => t('Delete')), '$paginate' => paginate($a))); return $o; }
function _contact_detail_for_template($rr) { $community = ''; switch ($rr['rel']) { case CONTACT_IS_FRIEND: $dir_icon = 'images/lrarrow.gif'; $alt_text = t('Mutual Friendship'); break; case CONTACT_IS_FOLLOWER: $dir_icon = 'images/larrow.gif'; $alt_text = t('is a fan of yours'); break; case CONTACT_IS_SHARING: $dir_icon = 'images/rarrow.gif'; $alt_text = t('you are a fan of'); break; default: break; } if ($rr['network'] === NETWORK_DFRN && $rr['rel']) { $url = "redir/{$rr['id']}"; $sparkle = ' class="sparkle" '; } else { $url = $rr['url']; $sparkle = ''; } //test if contact is a forum page if (isset($rr['forum']) or isset($rr['prv'])) { $community = ($rr['forum'] or $rr['prv']); } return array('img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $rr['name'], $rr['url']), 'edit_hover' => t('Edit contact'), 'photo_menu' => contact_photo_menu($rr), 'id' => $rr['id'], 'alt_text' => $alt_text, 'dir_icon' => $dir_icon, 'thumb' => proxy_url($rr['thumb'], false, PROXY_SIZE_THUMB), 'name' => htmlentities($rr['name']), 'username' => htmlentities($rr['name']), 'account_type' => $community ? t('Forum') : '', 'sparkle' => $sparkle, 'itemurl' => $rr['addr'] != "" ? $rr['addr'] : $rr['url'], 'url' => $url, 'network' => network_to_name($rr['network'], $rr['url'])); }
function contact_photo_menu($contact, $uid = 0) { $a = get_app(); $contact_url = ""; $pm_url = ""; $status_link = ""; $photos_link = ""; $posts_link = ""; $contact_drop_link = ""; $poke_link = ""; if ($uid == 0) { $uid = local_user(); } if ($contact["uid"] != $uid) { if ($uid == 0) { $profile_link = zrl($contact['url']); $menu = array('profile' => array(t("View Profile"), $profile_link, true)); return $menu; } $r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `network` = '%s' AND `uid` = %d", dbesc($contact["nurl"]), dbesc($contact["network"]), intval($uid)); if ($r) { return contact_photo_menu($r[0], $uid); } else { $profile_link = zrl($contact['url']); $connlnk = 'follow/?url=' . $contact['url']; $menu = array('profile' => array(t("View Profile"), $profile_link, true), 'follow' => array(t("Connect/Follow"), $connlnk, true)); return $menu; } } $sparkle = false; if ($contact['network'] === NETWORK_DFRN) { $sparkle = true; $profile_link = $a->get_baseurl() . '/redir/' . $contact['id']; } else { $profile_link = $contact['url']; } if ($profile_link === 'mailbox') { $profile_link = ''; } if ($sparkle) { $status_link = $profile_link . "?url=status"; $photos_link = $profile_link . "?url=photos"; $profile_link = $profile_link . "?url=profile"; } if (in_array($contact["network"], array(NETWORK_DFRN, NETWORK_DIASPORA))) { $pm_url = $a->get_baseurl() . '/message/new/' . $contact['id']; } if ($contact["network"] == NETWORK_DFRN) { $poke_link = $a->get_baseurl() . '/poke/?f=&c=' . $contact['id']; } $contact_url = $a->get_baseurl() . '/contacts/' . $contact['id']; $posts_link = $a->get_baseurl() . "/contacts/" . $contact['id'] . '/posts'; $contact_drop_link = $a->get_baseurl() . "/contacts/" . $contact['id'] . '/drop?confirm=1'; /** * menu array: * "name" => [ "Label", "link", (bool)Should the link opened in a new tab? ] */ $menu = array('status' => array(t("View Status"), $status_link, true), 'profile' => array(t("View Profile"), $profile_link, true), 'photos' => array(t("View Photos"), $photos_link, true), 'network' => array(t("Network Posts"), $posts_link, false), 'edit' => array(t("Edit Contact"), $contact_url, false), 'drop' => array(t("Drop Contact"), $contact_drop_link, false), 'pm' => array(t("Send PM"), $pm_url, false), 'poke' => array(t("Poke"), $poke_link, false)); $args = array('contact' => $contact, 'menu' => &$menu); call_hooks('contact_photo_menu', $args); $menucondensed = array(); foreach ($menu as $menuname => $menuitem) { if ($menuitem[1] != "") { $menucondensed[$menuname] = $menuitem; } } return $menucondensed; }