function wallmessage_content(&$a) { if (!get_my_url()) { notice(t('Permission denied.') . EOL); return; } $recipient = $a->argc > 1 ? $a->argv[1] : ''; if (!$recipient) { notice(t('No recipient.') . EOL); return; } $r = q("select * from user where nickname = '%s' limit 1", dbesc($recipient)); if (!count($r)) { notice(t('No recipient.') . EOL); logger('wallmessage: no recipient'); return; } $user = $r[0]; if (!intval($user['unkmail'])) { notice(t('Permission denied.') . EOL); return; } $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1", intval($user['uid'])); if ($r[0]['total'] > $user['cntunkmail']) { notice(sprintf(t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']))); return; } $tpl = get_markup_template('wallmsg-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$editselect' => '/(profile-jot-text|prvmail-text)/', '$nickname' => $user['nickname'], '$linkurl' => t('Please enter a link URL:'))); $tpl = get_markup_template('wallmessage.tpl'); $o .= replace_macros($tpl, array('$header' => t('Send Private Message'), '$subheader' => sprintf(t('If you wish for %s to respond, please check that the privacy settings on your site allow private mail from unknown senders.'), $user['username']), '$to' => t('To:'), '$subject' => t('Subject:'), '$recipname' => $user['username'], '$nickname' => $user['nickname'], '$subjtxt' => x($_REQUEST, 'subject') ? strip_tags($_REQUEST['subject']) : '', '$text' => x($_REQUEST, 'body') ? escape_tags(htmlspecialchars($_REQUEST['body'])) : '', '$readonly' => '', '$yourmessage' => t('Your message:'), '$select' => $select, '$parent' => '', '$upload' => t('Upload photo'), '$insert' => t('Insert web link'), '$wait' => t('Please wait'))); return $o; }
/** * @brief Adds a zid parameter to a url. * * @param string $s * The url to accept the zid * @param boolean $address * $address to use instead of session environment * @return string * * @hooks 'zid' * string url - url to accept zid * string zid - urlencoded zid * string result - the return string we calculated, change it if you want to return something else */ function zid($s, $address = '') { if (!strlen($s) || strpos($s, 'zid=')) { return $s; } $has_params = strpos($s, '?') ? true : false; $num_slashes = substr_count($s, '/'); if (!$has_params) { $has_params = strpos($s, '&') ? true : false; } $achar = strpos($s, '?') ? '&' : '?'; $mine = get_my_url(); $myaddr = $address ? $address : get_my_address(); /** @FIXME checking against our own channel url is no longer reliable. We may have a lot * of urls attached to out channel. Should probably match against our site, since we * will not need to remote authenticate on our own site anyway. */ if ($mine && $myaddr && !link_compare($mine, $s)) { $zurl = $s . ($num_slashes >= 3 ? '' : '/') . $achar . 'zid=' . urlencode($myaddr); } else { $zurl = $s; } $arr = array('url' => $s, 'zid' => urlencode($myaddr), 'result' => $zurl); call_hooks('zid', $arr); return $arr['result']; }
function nav(&$a) { /** * * Build page header and site navigation bars * */ $ssl_state = local_user() ? true : false; if (!x($a->page, 'nav')) { $a->page['nav'] = ''; } /** * Placeholder div for popup panel */ $a->page['nav'] .= '<div id="panel" style="display: none;"></div>'; /** * * Our network is distributed, and as you visit friends some of the * sites look exactly the same - it isn't always easy to know where you are. * Display the current site location as a navigation aid. * */ $myident = is_array($a->user) && isset($a->user['nickname']) ? $a->user['nickname'] . '@' : ''; $sitelocation = $myident . substr($a->get_baseurl($ssl_state), strpos($a->get_baseurl($ssl_state), '//') + 2); // nav links: array of array('href', 'text', 'extra css classes', 'title') $nav = array(); /** * Display login or logout */ $nav['usermenu'] = array(); $userinfo = null; if (local_user()) { $nav['logout'] = array('logout', t('Logout'), "", t('End this session')); // user menu $nav['usermenu'][] = array('profile/' . $a->user['nickname'], t('Status'), "", t('Your posts and conversations')); $nav['usermenu'][] = array('profile/' . $a->user['nickname'] . '?tab=profile', t('Profile'), "", t('Your profile page')); $nav['usermenu'][] = array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos')); $nav['usermenu'][] = array('events/', t('Events'), "", t('Your events')); $nav['usermenu'][] = array('notes/', t('Personal notes'), "", t('Your personal photos')); // user info $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid'])); $userinfo = array('icon' => count($r) ? $r[0]['micro'] : $a->get_baseurl($ssl_state) . "/images/person-48.jpg", 'name' => $a->user['username']); } else { $nav['login'] = array('login', t('Login'), $a->module == 'login' ? 'selected' : '', t('Sign in')); } /** * "Home" should also take you home from an authenticated remote profile connection */ $homelink = get_my_url(); if (!$homelink) { $homelink = x($_SESSION, 'visitor_home') ? $_SESSION['visitor_home'] : ''; } if ($a->module != 'home' && !local_user()) { $nav['home'] = array($homelink, t('Home'), "", t('Home Page')); } if ($a->config['register_policy'] == REGISTER_OPEN && !local_user() && !remote_user()) { $nav['register'] = array('register', t('Register'), "", t('Create an account')); } $help_url = $a->get_baseurl($ssl_state) . '/help'; if (!get_config('system', 'hide_help')) { $nav['help'] = array($help_url, t('Help'), "", t('Help and documentation')); } if (count($a->apps) > 0) { $nav['apps'] = array('apps', t('Apps'), "", t('Addon applications, utilities, games')); } $nav['search'] = array('search', t('Search'), "", t('Search site content')); $gdirpath = 'directory'; if (strlen(get_config('system', 'singleuser'))) { $gdir = dirname(get_config('system', 'directory_submit_url')); if (strlen($gdir)) { $gdirpath = $gdir; } } elseif (!get_config('system', 'no_community_page')) { $nav['community'] = array('community', t('Community'), "", t('Conversations on this site')); } $nav['directory'] = array($gdirpath, t('Directory'), "", t('People directory')); /** * * The following nav links are only show to logged in users * */ if (local_user()) { $nav['network'] = array('network', t('Network'), "", t('Conversations from your friends')); $nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations')); /* only show friend requests for normal pages. Other page types have automatic friendship. */ if ($_SESSION['page_flags'] == PAGE_NORMAL || $_SESSION['page_flags'] == PAGE_PRVGROUP) { $nav['introductions'] = array('notifications/intros', t('Introductions'), "", t('Friend Requests')); $nav['notifications'] = array('notifications', t('Notifications'), "", t('Notifications')); $nav['notifications']['all'] = array('notifications/system', t('See all notifications'), "", ""); $nav['notifications']['mark'] = array('', t('Mark all system notifications seen'), '', ''); } $nav['messages'] = array('message', t('Messages'), "", t('Private mail')); $nav['messages']['inbox'] = array('message', t('Inbox'), "", t('Inbox')); $nav['messages']['outbox'] = array('message/sent', t('Outbox'), "", t('Outbox')); $nav['messages']['new'] = array('message/new', t('New Message'), "", t('New Message')); if (is_array($a->identities) && count($a->identities) > 1) { $nav['manage'] = array('manage', t('Manage'), "", t('Manage other pages')); } $nav['settings'] = array('settings', t('Settings'), "", t('Account settings')); $nav['profiles'] = array('profiles', t('Profiles'), "", t('Manage/edit profiles')); $nav['contacts'] = array('contacts', t('Contacts'), "", t('Manage/edit friends and contacts')); } /** * Admin page */ if (is_site_admin()) { $nav['admin'] = array('admin/', t('Admin'), "", t('Site setup and configuration')); } /** * * Provide a banner/logo/whatever * */ $banner = get_config('system', 'banner'); if ($banner === false) { $banner .= '<a href="http://friendica.com"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="http://friendica.com">Friendica</a></span>'; } $tpl = get_markup_template('nav.tpl'); $a->page['nav'] .= replace_macros($tpl, array('$langselector' => lang_selector(), '$sitelocation' => $sitelocation, '$nav' => $nav, '$banner' => $banner, '$emptynotifications' => t('Nothing new here'), '$userinfo' => $userinfo, '$sel' => $a->nav_sel, '$apps' => $a->apps)); call_hooks('page_header', $a->page['nav']); }
function zrl($s, $force = false) { if (!strlen($s)) { return $s; } if (!strpos($s, '/profile/') && !$force) { return $s; } if ($force && substr($s, -1, 1) !== '/') { $s = $s . '/'; } $achar = strpos($s, '?') ? '&' : '?'; $mine = get_my_url(); if ($mine and !link_compare($mine, $s)) { return $s . $achar . 'zrl=' . urlencode($mine); } return $s; }
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; }
/** @file */ function nav(&$a) { /** * * Build page header and site navigation bars * */ if (!x($a->page, 'nav')) { $a->page['nav'] = ''; } $base = z_root(); $a->page['htmlhead'] .= <<<EOT <script>\$(document).ready(function() { \t\$("#nav-search-text").search_autocomplete('{$base}/acl'); }); </script> EOT; if (local_channel()) { $channel = $a->get_channel(); $observer = $a->get_observer(); $prof = q("select id from profile where uid = %d and is_default = 1", intval($channel['channel_id'])); $chans = q("select channel_name, channel_id from channel where channel_account_id = %d and not ( channel_pageflags & %d )>0 order by channel_name ", intval(get_account_id()), intval(PAGE_REMOVED)); } elseif (remote_channel()) { $observer = $a->get_observer(); } $myident = $channel ? $channel['xchan_addr'] : ''; $sitelocation = $myident ? $myident : $a->get_hostname(); /** * * Provide a banner/logo/whatever * */ $banner = get_config('system', 'banner'); if ($banner === false) { $banner = get_config('system', 'sitename'); } $a->page['header'] .= replace_macros(get_markup_template('hdr.tpl'), array('$baseurl' => $a->get_baseurl(), '$sitelocation' => $sitelocation, '$banner' => $banner)); // nav links: array of array('href', 'text', 'extra css classes', 'title') $nav = array(); /** * Display login or logout */ $nav['usermenu'] = array(); $userinfo = null; $nav['loginmenu'] = array(); if (local_channel()) { if ($chans && count($chans) > 1 && feature_enabled(local_channel(), 'nav_channel_select')) { $nav['channels'] = $chans; } $nav['logout'] = array('logout', t('Logout'), "", t('End this session'), 'logout_nav_btn'); // user menu $nav['usermenu'][] = array('channel/' . $channel['channel_address'], t('Home'), "", t('Your posts and conversations'), 'channel_nav_btn'); $nav['usermenu'][] = array('profile/' . $channel['channel_address'], t('View Profile'), "", t('Your profile page'), 'profile_nav_btn'); if (feature_enabled(local_channel(), 'multi_profiles')) { $nav['usermenu'][] = array('profiles', t('Edit Profiles'), "", t('Manage/Edit profiles'), 'profiles_nav_btn'); } else { $nav['usermenu'][] = array('profiles/' . $prof[0]['id'], t('Edit Profile'), "", t('Edit your profile'), 'profiles_nav_btn'); } $nav['usermenu'][] = array('photos/' . $channel['channel_address'], t('Photos'), "", t('Your photos'), 'photos_nav_btn'); $nav['usermenu'][] = array('cloud/' . $channel['channel_address'], t('Files'), "", t('Your files'), 'cloud_nav_btn'); require_once 'include/chat.php'; $has_chats = chatroom_list_count(local_channel()); if ($has_chats) { $nav['usermenu'][] = array('chat/' . $channel['channel_address'], t('Chat'), "", t('Your chatrooms'), 'chat_nav_btn'); } require_once 'include/menu.php'; $has_bookmarks = menu_list_count(local_channel(), '', MENU_BOOKMARK) + menu_list_count(local_channel(), '', MENU_SYSTEM | MENU_BOOKMARK); if ($has_bookmarks) { $nav['usermenu'][] = array('bookmarks', t('Bookmarks'), "", t('Your bookmarks'), 'bookmarks_nav_btn'); } if (feature_enabled($channel['channel_id'], 'webpages')) { $nav['usermenu'][] = array('webpages/' . $channel['channel_address'], t('Webpages'), "", t('Your webpages'), 'webpages_nav_btn'); } } else { if (!get_account_id()) { $nav['loginmenu'][] = array('login', t('Login'), '', t('Sign in'), 'login_nav_btn'); } else { $nav['alogout'] = array('logout', t('Logout'), "", t('End this session'), 'logout_nav_btn'); } } if ($observer) { $userinfo = array('icon' => $observer['xchan_photo_m'], 'name' => $observer['xchan_addr']); } if ($observer) { $nav['lock'] = array('logout', '', 'lock', sprintf(t('%s - click to logout'), $observer['xchan_addr'])); } else { $nav['loginmenu'][] = array('rmagic', t('Remote authentication'), '', t('Click to authenticate to your home hub'), 'rmagic_nav_btn'); } /** * "Home" should also take you home from an authenticated remote profile connection */ $homelink = get_my_url(); if (!$homelink) { $observer = $a->get_observer(); $homelink = $observer ? $observer['xchan_url'] : ''; } if ($a->module != 'home' && !local_channel()) { $nav['home'] = array($homelink, t('Home'), "", t('Home Page'), 'home_nav_btn'); } if ($a->config['system']['register_policy'] == REGISTER_OPEN && !local_channel() && !remote_channel()) { $nav['register'] = array('register', t('Register'), "", t('Create an account'), 'register_nav_btn'); } $help_url = z_root() . '/help?f=&cmd=' . $a->cmd; if (!get_config('system', 'hide_help')) { $nav['help'] = array($help_url, t('Help'), "", t('Help and documentation'), 'help_nav_btn'); } $nav['apps'] = array('apps', t('Apps'), "", t('Applications, utilities, links, games'), 'apps_nav_btn'); $nav['search'] = array('search', t('Search'), "", t('Search site content')); $nav['directory'] = array('directory', t('Directory'), "", t('Channel Directory'), 'directory_nav_btn'); /** * * The following nav links are only show to logged in users * */ if (local_channel()) { $nav['network'] = array('network', t('Matrix'), "", t('Your matrix'), 'network_nav_btn'); $nav['network']['mark'] = array('', t('Mark all matrix notifications seen'), '', ''); $nav['home'] = array('channel/' . $channel['channel_address'], t('Channel Home'), "", t('Channel home'), 'home_nav_btn'); $nav['home']['mark'] = array('', t('Mark all channel notifications seen'), '', ''); $nav['intros'] = array('connections/ifpending', t('Connections'), "", t('Connections'), 'connections_nav_btn'); $nav['notifications'] = array('notifications/system', t('Notices'), "", t('Notifications'), 'notifications_nav_btn'); $nav['notifications']['all'] = array('notifications/system', t('See all notifications'), "", ""); $nav['notifications']['mark'] = array('', t('Mark all system notifications seen'), '', ''); $nav['messages'] = array('message', t('Mail'), "", t('Private mail'), 'mail_nav_btn'); $nav['messages']['all'] = array('message', t('See all private messages'), "", ""); $nav['messages']['mark'] = array('', t('Mark all private messages seen'), '', ''); $nav['messages']['inbox'] = array('message', t('Inbox'), "", t('Inbox')); $nav['messages']['outbox'] = array('message/sent', t('Outbox'), "", t('Outbox')); $nav['messages']['new'] = array('mail/new', t('New Message'), "", t('New Message')); $nav['all_events'] = array('events', t('Events'), "", t('Event Calendar'), 'events_nav_btn'); $nav['all_events']['all'] = array('events', t('See all events'), "", ""); $nav['all_events']['mark'] = array('', t('Mark all events seen'), '', ''); $nav['manage'] = array('manage', t('Channel Manager'), "", t('Manage Your Channels'), 'manage_nav_btn'); $nav['settings'] = array('settings', t('Settings'), "", t('Account/Channel Settings'), 'settings_nav_btn'); } /** * Admin page */ if (is_site_admin()) { $nav['admin'] = array('admin/', t('Admin'), "", t('Site Setup and Configuration'), 'admin_nav_btn'); } /** * * Provide a banner/logo/whatever * */ $banner = get_config('system', 'banner'); if ($banner === false) { $banner = get_config('system', 'sitename'); } $x = array('nav' => $nav, 'usermenu' => $userinfo); call_hooks('nav', $x); // Not sure the best place to put this on the page. So I'm implementing it but leaving it // turned off until somebody discovers this and figures out a good location for it. $powered_by = ''; // $powered_by = '<strong>red<img class="smiley" src="' . $a->get_baseurl() . '/images/rm-16.png" alt="r#" />matrix</strong>'; $tpl = get_markup_template('nav.tpl'); $a->page['nav'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(), '$sitelocation' => $sitelocation, '$nav' => $x['nav'], '$banner' => $banner, '$emptynotifications' => t('Loading...'), '$userinfo' => $x['usermenu'], '$localuser' => local_channel(), '$sel' => $a->nav_sel, '$powered_by' => $powered_by, '$help' => t('@name, #tag, content'), '$pleasewait' => t('Please wait...'))); call_hooks('page_header', $a->page['nav']); }
function common_friends_visitor_widget($profile_uid) { $a = get_app(); if (local_user() == $profile_uid) { return; } $cid = $zcid = 0; if (is_array($_SESSION['remote'])) { foreach ($_SESSION['remote'] as $visitor) { if ($visitor['uid'] == $profile_uid) { $cid = $visitor['cid']; break; } } } 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; } require_once 'include/socgraph.php'; if ($cid) { $t = count_common_friends($profile_uid, $cid); } else { $t = count_common_friends_zcid($profile_uid, $zcid); } if (!$t) { return; } if ($cid) { $r = common_friends($profile_uid, $cid, 0, 5, true); } else { $r = common_friends_zcid($profile_uid, $zcid, 0, 5, true); } return replace_macros(get_markup_template('remote_friends_common.tpl'), array('$desc' => sprintf(tt("%d contact in common", "%d contacts in common", $t), $t), '$base' => $a->get_baseurl(), '$uid' => $profile_uid, '$cid' => $cid ? $cid : '0', '$linkmore' => $t > 5 ? 'true' : '', '$more' => t('show more'), '$items' => $r)); }
/** @file */ function nav(&$a) { /** * * Build page header and site navigation bars * */ if (!x($a->page, 'nav')) { $a->page['nav'] = ''; } $base = z_root(); $a->page['htmlhead'] .= <<<EOT <script>\$(document).ready(function() { var a; a = \$("#nav-search-text").autocomplete({ serviceUrl: '{$base}/acl', minChars: 2, width: 250, id: 'nav-search-text-ac', }); a.setOptions({ autoSubmit: true, params: { type: 'x' }}); }); </script> EOT; if (local_user()) { $channel = $a->get_channel(); $observer = $a->get_observer(); $prof = q("select id from profile where uid = %d and is_default = 1", intval($channel['channel_id'])); $chans = q("select channel_name, channel_id from channel where channel_account_id = %d and not ( channel_pageflags & %d ) order by channel_name ", intval(get_account_id()), intval(PAGE_REMOVED)); } elseif (remote_user()) { $observer = $a->get_observer(); } $myident = $channel ? $channel['xchan_addr'] : ''; $sitelocation = $myident ? $myident : $a->get_hostname(); /** * * Provide a banner/logo/whatever * */ $banner = get_config('system', 'banner'); if ($banner === false) { $banner = get_config('system', 'sitename'); } $a->page['header'] .= replace_macros(get_markup_template('hdr.tpl'), array('$baseurl' => $a->get_baseurl(), '$sitelocation' => $sitelocation, '$banner' => $banner)); // nav links: array of array('href', 'text', 'extra css classes', 'title') $nav = array(); /** * Display login or logout */ $nav['usermenu'] = array(); $userinfo = null; if (local_user()) { if ($chans && count($chans) > 1 && feature_enabled(local_user(), 'nav_channel_select')) { $nav['channels'] = $chans; } $nav['logout'] = array('logout', t('Logout'), "", t('End this session')); // user menu $nav['usermenu'][] = array('channel/' . $channel['channel_address'], t('Home'), "", t('Your posts and conversations')); $nav['usermenu'][] = array('profile/' . $channel['channel_address'], t('View Profile'), "", t('Your profile page')); if (feature_enabled(local_user(), 'multi_profiles')) { $nav['usermenu'][] = array('profiles', t('Edit Profiles'), "", t('Manage/Edit profiles')); } else { $nav['usermenu'][] = array('profiles/' . $prof[0]['id'], t('Edit Profile'), "", t('Edit your profile')); } $nav['usermenu'][] = array('photos/' . $channel['channel_address'], t('Photos'), "", t('Your photos')); $nav['usermenu'][] = array('cloud/' . $channel['channel_address'], t('Files'), "", t('Your files')); require_once 'include/chat.php'; $chats = chatroom_list(local_user()); if (count($chats)) { $nav['usermenu'][] = array('chat/' . $channel['channel_address'], t('Chat'), "", t('Your chatrooms')); } $nav['usermenu'][] = array('bookmarks', t('Bookmarks'), "", t('Your bookmarks')); if (feature_enabled($channel['channel_id'], 'webpages')) { $nav['usermenu'][] = array('webpages/' . $channel['channel_address'], t('Webpages'), "", t('Your webpages')); } } else { if (!get_account_id()) { $nav['login'] = array('login', t('Login'), $a->module == 'login' ? 'selected' : '', t('Sign in')); } else { $nav['alogout'] = array('logout', t('Logout'), "", t('End this session')); } } if ($observer) { $userinfo = array('icon' => $observer['xchan_photo_m'], 'name' => $observer['xchan_addr']); } if ($observer) { $nav['locked'] = true; $nav['lock'] = array('logout', '', 'lock', sprintf(t('%s - click to logout'), $observer['xchan_addr'])); } else { $nav['locked'] = false; $nav['lock'] = array('rmagic', '', 'unlock', t('Click to authenticate to your home hub')); } /** * "Home" should also take you home from an authenticated remote profile connection */ $homelink = get_my_url(); if (!$homelink) { $observer = $a->get_observer(); $homelink = $observer ? $observer['xchan_url'] : ''; } if ($a->module != 'home' && !local_user()) { $nav['home'] = array($homelink, t('Home'), "", t('Home Page')); } if ($a->config['system']['register_policy'] == REGISTER_OPEN && !local_user() && !remote_user()) { $nav['register'] = array('register', t('Register'), "", t('Create an account')); } $help_url = z_root() . '/help?f=&cmd=' . $a->cmd; if (!get_config('system', 'hide_help')) { $nav['help'] = array($help_url, t('Help'), "", t('Help and documentation')); } $nav['apps'] = array('apps', t('Apps'), "", t('Applications, utilities, links, games')); $nav['search'] = array('search', t('Search'), "", t('Search site content')); $nav['directory'] = array('directory', t('Directory'), "", t('Channel Locator')); /** * * The following nav links are only show to logged in users * */ if (local_user()) { $nav['network'] = array('network', t('Matrix'), "", t('Your matrix')); $nav['network']['mark'] = array('', t('Mark all matrix notifications seen'), '', ''); $nav['home'] = array('channel/' . $channel['channel_address'], t('Channel Home'), "", t('Channel home')); $nav['home']['mark'] = array('', t('Mark all channel notifications seen'), '', ''); $nav['intros'] = array('connections/ifpending', t('Connections'), "", t('Connections')); $nav['notifications'] = array('notifications/system', t('Notices'), "", t('Notifications')); $nav['notifications']['all'] = array('notifications/system', t('See all notifications'), "", ""); $nav['notifications']['mark'] = array('', t('Mark all system notifications seen'), '', ''); $nav['messages'] = array('message', t('Mail'), "", t('Private mail')); $nav['messages']['all'] = array('message', t('See all private messages'), "", ""); $nav['messages']['mark'] = array('', t('Mark all private messages seen'), '', ''); $nav['messages']['inbox'] = array('message', t('Inbox'), "", t('Inbox')); $nav['messages']['outbox'] = array('message/sent', t('Outbox'), "", t('Outbox')); $nav['messages']['new'] = array('mail/new', t('New Message'), "", t('New Message')); $nav['all_events'] = array('events', t('Events'), "", t('Event Calendar')); $nav['all_events']['all'] = array('events', t('See all events'), "", ""); $nav['all_events']['mark'] = array('', t('Mark all events seen'), '', ''); $nav['manage'] = array('manage', t('Channel Manager'), "", t('Manage Your Channels')); $nav['settings'] = array('settings', t('Settings'), "", t('Account/Channel Settings')); } /** * Admin page */ if (is_site_admin()) { $nav['admin'] = array('admin/', t('Admin'), "", t('Site Setup and Configuration')); } /** * * Provide a banner/logo/whatever * */ $banner = get_config('system', 'banner'); if ($banner === false) { $banner = get_config('system', 'sitename'); } $x = array('nav' => $nav, 'usermenu' => $userinfo); call_hooks('nav', $x); $tpl = get_markup_template('nav.tpl'); $a->page['nav'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(), '$sitelocation' => $sitelocation, '$nav' => $x['nav'], '$banner' => $banner, '$emptynotifications' => t('Nothing new here'), '$userinfo' => $x['usermenu'], '$localuser' => local_user(), '$sel' => $a->nav_sel, '$pleasewait' => t('Please wait...'))); call_hooks('page_header', $a->page['nav']); }
function nav_info(&$a) { $ssl_state = local_user() ? true : false; /** * * Our network is distributed, and as you visit friends some of the * sites look exactly the same - it isn't always easy to know where you are. * Display the current site location as a navigation aid. * */ $myident = is_array($a->user) && isset($a->user['nickname']) ? $a->user['nickname'] . '@' : ''; $sitelocation = $myident . substr($a->get_baseurl($ssl_state), strpos($a->get_baseurl($ssl_state), '//') + 2); // nav links: array of array('href', 'text', 'extra css classes', 'title') $nav = array(); /** * Display login or logout */ $nav['usermenu'] = array(); $userinfo = null; if (local_user()) { $nav['logout'] = array('logout', t('Logout'), "", t('End this session')); // user menu $nav['usermenu'][] = array('profile/' . $a->user['nickname'], t('Status'), "", t('Your posts and conversations')); $nav['usermenu'][] = array('profile/' . $a->user['nickname'] . '?tab=profile', t('Profile'), "", t('Your profile page')); $nav['usermenu'][] = array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos')); $nav['usermenu'][] = array('videos/' . $a->user['nickname'], t('Videos'), "", t('Your videos')); $nav['usermenu'][] = array('events/', t('Events'), "", t('Your events')); $nav['usermenu'][] = array('notes/', t('Personal notes'), "", t('Your personal notes')); // user info $r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid'])); $userinfo = array('icon' => count($r) ? $a->get_cached_avatar_image($r[0]['micro']) : $a->get_baseurl($ssl_state) . "/images/person-48.jpg", 'name' => $a->user['username']); } else { $nav['login'] = array('login', t('Login'), $a->module == 'login' ? 'selected' : '', t('Sign in')); } /** * "Home" should also take you home from an authenticated remote profile connection */ $homelink = get_my_url(); if (!$homelink) { $homelink = x($_SESSION, 'visitor_home') ? $_SESSION['visitor_home'] : ''; } if ($a->module != 'home' && !local_user()) { $nav['home'] = array($homelink, t('Home'), "", t('Home Page')); } if ($a->config['register_policy'] == REGISTER_OPEN && !local_user() && !remote_user()) { $nav['register'] = array('register', t('Register'), "", t('Create an account')); } $help_url = $a->get_baseurl($ssl_state) . '/help'; if (!get_config('system', 'hide_help')) { $nav['help'] = array($help_url, t('Help'), "", t('Help and documentation')); } if (count($a->apps) > 0) { $nav['apps'] = array('apps', t('Apps'), "", t('Addon applications, utilities, games')); } $nav['search'] = array('search', t('Search'), "", t('Search site content')); $nav['searchoption'] = array(t("Full Text"), t("Tags"), t("Contacts")); if (get_config('system', 'poco_local_search')) { $nav['searchoption'][] = t("Forums"); } $gdirpath = 'directory'; if (strlen(get_config('system', 'singleuser'))) { $gdir = get_config('system', 'directory'); if (strlen($gdir)) { $gdirpath = $gdir; } } elseif (get_config('system', 'community_page_style') == CP_USERS_ON_SERVER) { $nav['community'] = array('community', t('Community'), "", t('Conversations on this site')); } elseif (get_config('system', 'community_page_style') == CP_GLOBAL_COMMUNITY) { $nav['community'] = array('community', t('Community'), "", t('Conversations on the network')); } $nav['directory'] = array($gdirpath, t('Directory'), "", t('People directory')); $nav['about'] = array('friendica', t('Information'), "", t('Information about this friendica instance')); /** * * The following nav links are only show to logged in users * */ if (local_user()) { $nav['network'] = array('network', t('Network'), "", t('Conversations from your friends')); $nav['net_reset'] = array('network/0?f=&order=comment&nets=all', t('Network Reset'), "", t('Load Network page with no filters')); $nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations')); if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_PRVGROUP))) { /* only show friend requests for normal pages. Other page types have automatic friendship. */ if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_PRVGROUP))) { $nav['introductions'] = array('notifications/intros', t('Introductions'), "", t('Friend Requests')); } if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE))) { $nav['notifications'] = array('notifications', t('Notifications'), "", t('Notifications')); $nav['notifications']['all'] = array('notifications/system', t('See all notifications'), "", ""); $nav['notifications']['mark'] = array('', t('Mark all system notifications seen'), '', ''); } } $nav['messages'] = array('message', t('Messages'), "", t('Private mail')); $nav['messages']['inbox'] = array('message', t('Inbox'), "", t('Inbox')); $nav['messages']['outbox'] = array('message/sent', t('Outbox'), "", t('Outbox')); $nav['messages']['new'] = array('message/new', t('New Message'), "", t('New Message')); if (is_array($a->identities) && count($a->identities) > 1) { $nav['manage'] = array('manage', t('Manage'), "", t('Manage other pages')); } $nav['delegations'] = array('delegate', t('Delegations'), "", t('Delegate Page Management')); $nav['settings'] = array('settings', t('Settings'), "", t('Account settings')); if (feature_enabled(local_user(), 'multi_profiles')) { $nav['profiles'] = array('profiles', t('Profiles'), "", t('Manage/Edit Profiles')); } $nav['contacts'] = array('contacts', t('Contacts'), "", t('Manage/edit friends and contacts')); } /** * Admin page */ if (is_site_admin()) { $nav['admin'] = array('admin/', t('Admin'), "", t('Site setup and configuration')); } $nav['navigation'] = array('navigation/', t('Navigation'), "", t('Site map')); /** * * Provide a banner/logo/whatever * */ $banner = get_config('system', 'banner'); if ($banner === false) { $banner .= '<a href="http://friendica.com"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="http://friendica.com">Friendica</a></span>'; } call_hooks('nav_info', $nav); return array('sitelocation' => $sitelocation, 'nav' => $nav, 'banner' => $banner, 'userinfo' => $userinfo); }
/** * @brief Construct remote nav menu * * It creates a remote baseurl form $_SESSION for remote users and friendica * visitors. This url will be added to some of the nav links. With this behaviour * the user will come back to her/his own pages on his/her friendica server. * Not all possible links are available (notifications, administrator, manage, * notes aren't available because we have no way the check remote permissions).. * Some links will point to the local pages because the user would expect * local page (these pages are: search, community, help, apps, directory). * * @param app $a The App class * @param array $nav The original nav menu */ function frio_remote_nav($a, &$nav) { // get the homelink from $_XSESSION $homelink = get_my_url(); if (!$homelink) { $homelink = x($_SESSION, 'visitor_home') ? $_SESSION['visitor_home'] : ''; } // split up the url in it's parts (protocol,domain/directory, /profile/, nickname // I'm not familiar with regex, so someone might find a better solutionen // // E.g $homelink = 'https://friendica.domain.com/profile/mickey' should result in an array // with 0 => 'https://friendica.domain.com/profile/mickey' 1 => 'https://', // 2 => 'friendica.domain.com' 3 => '/profile/' 4 => 'mickey' // //$server_url = preg_match('/^(https?:\/\/.*?)\/profile\//2', $homelink); preg_match('/^(https?:\\/\\/)?(.*?)(\\/profile\\/)(.*)/', $homelink, $url_parts); // Construct the server url of the visitor. So we could link back to his/her own menu. // And construct a webbie (e.g. mickey@friendica.domain.com for the search in gcontact // We use the webbie for search in gcontact because we don't know if gcontact table stores // the right value if its http or https protocol if (count($url_parts)) { $server_url = $url_parts[1] . $url_parts[2]; $webbie = $url_parts[4] . '@' . $url_parts[2]; } // since $userinfo isn't available for the hook we write it to the nav array // this isn't optimal because the contact query will be done now twice if (local_user()) { // empty the server url for local user because we won't need it $server_url = ''; // user info $r = q("SELECT `micro` FROM `contact` WHERE `uid` = %d AND `self` = 1", intval($a->user['uid'])); $r[0]['photo'] = count($r) ? $a->remove_baseurl($r[0]['micro']) : "images/person-48.jpg"; $r[0]['name'] = $a->user['username']; } elseif (!local_user() && remote_user()) { $r = q("SELECT `name`, `nick`, `micro` AS `photo` FROM `contact` WHERE `id` = %d", intval(remote_user())); $nav['remote'] = t("Remote"); } elseif (get_my_url()) { $r = q("SELECT `name`, `nick`, `photo` FROM `gcontact`\n\t\t\t\tWHERE `addr` = '%s' AND `network` = 'dfrn'", dbesc($webbie)); $nav['remote'] = t("Visitor"); } if (count($r)) { $nav['userinfo'] = array('icon' => count($r) ? $r[0]['photo'] : "images/person-48.jpg", 'name' => $r[0]['name']); } if (!local_user() && !empty($server_url)) { $nav['logout'] = array($server_url . '/logout', t('Logout'), "", t('End this session')); // user menu $nav['usermenu'][] = array($server_url . '/profile/' . $a->user['nickname'], t('Status'), "", t('Your posts and conversations')); $nav['usermenu'][] = array($server_url . '/profile/' . $a->user['nickname'] . '?tab=profile', t('Profile'), "", t('Your profile page')); $nav['usermenu'][] = array($server_url . '/photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos')); $nav['usermenu'][] = array($server_url . '/videos/' . $a->user['nickname'], t('Videos'), "", t('Your videos')); $nav['usermenu'][] = array($server_url . '/events/', t('Events'), "", t('Your events')); // navbar links $nav['network'] = array($server_url . '/network', t('Network'), "", t('Conversations from your friends')); $nav['events'] = array($server_url . '/events', t('Events'), "", t('Events and Calendar')); $nav['messages'] = array($server_url . '/message', t('Messages'), "", t('Private mail')); $nav['settings'] = array($server_url . '/settings', t('Settings'), "", t('Account settings')); $nav['contacts'] = array($server_url . '/contacts', t('Contacts'), "", t('Manage/edit friends and contacts')); $nav['sitename'] = $a->config['sitename']; } }
function dfrn_request_content(&$a) { if ($a->argc != 2 || !count($a->profile)) { return ""; } // "Homecoming". Make sure we're logged in to this site as the correct user. Then offer a confirm button // to send us to the post section to record the introduction. if (x($_GET, 'dfrn_url')) { if (!local_user()) { info(t("Please login to confirm introduction.") . EOL); /* setup the return URL to come back to this page if they use openid */ $stripped = str_replace('q=', '', $a->query_string); $_SESSION['return_url'] = trim($stripped, '/'); return login(); } // Edge case, but can easily happen in the wild. This person is authenticated, // but not as the person who needs to deal with this request. if ($a->user['nickname'] != $a->argv[1]) { notice(t("Incorrect identity currently logged in. Please login to <strong>this</strong> profile.") . EOL); return login(); } $dfrn_url = notags(trim(hex2bin($_GET['dfrn_url']))); $aes_allow = x($_GET, 'aes_allow') && $_GET['aes_allow'] == 1 ? 1 : 0; $confirm_key = x($_GET, 'confirm_key') ? $_GET['confirm_key'] : ""; $tpl = get_markup_template("dfrn_req_confirm.tpl"); $o = replace_macros($tpl, array('$dfrn_url' => $dfrn_url, '$aes_allow' => $aes_allow ? '<input type="hidden" name="aes_allow" value="1" />' : "", '$hidethem' => t('Hide this contact'), '$hidechecked' => '', '$confirm_key' => $confirm_key, '$welcome' => sprintf(t('Welcome home %s.'), $a->user['username']), '$please' => sprintf(t('Please confirm your introduction/connection request to %s.'), $dfrn_url), '$submit' => t('Confirm'), '$uid' => $_SESSION['uid'], '$nickname' => $a->user['nickname'], 'dfrn_rawurl' => $_GET['dfrn_url'])); return $o; } elseif (x($_GET, 'confirm_key') && strlen($_GET['confirm_key'])) { // we are the requestee and it is now safe to send our user their introduction, // We could just unblock it, but first we have to jump through a few hoops to // send an email, or even to find out if we need to send an email. $intro = q("SELECT * FROM `intro` WHERE `hash` = '%s' LIMIT 1", dbesc($_GET['confirm_key'])); if (count($intro)) { $r = q("SELECT `contact`.*, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`\n\t\t\t\tWHERE `contact`.`id` = %d LIMIT 1", intval($intro[0]['contact-id'])); $auto_confirm = false; if (count($r)) { if ($r[0]['page-flags'] != PAGE_NORMAL && $r[0]['page-flags'] != PAGE_PRVGROUP) { $auto_confirm = true; } if (!$auto_confirm) { notification(array('type' => NOTIFY_INTRO, 'notify_flags' => $r[0]['notify-flags'], 'language' => $r[0]['language'], 'to_name' => $r[0]['username'], 'to_email' => $r[0]['email'], 'uid' => $r[0]['uid'], 'link' => $a->get_baseurl() . '/notifications/intros', 'source_name' => strlen(stripslashes($r[0]['name'])) ? stripslashes($r[0]['name']) : t('[Name Withheld]'), 'source_link' => $r[0]['url'], 'source_photo' => $r[0]['photo'], 'verb' => ACTIVITY_REQ_FRIEND, 'otype' => 'intro')); } if ($auto_confirm) { require_once 'mod/dfrn_confirm.php'; $handsfree = array('uid' => $r[0]['uid'], 'node' => $r[0]['nickname'], 'dfrn_id' => $r[0]['issued-id'], 'intro_id' => $intro[0]['id'], 'duplex' => $r[0]['page-flags'] == PAGE_FREELOVE ? 1 : 0, 'activity' => intval(get_pconfig($r[0]['uid'], 'system', 'post_newfriend'))); dfrn_confirm_post($a, $handsfree); } } if (!$auto_confirm) { // If we are auto_confirming, this record will have already been nuked // in dfrn_confirm_post() $r = q("UPDATE `intro` SET `blocked` = 0 WHERE `hash` = '%s'", dbesc($_GET['confirm_key'])); } } killme(); return; // NOTREACHED } else { /** * Normal web request. Display our user's introduction form. */ if (get_config('system', 'block_public') && !local_user() && !remote_user()) { if (!get_config('system', 'local_block')) { notice(t('Public access denied.') . EOL); return; } } /** * Try to auto-fill the profile address */ // At first look if an address was provided // Otherwise take the local address if (x($_GET, 'addr') and $_GET['addr'] != "") { $myaddr = hex2bin($_GET['addr']); } elseif (x($_GET, 'address') and $_GET['address'] != "") { $myaddr = $_GET['address']; } elseif (local_user()) { if (strlen($a->path)) { $myaddr = $a->get_baseurl() . '/profile/' . $a->user['nickname']; } else { $myaddr = $a->user['nickname'] . '@' . substr(z_root(), strpos(z_root(), '://') + 3); } } else { // last, try a zrl $myaddr = get_my_url(); } $target_addr = $a->profile['nickname'] . '@' . substr(z_root(), strpos(z_root(), '://') + 3); /** * * The auto_request form only has the profile address * because nobody is going to read the comments and * it doesn't matter if they know you or not. * */ if ($a->profile['page-flags'] == PAGE_NORMAL) { $tpl = get_markup_template('dfrn_request.tpl'); } else { $tpl = get_markup_template('auto_request.tpl'); } $page_desc .= t("Please enter your 'Identity Address' from one of the following supported communications networks:"); // see if we are allowed to have NETWORK_MAIL2 contacts $mail_disabled = function_exists('imap_open') && !get_config('system', 'imap_disabled') ? 0 : 1; if (get_config('system', 'dfrn_only')) { $mail_disabled = 1; } if (!$mail_disabled) { $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", intval($a->profile['uid'])); if (!count($r)) { $mail_disabled = 1; } } // "coming soon" is disabled for now //$emailnet = (($mail_disabled) ? '' : t("<strike>Connect as an email follower</strike> \x28Coming soon\x29")); $emailnet = ""; $invite_desc = t('If you are not yet a member of the free social web, <a href="http://dir.friendica.com/siteinfo">follow this link to find a public Friendica site and join us today</a>.'); $o .= replace_macros($tpl, array('$header' => t('Friend/Connection Request'), '$desc' => t('Examples: jojo@demo.friendica.com, http://demo.friendica.com/profile/jojo, testuser@identi.ca'), '$pls_answer' => t('Please answer the following:'), '$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'), $a->profile['name']), false, '', array(t('No'), t('Yes'))), '$add_note' => t('Add a personal note:'), '$page_desc' => $page_desc, '$friendica' => t('Friendica'), '$statusnet' => t('StatusNet/Federated Social Web'), '$diaspora' => t('Diaspora'), '$diasnote' => sprintf(t(' - please do not use this form. Instead, enter %s into your Diaspora search bar.'), $target_addr), '$your_address' => t('Your Identity Address:'), '$invite_desc' => $invite_desc, '$emailnet' => $emailnet, '$submit' => t('Submit Request'), '$cancel' => t('Cancel'), '$nickname' => $a->argv[1], '$name' => $a->profile['name'], '$myaddr' => $myaddr)); return $o; } return; // Somebody is fishing. }
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; }