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 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'] .= 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' => proxy_url($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; }
/** * @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; }
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 allfriends_content(&$a) { $o = ''; if (!local_user()) { notice(t('Permission denied.') . EOL); return; } if ($a->argc > 1) { $cid = intval($a->argv[1]); } if (!$cid) { return; } $uid = $a->user[uid]; $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval(local_user())); if (!count($c)) { return; } $a->page['aside'] = ""; profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"])); $total = count_all_friends(local_user(), $cid); if (count($total)) { $a->set_pager_total($total); } $r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']); if (!count($r)) { $o .= t('No friends to display.'); return $o; } $id = 0; foreach ($r as $rr) { //get further details of the contact $contact_details = get_contact_details_by_url($rr['url'], $uid); $photo_menu = ''; // $rr[cid] is only available for common contacts. So if the contact is a common one, use contact_photo_menu to generate the photo_menu // If the contact is not common to the user, Connect/Follow' will be added to the photo menu if ($rr[cid]) { $rr[id] = $rr[cid]; $photo_menu = contact_photo_menu($rr); } else { $connlnk = $a->get_baseurl() . '/follow/?url=' . $rr['url']; $photo_menu = array(array(t("View Profile"), zrl($rr['url']))); $photo_menu[] = array(t("Connect/Follow"), $connlnk); } $entry = array('url' => $rr['url'], 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $rr['url'], 'name' => htmlentities($rr['name']), 'thumb' => proxy_url($rr['photo'], false, PROXY_SIZE_THUMB), 'img_hover' => htmlentities($rr['name']), 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'network' => network_to_name($contact_details['network'], $contact_details['url']), 'photo_menu' => $photo_menu, 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'id' => ++$id); $entries[] = $entry; } $tab_str = contacts_tab($a, $cid, 3); $tpl = get_markup_template('viewcontact_template.tpl'); $o .= replace_macros($tpl, array('$tab_str' => $tab_str, '$contacts' => $entries, '$paginate' => paginate($a))); return $o; }
function viewcontacts_content(&$a) { require_once "mod/proxy.php"; if (get_config('system', 'block_public') && !local_user() && !remote_user()) { notice(t('Public access denied.') . EOL); return; } if (!count($a->profile) || $a->profile['hide-friends']) { notice(t('Permission denied.') . EOL); return; } $o = ""; // tabs $o .= profile_tabs($a, $is_owner, $a->data['user']['nickname']); $r = q("SELECT COUNT(*) AS `total` FROM `contact`\n\t\tWHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0\n\t\t\tAND `network` IN ('%s', '%s', '%s')", intval($a->profile['uid']), dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS)); if (count($r)) { $a->set_pager_total($r[0]['total']); } $r = q("SELECT * FROM `contact`\n\t\tWHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0\n\t\t\tAND `network` IN ('%s', '%s', '%s')\n\t\tORDER BY `name` ASC LIMIT %d, %d", intval($a->profile['uid']), dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS), intval($a->pager['start']), intval($a->pager['itemspage'])); if (!count($r)) { info(t('No contacts.') . EOL); return $o; } $contacts = array(); foreach ($r as $rr) { if ($rr['self']) { continue; } $url = $rr['url']; // route DFRN profiles through the redirect $is_owner = local_user() && $a->profile['profile_uid'] == local_user() ? true : false; if ($is_owner && $rr['network'] === NETWORK_DFRN && $rr['rel']) { $url = 'redir/' . $rr['id']; } else { $url = zrl($url); } $contact_details = get_contact_details_by_url($rr['url'], $a->profile['uid']); $contacts[] = array('id' => $rr['id'], 'img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $rr['name'], $rr['url']), 'photo_menu' => contact_photo_menu($rr), 'thumb' => proxy_url($rr['thumb'], false, PROXY_SIZE_THUMB), 'name' => htmlentities(substr($rr['name'], 0, 20)), 'username' => htmlentities($rr['name']), 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'url' => $url, 'sparkle' => '', 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $rr['url'], 'network' => network_to_name($rr['network'], $rr['url'])); } $tpl = get_markup_template("viewcontact_template.tpl"); $o .= replace_macros($tpl, array('$title' => t('Contacts'), '$contacts' => $contacts, '$paginate' => paginate($a))); return $o; }
function 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; } $r = q("SELECT COUNT(*) as `total` FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 ", intval($a->profile['uid'])); if (count($r)) { $a->set_pager_total($r[0]['total']); } $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 ORDER BY `name` ASC LIMIT %d , %d ", intval($a->profile['uid']), 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); } $contacts[] = array('id' => $rr['id'], 'img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $rr['name'], $rr['url']), 'thumb' => proxy_url($rr['thumb']), 'name' => substr($rr['name'], 0, 20), 'username' => $rr['name'], 'url' => $url, 'sparkle' => '', 'itemurl' => $rr['url'], 'network' => network_to_name($rr['network'], $rr['url'])); } $tpl = get_markup_template("viewcontact_template.tpl"); $o .= replace_macros($tpl, array('$title' => t('View Contacts'), '$contacts' => $contacts, '$paginate' => paginate($a))); return $o; }
/** * @brief Forumlist widget * * Sidebar widget to show subcribed friendica forums. If activated * in the settings, it appears at the notwork page sidebar * * @param int $uid * @param int $cid * The contact id which is used to mark a forum as "selected" * @return string */ function widget_forumlist($uid, $cid = 0) { if (!intval(feature_enabled(local_user(), 'forumlist_widget'))) { return; } $o = ''; //sort by last updated item $lastitem = true; $contacts = get_forumlist($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.tpl'); $o .= 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'))); } return $o; }
/** * Get data in a form usable by a conversation template * * Returns: * _ The data requested on success * _ false on failure */ public function get_template_data($alike, $dlike, $thread_level = 1) { require_once "mod/proxy.php"; $result = array(); $a = $this->get_app(); $item = $this->get_data(); $edited = false; if (strcmp($item['created'], $item['edited']) != 0) { $edited = array('label' => t('This entry was edited'), 'date' => datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r'), 'relative' => relative_date($item['edited'])); } $commentww = ''; $sparkle = ''; $buttons = ''; $dropping = false; $star = false; $ignore = false; $isstarred = "unstarred"; $indent = ''; $shiny = ''; $osparkle = ''; $total_children = $this->count_descendants(); $conv = $this->get_conversation(); $lock = $item['private'] == 1 || $item['uid'] == local_user() && (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) ? t('Private Message') : false; $shareable = $conv->get_profile_owner() == local_user() && $item['private'] != 1 ? true : false; if (local_user() && link_compare($a->contact['url'], $item['author-link'])) { $edpost = array($a->get_baseurl($ssl_state) . "/editpost/" . $item['id'], t("Edit")); } else { $edpost = false; } if ($this->get_data_value('uid') == local_user() || $this->is_visiting()) { $dropping = true; } $drop = array('dropping' => $dropping, 'pagedrop' => feature_enabled($conv->get_profile_owner(), 'multi_delete') ? $item['pagedrop'] : '', 'select' => t('Select'), 'delete' => t('Delete')); $filer = $conv->get_profile_owner() == local_user() ? t("save to folder") : false; $diff_author = link_compare($item['url'], $item['author-link']) ? false : true; $profile_name = strlen($item['author-name']) && $diff_author ? $item['author-name'] : $item['name']; if ($item['author-link'] && !$item['author-name']) { $profile_name = $item['author-link']; } $sp = false; $profile_link = best_link_url($item, $sp); if ($profile_link === 'mailbox') { $profile_link = ''; } if ($sp) { $sparkle = ' sparkle'; } else { $profile_link = zrl($profile_link); } $normalised = normalise_link(strlen($item['author-link']) ? $item['author-link'] : $item['url']); if ($normalised != 'mailbox' && x($a->contacts, $normalised)) { $profile_avatar = $a->contacts[$normalised]['thumb']; } else { $profile_avatar = strlen($item['author-avatar']) && $diff_author ? $item['author-avatar'] : $a->get_cached_avatar_image($this->get_data_value('thumb')); } $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); call_hooks('render_location', $locate); $location = strlen($locate['html']) ? $locate['html'] : render_location_google($locate); $searchpath = $a->get_baseurl() . "/search?tag="; $tags = array(); $hashtags = array(); $mentions = array(); /*foreach(explode(',',$item['tag']) as $tag){ $tag = trim($tag); if ($tag!="") { $t = bbcode($tag); $tags[] = $t; if($t[0] == '#') $hashtags[] = $t; elseif($t[0] == '@') $mentions[] = $t; } }*/ $like = x($alike, $item['uri']) ? format_like($alike[$item['uri']], $alike[$item['uri'] . '-l'], 'like', $item['uri']) : ''; $dislike = x($dlike, $item['uri']) ? format_like($dlike[$item['uri']], $dlike[$item['uri'] . '-l'], 'dislike', $item['uri']) : ''; /* * We should avoid doing this all the time, but it depends on the conversation mode * And the conv mode may change when we change the conv, or it changes its mode * Maybe we should establish a way to be notified about conversation changes */ $this->check_wall_to_wall(); if ($this->is_wall_to_wall() && $this->get_owner_url() == $this->get_redirect_url()) { $osparkle = ' sparkle'; } if ($this->is_toplevel()) { if ($conv->get_profile_owner() == local_user()) { $isstarred = $item['starred'] ? "starred" : "unstarred"; $star = array('do' => t("add star"), 'undo' => t("remove star"), 'toggle' => t("toggle star status"), 'classdo' => $item['starred'] ? "hidden" : "", 'classundo' => $item['starred'] ? "" : "hidden", 'starred' => t('starred')); $r = q("SELECT `ignored` FROM `thread` WHERE `uid` = %d AND `iid` = %d LIMIT 1", intval($item['uid']), intval($item['id'])); if (count($r)) { $ignore = array('do' => t("ignore thread"), 'undo' => t("unignore thread"), 'toggle' => t("toggle ignore status"), 'classdo' => $r[0]['ignored'] ? "hidden" : "", 'classundo' => $r[0]['ignored'] ? "" : "hidden", 'ignored' => t('ignored')); } $tagger = ''; if (feature_enabled($conv->get_profile_owner(), 'commtag')) { $tagger = array('add' => t("add tag"), 'class' => ""); } } } else { $indent = 'comment'; } if ($conv->is_writable()) { $buttons = array('like' => array(t("I like this (toggle)"), t("like")), 'dislike' => feature_enabled($conv->get_profile_owner(), 'dislike') ? array(t("I don't like this (toggle)"), t("dislike")) : ''); if ($shareable) { $buttons['share'] = array(t('Share this'), t('share')); } } if (strcmp(datetime_convert('UTC', 'UTC', $item['created']), datetime_convert('UTC', 'UTC', 'now - 12 hours')) > 0) { $shiny = 'shiny'; } localize_item($item); if ($item["postopts"] and !get_config("system", "suppress_language")) { //$langdata = explode(";", $item["postopts"]); //$langstr = substr($langdata[0], 5)." (".round($langdata[1]*100, 1)."%)"; $langstr = ""; if (substr($item["postopts"], 0, 5) == "lang=") { $postopts = substr($item["postopts"], 5); $languages = explode(":", $postopts); if (sizeof($languages) == 1) { $languages = array(); $languages[] = $postopts; } foreach ($languages as $language) { $langdata = explode(";", $language); if ($langstr != "") { $langstr .= ", "; } //$langstr .= $langdata[0]." (".round($langdata[1]*100, 1)."%)"; $langstr .= round($langdata[1] * 100, 1) . "% " . $langdata[0]; } } } $body = prepare_body($item, true); list($categories, $folders) = get_cats_and_terms($item); if ($a->theme['template_engine'] === 'internal') { $body_e = template_escape($body); $text_e = strip_tags(template_escape($body)); $name_e = template_escape($profile_name); $title_e = template_escape($item['title']); $location_e = template_escape($location); $owner_name_e = template_escape($this->get_owner_name()); } else { $body_e = $body; $text_e = strip_tags($body); $name_e = $profile_name; $title_e = $item['title']; $location_e = $location; $owner_name_e = $this->get_owner_name(); } // Disable features that aren't available in several networks if ($item["item_network"] != "dfrn" and isset($buttons["dislike"])) { unset($buttons["dislike"]); $tagger = ''; } if ($item["item_network"] == "feed" and isset($buttons["like"])) { unset($buttons["like"]); } if ($item["item_network"] == "mail" and isset($buttons["like"])) { unset($buttons["like"]); } if ($item["item_network"] == "dspr" and $indent == 'comment' and isset($buttons["like"])) { unset($buttons["like"]); } // Facebook can like comments - but it isn't programmed in the connector yet. if ($item["item_network"] == "face" and $indent == 'comment' and isset($buttons["like"])) { unset($buttons["like"]); } $tmp_item = array('template' => $this->get_template(), 'type' => implode("", array_slice(explode("/", $item['verb']), -1)), 'tags' => $item['tags'], 'hashtags' => $item['hashtags'], 'mentions' => $item['mentions'], 'txt_cats' => t('Categories:'), 'txt_folders' => t('Filed under:'), 'has_cats' => count($categories) ? 'true' : '', 'has_folders' => count($folders) ? 'true' : '', 'categories' => $categories, 'folders' => $folders, 'body' => $body_e, 'text' => $text_e, 'id' => $this->get_id(), 'guid' => $item['guid'], 'linktitle' => sprintf(t('View %s\'s profile @ %s'), $profile_name, strlen($item['author-link']) ? $item['author-link'] : $item['url']), 'olinktitle' => sprintf(t('View %s\'s profile @ %s'), $this->get_owner_name(), strlen($item['owner-link']) ? $item['owner-link'] : $item['url']), 'to' => t('to'), 'via' => t('via'), 'wall' => t('Wall-to-Wall'), 'vwall' => t('via Wall-To-Wall:'), 'profile_url' => $profile_link, 'item_photo_menu' => item_photo_menu($item), 'name' => $name_e, 'thumb' => proxy_url($profile_avatar), 'osparkle' => $osparkle, 'sparkle' => $sparkle, 'title' => $title_e, 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), 'ago' => $item['app'] ? sprintf(t('%s from %s'), relative_date($item['created']), $item['app']) : relative_date($item['created']), 'app' => $item['app'], 'created' => relative_date($item['created']), 'lock' => $lock, 'location' => $location_e, 'indent' => $indent, 'shiny' => $shiny, 'owner_url' => $this->get_owner_url(), 'owner_photo' => proxy_url($this->get_owner_photo()), 'owner_name' => $owner_name_e, 'plink' => get_plink($item), 'edpost' => feature_enabled($conv->get_profile_owner(), 'edit_posts') ? $edpost : '', 'isstarred' => $isstarred, 'star' => feature_enabled($conv->get_profile_owner(), 'star_posts') ? $star : '', 'ignore' => feature_enabled($conv->get_profile_owner(), 'ignore_posts') ? $ignore : '', 'tagger' => $tagger, 'filer' => feature_enabled($conv->get_profile_owner(), 'filing') ? $filer : '', 'drop' => $drop, 'vote' => $buttons, 'like' => $like, 'dislike' => $dislike, 'switchcomment' => t('Comment'), 'comment' => $this->get_comment_box($indent), 'previewing' => $conv->is_preview() ? ' preview ' : '', 'wait' => t('Please wait'), 'thread_level' => $thread_level, 'postopts' => $langstr, 'edited' => $edited, 'network' => $item["item_network"], 'network_name' => network_to_name($item['item_network'])); $arr = array('item' => $item, 'output' => $tmp_item); call_hooks('display_item', $arr); $result = $arr['output']; $result['children'] = array(); $children = $this->get_children(); $nb_children = count($children); if ($nb_children > 0) { foreach ($children as $child) { $result['children'][] = $child->get_template_data($alike, $dlike, $thread_level + 1); } // Collapse if ($nb_children > 2 || $thread_level > 1) { $result['children'][0]['comment_firstcollapsed'] = true; $result['children'][0]['num_comments'] = sprintf(tt('%d comment', '%d comments', $total_children), $total_children); $result['children'][0]['hidden_comments_num'] = $total_children; $result['children'][0]['hidden_comments_text'] = tt('comment', 'comments', $total_children); $result['children'][0]['hide_text'] = t('show more'); if ($thread_level > 1) { $result['children'][$nb_children - 1]['comment_lastcollapsed'] = true; } else { $result['children'][$nb_children - 3]['comment_lastcollapsed'] = true; } } } if ($this->is_toplevel()) { $result['total_comments_num'] = "{$total_children}"; $result['total_comments_text'] = tt('comment', 'comments', $total_children); } $result['private'] = $item['private']; $result['toplevel'] = $this->is_toplevel() ? 'toplevel_item' : ''; if ($this->is_threaded()) { $result['flatten'] = false; $result['threaded'] = true; } else { $result['flatten'] = true; $result['threaded'] = false; } return $result; }
function display_fetchauthor($a, $item) { require_once "mod/proxy.php"; require_once "include/bbcode.php"; $profiledata = array(); $profiledata["uid"] = -1; $profiledata["nickname"] = $item["author-name"]; $profiledata["name"] = $item["author-name"]; $profiledata["picdate"] = ""; $profiledata["photo"] = proxy_url($item["author-avatar"]); $profiledata["url"] = $item["author-link"]; $profiledata["network"] = $item["network"]; // Fetching further contact data from the contact table $r = q("SELECT `photo`, `nick`, `location`, `about` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d", normalise_link($profiledata["url"]), $item["uid"]); if (count($r)) { $profiledata["photo"] = proxy_url($r[0]["photo"]); $profiledata["address"] = proxy_parse_html(bbcode($r[0]["location"])); $profiledata["about"] = proxy_parse_html(bbcode($r[0]["about"])); if ($r[0]["nick"] != "") { $profiledata["nickname"] = $r[0]["nick"]; } } // Fetching profile data from unique contacts $r = q("SELECT `avatar`, `nick`, `location`, `about` FROM `unique_contacts` WHERE `url` = '%s'", normalise_link($profiledata["url"])); if (count($r)) { if ($profiledata["photo"] == "") { $profiledata["photo"] = proxy_url($r[0]["avatar"]); } if ($profiledata["address"] == "") { $profiledata["address"] = proxy_parse_html(bbcode($r[0]["location"])); } if ($profiledata["about"] == "") { $profiledata["about"] = proxy_parse_html(bbcode($r[0]["about"])); } if ($profiledata["nickname"] == "" and $r[0]["nick"] != "") { $profiledata["nickname"] = $r[0]["nick"]; } } // Check for a repeated message $skip = false; $body = trim($item["body"]); // Skip if it isn't a pure repeated messages // Does it start with a share? if (!$skip and strpos($body, "[share") > 0) { $skip = true; } // Does it end with a share? if (!$skip and strlen($body) > strrpos($body, "[/share]") + 8) { $skip = true; } if (!$skip) { $attributes = preg_replace("/\\[share(.*?)\\]\\s?(.*?)\\s?\\[\\/share\\]\\s?/ism", "\$1", $body); // Skip if there is no shared message in there if ($body == $attributes) { $skip = true; } } if (!$skip) { $author = ""; preg_match("/author='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") { $profiledata["name"] = html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8'); } preg_match('/author="(.*?)"/ism', $attributes, $matches); if ($matches[1] != "") { $profiledata["name"] = html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8'); } $profile = ""; preg_match("/profile='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") { $profiledata["url"] = $matches[1]; } preg_match('/profile="(.*?)"/ism', $attributes, $matches); if ($matches[1] != "") { $profiledata["url"] = $matches[1]; } $avatar = ""; preg_match("/avatar='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") { $profiledata["photo"] = $matches[1]; } preg_match('/avatar="(.*?)"/ism', $attributes, $matches); if ($matches[1] != "") { $profiledata["photo"] = $matches[1]; } $profiledata["nickname"] = $profiledata["name"]; $profiledata["network"] = GetProfileUsername($profiledata["url"], "", false, true); $profiledata["address"] = ""; $profiledata["about"] = ""; // Fetching profile data from unique contacts if ($profiledata["url"] != "") { $r = q("SELECT `avatar`, `nick`, `location`, `about` FROM `unique_contacts` WHERE `url` = '%s'", normalise_link($profiledata["url"])); if (count($r)) { $profiledata["photo"] = proxy_url($r[0]["avatar"]); $profiledata["address"] = proxy_parse_html(bbcode($r[0]["location"])); $profiledata["about"] = proxy_parse_html(bbcode($r[0]["about"])); if ($r[0]["nick"] != "") { $profiledata["nickname"] = $r[0]["nick"]; } } } } if (local_user()) { if ($profiledata["network"] == NETWORK_DFRN) { $connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]) . "&addr=" . bin2hex($a->get_baseurl() . "/profile/" . $a->user["nickname"]); $profiledata["remoteconnect"] = $connect; } elseif ($profiledata["network"] == NETWORK_DIASPORA) { $profiledata["remoteconnect"] = $a->get_baseurl() . "/contacts?add=" . GetProfileUsername($profiledata["url"], "", true); } } elseif ($profiledata["network"] == NETWORK_DFRN) { $connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]); $profiledata["remoteconnect"] = $connect; } return $profiledata; }
function dirfind_content(&$a, $prefix = "") { $community = false; $discover_user = false; $local = get_config('system', 'poco_local_search'); $search = $prefix . notags(trim($_REQUEST['search'])); if (strpos($search, '@') === 0) { $search = substr($search, 1); if (valid_email($search) and validate_email($search) or substr(normalise_link($search), 0, 7) == "http://") { $user_data = probe_url($search); $discover_user = in_array($user_data["network"], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA)); } } if (strpos($search, '!') === 0) { $search = substr($search, 1); $community = true; } $o = ''; if ($search) { if ($discover_user) { $j = new stdClass(); $j->total = 1; $j->items_page = 1; $j->page = $a->pager['page']; $objresult = new stdClass(); $objresult->cid = 0; $objresult->name = $user_data["name"]; $objresult->addr = $user_data["addr"]; $objresult->url = $user_data["url"]; $objresult->photo = $user_data["photo"]; $objresult->tags = ""; $objresult->network = $user_data["network"]; $contact = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1", dbesc(normalise_link($user_data["url"])), intval(local_user())); if ($contact) { $objresult->cid = $contact[0]["id"]; } $j->results[] = $objresult; poco_check($user_data["url"], $user_data["name"], $user_data["network"], $user_data["photo"], "", "", "", "", "", datetime_convert(), 0); } elseif ($local) { if ($community) { $extra_sql = " AND `community`"; } else { $extra_sql = ""; } $perpage = 80; $startrec = $a->pager['page'] * $perpage - $perpage; if (get_config('system', 'diaspora_enabled')) { $diaspora = NETWORK_DIASPORA; } else { $diaspora = NETWORK_DFRN; } if (!get_config('system', 'ostatus_disabled')) { $ostatus = NETWORK_OSTATUS; } else { $ostatus = NETWORK_DFRN; } $count = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `network` IN ('%s', '%s', '%s') AND\n\t\t\t\t\t(`url` REGEXP '%s' OR `name` REGEXP '%s' OR `location` REGEXP '%s' OR\n\t\t\t\t\t\t`about` REGEXP '%s' OR `keywords` REGEXP '%s')" . $extra_sql, dbesc(NETWORK_DFRN), dbesc($ostatus), dbesc($diaspora), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search))); $results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`photo`, `gcontact`.`network`, `gcontact`.`keywords`, `gcontact`.`addr`\n\t\t\t\t\tFROM `gcontact`\n\t\t\t\t\tLEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl`\n\t\t\t\t\t\tAND `contact`.`uid` = %d AND NOT `contact`.`blocked`\n\t\t\t\t\t\tAND NOT `contact`.`pending` AND `contact`.`rel` IN ('%s', '%s')\n\t\t\t\t\tWHERE `gcontact`.`network` IN ('%s', '%s', '%s') AND\n\t\t\t\t\t((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)) AND\n\t\t\t\t\t(`gcontact`.`url` REGEXP '%s' OR `gcontact`.`name` REGEXP '%s' OR `gcontact`.`location` REGEXP '%s' OR\n\t\t\t\t\t\t`gcontact`.`about` REGEXP '%s' OR `gcontact`.`keywords` REGEXP '%s') {$extra_sql}\n\t\t\t\t\t\tGROUP BY `gcontact`.`nurl`\n\t\t\t\t\t\tORDER BY `gcontact`.`updated` DESC LIMIT %d, %d", intval(local_user()), dbesc(CONTACT_IS_SHARING), dbesc(CONTACT_IS_FRIEND), dbesc(NETWORK_DFRN), dbesc($ostatus), dbesc($diaspora), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)), intval($startrec), intval($perpage)); $j = new stdClass(); $j->total = $count[0]["total"]; $j->items_page = $perpage; $j->page = $a->pager['page']; foreach ($results as $result) { if (poco_alternate_ostatus_url($result["url"])) { continue; } if ($result["name"] == "") { $urlparts = parse_url($result["url"]); $result["name"] = end(explode("/", $urlparts["path"])); } $objresult = new stdClass(); $objresult->cid = $result["cid"]; $objresult->name = $result["name"]; $objresult->addr = $result["addr"]; $objresult->url = $result["url"]; $objresult->photo = $result["photo"]; $objresult->tags = $result["keywords"]; $objresult->network = $result["network"]; $j->results[] = $objresult; } // Add found profiles from the global directory to the local directory proc_run('php', 'include/discover_poco.php', "dirsearch", urlencode($search)); } else { $p = $a->pager['page'] != 1 ? '&p=' . $a->pager['page'] : ''; if (strlen(get_config('system', 'directory'))) { $x = fetch_url(get_server() . '/lsearch?f=' . $p . '&search=' . urlencode($search)); } $j = json_decode($x); } if ($j->total) { $a->set_pager_total($j->total); $a->set_pager_itemspage($j->items_page); } if (count($j->results)) { $id = 0; foreach ($j->results as $jj) { $alt_text = ""; $contact_details = get_contact_details_by_url($jj->url, local_user()); $itemurl = $contact_details["addr"] != "" ? $contact_details["addr"] : $jj->url; // If We already know this contact then don't show the "connect" button if ($jj->cid > 0) { $connlnk = ""; $conntxt = ""; $contact = q("SELECT * FROM `contact` WHERE `id` = %d", intval($jj->cid)); if ($contact) { $photo_menu = contact_photo_menu($contact[0]); $details = _contact_detail_for_template($contact[0]); $alt_text = $details['alt_text']; } else { $photo_menu = array(); } } else { $connlnk = $a->get_baseurl() . '/follow/?url=' . ($jj->connect ? $jj->connect : $jj->url); $conntxt = t('Connect'); $photo_menu = array(array(t("View Profile"), zrl($jj->url))); $photo_menu[] = array(t("Connect/Follow"), $connlnk); } $jj->photo = str_replace("http:///photo/", get_server() . "/photo/", $jj->photo); $entry = array('alt_text' => $alt_text, 'url' => zrl($jj->url), 'itemurl' => $itemurl, 'name' => htmlentities($jj->name), 'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB), 'img_hover' => $jj->tags, 'conntxt' => $conntxt, 'connlnk' => $connlnk, 'photo_menu' => $photo_menu, 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'network' => network_to_name($jj->network, $jj->url), 'id' => ++$id); $entries[] = $entry; } $tpl = get_markup_template('viewcontact_template.tpl'); $o .= replace_macros($tpl, array('title' => sprintf(t('People Search - %s'), $search), '$contacts' => $entries, '$paginate' => paginate($a))); } else { info(t('No matches') . EOL); } } return $o; }
function acl_lookup(&$a, $out_type = 'json') { if (!local_user()) { return ""; } $start = x($_REQUEST, 'start') ? $_REQUEST['start'] : 0; $count = x($_REQUEST, 'count') ? $_REQUEST['count'] : 100; $search = x($_REQUEST, 'search') ? $_REQUEST['search'] : ""; $type = x($_REQUEST, 'type') ? $_REQUEST['type'] : ""; $conv_id = x($_REQUEST, 'conversation') ? $_REQUEST['conversation'] : null; // For use with jquery.autocomplete for private mail completion if (x($_REQUEST, 'query') && strlen($_REQUEST['query'])) { if (!$type) { $type = 'm'; } $search = $_REQUEST['query']; } if ($search != "") { $sql_extra = "AND `name` LIKE '%%" . dbesc($search) . "%%'"; $sql_extra2 = "AND (`attag` LIKE '%%" . dbesc($search) . "%%' OR `name` LIKE '%%" . dbesc($search) . "%%' OR `nick` LIKE '%%" . dbesc($search) . "%%')"; } else { $sql_extra = $sql_extra2 = ""; } // count groups and contacts if ($type == '' || $type == 'g') { $r = q("SELECT COUNT(*) AS g FROM `group` WHERE `deleted` = 0 AND `uid` = %d {$sql_extra}", intval(local_user())); $group_count = (int) $r[0]['g']; } else { $group_count = 0; } if ($type == '' || $type == 'c') { $r = q("SELECT COUNT(*) AS c FROM `contact`\n\t\t\t\tWHERE `uid` = %d AND `self` = 0\n\t\t\t\tAND `blocked` = 0 AND `pending` = 0 AND `archive` = 0\n\t\t\t\tAND `notify` != '' {$sql_extra2}", intval(local_user())); $contact_count = (int) $r[0]['c']; } elseif ($type == 'm') { // autocomplete for Private Messages $r = q("SELECT COUNT(*) AS c FROM `contact`\n\t\t\t\tWHERE `uid` = %d AND `self` = 0\n\t\t\t\tAND `blocked` = 0 AND `pending` = 0 AND `archive` = 0\n\t\t\t\tAND `network` IN ('%s','%s','%s') {$sql_extra2}", intval(local_user()), dbesc(NETWORK_DFRN), dbesc(NETWORK_ZOT), dbesc(NETWORK_DIASPORA)); $contact_count = (int) $r[0]['c']; } elseif ($type == 'a') { // autocomplete for Contacts $r = q("SELECT COUNT(*) AS c FROM `contact`\n\t\t\t\tWHERE `uid` = %d AND `self` = 0\n\t\t\t\tAND `pending` = 0 {$sql_extra2}", intval(local_user())); $contact_count = (int) $r[0]['c']; } else { $contact_count = 0; } $tot = $group_count + $contact_count; $groups = array(); $contacts = array(); if ($type == '' || $type == 'g') { $r = q("SELECT `group`.`id`, `group`.`name`, GROUP_CONCAT(DISTINCT `group_member`.`contact-id` SEPARATOR ',') as uids\n\t\t\t\tFROM `group`,`group_member`\n\t\t\t\tWHERE `group`.`deleted` = 0 AND `group`.`uid` = %d\n\t\t\t\t\tAND `group_member`.`gid`=`group`.`id`\n\t\t\t\t\t{$sql_extra}\n\t\t\t\tGROUP BY `group`.`id`\n\t\t\t\tORDER BY `group`.`name`\n\t\t\t\tLIMIT %d,%d", intval(local_user()), intval($start), intval($count)); foreach ($r as $g) { // logger('acl: group: ' . $g['name'] . ' members: ' . $g['uids']); $groups[] = array("type" => "g", "photo" => "images/twopeople.png", "name" => $g['name'], "id" => intval($g['id']), "uids" => array_map("intval", explode(",", $g['uids'])), "link" => '', "forum" => '0'); } } if ($type == '' || $type == 'c') { $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, forum FROM `contact`\n\t\t\tWHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != ''\n\t\t\t{$sql_extra2}\n\t\t\tORDER BY `name` ASC ", intval(local_user())); } elseif ($type == 'm') { $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag` FROM `contact`\n\t\t\tWHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0\n\t\t\tAND `network` IN ('%s','%s','%s')\n\t\t\t{$sql_extra2}\n\t\t\tORDER BY `name` ASC ", intval(local_user()), dbesc(NETWORK_DFRN), dbesc(NETWORK_ZOT), dbesc(NETWORK_DIASPORA)); } elseif ($type == 'a') { $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag` FROM `contact`\n\t\t\tWHERE `uid` = %d AND `pending` = 0\n\t\t\t{$sql_extra2}\n\t\t\tORDER BY `name` ASC ", intval(local_user())); } else { $r = array(); } if ($type == 'm' || $type == 'a') { $x = array(); $x['query'] = $search; $x['photos'] = array(); $x['links'] = array(); $x['suggestions'] = array(); $x['data'] = array(); if (count($r)) { foreach ($r as $g) { $x['photos'][] = proxy_url($g['micro']); $x['links'][] = $g['url']; $x['suggestions'][] = $g['name']; $x['data'][] = intval($g['id']); } } echo json_encode($x); killme(); } if (count($r)) { foreach ($r as $g) { $contacts[] = array("type" => "c", "photo" => proxy_url($g['micro']), "name" => $g['name'], "id" => intval($g['id']), "network" => $g['network'], "link" => $g['url'], "nick" => $g['attag'] ? $g['attag'] : $g['nick'], "forum" => $g['forum']); } } $items = array_merge($groups, $contacts); if ($conv_id) { /* if $conv_id is set, get unknow contacts in thread */ /* but first get know contacts url to filter them out */ function _contact_link($i) { return dbesc($i['link']); } $known_contacts = array_map(_contact_link, $contacts); $unknow_contacts = array(); $r = q("select\n\t\t\t\t\t`author-avatar`,`author-name`,`author-link`\n\t\t\t\tfrom item where parent=%d\n\t\t\t\tand (\n\t\t\t\t\t`author-name` LIKE '%%%s%%' OR\n\t\t\t\t\t`author-link` LIKE '%%%s%%'\n\t\t\t\t) and\n\t\t\t\t`author-link` NOT IN ('%s')\n\t\t\t\tGROUP BY `author-link`\n\t\t\t\tORDER BY `author-name` ASC\n\t\t\t\t", intval($conv_id), dbesc($search), dbesc($search), implode("','", $known_contacts)); if (is_array($r) && count($r)) { foreach ($r as $row) { // nickname.. $up = parse_url($row['author-link']); $nick = explode("/", $up['path']); $nick = $nick[count($nick) - 1]; $nick .= "@" . $up['host']; // /nickname $unknow_contacts[] = array("type" => "c", "photo" => proxy_url($row['author-avatar']), "name" => $row['author-name'], "id" => '', "network" => "unknown", "link" => $row['author-link'], "nick" => $nick, "forum" => false); } } $items = array_merge($items, $unknow_contacts); $tot += count($unknow_contacts); } if ($out_type === 'html') { $o = array('tot' => $tot, 'start' => $start, 'count' => $count, 'groups' => $groups, 'contacts' => $contacts); return $o; } $o = array('tot' => $tot, 'start' => $start, 'count' => $count, 'items' => $items); echo json_encode($o); killme(); }
function xmlize($href, $name, $url, $photo, $date, $seen, $message) { require_once "mod/proxy.php"; $photo = proxy_url($photo); $data = array('href' => &$href, 'name' => &$name, 'url' => &$url, 'photo' => &$photo, 'date' => &$date, 'seen' => &$seen, 'messsage' => &$message); call_hooks('ping_xmlize', $data); $notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s" seen="%s" >%s</note>'; return sprintf($notsxml, xmlify($href), xmlify($name), xmlify($url), xmlify($photo), xmlify($date), xmlify($seen), xmlify($message)); }
function directory_content(&$a) { require_once "mod/proxy.php"; if (get_config('system', 'block_public') && !local_user() && !remote_user()) { notice(t('Public access denied.') . EOL); return; } $o = ''; nav_set_selected('directory'); if (x($a->data, 'search')) { $search = notags(trim($a->data['search'])); } else { $search = x($_GET, 'search') ? notags(trim(rawurldecode($_GET['search']))) : ''; } $tpl = get_markup_template('directory_header.tpl'); $globaldir = ''; $gdirpath = dirname(get_config('system', 'directory_submit_url')); if (strlen($gdirpath)) { $globaldir = '<ul><li><div id="global-directory-link"><a href="' . zrl($gdirpath, true) . '">' . t('Global Directory') . '</a></div></li></ul>'; } $admin = ''; $o .= replace_macros($tpl, array('$search' => $search, '$globaldir' => $globaldir, '$desc' => t('Find on this site'), '$admin' => $admin, '$finding' => strlen($search) ? '<h4>' . t('Finding: ') . "'" . $search . "'" . '</h4>' : "", '$sitedir' => t('Site Directory'), '$submit' => t('Find'))); if ($search) { $search = dbesc($search); } $sql_extra = strlen($search) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `pdesc`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`pub_keywords`,`prv_keywords` ) AGAINST ('{$search}' IN BOOLEAN MODE) " : ""; $publish = get_config('system', 'publish_all') ? '' : " AND `publish` = 1 "; $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 {$publish} AND `user`.`blocked` = 0 {$sql_extra} "); if (count($r)) { $a->set_pager_total($r[0]['total']); } $order = " ORDER BY `name` ASC "; $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 {$publish} AND `user`.`blocked` = 0 {$sql_extra} {$order} LIMIT %d , %d ", intval($a->pager['start']), intval($a->pager['itemspage'])); if (count($r)) { if (in_array('small', $a->argv)) { $photo = 'thumb'; } else { $photo = 'photo'; } foreach ($r as $rr) { $profile_link = $a->get_baseurl() . '/profile/' . (strlen($rr['nickname']) ? $rr['nickname'] : $rr['profile_uid']); $pdesc = $rr['pdesc'] ? $rr['pdesc'] . '<br />' : ''; $details = ''; if (strlen($rr['locality'])) { $details .= $rr['locality']; } if (strlen($rr['region'])) { if (strlen($rr['locality'])) { $details .= ', '; } $details .= $rr['region']; } if (strlen($rr['country-name'])) { if (strlen($details)) { $details .= ', '; } $details .= $rr['country-name']; } if (strlen($rr['dob'])) { if (($years = age($rr['dob'], $rr['timezone'], '')) != 0) { $details .= '<br />' . t('Age: ') . $years; } } if (strlen($rr['gender'])) { $details .= '<br />' . t('Gender: ') . $rr['gender']; } if ($rr['page-flags'] == PAGE_NORMAL) { $page_type = "Personal Profile"; } if ($rr['page-flags'] == PAGE_SOAPBOX) { $page_type = "Fan Page"; } if ($rr['page-flags'] == PAGE_COMMUNITY) { $page_type = "Community Forum"; } if ($rr['page-flags'] == PAGE_FREELOVE) { $page_type = "Open Forum"; } if ($rr['page-flags'] == PAGE_PRVGROUP) { $page_type = "Private Group"; } $profile = $rr; if (x($profile, 'address') == 1 || x($profile, 'locality') == 1 || x($profile, 'region') == 1 || x($profile, 'postal-code') == 1 || x($profile, 'country-name') == 1) { $location = t('Location:'); } $gender = x($profile, 'gender') == 1 ? t('Gender:') : False; $marital = x($profile, 'marital') == 1 ? t('Status:') : False; $homepage = x($profile, 'homepage') == 1 ? t('Homepage:') : False; $about = x($profile, 'about') == 1 ? t('About:') : False; $tpl = get_markup_template('directory_item.tpl'); if ($a->theme['template_engine'] === 'internal') { $location_e = template_escape($location); } else { $location_e = $location; } $entry = replace_macros($tpl, array('$id' => $rr['id'], '$profile_link' => $profile_link, '$photo' => proxy_url($a->get_cached_avatar_image($rr[$photo])), '$alt_text' => $rr['name'], '$name' => $rr['name'], '$details' => $pdesc . $details, '$page_type' => $page_type, '$profile' => $profile, '$location' => $location_e, '$gender' => $gender, '$pdesc' => $pdesc, '$marital' => $marital, '$homepage' => $homepage, '$about' => $about)); $arr = array('contact' => $rr, 'entry' => $entry); call_hooks('directory_item', $arr); unset($profile); unset($location); $o .= $entry; } $o .= "<div class=\"directory-end\" ></div>\r\n"; $o .= paginate($a); } else { info(t("No entries (some entries may be hidden).") . EOL); } return $o; }
function curweather_network_mod_init(&$fk_app, &$b) { if (!intval(get_pconfig(local_user(), 'curweather', 'curweather_enable'))) { return; } $fk_app->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $fk_app->get_baseurl() . '/addon/curweather/curweather.css' . '" media="all" />' . "\r\n"; // $rpt value is needed for location // $lang will be taken from the browser session to honour user settings // TODO $lang does not work if the default settings are used // and not all response strings are translated // $units can be set in the settings by the user // $appid is configured by the admin in the admin panel // those parameters will be used to get: cloud status, temperature, preassure // and relative humidity for display, also the relevent area of the map is // linked from lat/log of the reply of OWMp $rpt = get_pconfig(local_user(), 'curweather', 'curweather_loc'); // set the language to the browsers language and use metric units $lang = $_SESSION['language']; $units = get_pconfig(local_user(), 'curweather', 'curweather_units'); $appid = get_config('curweather', 'appid'); $cachetime = intval(get_config('curweather', 'cachetime')); if ($units === "") { $units = 'metric'; } $ok = true; $res = getWeather($rpt, $units, $lang, $appid, $cachetime); if ($res === false) { $ok = false; } if ($ok) { $t = get_markup_template("widget.tpl", "addon/curweather/"); $curweather = replace_macros($t, array('$title' => t("Current Weather"), '$icon' => proxy_url('http://openweathermap.org/img/w/' . $res['icon'] . '.png'), '$city' => $res['city'], '$lon' => $res['lon'], '$lat' => $res['lat'], '$description' => $res['descripion'], '$temp' => $res['temperature'], '$relhumidity' => array('caption' => t('Relative Humidity'), 'val' => $res['humidity']), '$pressure' => array('caption' => t('Pressure'), 'val' => $res['pressure']), '$wind' => array('caption' => t('Wind'), 'val' => $res['wind']), '$lastupdate' => t('Last Updated') . ': ' . $res['update'] . 'UTC', '$databy' => t('Data by'), '$showonmap' => t('Show on map'))); } else { $t = get_markup_template('widget-error.tpl', 'addon/curweather/'); $curweather = replace_macros($t, array('$problem' => t('There was a problem accessing the weather data. But have a look'), '$rpt' => $rpt, '$atOWM' => t('at OpenWeatherMap'))); } $fk_app->page['aside'] = $curweather . $fk_app->page['aside']; }
function api_get_entitities(&$text, $bbcode) { /* To-Do: * Links at the first character of the post */ $a = get_app(); $include_entities = strtolower(x($_REQUEST, 'include_entities') ? $_REQUEST['include_entities'] : "false"); if ($include_entities != "true") { preg_match_all("/\\[img](.*?)\\[\\/img\\]/ism", $bbcode, $images); foreach ($images[1] as $image) { $replace = proxy_url($image); $text = str_replace($image, $replace, $text); } return array(); } $bbcode = bb_CleanPictureLinks($bbcode); // Change pure links in text to bbcode uris $bbcode = preg_replace("/([^\\]\\='" . '"' . "]|^)(https?\\:\\/\\/[a-zA-Z0-9\\:\\/\\-\\?\\&\\;\\.\\=\\_\\~\\#\\%\$\\!\\+\\,]+)/ism", '$1[url=$2]$2[/url]', $bbcode); $entities = array(); $entities["hashtags"] = array(); $entities["symbols"] = array(); $entities["urls"] = array(); $entities["user_mentions"] = array(); $URLSearchString = "^\\[\\]"; $bbcode = preg_replace("/#\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", '#$2', $bbcode); $bbcode = preg_replace("/\\[bookmark\\=([{$URLSearchString}]*)\\](.*?)\\[\\/bookmark\\]/ism", '[url=$1]$2[/url]', $bbcode); //$bbcode = preg_replace("/\[url\](.*?)\[\/url\]/ism",'[url=$1]$1[/url]',$bbcode); $bbcode = preg_replace("/\\[video\\](.*?)\\[\\/video\\]/ism", '[url=$1]$1[/url]', $bbcode); $bbcode = preg_replace("/\\[youtube\\]([A-Za-z0-9\\-_=]+)(.*?)\\[\\/youtube\\]/ism", '[url=https://www.youtube.com/watch?v=$1]https://www.youtube.com/watch?v=$1[/url]', $bbcode); $bbcode = preg_replace("/\\[youtube\\](.*?)\\[\\/youtube\\]/ism", '[url=$1]$1[/url]', $bbcode); $bbcode = preg_replace("/\\[vimeo\\]([0-9]+)(.*?)\\[\\/vimeo\\]/ism", '[url=https://vimeo.com/$1]https://vimeo.com/$1[/url]', $bbcode); $bbcode = preg_replace("/\\[vimeo\\](.*?)\\[\\/vimeo\\]/ism", '[url=$1]$1[/url]', $bbcode); $bbcode = preg_replace("/\\[img\\=([0-9]*)x([0-9]*)\\](.*?)\\[\\/img\\]/ism", '[img]$3[/img]', $bbcode); //preg_match_all("/\[url\]([$URLSearchString]*)\[\/url\]/ism", $bbcode, $urls1); preg_match_all("/\\[url\\=([{$URLSearchString}]*)\\](.*?)\\[\\/url\\]/ism", $bbcode, $urls); $ordered_urls = array(); foreach ($urls[1] as $id => $url) { //$start = strpos($text, $url, $offset); $start = iconv_strpos($text, $url, 0, "UTF-8"); if (!($start === false)) { $ordered_urls[$start] = array("url" => $url, "title" => $urls[2][$id]); } } ksort($ordered_urls); $offset = 0; //foreach ($urls[1] AS $id=>$url) { foreach ($ordered_urls as $url) { if (substr($url["title"], 0, 7) != "http://" and substr($url["title"], 0, 8) != "https://" and !strpos($url["title"], "http://") and !strpos($url["title"], "https://")) { $display_url = $url["title"]; } else { $display_url = str_replace(array("http://www.", "https://www."), array("", ""), $url["url"]); $display_url = str_replace(array("http://", "https://"), array("", ""), $display_url); if (strlen($display_url) > 26) { $display_url = substr($display_url, 0, 25) . "…"; } } //$start = strpos($text, $url, $offset); $start = iconv_strpos($text, $url["url"], $offset, "UTF-8"); if (!($start === false)) { $entities["urls"][] = array("url" => $url["url"], "expanded_url" => $url["url"], "display_url" => $display_url, "indices" => array($start, $start + strlen($url["url"]))); $offset = $start + 1; } } preg_match_all("/\\[img](.*?)\\[\\/img\\]/ism", $bbcode, $images); $ordered_images = array(); foreach ($images[1] as $image) { //$start = strpos($text, $url, $offset); $start = iconv_strpos($text, $image, 0, "UTF-8"); if (!($start === false)) { $ordered_images[$start] = $image; } } //$entities["media"] = array(); $offset = 0; foreach ($ordered_images as $url) { $display_url = str_replace(array("http://www.", "https://www."), array("", ""), $url); $display_url = str_replace(array("http://", "https://"), array("", ""), $display_url); if (strlen($display_url) > 26) { $display_url = substr($display_url, 0, 25) . "…"; } $start = iconv_strpos($text, $url, $offset, "UTF-8"); if (!($start === false)) { $image = get_photo_info($url); if ($image) { // If image cache is activated, then use the following sizes: // thumb (150), small (340), medium (600) and large (1024) if (!get_config("system", "proxy_disabled")) { $media_url = proxy_url($url); $sizes = array(); $scale = scale_image($image[0], $image[1], 150); $sizes["thumb"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit"); if ($image[0] > 150 or $image[1] > 150) { $scale = scale_image($image[0], $image[1], 340); $sizes["small"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit"); } $scale = scale_image($image[0], $image[1], 600); $sizes["medium"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit"); if ($image[0] > 600 or $image[1] > 600) { $scale = scale_image($image[0], $image[1], 1024); $sizes["large"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit"); } } else { $media_url = $url; $sizes["medium"] = array("w" => $image[0], "h" => $image[1], "resize" => "fit"); } $entities["media"][] = array("id" => $start + 1, "id_str" => (string) $start + 1, "indices" => array($start, $start + strlen($url)), "media_url" => normalise_link($media_url), "media_url_https" => $media_url, "url" => $url, "display_url" => $display_url, "expanded_url" => $url, "type" => "photo", "sizes" => $sizes); } $offset = $start + 1; } } return $entities; }
/** * return xml from notification array * * @param array $n Notification array: * 'href' => notification link * 'name' => subject name * 'url' => subject url * 'photo' => subject photo * 'date' => notification date * 'seen' => bool true/false * 'message' => notification message. "{0}" will be replaced by subject name **/ function xmlize($n) { $n['photo'] = proxy_url($n['photo']); $n['message'] = html_entity_decode($n['message'], ENT_COMPAT | ENT_HTML401, "UTF-8"); $n['name'] = html_entity_decode($n['name'], ENT_COMPAT | ENT_HTML401, "UTF-8"); // Are the nofications calles from the regular process or via the friendica app? $regularnotifications = (intval($_GET['uid']) and intval($_GET['_'])); $a = get_app(); if ($a->is_friendica_app() or !$regularnotifications) { $n['message'] = str_replace("{0}", $n['name'], $n['message']); } $local_time = datetime_convert('UTC', date_default_timezone_get(), $n['date']); call_hooks('ping_xmlize', $n); $notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s" seen="%s" timestamp="%s" >%s</note>' . "\n"; return sprintf($notsxml, xmlify($n['href']), xmlify($n['name']), xmlify($n['url']), xmlify($n['photo']), xmlify(relative_date($n['date'])), xmlify($n['seen']), xmlify(strtotime($local_time)), xmlify($n['message'])); }
function profile_sidebar($profile, $block = 0) { $a = get_app(); $o = ''; $location = false; $address = false; // $pdesc = true; if (!is_array($profile) && !count($profile)) { return $o; } $profile['picdate'] = urlencode($profile['picdate']); if ($profile['network'] != "" and $profile['network'] != NETWORK_DFRN) { $profile['network_name'] = format_network_name($profile['network'], $profile['url']); } else { $profile['network_name'] = ""; } call_hooks('profile_sidebar_enter', $profile); // don't show connect link to yourself $connect = $profile['uid'] != local_user() ? t('Connect') : False; // don't show connect link to authenticated visitors either if (remote_user() && count($_SESSION['remote'])) { foreach ($_SESSION['remote'] as $visitor) { if ($visitor['uid'] == $profile['uid']) { $connect = false; break; } } } // Is the local user already connected to that user? if ($connect and local_user()) { if (isset($profile["url"])) { $profile_url = normalise_link($profile["url"]); } else { $profile_url = normalise_link($a->get_baseurl() . "/profile/" . $profile["nickname"]); } $r = q("SELECT * FROM `contact` WHERE NOT `pending` AND `uid` = %d AND `nurl` = '%s'", local_user(), $profile_url); if (count($r)) { $connect = false; } } if ($connect and $profile['network'] != NETWORK_DFRN and !isset($profile['remoteconnect'])) { $connect = false; } if (isset($profile['remoteconnect'])) { $remoteconnect = $profile['remoteconnect']; } if ($connect and $profile['network'] == NETWORK_DFRN and !isset($remoteconnect)) { $subscribe_feed = t("Atom feed"); } else { $subscribe_feed = false; } if (get_my_url() && $profile['unkmail'] && $profile['uid'] != local_user()) { $wallmessage = t('Message'); } else { $wallmessage = false; } // show edit profile to yourself if ($profile['uid'] == local_user() && feature_enabled(local_user(), 'multi_profiles')) { $profile['edit'] = array($a->get_baseurl() . '/profiles', t('Profiles'), "", t('Manage/edit profiles')); $r = q("SELECT * FROM `profile` WHERE `uid` = %d", local_user()); $profile['menu'] = array('chg_photo' => t('Change profile photo'), 'cr_new' => t('Create New Profile'), 'entries' => array()); if (count($r)) { foreach ($r as $rr) { $profile['menu']['entries'][] = array('photo' => $rr['thumb'], 'id' => $rr['id'], 'alt' => t('Profile Image'), 'profile_name' => $rr['profile-name'], 'isdefault' => $rr['is-default'], 'visibile_to_everybody' => t('visible to everybody'), 'edit_visibility' => t('Edit visibility')); } } } if ($profile['uid'] == local_user() && !feature_enabled(local_user(), 'multi_profiles')) { $profile['edit'] = array($a->get_baseurl() . '/profiles/' . $profile['id'], t('Edit profile'), "", t('Edit profile')); $profile['menu'] = array('chg_photo' => t('Change profile photo'), 'cr_new' => null, 'entries' => array()); } // check if profile is a forum if (intval($profile['page-flags']) == PAGE_COMMUNITY || intval($profile['page-flags']) == PAGE_PRVGROUP || intval($profile['forum']) || intval($profile['prv']) || intval($profile['community'])) { $account_type = t('Forum'); } else { $account_type = ""; } if (x($profile, 'address') == 1 || x($profile, 'locality') == 1 || x($profile, 'region') == 1 || x($profile, 'postal-code') == 1 || x($profile, 'country-name') == 1) { $location = t('Location:'); } $gender = x($profile, 'gender') == 1 ? t('Gender:') : False; $marital = x($profile, 'marital') == 1 ? t('Status:') : False; $homepage = x($profile, 'homepage') == 1 ? t('Homepage:') : False; $about = x($profile, 'about') == 1 ? t('About:') : False; if (($profile['hidewall'] || $block) && !local_user() && !remote_user()) { $location = $pdesc = $gender = $marital = $homepage = $about = False; } $firstname = strpos($profile['name'], ' ') ? trim(substr($profile['name'], 0, strpos($profile['name'], ' '))) : $profile['name']; $lastname = $firstname === $profile['name'] ? '' : trim(substr($profile['name'], strlen($firstname))); $diaspora = array('guid' => $profile['guid'], 'podloc' => $a->get_baseurl(), 'searchable' => $profile['publish'] && $profile['net-publish'] ? 'true' : 'false', 'nickname' => $profile['nickname'], 'fullname' => $profile['name'], 'firstname' => $firstname, 'lastname' => $lastname, 'photo300' => $a->get_cached_avatar_image($a->get_baseurl() . '/photo/custom/300/' . $profile['uid'] . '.jpg'), 'photo100' => $a->get_cached_avatar_image($a->get_baseurl() . '/photo/custom/100/' . $profile['uid'] . '.jpg'), 'photo50' => $a->get_cached_avatar_image($a->get_baseurl() . '/photo/custom/50/' . $profile['uid'] . '.jpg')); if (!$block) { $contact_block = contact_block(); if (is_array($a->profile) and !$a->profile['hide-friends']) { $r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1", intval($a->profile['uid'])); if (count($r)) { $updated = date("c", strtotime($r[0]['updated'])); } $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0\n\t\t\t\t\t\tAND `network` IN ('%s', '%s', '%s', '')", intval($profile['uid']), dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS)); if (count($r)) { $contacts = intval($r[0]['total']); } } } $p = array(); foreach ($profile as $k => $v) { $k = str_replace('-', '_', $k); $p[$k] = $v; } if (isset($p["about"])) { $p["about"] = bbcode($p["about"]); } if (isset($p["location"])) { $p["location"] = bbcode($p["location"]); } if (isset($p["photo"])) { $p["photo"] = proxy_url($p["photo"], false, PROXY_SIZE_SMALL); } if ($a->theme['template_engine'] === 'internal') { $location = template_escape($location); } $tpl = get_markup_template('profile_vcard.tpl'); $o .= replace_macros($tpl, array('$profile' => $p, '$connect' => $connect, '$remoteconnect' => $remoteconnect, '$subscribe_feed' => $subscribe_feed, '$wallmessage' => $wallmessage, '$account_type' => $account_type, '$location' => $location, '$gender' => $gender, '$marital' => $marital, '$homepage' => $homepage, '$about' => $about, '$network' => t('Network:'), '$contacts' => $contacts, '$updated' => $updated, '$diaspora' => $diaspora, '$contact_block' => $contact_block)); $arr = array('profile' => &$profile, 'entry' => &$o); call_hooks('profile_sidebar', $arr); return $o; }
function directory_content(&$a) { global $db; require_once "mod/proxy.php"; if (get_config('system', 'block_public') && !local_user() && !remote_user() || get_config('system', 'block_local_dir') && !local_user() && !remote_user()) { notice(t('Public access denied.') . EOL); return; } $o = ''; nav_set_selected('directory'); if (x($a->data, 'search')) { $search = notags(trim($a->data['search'])); } else { $search = x($_GET, 'search') ? notags(trim(rawurldecode($_GET['search']))) : ''; } $gdirpath = ''; $dirurl = get_config('system', 'directory'); if (strlen($dirurl)) { $gdirpath = zrl($dirurl, true); } if ($search) { $search = dbesc($search); $sql_extra = " AND ((`profile`.`name` LIKE '%{$search}%') OR\n\t\t\t\t(`user`.`nickname` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`pdesc` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`locality` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`region` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`country-name` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`gender` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`marital` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`sexual` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`about` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`romance` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`work` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`education` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`pub_keywords` LIKE '%{$search}%') OR\n\t\t\t\t(`profile`.`prv_keywords` LIKE '%{$search}%'))"; } $publish = get_config('system', 'publish_all') ? '' : " AND `publish` = 1 "; $r = $db->q("SELECT COUNT(*) AS `total` FROM `profile`\n\t\t\tLEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`\n\t\t\tWHERE `is-default` = 1 {$publish} AND `user`.`blocked` = 0 {$sql_extra} "); if (count($r)) { $a->set_pager_total($r[0]['total']); } $order = " ORDER BY `name` ASC "; $limit = intval($a->pager['start']) . "," . intval($a->pager['itemspage']); $r = $db->q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`,\n\t\t\t`contact`.`addr`, `contact`.`url` AS profile_url FROM `profile`\n\t\t\tLEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`\n\t\t\tLEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid`\n\t\t\tWHERE `is-default` = 1 {$publish} AND `user`.`blocked` = 0 AND `contact`.`self` {$sql_extra} {$order} LIMIT " . $limit); if (count($r)) { if (in_array('small', $a->argv)) { $photo = 'thumb'; } else { $photo = 'photo'; } foreach ($r as $rr) { $community = ''; $itemurl = ''; $itemurl = $rr['addr'] != "" ? $rr['addr'] : $rr['profile_url']; $profile_link = z_root() . '/profile/' . (strlen($rr['nickname']) ? $rr['nickname'] : $rr['profile_uid']); $pdesc = $rr['pdesc'] ? $rr['pdesc'] . '<br />' : ''; $details = ''; if (strlen($rr['locality'])) { $details .= $rr['locality']; } if (strlen($rr['region'])) { if (strlen($rr['locality'])) { $details .= ', '; } $details .= $rr['region']; } if (strlen($rr['country-name'])) { if (strlen($details)) { $details .= ', '; } $details .= $rr['country-name']; } // if(strlen($rr['dob'])) { // if(($years = age($rr['dob'],$rr['timezone'],'')) != 0) // $details .= '<br />' . t('Age: ') . $years ; // } // if(strlen($rr['gender'])) // $details .= '<br />' . t('Gender: ') . $rr['gender']; // show if account is a community account // ToDo the other should be also respected, but first we need a good translatiion // and systemwide consistency for displaying the page type if (intval($rr['page-flags']) == PAGE_COMMUNITY or intval($rr['page-flags']) == PAGE_PRVGROUP) { $community = true; } $profile = $rr; if (x($profile, 'address') == 1 || x($profile, 'locality') == 1 || x($profile, 'region') == 1 || x($profile, 'postal-code') == 1 || x($profile, 'country-name') == 1) { $location = t('Location:'); } $gender = x($profile, 'gender') == 1 ? t('Gender:') : False; $marital = x($profile, 'marital') == 1 ? t('Status:') : False; $homepage = x($profile, 'homepage') == 1 ? t('Homepage:') : False; $about = x($profile, 'about') == 1 ? t('About:') : False; if ($a->theme['template_engine'] === 'internal') { $location_e = template_escape($location); } else { $location_e = $location; } $photo_menu = array(array(t("View Profile"), zrl($profile_link))); $entry = array('id' => $rr['id'], 'url' => $profile_link, 'itemurl' => $itemurl, 'thumb' => proxy_url($a->get_cached_avatar_image($rr[$photo]), false, PROXY_SIZE_THUMB), 'img_hover' => $rr['name'], 'name' => $rr['name'], 'details' => $details, 'account_type' => $community ? t('Forum') : '', 'profile' => $profile, 'location' => $location_e, 'tags' => $rr['pub_keywords'], 'gender' => $gender, 'pdesc' => $pdesc, 'marital' => $marital, 'homepage' => $homepage, 'about' => $about, 'photo_menu' => $photo_menu); $arr = array('contact' => $rr, 'entry' => $entry); call_hooks('directory_item', $arr); unset($profile); unset($location); if (!$arr['entry']) { continue; } $entries[] = $arr['entry']; } $tpl = get_markup_template('directory_header.tpl'); $o .= replace_macros($tpl, array('$search' => $search, '$globaldir' => t('Global Directory'), '$gdirpath' => $gdirpath, '$desc' => t('Find on this site'), '$contacts' => $entries, '$finding' => t('Finding:'), '$findterm' => strlen($search) ? $search : "", '$title' => t('Site Directory'), '$submit' => t('Find'), '$paginate' => paginate($a))); } else { info(t("No entries (some entries may be hidden).") . EOL); } return $o; }
function buffer_send(&$a, &$b) { if ($b['deleted'] || $b['private'] || $b['created'] !== $b['edited']) { return; } if (!strstr($b['postopts'], 'buffer')) { return; } if ($b['parent'] != $b['id']) { return; } // if post comes from buffer don't send it back //if($b['app'] == "Buffer") // return; $client_id = get_config("buffer", "client_id"); $client_secret = get_config("buffer", "client_secret"); $access_token = get_pconfig($b['uid'], "buffer", "access_token"); if ($access_token) { $buffer = new BufferApp($client_id, $client_secret, $callback_url, $access_token); require_once "include/plaintext.php"; require_once "include/network.php"; $profiles = $buffer->go('/profiles'); if (is_array($profiles)) { logger("Will send these parameter " . print_r($b, true), LOGGER_DEBUG); foreach ($profiles as $profile) { if (!$profile->default) { continue; } $send = false; switch ($profile->service) { case 'appdotnet': $send = $b["extid"] != NETWORK_APPNET; $limit = 256; $markup = false; $includedlinks = true; $htmlmode = 6; break; case 'facebook': $send = $b["extid"] != NETWORK_FACEBOOK; $limit = 0; $markup = false; $includedlinks = false; $htmlmode = 9; break; case 'google': $send = $b["extid"] != NETWORK_GPLUS; $limit = 0; $markup = true; $includedlinks = false; $htmlmode = 9; break; case 'twitter': $send = $b["extid"] != NETWORK_TWITTER; $limit = 140; $markup = false; $includedlinks = true; $htmlmode = 8; break; case 'linkedin': $send = $b["extid"] != NETWORK_LINKEDIN; $limit = 700; $markup = false; $includedlinks = true; $htmlmode = 2; break; } if (!$send) { continue; } $item = $b; // Markup for Google+ if ($markup) { if ($item["title"] != "") { $item["title"] = "*" . $item["title"] . "*"; } $item["body"] = preg_replace("(\\[b\\](.*?)\\[\\/b\\])ism", '*$1*', $item["body"]); $item["body"] = preg_replace("(\\[i\\](.*?)\\[\\/i\\])ism", '_$1_', $item["body"]); $item["body"] = preg_replace("(\\[s\\](.*?)\\[\\/s\\])ism", '-$1-', $item["body"]); } $post = plaintext($a, $item, $limit, $includedlinks, $htmlmode); logger("buffer_send: converted message " . $b["id"] . " result: " . print_r($post, true), LOGGER_DEBUG); // The image proxy is used as a sanitizer. Buffer seems to be really picky about pictures require_once "mod/proxy.php"; if (isset($post["image"])) { $post["image"] = proxy_url($post["image"]); } if (isset($post["preview"])) { $post["preview"] = proxy_url($post["preview"]); } //if ($profile->service == "twitter") { if ($includedlinks) { if (isset($post["url"])) { $post["url"] = short_link($post["url"]); } if (isset($post["image"])) { $post["image"] = short_link($post["image"]); } if (isset($post["preview"])) { $post["preview"] = short_link($post["preview"]); } } // Seems like a bug to me // Buffer doesn't add links to Twitter and App.net (but pictures) //if ($includedlinks AND isset($post["url"])) if ($profile->service == "twitter" and isset($post["url"]) and $post["type"] != "photo") { $post["text"] .= " " . $post["url"]; } elseif ($profile->service == "appdotnet" and isset($post["url"]) and isset($post["title"]) and $post["type"] != "photo") { $post["title"] = shortenmsg($post["title"], 90); $post["text"] = shortenmsg($post["text"], $limit - (24 + strlen($post["title"]))); $post["text"] .= "\n[" . $post["title"] . "](" . $post["url"] . ")"; } elseif ($profile->service == "appdotnet" and isset($post["url"]) and $post["type"] != "photo") { $post["text"] .= " " . $post["url"]; } elseif ($profile->service == "google") { $post["text"] .= html_entity_decode(" ", ENT_QUOTES, 'UTF-8'); } // Send a special blank to identify the post through the "fromgplus" addon $message = array(); $message["text"] = $post["text"]; $message["profile_ids[]"] = $profile->id; $message["shorten"] = false; $message["now"] = true; if (isset($post["title"])) { $message["media[title]"] = $post["title"]; } if (isset($post["description"])) { $message["media[description]"] = $post["description"]; } if (isset($post["url"]) and $post["type"] != "photo") { $message["media[link]"] = $post["url"]; } if (isset($post["image"])) { $message["media[picture]"] = $post["image"]; if ($post["type"] == "photo") { $message["media[thumbnail]"] = $post["image"]; } } if (isset($post["preview"])) { $message["media[thumbnail]"] = $post["preview"]; } //print_r($message); logger("buffer_send: data for message " . $b["id"] . ": " . print_r($message, true), LOGGER_DEBUG); $ret = $buffer->go('/updates/create', $message); logger("buffer_send: send message " . $b["id"] . " result: " . print_r($ret, true), LOGGER_DEBUG); } } } }
function render_content(&$a, $items, $mode, $update, $preview = false) { require_once 'include/bbcode.php'; require_once 'mod/proxy.php'; $ssl_state = local_user() ? true : false; $profile_owner = 0; $page_writeable = false; $previewing = $preview ? ' preview ' : ''; if ($mode === 'network') { $profile_owner = local_user(); $page_writeable = true; } if ($mode === 'profile') { $profile_owner = $a->profile['profile_uid']; $page_writeable = can_write_wall($a, $profile_owner); } if ($mode === 'notes') { $profile_owner = local_user(); $page_writeable = true; } if ($mode === 'display') { $profile_owner = $a->profile['uid']; $page_writeable = can_write_wall($a, $profile_owner); } if ($mode === 'community') { $profile_owner = 0; $page_writeable = false; } if ($update) { $return_url = $_SESSION['return_url']; } else { $return_url = $_SESSION['return_url'] = $a->query_string; } load_contact_links(local_user()); $cb = array('items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview); call_hooks('conversation_start', $cb); $items = $cb['items']; $cmnt_tpl = get_markup_template('comment_item.tpl'); $tpl = 'wall_item.tpl'; $wallwall = 'wallwall_item.tpl'; $hide_comments_tpl = get_markup_template('hide_comments.tpl'); $alike = array(); $dlike = array(); // array with html for each thread (parent+comments) $threads = array(); $threadsid = -1; if ($items && count($items)) { if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') { // "New Item View" on network page or search page results // - just loop through the items and format them minimally for display //$tpl = get_markup_template('search_item.tpl'); $tpl = 'search_item.tpl'; foreach ($items as $item) { $threadsid++; $comment = ''; $owner_url = ''; $owner_photo = ''; $owner_name = ''; $sparkle = ''; if ($mode === 'search' || $mode === 'community') { if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && $item['id'] != $item['parent']) { continue; } $nickname = $item['nickname']; } else { $nickname = $a->user['nickname']; } // prevent private email from leaking. if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) { continue; } $profile_name = strlen($item['author-name']) ? $item['author-name'] : $item['name']; if ($item['author-link'] && !$item['author-name']) { $profile_name = $item['author-link']; } $sp = false; $profile_link = best_link_url($item, $sp); if ($profile_link === 'mailbox') { $profile_link = ''; } if ($sp) { $sparkle = ' sparkle'; } else { $profile_link = zrl($profile_link); } $normalised = normalise_link(strlen($item['author-link']) ? $item['author-link'] : $item['url']); if ($normalised != 'mailbox' && x($a->contacts[$normalised])) { $profile_avatar = $a->contacts[$normalised]['thumb']; } else { $profile_avatar = strlen($item['author-avatar']) ? $a->get_cached_avatar_image($item['author-avatar']) : $item['thumb']; } $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); call_hooks('render_location', $locate); $location = strlen($locate['html']) ? $locate['html'] : render_location_dummy($locate); localize_item($item); if ($mode === 'network-new') { $dropping = true; } else { $dropping = false; } $drop = array('dropping' => $dropping, 'select' => t('Select'), 'delete' => t('Delete')); $star = false; $isstarred = "unstarred"; $lock = false; $likebuttons = false; $shareable = false; $body = prepare_body($item, true); if ($a->theme['template_engine'] === 'internal') { $name_e = template_escape($profile_name); $title_e = template_escape($item['title']); $body_e = template_escape($body); $text_e = strip_tags(template_escape($body)); $location_e = template_escape($location); $owner_name_e = template_escape($owner_name); } else { $name_e = $profile_name; $title_e = $item['title']; $body_e = $body; $text_e = strip_tags($body); $location_e = $location; $owner_name_e = $owner_name; } //$tmp_item = replace_macros($tpl,array( $tmp_item = array('template' => $tpl, 'id' => $preview ? 'P0' : $item['item_id'], 'linktitle' => sprintf(t('View %s\'s profile @ %s'), $profile_name, strlen($item['author-link']) ? $item['author-link'] : $item['url']), 'profile_url' => $profile_link, 'item_photo_menu' => item_photo_menu($item), 'name' => $name_e, 'sparkle' => $sparkle, 'lock' => $lock, 'thumb' => proxy_url($profile_avatar), 'title' => $title_e, 'body' => $body_e, 'text' => $text_e, 'ago' => $item['app'] ? sprintf(t('%s from %s'), relative_date($item['created']), $item['app']) : relative_date($item['created']), 'location' => $location_e, 'indent' => '', 'owner_name' => $owner_name_e, 'owner_url' => $owner_url, 'owner_photo' => proxy_url($owner_photo), 'plink' => get_plink($item), 'edpost' => false, 'isstarred' => $isstarred, 'star' => $star, 'drop' => $drop, 'vote' => $likebuttons, 'like' => '', 'dislike' => '', 'comment' => '', 'conv' => $preview ? '' : array('href' => $a->get_baseurl($ssl_state) . '/display/' . $item['guid'], 'title' => t('View in context')), 'previewing' => $previewing, 'wait' => t('Please wait')); $arr = array('item' => $item, 'output' => $tmp_item); call_hooks('display_item', $arr); $threads[$threadsid]['id'] = $item['item_id']; $threads[$threadsid]['items'] = array($arr['output']); } } else { // Normal View // Figure out how many comments each parent has // (Comments all have gravity of 6) // Store the result in the $comments array $comments = array(); foreach ($items as $item) { if (intval($item['gravity']) == 6 && $item['id'] != $item['parent']) { if (!x($comments, $item['parent'])) { $comments[$item['parent']] = 1; } else { $comments[$item['parent']] += 1; } } elseif (!x($comments, $item['parent'])) { $comments[$item['parent']] = 0; } // avoid notices later on } // map all the like/dislike activities for each parent item // Store these in the $alike and $dlike arrays foreach ($items as $item) { like_puller($a, $item, $alike, 'like'); like_puller($a, $item, $dlike, 'dislike'); } $comments_collapsed = false; $comments_seen = 0; $comment_lastcollapsed = false; $comment_firstcollapsed = false; $blowhard = 0; $blowhard_count = 0; foreach ($items as $item) { $comment = ''; $template = $tpl; $commentww = ''; $sparkle = ''; $owner_url = $owner_photo = $owner_name = ''; // We've already parsed out like/dislike for special treatment. We can ignore them now if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && $item['id'] != $item['parent']) { continue; } $toplevelpost = $item['id'] == $item['parent'] ? true : false; // Take care of author collapsing and comment collapsing // (author collapsing is currently disabled) // If a single author has more than 3 consecutive top-level posts, squash the remaining ones. // If there are more than two comments, squash all but the last 2. if ($toplevelpost) { $item_writeable = $item['writable'] || $item['self'] ? true : false; $comments_seen = 0; $comments_collapsed = false; $comment_lastcollapsed = false; $comment_firstcollapsed = false; $threadsid++; $threads[$threadsid]['id'] = $item['item_id']; $threads[$threadsid]['private'] = $item['private']; $threads[$threadsid]['items'] = array(); } else { // prevent private email reply to public conversation from leaking. if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) { continue; } $comments_seen++; $comment_lastcollapsed = false; $comment_firstcollapsed = false; } $override_comment_box = $page_writeable && $item_writeable ? true : false; $show_comment_box = $page_writeable && $item_writeable && $comments_seen == $comments[$item['parent']] ? true : false; if ($comments[$item['parent']] > 2 && $comments_seen <= $comments[$item['parent']] - 2 && $item['gravity'] == 6) { if (!$comments_collapsed) { $threads[$threadsid]['num_comments'] = sprintf(tt('%d comment', '%d comments', $comments[$item['parent']]), $comments[$item['parent']]); $threads[$threadsid]['hidden_comments_num'] = $comments[$item['parent']]; $threads[$threadsid]['hidden_comments_text'] = tt('comment', 'comments', $comments[$item['parent']]); $threads[$threadsid]['hide_text'] = t('show more'); $comments_collapsed = true; $comment_firstcollapsed = true; } } if ($comments[$item['parent']] > 2 && $comments_seen == $comments[$item['parent']] - 1) { $comment_lastcollapsed = true; } $redirect_url = $a->get_baseurl($ssl_state) . '/redir/' . $item['cid']; $lock = $item['private'] == 1 || $item['uid'] == local_user() && (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) ? t('Private Message') : false; // Top-level wall post not written by the wall owner (wall-to-wall) // First figure out who owns it. $osparkle = ''; if ($toplevelpost && !$item['self'] && $mode !== 'profile') { if ($item['wall']) { // On the network page, I am the owner. On the display page it will be the profile owner. // This will have been stored in $a->page_contact by our calling page. // Put this person as the wall owner of the wall-to-wall notice. $owner_url = zrl($a->page_contact['url']); $owner_photo = $a->page_contact['thumb']; $owner_name = $a->page_contact['name']; $template = $wallwall; $commentww = 'ww'; } if (!$item['wall'] && $item['owner-link']) { $owner_linkmatch = $item['owner-link'] && link_compare($item['owner-link'], $item['author-link']); $alias_linkmatch = $item['alias'] && link_compare($item['alias'], $item['author-link']); $owner_namematch = $item['owner-name'] && $item['owner-name'] == $item['author-name']; if (!$owner_linkmatch && !$alias_linkmatch && !$owner_namematch) { // The author url doesn't match the owner (typically the contact) // and also doesn't match the contact alias. // The name match is a hack to catch several weird cases where URLs are // all over the park. It can be tricked, but this prevents you from // seeing "Bob Smith to Bob Smith via Wall-to-wall" and you know darn // well that it's the same Bob Smith. // But it could be somebody else with the same name. It just isn't highly likely. $owner_url = $item['owner-link']; $owner_photo = $item['owner-avatar']; $owner_name = $item['owner-name']; $template = $wallwall; $commentww = 'ww'; // If it is our contact, use a friendly redirect link if (link_compare($item['owner-link'], $item['url']) && $item['network'] === NETWORK_DFRN) { $owner_url = $redirect_url; $osparkle = ' sparkle'; } else { $owner_url = zrl($owner_url); } } } } $likebuttons = ''; $shareable = $profile_owner == local_user() && $item['private'] != 1 ? true : false; if ($page_writeable) { /* if($toplevelpost) { */ $likebuttons = array('like' => array(t("I like this (toggle)"), t("like")), 'dislike' => array(t("I don't like this (toggle)"), t("dislike"))); if ($shareable) { $likebuttons['share'] = array(t('Share this'), t('share')); } /* } */ $qc = $qcomment = null; if (in_array('qcomment', $a->plugins)) { $qc = local_user() ? get_pconfig(local_user(), 'qcomment', 'words') : null; $qcomment = $qc ? explode("\n", $qc) : null; } if ($show_comment_box || $show_comment_box == false && $override_comment_box == false && $item['last-child']) { $comment = replace_macros($cmnt_tpl, array('$return_path' => '', '$jsreload' => $mode === 'display' ? $_SESSION['return_url'] : '', '$type' => $mode === 'profile' ? 'wall-comment' : 'net-comment', '$id' => $item['item_id'], '$parent' => $item['parent'], '$qcomment' => $qcomment, '$profile_uid' => $profile_owner, '$mylink' => $a->contact['url'], '$mytitle' => t('This is you'), '$myphoto' => $a->contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$edbold' => t('Bold'), '$editalic' => t('Italic'), '$eduline' => t('Underline'), '$edquote' => t('Quote'), '$edcode' => t('Code'), '$edimg' => t('Image'), '$edurl' => t('Link'), '$edvideo' => t('Video'), '$preview' => t('Preview'), '$sourceapp' => t($a->sourcename), '$ww' => $mode === 'network' ? $commentww : '', '$rand_num' => random_digits(12))); } } if (local_user() && link_compare($a->contact['url'], $item['author-link'])) { $edpost = array($a->get_baseurl($ssl_state) . "/editpost/" . $item['id'], t("Edit")); } else { $edpost = false; } $drop = ''; $dropping = false; if (intval($item['contact-id']) && $item['contact-id'] == remote_user() || $item['uid'] == local_user()) { $dropping = true; } $drop = array('dropping' => $dropping, 'select' => t('Select'), 'delete' => t('Delete')); $star = false; $filer = false; $isstarred = "unstarred"; if ($profile_owner == local_user()) { if ($toplevelpost) { $isstarred = $item['starred'] ? "starred" : "unstarred"; $star = array('do' => t("add star"), 'undo' => t("remove star"), 'toggle' => t("toggle star status"), 'classdo' => $item['starred'] ? "hidden" : "", 'classundo' => $item['starred'] ? "" : "hidden", 'starred' => t('starred'), 'tagger' => t("add tag"), 'classtagger' => ""); } $filer = t("save to folder"); } $photo = $item['photo']; $thumb = $item['thumb']; // Post was remotely authored. $diff_author = link_compare($item['url'], $item['author-link']) ? false : true; $profile_name = strlen($item['author-name']) && $diff_author ? $item['author-name'] : $item['name']; if ($item['author-link'] && !$item['author-name']) { $profile_name = $item['author-link']; } $sp = false; $profile_link = best_link_url($item, $sp); if ($profile_link === 'mailbox') { $profile_link = ''; } if ($sp) { $sparkle = ' sparkle'; } else { $profile_link = zrl($profile_link); } $normalised = normalise_link(strlen($item['author-link']) ? $item['author-link'] : $item['url']); if ($normalised != 'mailbox' && x($a->contacts, $normalised)) { $profile_avatar = $a->contacts[$normalised]['thumb']; } else { $profile_avatar = strlen($item['author-avatar']) && $diff_author ? $item['author-avatar'] : $a->get_cached_avatar_image($thumb); } $like = x($alike, $item['uri']) ? format_like($alike[$item['uri']], $alike[$item['uri'] . '-l'], 'like', $item['uri']) : ''; $dislike = x($dlike, $item['uri']) ? format_like($dlike[$item['uri']], $dlike[$item['uri'] . '-l'], 'dislike', $item['uri']) : ''; $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); call_hooks('render_location', $locate); $location = strlen($locate['html']) ? $locate['html'] : render_location_dummy($locate); $indent = $toplevelpost ? '' : ' comment'; $shiny = ""; if (strcmp(datetime_convert('UTC', 'UTC', $item['created']), datetime_convert('UTC', 'UTC', 'now - 12 hours')) > 0) { $shiny = 'shiny'; } // localize_item($item); $tags = array(); foreach (explode(',', $item['tag']) as $tag) { $tag = trim($tag); if ($tag != "") { $tags[] = bbcode($tag); } } // Build the HTML $body = prepare_body($item, true); //$tmp_item = replace_macros($template, if ($a->theme['template_engine'] === 'internal') { $body_e = template_escape($body); $text_e = strip_tags(template_escape($body)); $name_e = template_escape($profile_name); $title_e = template_escape($item['title']); $location_e = template_escape($location); $owner_name_e = template_escape($owner_name); } else { $body_e = $body; $text_e = strip_tags($body); $name_e = $profile_name; $title_e = $item['title']; $location_e = $location; $owner_name_e = $owner_name; } $tmp_item = array('comment_firstcollapsed' => $comment_firstcollapsed, 'comment_lastcollapsed' => $comment_lastcollapsed, 'template' => $template, 'type' => implode("", array_slice(explode("/", $item['verb']), -1)), 'tags' => $tags, 'body' => $body_e, 'text' => $text_e, 'id' => $item['item_id'], 'linktitle' => sprintf(t('View %s\'s profile @ %s'), $profile_name, strlen($item['author-link']) ? $item['author-link'] : $item['url']), 'olinktitle' => sprintf(t('View %s\'s profile @ %s'), $profile_name, strlen($item['owner-link']) ? $item['owner-link'] : $item['url']), 'to' => t('to'), 'wall' => t('Wall-to-Wall'), 'vwall' => t('via Wall-To-Wall:'), 'profile_url' => $profile_link, 'item_photo_menu' => item_photo_menu($item), 'name' => $name_e, 'thumb' => proxy_url($profile_avatar), 'osparkle' => $osparkle, 'sparkle' => $sparkle, 'title' => $title_e, 'ago' => $item['app'] ? sprintf(t('%s from %s'), relative_date($item['created']), $item['app']) : relative_date($item['created']), 'lock' => $lock, 'location' => $location_e, 'indent' => $indent, 'shiny' => $shiny, 'owner_url' => $owner_url, 'owner_photo' => proxy_url($owner_photo), 'owner_name' => $owner_name_e, 'plink' => get_plink($item), 'edpost' => $edpost, 'isstarred' => $isstarred, 'star' => $star, 'filer' => $filer, 'drop' => $drop, 'vote' => $likebuttons, 'like' => $like, 'dislike' => $dislike, 'comment' => $comment, 'previewing' => $previewing, 'wait' => t('Please wait')); $arr = array('item' => $item, 'output' => $tmp_item); call_hooks('display_item', $arr); $threads[$threadsid]['items'][] = $arr['output']; } } } return $threads; }
/** * * @param array $contact * @param boolean $redirect * @param string $class * @param boolean $textmode * @return string #FIXME: remove html */ function micropro($contact, $redirect = false, $class = '', $textmode = false) { if ($class) { $class = ' ' . $class; } $url = $contact['url']; $sparkle = ''; $redir = false; if ($redirect) { $a = get_app(); $redirect_url = $a->get_baseurl() . '/redir/' . $contact['id']; if (local_user() && $contact['uid'] == local_user() && $contact['network'] === NETWORK_DFRN) { $redir = true; $url = $redirect_url; $sparkle = ' sparkle'; } else { $url = zrl($url); } } $click = x($contact, 'click') ? ' onclick="' . $contact['click'] . '" ' : ''; if ($click) { $url = ''; } if ($textmode) { return '<div class="contact-block-textdiv' . $class . '"><a class="contact-block-link' . $class . $sparkle . ($click ? ' fakelink' : '') . '" ' . ($redir ? ' target="redir" ' : '') . ($url ? ' href="' . $url . '"' : '') . $click . '" title="' . $contact['name'] . ' [' . $contact['url'] . ']" alt="' . $contact['name'] . '" >' . $contact['name'] . '</a></div>' . "\r\n"; } else { return '<div class="contact-block-div' . $class . '"><a class="contact-block-link' . $class . $sparkle . ($click ? ' fakelink' : '') . '" ' . ($redir ? ' target="redir" ' : '') . ($url ? ' href="' . $url . '"' : '') . $click . ' ><img class="contact-block-img' . $class . $sparkle . '" src="' . proxy_url($contact['micro']) . '" title="' . $contact['name'] . ' [' . $contact['url'] . ']" alt="' . $contact['name'] . '" /></a></div>' . "\r\n"; } }
function follow_content(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); goaway($_SESSION['return_url']); // NOTREACHED } $uid = local_user(); $url = notags(trim($_REQUEST['url'])); $submit = t('Submit Request'); // There is a current issue. It seems as if you can't start following a Friendica that is following you // With Diaspora this works - but Friendica is special, it seems ... $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND ((`rel` != %d) OR (`network` = '%s')) AND\n\t\t(`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s') AND\n\t\t`network` != '%s' LIMIT 1", intval(local_user()), dbesc(CONTACT_IS_FOLLOWER), dbesc(NETWORK_DFRN), dbesc(normalise_link($url)), dbesc(normalise_link($url)), dbesc($url), dbesc(NETWORK_STATUSNET)); if ($r) { notice(t('You already added this contact.') . EOL); $submit = ""; //goaway($_SESSION['return_url']); // NOTREACHED } $ret = probe_url($url); if ($ret["network"] == NETWORK_DIASPORA and !get_config('system', 'diaspora_enabled')) { notice(t("Diaspora support isn't enabled. Contact can't be added.") . EOL); $submit = ""; //goaway($_SESSION['return_url']); // NOTREACHED } if ($ret["network"] == NETWORK_OSTATUS and get_config('system', 'ostatus_disabled')) { notice(t("OStatus support is disabled. Contact can't be added.") . EOL); $submit = ""; //goaway($_SESSION['return_url']); // NOTREACHED } if ($ret["network"] == NETWORK_PHANTOM) { notice(t("The network type couldn't be detected. Contact can't be added.") . EOL); $submit = ""; //goaway($_SESSION['return_url']); // NOTREACHED } if ($ret["network"] == NETWORK_MAIL) { $ret["url"] = $ret["addr"]; } if ($ret['network'] === NETWORK_DFRN) { $request = $ret["request"]; $tpl = get_markup_template('dfrn_request.tpl'); } else { $request = $a->get_baseurl() . "/follow"; $tpl = get_markup_template('auto_request.tpl'); } $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid)); if (!$r) { notice(t('Permission denied.') . EOL); goaway($_SESSION['return_url']); // NOTREACHED } $myaddr = $r[0]["url"]; // Makes the connection request for friendica contacts easier $_SESSION["fastlane"] = $ret["url"]; $r = q("SELECT `location`, `about`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'", normalise_link($ret["url"])); if (!$r) { $r = array(array("location" => "", "about" => "", "keywords" => "")); } if ($ret['network'] === NETWORK_DIASPORA) { $r[0]["location"] = ""; $r[0]["about"] = ""; } $header = $ret["name"]; if ($ret["addr"] != "") { $header .= " <" . $ret["addr"] . ">"; } $header .= " (" . network_to_name($ret['network'], $ret['url']) . ")"; $o = replace_macros($tpl, array('$header' => htmlentities($header), '$photo' => proxy_url($ret["photo"], false, PROXY_SIZE_SMALL), '$desc' => "", '$pls_answer' => t('Please answer the following:'), '$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'), $ret["name"]), false, '', array(t('No'), t('Yes'))), '$add_note' => t('Add a personal note:'), '$page_desc' => "", '$friendica' => "", '$statusnet' => "", '$diaspora' => "", '$diasnote' => "", '$your_address' => t('Your Identity Address:'), '$invite_desc' => "", '$emailnet' => "", '$submit' => $submit, '$cancel' => t('Cancel'), '$nickname' => "", '$name' => $ret["name"], '$url' => $ret["url"], '$zrl' => zrl($ret["url"]), '$url_label' => t("Profile URL"), '$myaddr' => $myaddr, '$request' => $request, '$location' => bbcode($r[0]["location"]), '$location_label' => t("Location:"), '$about' => bbcode($r[0]["about"], false, false), '$about_label' => t("About:"), '$keywords' => $r[0]["keywords"], '$keywords_label' => t("Tags:"))); return $o; }
function common_content(&$a) { $o = ''; $cmd = $a->argv[1]; $uid = intval($a->argv[2]); $cid = intval($a->argv[3]); $zcid = 0; if (!local_user()) { notice(t('Permission denied.') . EOL); return; } if ($cmd !== 'loc' && $cmd != 'rem') { return; } if (!$uid) { return; } if ($cmd === 'loc' && $cid) { $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval($uid)); $a->page['aside'] = ""; profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"])); } else { $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", intval($uid)); $vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"), array('$name' => htmlentities($c[0]['name']), '$photo' => $c[0]['photo'], 'url' => z_root() . '/contacts/' . $cid)); if (!x($a->page, 'aside')) { $a->page['aside'] = ''; } $a->page['aside'] .= $vcard_widget; } if (!count($c)) { return; } if (!$cid) { if (get_my_url()) { $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1", dbesc(normalise_link(get_my_url())), intval($profile_uid)); if (count($r)) { $cid = $r[0]['id']; } else { $r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1", dbesc(normalise_link(get_my_url()))); if (count($r)) { $zcid = $r[0]['id']; } } } } if ($cid == 0 && $zcid == 0) { return; } if ($cid) { $t = count_common_friends($uid, $cid); } else { $t = count_common_friends_zcid($uid, $zcid); } if (count($t)) { $a->set_pager_total($t); } else { notice(t('No contacts in common.') . EOL); return $o; } if ($cid) { $r = common_friends($uid, $cid, $a->pager['start'], $a->pager['itemspage']); } else { $r = common_friends_zcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']); } if (!count($r)) { return $o; } $id = 0; foreach ($r as $rr) { //get further details of the contact $contact_details = get_contact_details_by_url($rr['url'], $uid); // $rr[id] is needed to use contact_photo_menu() $rr[id] = $rr[cid]; $photo_menu = ''; $photo_menu = contact_photo_menu($rr); $entry = array('url' => $rr['url'], 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $rr['url'], 'name' => $rr['name'], 'thumb' => proxy_url($rr['photo'], false, PROXY_SIZE_THUMB), 'img_hover' => htmlentities($rr['name']), 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'network' => network_to_name($contact_details['network'], $contact_details['url']), 'photo_menu' => $photo_menu, 'id' => ++$id); $entries[] = $entry; } if ($cmd === 'loc' && $cid && $uid == local_user()) { $tab_str = contacts_tab($a, $cid, 4); } else { $title = t('Common Friends'); } $tpl = get_markup_template('viewcontact_template.tpl'); $o .= replace_macros($tpl, array('$title' => $title, '$tab_str' => $tab_str, '$contacts' => $entries, '$paginate' => paginate($a))); return $o; }
function oembed_format_object($j) { require_once "mod/proxy.php"; $a = get_app(); $embedurl = $j->embedurl; $jhtml = oembed_iframe($j->embedurl, isset($j->width) ? $j->width : null, isset($j->height) ? $j->height : null); $ret = "<span class='oembed " . $j->type . "'>"; switch ($j->type) { case "video": if (isset($j->thumbnail_url)) { $tw = isset($j->thumbnail_width) && intval($j->thumbnail_width) ? $j->thumbnail_width : 200; $th = isset($j->thumbnail_height) && intval($j->thumbnail_height) ? $j->thumbnail_height : 180; // make sure we don't attempt divide by zero, fallback is a 1:1 ratio $tr = $th ? $tw / $th : 1; $th = 120; $tw = $th * $tr; $tpl = get_markup_template('oembed_video.tpl'); $ret .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl(), '$embedurl' => $embedurl, '$escapedhtml' => base64_encode($jhtml), '$tw' => $tw, '$th' => $th, '$turl' => $j->thumbnail_url)); } else { $ret = $jhtml; } $ret .= "<br>"; break; case "photo": $ret .= "<img width='" . $j->width . "' src='" . proxy_url($j->url) . "'>"; //$ret.= "<img width='".$j->width."' height='".$j->height."' src='".proxy_url($j->url)."'>"; $ret .= "<br>"; break; case "link": //$ret = "<a href='".$embedurl."'>".$j->title."</a>"; break; case "rich": // not so safe.. if (!get_config("system", "no_oembed_rich_content")) { $ret .= proxy_parse_html($jhtml); } break; } // add link to source if not present in "rich" type if ($j->type != 'rich' || !strpos($j->html, $embedurl)) { $ret .= "<h4>"; if (isset($j->title)) { if (isset($j->provider_name)) { $ret .= $j->provider_name . ": "; } $embedlink = isset($j->title) ? $j->title : $embedurl; $ret .= "<a href='{$embedurl}' rel='oembed'>{$embedlink}</a>"; if (isset($j->author_name)) { $ret .= " (" . $j->author_name . ")"; } } elseif (isset($j->provider_name) or isset($j->author_name)) { $embedlink = ""; if (isset($j->provider_name)) { $embedlink .= $j->provider_name; } if (isset($j->author_name)) { if ($embedlink != "") { $embedlink .= ": "; } $embedlink .= $j->author_name; } if (trim($embedlink) == "") { $embedlink = $embedurl; } $ret .= "<a href='{$embedurl}' rel='oembed'>{$embedlink}</a>"; } //if (isset($j->author_name)) $ret.=" by ".$j->author_name; //if (isset($j->provider_name)) $ret.=" on ".$j->provider_name; $ret .= "</h4>"; } else { // add <a> for html2bbcode conversion $ret .= "<a href='{$embedurl}' rel='oembed'>{$embedurl}</a>"; $ret .= "<br style='clear:left'>"; } $ret .= "</span>"; return mb_convert_encoding($ret, 'HTML-ENTITIES', mb_detect_encoding($ret)); }
if (count($serverAndToken) > 1) { $token = $serverAndToken[1]; } // Make a pattern that matches either-or $pat = str_replace(".", '[_\\.]', $url); $pat = "/" . str_replace("/", '\\/', $pat) . "/i"; if (preg_match($pat, $rUrl)) { // Substitute the .'s back into the URL for ($i = 0; $i < strlen($url); $i++) { if (substr($url, $i, 1) == ".") { $rUrl = substr_replace($rUrl, ".", $i, 1); } } $bAllowed = true; $token = trim($token); break; } } if ($bAllowed) { break; } } if (!$bAllowed) { header('HTTP/1.1 403 Forbidden'); return; } if (strlen($token) > 0) { $rUrl = $rUrl . (strpos($rUrl, "?") === false ? "?" : "&") . "token=" + token; } echo proxy_url($rUrl);
function bb_ShareAttributes($share, $simplehtml) { $attributes = $share[2]; $author = ""; preg_match("/author='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") { $author = html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8'); } preg_match('/author="(.*?)"/ism', $attributes, $matches); if ($matches[1] != "") { $author = $matches[1]; } $profile = ""; preg_match("/profile='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") { $profile = $matches[1]; } preg_match('/profile="(.*?)"/ism', $attributes, $matches); if ($matches[1] != "") { $profile = $matches[1]; } $avatar = ""; preg_match("/avatar='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") { $avatar = $matches[1]; } preg_match('/avatar="(.*?)"/ism', $attributes, $matches); if ($matches[1] != "") { $avatar = $matches[1]; } $link = ""; preg_match("/link='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") { $link = $matches[1]; } preg_match('/link="(.*?)"/ism', $attributes, $matches); if ($matches[1] != "") { $link = $matches[1]; } $posted = ""; $itemcache = get_itemcachepath(); // relative dates only make sense when they aren't cached if ($itemcache == "") { preg_match("/posted='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") { $posted = $matches[1]; } preg_match('/posted="(.*?)"/ism', $attributes, $matches); if ($matches[1] != "") { $posted = $matches[1]; } $reldate = $posted ? " " . relative_date($posted) : ''; } $userid = GetProfileUsername($profile, $author, false); $userid_compact = GetProfileUsername($profile, $author, true); $preshare = trim($share[1]); if ($preshare != "") { $preshare .= "<br /><br />"; } switch ($simplehtml) { case 1: $text = $preshare . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . ' <a href="' . $profile . '">' . $userid . "</a>: <br />»" . $share[3] . "«"; break; case 2: $text = $preshare . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . ' ' . $userid_compact . ": <br />" . $share[3]; break; case 3: // Diaspora $headline .= '<b>' . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . $userid . ':</b><br />'; $text = trim($share[1]); if ($text != "") { $text .= "<hr />"; } if (substr(normalise_link($link), 0, 19) != "http://twitter.com/") { $text .= $headline . '<blockquote>' . trim($share[3]) . "</blockquote><br />"; if ($link != "") { $text .= '<br /><a href="' . $link . '">[l]</a>'; } } else { $text .= '<br /><a href="' . $link . '">' . $link . '</a>'; } break; case 4: $headline = '<div class="shared_header">'; $headline .= '<span><b>' . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8'); $headline .= sprintf(t('<a href="%1$s" target="_blank">%2$s</a> %3$s'), $link, $userid, $posted); $headline .= ":</b></span></div>"; $text = trim($share[1]); if ($text != "") { $text .= "<hr />"; } $text .= $headline . '<blockquote class="shared_content">' . trim($share[3]) . "</blockquote><br />"; break; case 5: $text = $preshare . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . ' ' . $userid_compact . ": <br />" . $share[3]; break; case 6: // app.net $text = $preshare . ">> @" . $userid_compact . ": <br />" . $share[3]; break; case 7: // statusnet/GNU Social $text = $preshare . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . " @" . $userid_compact . ": " . $share[3]; break; case 8: // twitter $text = $preshare . "RT @" . $userid_compact . ": " . $share[3]; break; case 9: // Google+/Facebook $text = $preshare . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . ' ' . $userid_compact . ": <br />" . $share[3]; if ($link != "") { $text .= "<br /><br />" . $link; } break; default: $headline = trim($share[1]) . '<div class="shared_header">'; if ($avatar != "") { $headline .= '<img src="' . proxy_url($avatar, false, PROXY_SIZE_MICRO) . '" height="32" width="32" >'; } $headline .= sprintf(t('<span><a href="%s" target="_blank">%s</a> wrote the following <a href="%s" target="_blank">post</a>' . $reldate . ':</span>'), $profile, $author, $link); $headline .= "</div>"; $text = $headline . '<blockquote class="shared_content">' . trim($share[3]) . "</blockquote>"; break; } return $text; }
function notifications_content(&$a) { if (!local_user()) { notice(t('Permission denied.') . EOL); return; } nav_set_selected('notifications'); $json = $a->argc > 1 && $a->argv[$a->argc - 1] === 'json' ? true : false; $o = ''; $tabs = array(array('label' => t('System'), 'url' => $a->get_baseurl(true) . '/notifications/system', 'sel' => $a->argv[1] == 'system' ? 'active' : '', 'accesskey' => 'y'), array('label' => t('Network'), 'url' => $a->get_baseurl(true) . '/notifications/network', 'sel' => $a->argv[1] == 'network' ? 'active' : '', 'accesskey' => 'w'), array('label' => t('Personal'), 'url' => $a->get_baseurl(true) . '/notifications/personal', 'sel' => $a->argv[1] == 'personal' ? 'active' : '', 'accesskey' => 'r'), array('label' => t('Home'), 'url' => $a->get_baseurl(true) . '/notifications/home', 'sel' => $a->argv[1] == 'home' ? 'active' : '', 'accesskey' => 'h'), array('label' => t('Introductions'), 'url' => $a->get_baseurl(true) . '/notifications/intros', 'sel' => $a->argv[1] == 'intros' ? 'active' : '', 'accesskey' => 'i')); $o = ""; if ($a->argc > 1 && $a->argv[1] == 'intros' || $a->argc == 1) { nav_set_selected('introductions'); if ($a->argc > 2 && $a->argv[2] == 'all') { $sql_extra = ''; } else { $sql_extra = " AND `ignore` = 0 "; } $notif_tpl = get_markup_template('notifications.tpl'); $notif_content .= '<a href="' . (strlen($sql_extra) ? 'notifications/intros/all' : 'notifications/intros') . '" id="notifications-show-hide-link" >' . (strlen($sql_extra) ? t('Show Ignored Requests') : t('Hide Ignored Requests')) . '</a></div>' . "\r\n"; $r = q("SELECT COUNT(*)\tAS `total` FROM `intro`\n\t\t\tWHERE `intro`.`uid` = %d {$sql_extra} AND `intro`.`blocked` = 0 ", intval($_SESSION['uid'])); if ($r && count($r)) { $a->set_pager_total($r[0]['total']); $a->set_pager_itemspage(20); } $r = q("SELECT `intro`.`id` AS `intro_id`, `intro`.*, `contact`.*, `fcontact`.`name` AS `fname`,`fcontact`.`url` AS `furl`,`fcontact`.`photo` AS `fphoto`,`fcontact`.`request` AS `frequest`,\n\t\t\t\t`gcontact`.`location` AS `glocation`, `gcontact`.`about` AS `gabout`,\n\t\t\t\t`gcontact`.`keywords` AS `gkeywords`, `gcontact`.`gender` AS `ggender`,\n\t\t\t\t`gcontact`.`network` AS `gnetwork`\n\t\t\tFROM `intro`\n\t\t\t\tLEFT JOIN `contact` ON `contact`.`id` = `intro`.`contact-id`\n\t\t\t\tLEFT JOIN `gcontact` ON `gcontact`.`nurl` = `contact`.`nurl`\n\t\t\t\tLEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`\n\t\t\tWHERE `intro`.`uid` = %d {$sql_extra} AND `intro`.`blocked` = 0 ", intval($_SESSION['uid'])); if ($r !== false && count($r)) { $sugg = get_markup_template('suggestions.tpl'); $tpl = get_markup_template("intros.tpl"); foreach ($r as $rr) { if ($rr['fid']) { $return_addr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname() . ($a->path ? '/' . $a->path : '')); $notif_content .= replace_macros($sugg, array('$str_notifytype' => t('Notification type: '), '$notify_type' => t('Friend Suggestion'), '$intro_id' => $rr['intro_id'], '$madeby' => sprintf(t('suggested by %s'), $rr['name']), '$contact_id' => $rr['contact-id'], '$photo' => x($rr, 'fphoto') ? proxy_url($rr['fphoto'], false, PROXY_SIZE_SMALL) : "images/person-175.jpg", '$fullname' => $rr['fname'], '$url' => zrl($rr['furl']), '$hidden' => array('hidden', t('Hide this contact from others'), $rr['hidden'] == 1, ''), '$activity' => array('activity', t('Post a new friend activity'), intval(get_pconfig(local_user(), 'system', 'post_newfriend')) ? '1' : 0, t('if applicable')), '$knowyou' => $knowyou, '$approve' => t('Approve'), '$note' => $rr['note'], '$request' => $rr['frequest'] . '?addr=' . $return_addr, '$ignore' => t('Ignore'), '$discard' => t('Discard'))); continue; } $friend_selected = $rr['network'] !== NETWORK_OSTATUS ? ' checked="checked" ' : ' disabled '; $fan_selected = $rr['network'] === NETWORK_OSTATUS ? ' checked="checked" disabled ' : ''; $dfrn_tpl = get_markup_template('netfriend.tpl'); $knowyou = ''; $dfrn_text = ''; if ($rr['network'] === NETWORK_DFRN || $rr['network'] === NETWORK_DIASPORA) { if ($rr['network'] === NETWORK_DFRN) { $knowyou = t('Claims to be known to you: ') . ($rr['knowyou'] ? t('yes') : t('no')); $helptext = t('Shall your connection be bidirectional or not? "Friend" implies that you allow to read and you subscribe to their posts. "Fan/Admirer" means that you allow to read but you do not want to read theirs. Approve as: '); } else { $knowyou = ''; $helptext = t('Shall your connection be bidirectional or not? "Friend" implies that you allow to read and you subscribe to their posts. "Sharer" means that you allow to read but you do not want to read theirs. Approve as: '); } $dfrn_text = replace_macros($dfrn_tpl, array('$intro_id' => $rr['intro_id'], '$friend_selected' => $friend_selected, '$fan_selected' => $fan_selected, '$approve_as' => $helptext, '$as_friend' => t('Friend'), '$as_fan' => $rr['network'] == NETWORK_DIASPORA ? t('Sharer') : t('Fan/Admirer'))); } $header = $rr["name"]; $ret = probe_url($rr["url"]); if ($rr['gnetwork'] == "") { $rr['gnetwork'] = $ret["network"]; } if ($ret["addr"] != "") { $header .= " <" . $ret["addr"] . ">"; } $header .= " (" . network_to_name($rr['gnetwork'], $rr['url']) . ")"; // Don't show these data until you are connected. Diaspora is doing the same. if ($rr['gnetwork'] === NETWORK_DIASPORA) { $rr['glocation'] = ""; $rr['gabout'] = ""; $rr['ggender'] = ""; } $notif_content .= replace_macros($tpl, array('$header' => htmlentities($header), '$str_notifytype' => t('Notification type: '), '$notify_type' => $rr['network'] !== NETWORK_OSTATUS ? t('Friend/Connect Request') : t('New Follower'), '$dfrn_text' => $dfrn_text, '$dfrn_id' => $rr['issued-id'], '$uid' => $_SESSION['uid'], '$intro_id' => $rr['intro_id'], '$contact_id' => $rr['contact-id'], '$photo' => x($rr, 'photo') ? proxy_url($rr['photo'], false, PROXY_SIZE_SMALL) : "images/person-175.jpg", '$fullname' => $rr['name'], '$location' => bbcode($rr['glocation'], false, false), '$location_label' => t('Location:'), '$about' => bbcode($rr['gabout'], false, false), '$about_label' => t('About:'), '$keywords' => $rr['gkeywords'], '$keywords_label' => t('Tags:'), '$gender' => $rr['ggender'], '$gender_label' => t('Gender:'), '$hidden' => array('hidden', t('Hide this contact from others'), $rr['hidden'] == 1, ''), '$activity' => array('activity', t('Post a new friend activity'), intval(get_pconfig(local_user(), 'system', 'post_newfriend')) ? '1' : 0, t('if applicable')), '$url' => $rr['url'], '$zrl' => zrl($rr['url']), '$url_label' => t('Profile URL'), '$knowyou' => $knowyou, '$approve' => t('Approve'), '$note' => $rr['note'], '$ignore' => t('Ignore'), '$discard' => t('Discard'))); } } else { info(t('No introductions.') . EOL); } $o .= replace_macros($notif_tpl, array('$notif_header' => t('Notifications'), '$tabs' => $tabs, '$notif_content' => $notif_content)); $o .= paginate($a); return $o; } else { if ($a->argc > 1 && $a->argv[1] == 'network') { $notif_tpl = get_markup_template('notifications.tpl'); $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,\n\t\t\t\t`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`,\n\t\t\t\t`pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid`\n\t\t\t\tFROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`\n\t\t\t\tWHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND `pitem`.`parent` != 0 AND\n\t\t\t\t `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC", intval(local_user())); $tpl_item_likes = get_markup_template('notifications_likes_item.tpl'); $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl'); $tpl_item_friends = get_markup_template('notifications_friends_item.tpl'); $tpl_item_comments = get_markup_template('notifications_comments_item.tpl'); $tpl_item_posts = get_markup_template('notifications_posts_item.tpl'); $notif_content = ''; if ($r) { foreach ($r as $it) { switch ($it['verb']) { case ACTIVITY_LIKE: $notif_content .= replace_macros($tpl_item_likes, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), '$item_text' => sprintf(t("%s liked %s's post"), $it['author-name'], $it['pname']), '$item_when' => relative_date($it['created']))); break; case ACTIVITY_DISLIKE: $notif_content .= replace_macros($tpl_item_dislikes, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), '$item_text' => sprintf(t("%s disliked %s's post"), $it['author-name'], $it['pname']), '$item_when' => relative_date($it['created']))); break; case ACTIVITY_FRIEND: $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">"; $obj = parse_xml_string($xmlhead . $it['object']); $it['fname'] = $obj->title; $notif_content .= replace_macros($tpl_item_friends, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), '$item_text' => sprintf(t("%s is now friends with %s"), $it['author-name'], $it['fname']), '$item_when' => relative_date($it['created']))); break; default: $item_text = $it['id'] == $it['parent'] ? sprintf(t("%s created a new post"), $it['author-name']) : sprintf(t("%s commented on %s's post"), $it['author-name'], $it['pname']); $tpl = $it['id'] == $it['parent'] ? $tpl_item_posts : $tpl_item_comments; $notif_content .= replace_macros($tpl, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), '$item_text' => $item_text, '$item_when' => relative_date($it['created']))); } } } else { $notif_content = t('No more network notifications.'); } $o .= replace_macros($notif_tpl, array('$notif_header' => t('Network Notifications'), '$tabs' => $tabs, '$notif_content' => $notif_content)); } else { if ($a->argc > 1 && $a->argv[1] == 'system') { $notif_tpl = get_markup_template('notifications.tpl'); $not_tpl = get_markup_template('notify.tpl'); require_once 'include/bbcode.php'; $r = q("SELECT * from notify where uid = %d and seen = 0 order by date desc", intval(local_user())); if (count($r) > 0) { foreach ($r as $it) { $notif_content .= replace_macros($not_tpl, array('$item_link' => $a->get_baseurl(true) . '/notify/view/' . $it['id'], '$item_image' => proxy_url($it['photo'], false, PROXY_SIZE_MICRO), '$item_text' => strip_tags(bbcode($it['msg'])), '$item_when' => relative_date($it['date']))); } } else { $notif_content .= t('No more system notifications.'); } $o .= replace_macros($notif_tpl, array('$notif_header' => t('System Notifications'), '$tabs' => $tabs, '$notif_content' => $notif_content)); } else { if ($a->argc > 1 && $a->argv[1] == 'personal') { $notif_tpl = get_markup_template('notifications.tpl'); $myurl = $a->get_baseurl(true) . '/profile/' . $a->user['nickname']; $myurl = substr($myurl, strpos($myurl, '://') + 3); $myurl = str_replace(array('www.', '.'), array('', '\\.'), $myurl); $diasp_url = str_replace('/profile/', '/u/', $myurl); $sql_extra .= sprintf(" AND ( `item`.`author-link` regexp '%s' or `item`.`tag` regexp '%s' or `item`.`tag` regexp '%s' ) ", dbesc($myurl . '$'), dbesc($myurl . '\\]'), dbesc($diasp_url . '\\]')); $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,\n\t\t\t\t`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`,\n\t\t\t\t`pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid`\n\t\t\t\tFROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`\n\t\t\t\tWHERE `item`.`unseen` = 1 AND `item`.`visible` = 1\n\t\t\t\t{$sql_extra}\n\t\t\t\tAND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC", intval(local_user())); $tpl_item_likes = get_markup_template('notifications_likes_item.tpl'); $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl'); $tpl_item_friends = get_markup_template('notifications_friends_item.tpl'); $tpl_item_comments = get_markup_template('notifications_comments_item.tpl'); $tpl_item_posts = get_markup_template('notifications_posts_item.tpl'); $notif_content = ''; if (count($r) > 0) { foreach ($r as $it) { switch ($it['verb']) { case ACTIVITY_LIKE: $notif_content .= replace_macros($tpl_item_likes, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => sprintf(t("%s liked %s's post"), $it['author-name'], $it['pname']), '$item_when' => relative_date($it['created']))); break; case ACTIVITY_DISLIKE: $notif_content .= replace_macros($tpl_item_dislikes, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => sprintf(t("%s disliked %s's post"), $it['author-name'], $it['pname']), '$item_when' => relative_date($it['created']))); break; case ACTIVITY_FRIEND: $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">"; $obj = parse_xml_string($xmlhead . $it['object']); $it['fname'] = $obj->title; $notif_content .= replace_macros($tpl_item_friends, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => sprintf(t("%s is now friends with %s"), $it['author-name'], $it['fname']), '$item_when' => relative_date($it['created']))); break; default: $item_text = $it['id'] == $it['parent'] ? sprintf(t("%s created a new post"), $it['author-name']) : sprintf(t("%s commented on %s's post"), $it['author-name'], $it['pname']); $tpl = $it['id'] == $it['parent'] ? $tpl_item_posts : $tpl_item_comments; $notif_content .= replace_macros($tpl, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => $item_text, '$item_when' => relative_date($it['created']))); } } } else { $notif_content = t('No more personal notifications.'); } $o .= replace_macros($notif_tpl, array('$notif_header' => t('Personal Notifications'), '$tabs' => $tabs, '$notif_content' => $notif_content)); } else { if ($a->argc > 1 && $a->argv[1] == 'home') { $notif_tpl = get_markup_template('notifications.tpl'); $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,\n\t\t\t\t`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`,\n\t\t\t\t`pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid`\n\t\t\t\tFROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`\n\t\t\t\tWHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND\n\t\t\t\t `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1 ORDER BY `item`.`created` DESC", intval(local_user())); $tpl_item_likes = get_markup_template('notifications_likes_item.tpl'); $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl'); $tpl_item_friends = get_markup_template('notifications_friends_item.tpl'); $tpl_item_comments = get_markup_template('notifications_comments_item.tpl'); $notif_content = ''; if (count($r) > 0) { foreach ($r as $it) { switch ($it['verb']) { case ACTIVITY_LIKE: $notif_content .= replace_macros($tpl_item_likes, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => sprintf(t("%s liked %s's post"), $it['author-name'], $it['pname']), '$item_when' => relative_date($it['created']))); break; case ACTIVITY_DISLIKE: $notif_content .= replace_macros($tpl_item_dislikes, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => sprintf(t("%s disliked %s's post"), $it['author-name'], $it['pname']), '$item_when' => relative_date($it['created']))); break; case ACTIVITY_FRIEND: $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">"; $obj = parse_xml_string($xmlhead . $it['object']); $it['fname'] = $obj->title; $notif_content .= replace_macros($tpl_item_friends, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => sprintf(t("%s is now friends with %s"), $it['author-name'], $it['fname']), '$item_when' => relative_date($it['created']))); break; default: $notif_content .= replace_macros($tpl_item_comments, array('$item_link' => $a->get_baseurl(true) . '/display/' . $it['pguid'], '$item_image' => $it['author-avatar'], '$item_text' => sprintf(t("%s commented on %s's post"), $it['author-name'], $it['pname']), '$item_when' => relative_date($it['created']))); } } } else { $notif_content = t('No more home notifications.'); } $o .= replace_macros($notif_tpl, array('$notif_header' => t('Home Notifications'), '$tabs' => $tabs, '$notif_content' => $notif_content)); } } } } } $o .= paginate($a); return $o; }
function conversation(&$a, $items, $mode, $update, $preview = false) { require_once 'include/bbcode.php'; require_once 'mod/proxy.php'; $ssl_state = local_user() ? true : false; $profile_owner = 0; $page_writeable = false; $live_update_div = ''; $arr_blocked = null; if (local_user()) { $str_blocked = get_pconfig(local_user(), 'system', 'blocked'); if ($str_blocked) { $arr_blocked = explode(',', $str_blocked); for ($x = 0; $x < count($arr_blocked); $x++) { $arr_blocked[$x] = trim($arr_blocked[$x]); } } } $previewing = $preview ? ' preview ' : ''; if ($mode === 'network') { $profile_owner = local_user(); $page_writeable = true; if (!$update) { // The special div is needed for liveUpdate to kick in for this page. // We only launch liveUpdate if you aren't filtering in some incompatible // way and also you aren't writing a comment (discovered in javascript). $live_update_div = '<div id="live-network"></div>' . "\r\n" . "<script> var profile_uid = " . $_SESSION['uid'] . "; var netargs = '" . substr($a->cmd, 8) . '?f=' . (x($_GET, 'cid') ? '&cid=' . $_GET['cid'] : '') . (x($_GET, 'search') ? '&search=' . $_GET['search'] : '') . (x($_GET, 'star') ? '&star=' . $_GET['star'] : '') . (x($_GET, 'order') ? '&order=' . $_GET['order'] : '') . (x($_GET, 'bmark') ? '&bmark=' . $_GET['bmark'] : '') . (x($_GET, 'liked') ? '&liked=' . $_GET['liked'] : '') . (x($_GET, 'conv') ? '&conv=' . $_GET['conv'] : '') . (x($_GET, 'spam') ? '&spam=' . $_GET['spam'] : '') . (x($_GET, 'nets') ? '&nets=' . $_GET['nets'] : '') . (x($_GET, 'cmin') ? '&cmin=' . $_GET['cmin'] : '') . (x($_GET, 'cmax') ? '&cmax=' . $_GET['cmax'] : '') . (x($_GET, 'file') ? '&file=' . $_GET['file'] : '') . "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n"; } } else { if ($mode === 'profile') { $profile_owner = $a->profile['profile_uid']; $page_writeable = can_write_wall($a, $profile_owner); if (!$update) { $tab = notags(trim($_GET['tab'])); $tab = $tab ? $tab : 'posts'; if ($tab === 'posts') { // This is ugly, but we can't pass the profile_uid through the session to the ajax updater, // because browser prefetching might change it on us. We have to deliver it with the page. $live_update_div = '<div id="live-profile"></div>' . "\r\n" . "<script> var profile_uid = " . $a->profile['profile_uid'] . "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n"; } } } else { if ($mode === 'notes') { $profile_owner = local_user(); $page_writeable = true; if (!$update) { $live_update_div = '<div id="live-notes"></div>' . "\r\n" . "<script> var profile_uid = " . local_user() . "; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n"; } } else { if ($mode === 'display') { $profile_owner = $a->profile['uid']; $page_writeable = can_write_wall($a, $profile_owner); if (!$update) { $live_update_div = '<div id="live-display"></div>' . "\r\n" . "<script> var profile_uid = " . $_SESSION['uid'] . ";" . " var profile_page = 1; </script>"; } } else { if ($mode === 'community') { $profile_owner = 0; $page_writeable = false; if (!$update) { $live_update_div = '<div id="live-community"></div>' . "\r\n" . "<script> var profile_uid = -1; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n"; } } else { if ($mode === 'search') { $live_update_div = '<div id="live-search"></div>' . "\r\n"; } } } } } } $page_dropping = local_user() && local_user() == $profile_owner ? true : false; if ($update) { $return_url = $_SESSION['return_url']; } else { $return_url = $_SESSION['return_url'] = $a->query_string; } load_contact_links(local_user()); $cb = array('items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview); call_hooks('conversation_start', $cb); $items = $cb['items']; $cmnt_tpl = get_markup_template('comment_item.tpl'); $hide_comments_tpl = get_markup_template('hide_comments.tpl'); $alike = array(); $dlike = array(); // array with html for each thread (parent+comments) $threads = array(); $threadsid = -1; $page_template = get_markup_template("conversation.tpl"); if ($items && count($items)) { if ($mode === 'network-new' || $mode === 'search' || $mode === 'community') { // "New Item View" on network page or search page results // - just loop through the items and format them minimally for display // $tpl = get_markup_template('search_item.tpl'); $tpl = 'search_item.tpl'; foreach ($items as $item) { if ($arr_blocked) { $blocked = false; foreach ($arr_blocked as $b) { if ($b && link_compare($item['author-link'], $b)) { $blocked = true; break; } } if ($blocked) { continue; } } $threadsid++; $comment = ''; $owner_url = ''; $owner_photo = ''; $owner_name = ''; $sparkle = ''; if ($mode === 'search' || $mode === 'community') { if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && $item['id'] != $item['parent']) { continue; } $nickname = $item['nickname']; } else { $nickname = $a->user['nickname']; } // prevent private email from leaking. if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) { continue; } $profile_name = strlen($item['author-name']) ? $item['author-name'] : $item['name']; if ($item['author-link'] && !$item['author-name']) { $profile_name = $item['author-link']; } $tags = array(); $hashtags = array(); $mentions = array(); $taglist = q("SELECT `type`, `term`, `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d) ORDER BY `tid`", intval(TERM_OBJ_POST), intval($item['id']), intval(TERM_HASHTAG), intval(TERM_MENTION)); foreach ($taglist as $tag) { if ($tag["url"] == "") { $tag["url"] = $searchpath . strtolower($tag["term"]); } if ($tag["type"] == TERM_HASHTAG) { $hashtags[] = "#<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>"; $prefix = "#"; } elseif ($tag["type"] == TERM_MENTION) { $mentions[] = "@<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>"; $prefix = "@"; } $tags[] = $prefix . "<a href=\"" . $tag["url"] . "\" target=\"_blank\">" . $tag["term"] . "</a>"; } /*foreach(explode(',',$item['tag']) as $tag){ $tag = trim($tag); if ($tag!="") { $t = bbcode($tag); $tags[] = $t; if($t[0] == '#') $hashtags[] = $t; elseif($t[0] == '@') $mentions[] = $t; } }*/ $sp = false; $profile_link = best_link_url($item, $sp); if ($profile_link === 'mailbox') { $profile_link = ''; } if ($sp) { $sparkle = ' sparkle'; } else { $profile_link = zrl($profile_link); } $normalised = normalise_link(strlen($item['author-link']) ? $item['author-link'] : $item['url']); if ($normalised != 'mailbox' && x($a->contacts[$normalised])) { $profile_avatar = $a->contacts[$normalised]['thumb']; } else { $profile_avatar = strlen($item['author-avatar']) ? $a->get_cached_avatar_image($item['author-avatar']) : $item['thumb']; } $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); call_hooks('render_location', $locate); $location = strlen($locate['html']) ? $locate['html'] : render_location_google($locate); localize_item($item); if ($mode === 'network-new') { $dropping = true; } else { $dropping = false; } $drop = array('dropping' => $dropping, 'pagedrop' => $page_dropping, 'select' => t('Select'), 'delete' => t('Delete')); $star = false; $isstarred = "unstarred"; $lock = false; $likebuttons = false; $shareable = false; $body = prepare_body($item, true, $preview); list($categories, $folders) = get_cats_and_terms($item); if ($a->theme['template_engine'] === 'internal') { $profile_name_e = template_escape($profile_name); $item['title_e'] = template_escape($item['title']); $body_e = template_escape($body); $tags_e = template_escape($tags); $hashtags_e = template_escape($hashtags); $mentions_e = template_escape($mentions); $location_e = template_escape($location); $owner_name_e = template_escape($owner_name); } else { $profile_name_e = $profile_name; $item['title_e'] = $item['title']; $body_e = $body; $tags_e = $tags; $hashtags_e = $hashtags; $mentions_e = $mentions; $location_e = $location; $owner_name_e = $owner_name; } $tmp_item = array('template' => $tpl, 'id' => $preview ? 'P0' : $item['item_id'], 'network' => $item['item_network'], 'linktitle' => sprintf(t('View %s\'s profile @ %s'), $profile_name, strlen($item['author-link']) ? $item['author-link'] : $item['url']), 'profile_url' => $profile_link, 'item_photo_menu' => item_photo_menu($item), 'name' => $profile_name_e, 'sparkle' => $sparkle, 'lock' => $lock, 'thumb' => proxy_url($profile_avatar), 'title' => $item['title_e'], 'body' => $body_e, 'tags' => $tags_e, 'hashtags' => $hashtags_e, 'mentions' => $mentions_e, 'txt_cats' => t('Categories:'), 'txt_folders' => t('Filed under:'), 'has_cats' => count($categories) ? 'true' : '', 'has_folders' => count($folders) ? 'true' : '', 'categories' => $categories, 'folders' => $folders, 'text' => strip_tags($body_e), 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), 'ago' => $item['app'] ? sprintf(t('%s from %s'), relative_date($item['created']), $item['app']) : relative_date($item['created']), 'location' => $location_e, 'indent' => '', 'owner_name' => $owner_name_e, 'owner_url' => $owner_url, 'owner_photo' => proxy_url($owner_photo), 'plink' => get_plink($item), 'edpost' => false, 'isstarred' => $isstarred, 'star' => $star, 'drop' => $drop, 'vote' => $likebuttons, 'like' => '', 'dislike' => '', 'comment' => '', 'conv' => $preview ? '' : array('href' => $a->get_baseurl($ssl_state) . '/display/' . $item['guid'], 'title' => t('View in context')), 'previewing' => $previewing, 'wait' => t('Please wait'), 'thread_level' => 1); $arr = array('item' => $item, 'output' => $tmp_item); call_hooks('display_item', $arr); $threads[$threadsid]['id'] = $item['item_id']; $threads[$threadsid]['network'] = $item['item_network']; $threads[$threadsid]['items'] = array($arr['output']); } } else { // Normal View $page_template = get_markup_template("threaded_conversation.tpl"); require_once 'object/Conversation.php'; require_once 'object/Item.php'; $conv = new Conversation($mode, $preview); // get all the topmost parents // this shouldn't be needed, as we should have only them in our array // But for now, this array respects the old style, just in case $threads = array(); foreach ($items as $item) { if ($arr_blocked) { $blocked = false; foreach ($arr_blocked as $b) { if ($b && link_compare($item['author-link'], $b)) { $blocked = true; break; } } if ($blocked) { continue; } } // Can we put this after the visibility check? like_puller($a, $item, $alike, 'like'); like_puller($a, $item, $dlike, 'dislike'); // Only add what is visible if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) { continue; } if (!visible_activity($item)) { continue; } call_hooks('display_item', $arr); $item['pagedrop'] = $page_dropping; if ($item['id'] == $item['parent']) { $item_object = new Item($item); $conv->add_thread($item_object); } } $threads = $conv->get_template_data($alike, $dlike); if (!$threads) { logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG); $threads = array(); } } } $o = replace_macros($page_template, array('$baseurl' => $a->get_baseurl($ssl_state), '$return_path' => $a->query_string, '$live_update' => $live_update_div, '$remove' => t('remove'), '$mode' => $mode, '$user' => $a->user, '$threads' => $threads, '$dropping' => $page_dropping && feature_enabled(local_user(), 'multi_delete') ? t('Delete Selected Items') : False)); return $o; }
function _contact_detail_for_template($rr) { switch ($rr['rel']) { case CONTACT_IS_FRIEND: $dir_icon = 'images/lrarrow.gif'; $alt_text = t('Mutual Friendship'); break; case CONTACT_IS_FOLLOWER: $dir_icon = 'images/larrow.gif'; $alt_text = t('is a fan of yours'); break; case CONTACT_IS_SHARING: $dir_icon = 'images/rarrow.gif'; $alt_text = t('you are a fan of'); break; default: break; } if ($rr['network'] === NETWORK_DFRN && $rr['rel']) { $url = "redir/{$rr['id']}"; $sparkle = ' class="sparkle" '; } else { $url = $rr['url']; $sparkle = ''; } return array('img_hover' => sprintf(t('Visit %s\'s profile [%s]'), $rr['name'], $rr['url']), 'edit_hover' => t('Edit contact'), 'photo_menu' => contact_photo_menu($rr), 'id' => $rr['id'], 'alt_text' => $alt_text, 'dir_icon' => $dir_icon, 'thumb' => proxy_url($rr['thumb']), 'name' => $rr['name'], 'username' => $rr['name'], 'sparkle' => $sparkle, 'itemurl' => $rr['url'], 'url' => $url, 'network' => network_to_name($rr['network'])); }