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; }
function widget_suggestions($arr) { if (!local_user() || !feature_enabled(local_user(), 'suggest')) { return ''; } require_once 'include/socgraph.php'; $r = suggestion_query(local_user(), get_observer_hash(), 0, 20); if (!$r) { return; } $arr = array(); // Get two random entries from the top 20 returned. // We'll grab the first one and the one immediately following. // This will throw some entropy intot he situation so you won't // be looking at the same two mug shots every time the widget runs $index = count($r) > 2 ? mt_rand(0, count($r) - 2) : 0; for ($x = $index; $x <= $index + 1; $x++) { $rr = $r[$x]; if (!$rr['xchan_url']) { break; } $connlnk = z_root() . '/follow/?url=' . $rr['xchan_addr']; $arr[] = array('url' => chanlink_url($rr['xchan_url']), 'profile' => $rr['xchan_url'], 'name' => $rr['xchan_name'], 'photo' => $rr['xchan_photo_m'], 'ignlnk' => z_root() . '/suggest?ignore=' . $rr['xchan_hash'], 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'ignore' => t('Ignore/Hide')); } $o = replace_macros(get_markup_template('suggest_widget.tpl'), array('$title' => t('Suggestions'), '$more' => t('See more...'), '$entries' => $arr)); 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 get() { $o = ''; if (!local_channel()) { notice(t('Permission denied.') . EOL); return; } $_SESSION['return_url'] = z_root() . '/' . \App::$cmd; $r = suggestion_query(local_channel(), get_observer_hash()); if (!$r) { info(t('No suggestions available. If this is a new site, please try again in 24 hours.')); return; } $arr = array(); foreach ($r as $rr) { $connlnk = z_root() . '/follow/?url=' . $rr['xchan_addr']; $arr[] = array('url' => chanlink_url($rr['xchan_url']), 'common' => $rr['total'], 'profile' => $rr['xchan_url'], 'name' => $rr['xchan_name'], 'photo' => $rr['xchan_photo_m'], 'ignlnk' => z_root() . '/suggest?ignore=' . $rr['xchan_hash'], 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'ignore' => t('Ignore/Hide')); } $o = replace_macros(get_markup_template('suggest_page.tpl'), array('$title' => t('Channel Suggestions'), '$entries' => $arr)); 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 get() { if (get_config('system', 'block_public') && !local_channel() && !remote_channel()) { notice(t('Public access denied.') . EOL); return; } $observer = get_observer_hash(); $globaldir = get_directory_setting($observer, 'globaldir'); // override your personal global search pref if we're doing a navbar search of the directory if (intval($_REQUEST['navsearch'])) { $globaldir = 1; } $safe_mode = get_directory_setting($observer, 'safemode'); $pubforums = get_directory_setting($observer, 'pubforums'); $o = ''; nav_set_selected('directory'); if (x($_POST, 'search')) { $search = notags(trim($_POST['search'])); } else { $search = x($_GET, 'search') ? notags(trim(rawurldecode($_GET['search']))) : ''; } if (strpos($search, '=') && local_channel() && get_pconfig(local_channel(), 'feature', 'expert')) { $advanced = $search; } $keywords = $_GET['keywords'] ? $_GET['keywords'] : ''; // Suggest channels if no search terms or keywords are given $suggest = local_channel() && x($_REQUEST, 'suggest') ? $_REQUEST['suggest'] : ''; if ($suggest) { $r = suggestion_query(local_channel(), get_observer_hash()); // Remember in which order the suggestions were $addresses = array(); $common = array(); $index = 0; foreach ($r as $rr) { $common[$rr['xchan_addr']] = $rr['total']; $addresses[$rr['xchan_addr']] = $index++; } // Build query to get info about suggested people $advanced = ''; foreach (array_keys($addresses) as $address) { $advanced .= "address=\"{$address}\" "; } // Remove last space in the advanced query $advanced = rtrim($advanced); } $tpl = get_markup_template('directory_header.tpl'); $dirmode = intval(get_config('system', 'directory_mode')); if ($dirmode == DIRECTORY_MODE_PRIMARY || $dirmode == DIRECTORY_MODE_STANDALONE) { $url = z_root() . '/dirsearch'; } if (!$url) { $directory = find_upstream_directory($dirmode); if (!$directory || !array_key_exists('url', $directory) || !$directory['url']) { logger('CRITICAL: No directory server URL'); } $url = $directory['url'] . '/dirsearch'; } $token = get_config('system', 'realm_token'); logger('mod_directory: URL = ' . $url, LOGGER_DEBUG); $contacts = array(); if (local_channel()) { $x = q("select abook_xchan from abook where abook_channel = %d", intval(local_channel())); if ($x) { foreach ($x as $xx) { $contacts[] = $xx['abook_xchan']; } } } if ($url) { $numtags = get_config('system', 'directorytags'); $kw = intval($numtags) > 0 ? intval($numtags) : 50; if (get_config('system', 'disable_directory_keywords')) { $kw = 0; } $query = $url . '?f=&kw=' . $kw . ($safe_mode != 1 ? '&safe=' . $safe_mode : ''); if ($token) { $query .= '&t=' . $token; } if (!$globaldir) { $query .= '&hub=' . \App::get_hostname(); } if ($search) { $query .= '&name=' . urlencode($search) . '&keywords=' . urlencode($search); } if (strpos($search, '@')) { $query .= '&address=' . urlencode($search); } if ($keywords) { $query .= '&keywords=' . urlencode($keywords); } if ($advanced) { $query .= '&query=' . urlencode($advanced); } if (!is_null($pubforums)) { $query .= '&pubforums=' . intval($pubforums); } $directory_sort_order = get_config('system', 'directory_sort_order'); if (!$directory_sort_order) { $directory_sort_order = 'date'; } $sort_order = x($_REQUEST, 'order') ? $_REQUEST['order'] : $directory_sort_order; if ($sort_order) { $query .= '&order=' . urlencode($sort_order); } if (\App::$pager['page'] != 1) { $query .= '&p=' . \App::$pager['page']; } logger('mod_directory: query: ' . $query); $x = z_fetch_url($query); logger('directory: return from upstream: ' . print_r($x, true), LOGGER_DATA); if ($x['success']) { $t = 0; $j = json_decode($x['body'], true); if ($j) { if ($j['results']) { $entries = array(); $photo = 'thumb'; foreach ($j['results'] as $rr) { $profile_link = chanlink_url($rr['url']); $pdesc = $rr['description'] ? $rr['description'] . '<br />' : ''; $connect_link = local_channel() ? z_root() . '/follow?f=&url=' . urlencode($rr['address']) : ''; // Checking status is disabled ATM until someone checks the performance impact more carefully //$online = remote_online_status($rr['address']); $online = ''; if (in_array($rr['hash'], $contacts)) { $connect_link = ''; } $location = ''; if (strlen($rr['locale'])) { $location .= $rr['locale']; } if (strlen($rr['region'])) { if (strlen($rr['locale'])) { $location .= ', '; } $location .= $rr['region']; } if (strlen($rr['country'])) { if (strlen($location)) { $location .= ', '; } $location .= $rr['country']; } $age = ''; if (strlen($rr['birthday'])) { if (($years = age($rr['birthday'], 'UTC', '')) != 0) { $age = $years; } } $page_type = ''; if ($rr['total_ratings']) { $total_ratings = sprintf(tt("%d rating", "%d ratings", $rr['total_ratings']), $rr['total_ratings']); } else { $total_ratings = ''; } $profile = $rr; if (x($profile, 'locale') == 1 || x($profile, 'region') == 1 || x($profile, 'postcode') == 1 || x($profile, 'country') == 1) { $gender = x($profile, 'gender') == 1 ? t('Gender: ') . $profile['gender'] : False; } $marital = x($profile, 'marital') == 1 ? t('Status: ') . $profile['marital'] : False; $homepage = x($profile, 'homepage') == 1 ? t('Homepage: ') : False; $homepageurl = x($profile, 'homepage') == 1 ? $profile['homepage'] : ''; $hometown = x($profile, 'hometown') == 1 ? $profile['hometown'] : False; $about = x($profile, 'about') == 1 ? bbcode($profile['about']) : False; $keywords = x($profile, 'keywords') ? $profile['keywords'] : ''; $out = ''; if ($keywords) { $keywords = str_replace(',', ' ', $keywords); $keywords = str_replace(' ', ' ', $keywords); $karr = explode(' ', $keywords); if ($karr) { if (local_channel()) { $r = q("select keywords from profile where uid = %d and is_default = 1 limit 1", intval(local_channel())); if ($r) { $keywords = str_replace(',', ' ', $r[0]['keywords']); $keywords = str_replace(' ', ' ', $keywords); $marr = explode(' ', $keywords); } } foreach ($karr as $k) { if (strlen($out)) { $out .= ', '; } if ($marr && in_arrayi($k, $marr)) { $out .= '<strong>' . $k . '</strong>'; } else { $out .= $k; } } } } $entry = array('id' => ++$t, 'profile_link' => $profile_link, 'public_forum' => $rr['public_forum'], 'photo' => $rr['photo'], 'hash' => $rr['hash'], 'alttext' => $rr['name'] . (local_channel() || remote_channel() ? ' ' . $rr['address'] : ''), 'name' => $rr['name'], 'age' => $age, 'age_label' => t('Age:'), 'profile' => $profile, 'address' => $rr['address'], 'nickname' => substr($rr['address'], 0, strpos($rr['address'], '@')), 'location' => $location, 'location_label' => t('Location:'), 'gender' => $gender, 'total_ratings' => $total_ratings, 'viewrate' => true, 'canrate' => local_channel() ? true : false, 'pdesc' => $pdesc, 'pdesc_label' => t('Description:'), 'marital' => $marital, 'homepage' => $homepage, 'homepageurl' => linkify($homepageurl), 'hometown' => $hometown, 'hometown_label' => t('Hometown:'), 'about' => $about, 'about_label' => t('About:'), 'conn_label' => t('Connect'), 'forum_label' => t('Public Forum:'), 'connect' => $connect_link, 'online' => $online, 'kw' => $out ? t('Keywords: ') : '', 'keywords' => $out, 'ignlink' => $suggest ? z_root() . '/directory?ignore=' . $rr['hash'] : '', 'ignore_label' => t('Don\'t suggest'), 'common_friends' => $common[$rr['address']] ? intval($common[$rr['address']]) : '', 'common_label' => t('Common connections:'), 'common_count' => intval($common[$rr['address']]), 'safe' => $safe_mode); $arr = array('contact' => $rr, 'entry' => $entry); call_hooks('directory_item', $arr); unset($profile); unset($location); if (!$arr['entry']) { continue; } if ($sort_order == '' && $suggest) { $entries[$addresses[$rr['address']]] = $arr['entry']; // Use the same indexes as originally to get the best suggestion first } else { $entries[] = $arr['entry']; } } ksort($entries); // Sort array by key so that foreach-constructs work as expected if ($j['keywords']) { \App::$data['directory_keywords'] = $j['keywords']; } logger('mod_directory: entries: ' . print_r($entries, true), LOGGER_DATA); if ($_REQUEST['aj']) { if ($entries) { $o = replace_macros(get_markup_template('directajax.tpl'), array('$entries' => $entries)); } else { $o = '<div id="content-complete"></div>'; } echo $o; killme(); } else { $maxheight = 94; $dirtitle = $globaldir ? t('Global Directory') : t('Local Directory'); $o .= "<script> var page_query = '" . $_GET['q'] . "'; var extra_args = '" . extra_query_args() . "' ; divmore_height = " . intval($maxheight) . "; </script>"; $o .= replace_macros($tpl, array('$search' => $search, '$desc' => t('Find'), '$finddsc' => t('Finding:'), '$safetxt' => htmlspecialchars($search, ENT_QUOTES, 'UTF-8'), '$entries' => $entries, '$dirlbl' => $suggest ? t('Channel Suggestions') : $dirtitle, '$submit' => t('Find'), '$next' => alt_pager($a, $j['records'], t('next page'), t('previous page')), '$sort' => t('Sort options'), '$normal' => t('Alphabetic'), '$reverse' => t('Reverse Alphabetic'), '$date' => t('Newest to Oldest'), '$reversedate' => t('Oldest to Newest'), '$suggest' => $suggest ? '&suggest=1' : '')); } } else { if ($_REQUEST['aj']) { $o = '<div id="content-complete"></div>'; echo $o; killme(); } if (\App::$pager['page'] == 1 && $j['records'] == 0 && strpos($search, '@')) { goaway(z_root() . '/chanview/?f=&address=' . $search); } info(t("No entries (some entries may be hidden).") . EOL); } } } } return $o; }
function vier_community_info() { $a = get_app(); $show_pages = get_vier_config("show_pages", 1); $show_profiles = get_vier_config("show_profiles", 1); $show_helpers = get_vier_config("show_helpers", 1); $show_services = get_vier_config("show_services", 1); $show_friends = get_vier_config("show_friends", 1); $show_lastusers = get_vier_config("show_lastusers", 1); //get_baseurl $url = $a->get_baseurl($ssl_state); $aside['$url'] = $url; // comunity_profiles if ($show_profiles) { $r = suggestion_query(local_user(), 0, 9); $tpl = get_markup_template('ch_directory_item.tpl'); if (count($r)) { $aside['$comunity_profiles_title'] = t('Community Profiles'); $aside['$comunity_profiles_items'] = array(); foreach ($r as $rr) { $entry = replace_macros($tpl, array('$id' => $rr['id'], '$profile_link' => $a->get_baseurl() . '/follow/?url=' . urlencode($rr['url']), '$photo' => proxy_url($rr['photo'], false, PROXY_SIZE_MICRO), '$alt_text' => $rr['name'])); $aside['$comunity_profiles_items'][] = $entry; } } } // last 9 users if ($show_lastusers) { $publish = get_config('system', 'publish_all') ? '' : " AND `publish` = 1 "; $order = " ORDER BY `register_date` DESC "; $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`\n\t\t\t\tFROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`\n\t\t\t\tWHERE `is-default` = 1 {$publish} AND `user`.`blocked` = 0 {$order} LIMIT %d , %d ", 0, 9); $tpl = get_markup_template('ch_directory_item.tpl'); if (count($r)) { $aside['$lastusers_title'] = t('Last users'); $aside['$lastusers_items'] = array(); foreach ($r as $rr) { $profile_link = $a->get_baseurl() . '/profile/' . (strlen($rr['nickname']) ? $rr['nickname'] : $rr['profile_uid']); $entry = replace_macros($tpl, array('$id' => $rr['id'], '$profile_link' => $profile_link, '$photo' => $a->get_cached_avatar_image($rr['thumb']), '$alt_text' => $rr['name'])); $aside['$lastusers_items'][] = $entry; } } } //right_aside FIND FRIENDS if ($show_friends and local_user()) { $nv = array(); $nv['title'] = array("", t('Find Friends'), "", ""); $nv['directory'] = array('directory', t('Local Directory'), "", ""); $nv['global_directory'] = array(get_server(), t('Global Directory'), "", ""); $nv['match'] = array('match', t('Similar Interests'), "", ""); $nv['suggest'] = array('suggest', t('Friend Suggestions'), "", ""); $nv['invite'] = array('invite', t('Invite Friends'), "", ""); $nv['search'] = '<form name="simple_bar" method="get" action="' . $a->get_baseurl() . '/dirfind"> <span class="sbox_l"></span> <span class="sbox"> <input type="text" name="search" size="13" maxlength="50"> </span> <span class="sbox_r" id="srch_clear"></span>'; $aside['$nv'] = $nv; } //Community_Pages at right_aside if ($show_pages and local_user()) { require_once 'include/forums.php'; if (x($_GET['cid']) && intval($_GET['cid']) != 0) { $cid = $_GET['cid']; } //sort by last updated item $lastitem = true; $contacts = get_forumlist($a->user['uid'], true, $lastitem, true); $total = count($contacts); $visible_forums = 10; if (count($contacts)) { $id = 0; foreach ($contacts as $contact) { $selected = $cid == $contact['id'] ? ' forum-selected' : ''; $entry = array('url' => z_root() . '/network?f=&cid=' . $contact['id'], 'external_url' => z_root() . '/redir/' . $contact['id'], 'name' => $contact['name'], 'cid' => $contact['id'], 'selected' => $selected, 'micro' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO), 'id' => ++$id); $entries[] = $entry; } $tpl = get_markup_template('widget_forumlist_right.tpl'); $page .= replace_macros($tpl, array('$title' => t('Forums'), '$forums' => $entries, '$link_desc' => t('External link to forum'), '$total' => $total, '$visible_forums' => $visible_forums, '$showmore' => t('show more'))); $aside['$page'] = $page; } } //END Community Page //helpers if ($show_helpers) { $r = array(); $helperlist = get_config("vier", "helperlist"); $helpers = explode(",", $helperlist); if ($helpers) { $query = ""; foreach ($helpers as $index => $helper) { if ($query != "") { $query .= ","; } $query .= "'" . dbesc(normalise_link(trim($helper))) . "'"; } $r = q("SELECT `url`, `name` FROM `gcontact` WHERE `nurl` IN (%s)", $query); } foreach ($r as $index => $helper) { $r[$index]["url"] = zrl($helper["url"]); } $r[] = array("url" => "help/Quick-Start-guide", "name" => t("Quick Start")); $tpl = get_markup_template('ch_helpers.tpl'); if ($r) { $helpers = array(); $helpers['title'] = array("", t('Help'), "", ""); $aside['$helpers_items'] = array(); foreach ($r as $rr) { $entry = replace_macros($tpl, array('$url' => $rr['url'], '$title' => $rr['name'])); $aside['$helpers_items'][] = $entry; } $aside['$helpers'] = $helpers; } } //end helpers //connectable services if ($show_services) { $r = array(); if (plugin_enabled("appnet")) { $r[] = array("photo" => "images/appnet.png", "name" => "App.net"); } if (plugin_enabled("buffer")) { $r[] = array("photo" => "images/buffer.png", "name" => "Buffer"); } if (plugin_enabled("blogger")) { $r[] = array("photo" => "images/blogger.png", "name" => "Blogger"); } if (plugin_enabled("dwpost")) { $r[] = array("photo" => "images/dreamwidth.png", "name" => "Dreamwidth"); } if (plugin_enabled("fbpost")) { $r[] = array("photo" => "images/facebook.png", "name" => "Facebook"); } if (plugin_enabled("ifttt")) { $r[] = array("photo" => "addon/ifttt/ifttt.png", "name" => "IFTTT"); } if (plugin_enabled("statusnet")) { $r[] = array("photo" => "images/gnusocial.png", "name" => "GNU Social"); } if (plugin_enabled("gpluspost")) { $r[] = array("photo" => "images/googleplus.png", "name" => "Google+"); } //if (plugin_enabled("ijpost")) // $r[] = array("photo" => "images/", "name" => ""); if (plugin_enabled("libertree")) { $r[] = array("photo" => "images/libertree.png", "name" => "Libertree"); } //if (plugin_enabled("ljpost")) // $r[] = array("photo" => "images/", "name" => ""); if (plugin_enabled("pumpio")) { $r[] = array("photo" => "images/pumpio.png", "name" => "pump.io"); } if (plugin_enabled("tumblr")) { $r[] = array("photo" => "images/tumblr.png", "name" => "Tumblr"); } if (plugin_enabled("twitter")) { $r[] = array("photo" => "images/twitter.png", "name" => "Twitter"); } if (plugin_enabled("wppost")) { $r[] = array("photo" => "images/wordpress.png", "name" => "Wordpress"); } if (function_exists("imap_open") and !get_config("system", "imap_disabled") and !get_config("system", "dfrn_only")) { $r[] = array("photo" => "images/mail.png", "name" => "E-Mail"); } $tpl = get_markup_template('ch_connectors.tpl'); if (count($r)) { $con_services = array(); $con_services['title'] = array("", t('Connect Services'), "", ""); $aside['$con_services'] = $con_services; foreach ($r as $rr) { $entry = replace_macros($tpl, array('$url' => $url, '$photo' => $rr['photo'], '$alt_text' => $rr['name'])); $aside['$connector_items'][] = $entry; } } } //end connectable services //print right_aside $tpl = get_markup_template('communityhome.tpl'); $a->page['right_aside'] = replace_macros($tpl, $aside); }