Exemplo n.º 1
0
function suggest_content(&$a)
{
    require_once "mod/proxy.php";
    $o = '';
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
    $a->page['aside'] .= findpeople_widget();
    $a->page['aside'] .= follow_widget();
    $r = suggestion_query(local_user());
    if (!count($r)) {
        $o .= t('No suggestions available. If this is a new site, please try again in 24 hours.');
        return $o;
    }
    require_once 'include/contact_selectors.php';
    foreach ($r as $rr) {
        $connlnk = $a->get_baseurl() . '/follow/?url=' . ($rr['connect'] ? $rr['connect'] : $rr['url']);
        $ignlnk = $a->get_baseurl() . '/suggest?ignore=' . $rr['id'];
        $photo_menu = array(array(t("View Profile"), zrl($rr["url"])));
        $photo_menu[] = array(t("Connect/Follow"), $connlnk);
        $photo_menu[] = array(t('Ignore/Hide'), $ignlnk);
        $contact_details = get_contact_details_by_url($rr["url"], local_user());
        $entry = array('url' => zrl($rr['url']), 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $rr['url'], 'img_hover' => $rr['url'], 'name' => $rr['name'], 'thumb' => proxy_url($rr['photo'], false, PROXY_SIZE_THUMB), 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'ignlnk' => $ignlnk, 'ignid' => $rr['id'], 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'photo_menu' => $photo_menu, 'ignore' => t('Ignore/Hide'), 'network' => network_to_name($rr['network'], $rr['url']), 'id' => ++$id);
        $entries[] = $entry;
    }
    $tpl = get_markup_template('viewcontact_template.tpl');
    $o .= replace_macros($tpl, array('$title' => t('Friend Suggestions'), '$contacts' => $entries));
    return $o;
}
Exemplo n.º 2
0
/**
 * @brief Controller for /match.
 *
 * It takes keywords from your profile and queries the directory server for
 * matching keywords from other profiles.
 *
 * @param App &$a
 * @return void|string
 */
function match_content(&$a)
{
    $o = '';
    if (!local_user()) {
        return;
    }
    $a->page['aside'] .= findpeople_widget();
    $a->page['aside'] .= follow_widget();
    $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
    $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user()));
    if (!count($r)) {
        return;
    }
    if (!$r[0]['pub_keywords'] && !$r[0]['prv_keywords']) {
        notice(t('No keywords to match. Please add keywords to your default profile.') . EOL);
        return;
    }
    $params = array();
    $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
    if ($tags) {
        $params['s'] = $tags;
        if ($a->pager['page'] != 1) {
            $params['p'] = $a->pager['page'];
        }
        if (strlen(get_config('system', 'directory'))) {
            $x = post_url(get_server() . '/msearch', $params);
        } else {
            $x = post_url($a->get_baseurl() . '/msearch', $params);
        }
        $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) {
                $match_nurl = normalise_link($jj->url);
                $match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1", intval(local_user()), dbesc($match_nurl));
                if (!count($match)) {
                    $jj->photo = str_replace("http:///photo/", get_server() . "/photo/", $jj->photo);
                    $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url;
                    $photo_menu = array(array(t("View Profile"), zrl($jj->url)));
                    $photo_menu[] = array(t("Connect/Follow"), $connlnk);
                    $contact_details = get_contact_details_by_url($jj->url, local_user());
                    $entry = array('url' => zrl($jj->url), 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $jj->url, 'name' => $jj->name, 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB), 'inttxt' => ' ' . t('is interested in:'), 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'img_hover' => $jj->tags, 'photo_menu' => $photo_menu, 'id' => ++$id);
                    $entries[] = $entry;
                }
            }
            $tpl = get_markup_template('viewcontact_template.tpl');
            $o .= replace_macros($tpl, array('$title' => t('Profile Match'), '$contacts' => $entries, '$paginate' => paginate($a)));
        } else {
            info(t('No matches') . EOL);
        }
    }
    return $o;
}
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
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) {
            $contact_details = get_contact_details_by_url($rr['url'], local_user());
            $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'], 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'sparkle' => $sparkle, 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $rr['url'], 'url' => $url, 'network' => network_to_name($rr['network'], $url));
        }
    }
    $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;
}
Exemplo n.º 6
0
function crepair_init(&$a)
{
    if (!local_user()) {
        return;
    }
    $contact_id = 0;
    if ($a->argc == 2 && intval($a->argv[1])) {
        $contact_id = intval($a->argv[1]);
        $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1", intval(local_user()), intval($contact_id));
        if (!count($r)) {
            $contact_id = 0;
        }
    }
    if (!x($a->page, 'aside')) {
        $a->page['aside'] = '';
    }
    if ($contact_id) {
        $a->data['contact'] = $r[0];
        $contact = $r[0];
        profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
    }
}
Exemplo n.º 7
0
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;
}
Exemplo n.º 8
0
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;
}
Exemplo n.º 9
0
function contact_posts($a, $contact_id)
{
    require_once 'include/conversation.php';
    $r = q("SELECT * FROM `contact` WHERE `id` = %d", intval($contact_id));
    if ($r) {
        $contact = $r[0];
        $a->page['aside'] = "";
        profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
    }
    if (get_config('system', 'old_pager')) {
        $r = q("SELECT COUNT(*) AS `total` FROM `item`\n\t\t\tWHERE `item`.`uid` = %d AND `author-link` IN ('%s', '%s')", intval(local_user()), dbesc(str_replace("https://", "http://", $contact["url"])), dbesc(str_replace("http://", "https://", $contact["url"])));
        $a->set_pager_total($r[0]['total']);
    }
    $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,\n\t\t\t`author-name` AS `name`, `owner-avatar` AS `photo`,\n\t\t\t`owner-link` AS `url`, `owner-avatar` AS `thumb`\n\t\tFROM `item` FORCE INDEX (uid_contactid_created)\n\t\tWHERE `item`.`uid` = %d AND `contact-id` = %d\n\t\t\tAND `author-link` IN ('%s', '%s')\n\t\tORDER BY `item`.`created` DESC LIMIT %d, %d", intval(local_user()), intval($contact_id), dbesc(str_replace("https://", "http://", $contact["url"])), dbesc(str_replace("http://", "https://", $contact["url"])), intval($a->pager['start']), intval($a->pager['itemspage']));
    $tab_str = contacts_tab($a, $contact_id, 1);
    $o .= $tab_str;
    $o .= conversation($a, $r, 'community', false);
    if (!get_config('system', 'old_pager')) {
        $o .= alt_pager($a, count($r));
    } else {
        $o .= paginate($a);
    }
    return $o;
}