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; } $c = q("select name, url, photo from contact where id = %d and uid = %d limit 1", intval($cid), intval(local_user())); $a->page['aside'] .= '<div class="vcard">' . '<div class="fn label">' . $c[0]['name'] . '</div>' . '<div id="profile-photo-wrapper">' . '<a href="/contacts/' . $cid . '"><img class="photo" width="175" height="175" src="' . $c[0]['photo'] . '" alt="' . $c[0]['name'] . '" /></div>' . '</div>'; if (!count($c)) { return; } $o .= '<h2>' . sprintf(t('Friends of %s'), $c[0]['name']) . '</h2>'; $r = all_friends(local_user(), $cid); if (!count($r)) { $o .= t('No friends to display.'); return $o; } $tpl = get_markup_template('common_friends.tpl'); foreach ($r as $rr) { $o .= replace_macros($tpl, array('$url' => $rr['url'], '$name' => $rr['name'], '$photo' => $rr['photo'], '$tags' => '')); } $o .= cleardiv(); // $o .= paginate($a); return $o; }
function get() { $o = ''; if (!\App::$profile['profile_uid']) { return; } $observer_hash = get_observer_hash(); if (!perm_is_allowed(\App::$profile['profile_uid'], $observer_hash, 'view_contacts')) { notice(t('Permission denied.') . EOL); return; } $o .= '<h2>' . t('Common connections') . '</h2>'; $t = count_common_friends(\App::$profile['profile_uid'], $observer_hash); if (!$t) { notice(t('No connections in common.') . EOL); return $o; } $r = common_friends(\App::$profile['profile_uid'], $observer_hash); if ($r) { $tpl = get_markup_template('common_friends.tpl'); foreach ($r as $rr) { $o .= replace_macros($tpl, array('$url' => $rr['xchan_url'], '$name' => $rr['xchan_name'], '$photo' => $rr['xchan_photo_m'], '$tags' => '')); } $o .= cleardiv(); } return $o; }
function suggest_content(&$a) { $o = ''; if (!local_user()) { notice(t('Permission denied.') . EOL); return; } $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; $a->page['aside'] .= follow_widget(); $a->page['aside'] .= findpeople_widget(); $o .= '<h2>' . t('Friend Suggestions') . '</h2>'; $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; } $tpl = get_markup_template('suggest_friends.tpl'); foreach ($r as $rr) { $connlnk = $a->get_baseurl() . '/follow/?url=' . ($rr['connect'] ? $rr['connect'] : $rr['url']); $o .= replace_macros($tpl, array('$url' => zrl($rr['url']), '$name' => $rr['name'], '$photo' => $rr['photo'], '$ignlnk' => $a->get_baseurl() . '/suggest?ignore=' . $rr['id'], '$ignid' => $rr['id'], '$conntxt' => t('Connect'), '$connlnk' => $connlnk, '$ignore' => t('Ignore/Hide'))); } $o .= cleardiv(); // $o .= paginate($a); return $o; }
function match_content(&$a) { $o = ''; if (!local_user()) { return; } $a->page['aside'] .= follow_widget(); $a->page['aside'] .= findpeople_widget(); $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; $o .= replace_macros(get_markup_template("section_title.tpl"), array('$title' => t('Profile Match'))); $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)) { $tpl = get_markup_template('match.tpl'); 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; $o .= replace_macros($tpl, array('$url' => zrl($jj->url), '$name' => $jj->name, '$photo' => proxy_url($jj->photo), '$inttxt' => ' ' . t('is interested in:'), '$conntxt' => t('Connect'), '$connlnk' => $connlnk, '$tags' => $jj->tags)); } } } else { info(t('No matches') . EOL); } } $o .= cleardiv(); $o .= paginate($a); return $o; }
function match_content(&$a) { $o = ''; if (!local_user()) { return; } $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; $o .= '<h2>' . t('Profile Match') . '</h2>'; $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_submit_url'))) { $x = post_url('http://dir.friendica.com/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)) { $tpl = get_markup_template('match.tpl'); foreach ($j->results as $jj) { $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url; $o .= replace_macros($tpl, array('$url' => zrl($jj->url), '$name' => $jj->name, '$photo' => $jj->photo, '$inttxt' => ' ' . t('is interested in:'), '$conntxt' => t('Connect'), '$connlnk' => $connlnk, '$tags' => $jj->tags)); } } else { info(t('No matches') . EOL); } } $o .= cleardiv(); $o .= paginate($a); return $o; }
function suggest_content(&$a) { $o = ''; if (!local_user()) { notice(t('Permission denied.') . EOL); return; } $a->page['aside'] .= follow_widget(); $a->page['aside'] .= findpeople_widget(); $o .= '<h2>' . t('Friend Suggestions') . '</h2>'; $r = suggestion_query(local_user()); if (!count($r)) { $o .= t('No suggestions. This works best when you have more than one contact/friend.'); return $o; } $tpl = get_markup_template('suggest_friends.tpl'); foreach ($r as $rr) { $o .= replace_macros($tpl, array('$url' => $rr['url'], '$name' => $rr['name'], '$photo' => $rr['photo'], '$ignlnk' => $a->get_baseurl() . '/suggest?ignore=' . $rr['id'], '$ignore' => t('Ignore/Hide'))); } $o .= cleardiv(); // $o .= paginate($a); return $o; }
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; } $c = q("select name, url, photo from contact where id = %d and uid = %d limit 1", intval($cid), intval(local_user())); $vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"), array('$name' => $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; } $o .= replace_macros(get_markup_template("section_title.tpl"), array('$title' => sprintf(t('Friends of %s'), $c[0]['name']))); $r = all_friends(local_user(), $cid); if (!count($r)) { $o .= t('No friends to display.'); return $o; } $tpl = get_markup_template('common_friends.tpl'); foreach ($r as $rr) { $o .= replace_macros($tpl, array('$url' => $rr['url'], '$name' => $rr['name'], '$photo' => $rr['photo'], '$tags' => '')); } $o .= cleardiv(); // $o .= paginate($a); return $o; }
function visage_content(&$a) { if (!local_channel()) { return; } $o = '<h3>' . t('Recent Channel/Profile Viewers') . '</h3>'; $enabled = get_pconfig(local_channel(), 'visage', 'enabled'); if (!$enabled) { $o .= t('This plugin/addon has not been configured.') . EOL; $o .= sprintf(t('Please visit the Visage settings on %s'), '<a href="settings/featured">' . t('your feature settings page') . '</a>'); return $o; } // let's play fair. require_once 'include/identity.php'; if (!is_public_profile()) { return $o; } $x = get_pconfig(local_channel(), 'visage', 'visitors'); if (!$x || !is_array($x)) { $o .= t('No entries.'); return $o; } $chans = ''; for ($n = 0; $n < count($x); $n++) { if ($chans) { $chans .= ','; } $chans .= "'" . dbesc($x[$n][0]) . "'"; } if ($chans) { $r = q("select * from xchan where xchan_hash in ( {$chans} )"); } if ($r) { $tpl = get_markup_template('common_friends.tpl'); for ($g = count($x) - 1; $g >= 0; $g--) { foreach ($r as $rr) { if ($x[$g][0] == $rr['xchan_hash']) { break; } } $o .= replace_macros($tpl, array('$url' => $rr['xchan_flags'] & XCHAN_FLAGS_HIDDEN ? z_root() : chanlink_url($rr['xchan_url']), '$name' => $rr['xchan_name'], '$photo' => $rr['xchan_photo_m'], '$tags' => $rr['xchan_flags'] & XCHAN_FLAGS_HIDDEN ? z_root() : chanlink_url($rr['xchan_url']), '$note' => relative_date($x[$g][1]))); } $o .= cleardiv(); } return $o; }
function common_content(&$a) { $o = ''; $cmd = $a->argv[1]; $uid = intval($a->argv[2]); $cid = intval($a->argv[3]); $zcid = 0; 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)); } else { $c = q("select name, url, photo from contact where self = 1 and uid = %d limit 1", intval($uid)); } $a->page['aside'] .= '<div class="vcard">' . '<div class="fn label">' . $c[0]['name'] . '</div>' . '<div id="profile-photo-wrapper">' . '<img class="photo" width="175" height="175" src="' . $c[0]['photo'] . '" alt="' . $c[0]['name'] . '" /></div>' . '</div>'; if (!count($c)) { return; } $o .= '<h2>' . t('Common Friends') . '</h2>'; 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); } $a->set_pager_total($t); if (!$t) { notice(t('No contacts in common.') . EOL); return $o; } if ($cid) { $r = common_friends($uid, $cid); } else { $r = common_friends_zcid($uid, $zcid); } if (!count($r)) { return $o; } $tpl = get_markup_template('common_friends.tpl'); foreach ($r as $rr) { $o .= replace_macros($tpl, array('$url' => $rr['url'], '$name' => $rr['name'], '$photo' => $rr['photo'], '$tags' => '')); } $o .= cleardiv(); // $o .= paginate($a); return $o; }
function common_content(&$a) { $o = ''; $cmd = $a->argv[1]; $uid = intval($a->argv[2]); $cid = intval($a->argv[3]); $zcid = 0; 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)); } 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' => $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; } $o .= replace_macros(get_markup_template("section_title.tpl"), array('$title' => t('Common Friends'))); 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); } $a->set_pager_total($t); if (!$t) { notice(t('No contacts in common.') . EOL); return $o; } if ($cid) { $r = common_friends($uid, $cid); } else { $r = common_friends_zcid($uid, $zcid); } if (!count($r)) { return $o; } $tpl = get_markup_template('common_friends.tpl'); foreach ($r as $rr) { $o .= replace_macros($tpl, array('$url' => $rr['url'], '$name' => $rr['name'], '$photo' => $rr['photo'], '$tags' => '')); } $o .= cleardiv(); // $o .= paginate($a); return $o; }