function impressum_show($a, &$b) { $b .= '<h3>' . t('Impressum') . '</h3>'; $owner = get_config('impressum', 'owner'); $owner_profile = get_config('impressum', 'ownerprofile'); $postal = proxy_parse_html(bbcode(get_config('impressum', 'postal'), true)); $notes = proxy_parse_html(bbcode(get_config('impressum', 'notes'), true)); $email = obfuscate_email(get_config('impressum', 'email')); if (strlen($owner)) { if (strlen($owner_profile)) { $tmp = '<a href="' . $owner_profile . '">' . $owner . '</a>'; } else { $tmp = $owner; } if (strlen($email)) { $b .= '<p><strong>' . t('Site Owner') . '</strong>: ' . $tmp . '<br /><strong>' . t('Email Address') . '</strong>: ' . $email . '</p>'; } else { $b .= '<p><strong>' . t('Site Owner') . '</strong>: ' . $tmp . '</p>'; } if (strlen($postal)) { $b .= '<p><strong>' . t('Postal Address') . '</strong><br />' . $postal . '</p>'; } if (strlen($notes)) { $b .= '<p>' . $notes . '</p>'; } } else { $b .= '<p>' . t('The impressum addon needs to be configured!<br />Please add at least the <tt>owner</tt> variable to your config file. For other variables please refer to the README file of the addon.') . '</p>'; } }
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)); }
/** * Given an item array, convert the body element from bbcode to html and add smilie icons. * If attach is true, also add icons for item attachments * * @param array $item * @param boolean $attach * @return string item body html * @hook prepare_body_init item array before any work * @hook prepare_body ('item'=>item array, 'html'=>body string) after first bbcode to html * @hook prepare_body_final ('item'=>item array, 'html'=>body string) after attach icons and blockquote special case handling (spoiler, author) */ function prepare_body(&$item, $attach = false, $preview = false) { $a = get_app(); call_hooks('prepare_body_init', $item); $searchpath = $a->get_baseurl() . "/search?tag="; $tags = array(); $hashtags = array(); $mentions = array(); if (!get_config('system', 'suppress_tags')) { $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>"; } } $item['tags'] = $tags; $item['hashtags'] = $hashtags; $item['mentions'] = $mentions; //$cachefile = get_cachefile($item["guid"]."-".strtotime($item["edited"])."-".hash("crc32", $item['body'])); $cachefile = get_cachefile($item["guid"] . "-" . hash("md5", $item['body'])); if ($cachefile != '') { if (file_exists($cachefile)) { $stamp1 = microtime(true); $s = file_get_contents($cachefile); $a->save_timestamp($stamp1, "file"); } else { redir_private_images($a, $item); $s = prepare_text($item['body']); $stamp1 = microtime(true); file_put_contents($cachefile, $s); $a->save_timestamp($stamp1, "file"); logger('prepare_body: put item ' . $item["id"] . ' into cachefile ' . $cachefile); } } else { redir_private_images($a, $item); $s = prepare_text($item['body']); } require_once "mod/proxy.php"; $s = proxy_parse_html($s); $prep_arr = array('item' => $item, 'html' => $s, 'preview' => $preview); call_hooks('prepare_body', $prep_arr); $s = $prep_arr['html']; if (!$attach) { // Replace the blockquotes with quotes that are used in mails $mailquote = '<blockquote type="cite" class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">'; $s = str_replace(array('<blockquote>', '<blockquote class="spoiler">', '<blockquote class="author">'), array($mailquote, $mailquote, $mailquote), $s); return $s; } $as = ''; $vhead = false; $arr = explode('[/attach],', $item['attach']); if (count($arr)) { $as .= '<div class="body-attach">'; foreach ($arr as $r) { $matches = false; $icon = ''; $cnt = preg_match_all('|\\[attach\\]href=\\"(.*?)\\" length=\\"(.*?)\\" type=\\"(.*?)\\" title=\\"(.*?)\\"|', $r, $matches, PREG_SET_ORDER); if ($cnt) { foreach ($matches as $mtch) { $mime = $mtch[3]; if (local_user() == $item['uid'] && $item['contact-id'] != $a->contact['id'] && $item['network'] == NETWORK_DFRN) { $the_url = $a->get_baseurl() . '/redir/' . $item['contact-id'] . '?f=1&url=' . $mtch[1]; } else { $the_url = $mtch[1]; } if (strpos($mime, 'video') !== false) { if (!$vhead) { $vhead = true; $a->page['htmlhead'] .= replace_macros(get_markup_template('videos_head.tpl'), array('$baseurl' => $a->get_baseurl())); $a->page['end'] .= replace_macros(get_markup_template('videos_end.tpl'), array('$baseurl' => $a->get_baseurl())); } $id = end(explode('/', $the_url)); $as .= replace_macros(get_markup_template('video_top.tpl'), array('$video' => array('id' => $id, 'title' => t('View Video'), 'src' => $the_url, 'mime' => $mime))); } $filetype = strtolower(substr($mime, 0, strpos($mime, '/'))); if ($filetype) { $filesubtype = strtolower(substr($mime, strpos($mime, '/') + 1)); $filesubtype = str_replace('.', '-', $filesubtype); } else { $filetype = 'unkn'; $filesubtype = 'unkn'; } $icon = '<div class="attachtype icon s22 type-' . $filetype . ' subtype-' . $filesubtype . '"></div>'; /*$icontype = strtolower(substr($mtch[3],0,strpos($mtch[3],'/'))); switch($icontype) { case 'video': case 'audio': case 'image': case 'text': $icon = '<div class="attachtype icon s22 type-' . $icontype . '"></div>'; break; default: $icon = '<div class="attachtype icon s22 type-unkn"></div>'; break; }*/ $title = strlen(trim($mtch[4])) ? escape_tags(trim($mtch[4])) : escape_tags($mtch[1]); $title .= ' ' . $mtch[2] . ' ' . t('bytes'); $as .= '<a href="' . strip_tags($the_url) . '" title="' . $title . '" class="attachlink" target="_blank" >' . $icon . '</a>'; } } } $as .= '<div class="clear"></div></div>'; } $s = $s . $as; // Look for spoiler $spoilersearch = '<blockquote class="spoiler">'; // Remove line breaks before the spoiler while (strpos($s, "\n" . $spoilersearch) !== false) { $s = str_replace("\n" . $spoilersearch, $spoilersearch, $s); } while (strpos($s, "<br />" . $spoilersearch) !== false) { $s = str_replace("<br />" . $spoilersearch, $spoilersearch, $s); } while (strpos($s, $spoilersearch) !== false) { $pos = strpos($s, $spoilersearch); $rnd = random_string(8); $spoilerreplace = '<br /> <span id="spoiler-wrap-' . $rnd . '" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'spoiler-' . $rnd . '\');">' . sprintf(t('Click to open/close')) . '</span>' . '<blockquote class="spoiler" id="spoiler-' . $rnd . '" style="display: none;">'; $s = substr($s, 0, $pos) . $spoilerreplace . substr($s, $pos + strlen($spoilersearch)); } // Look for quote with author $authorsearch = '<blockquote class="author">'; while (strpos($s, $authorsearch) !== false) { $pos = strpos($s, $authorsearch); $rnd = random_string(8); $authorreplace = '<br /> <span id="author-wrap-' . $rnd . '" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'author-' . $rnd . '\');">' . sprintf(t('Click to open/close')) . '</span>' . '<blockquote class="author" id="author-' . $rnd . '" style="display: block;">'; $s = substr($s, 0, $pos) . $authorreplace . substr($s, $pos + strlen($authorsearch)); } // replace friendica image url size with theme preference if (x($a->theme_info, 'item_image_size')) { $ps = $a->theme_info['item_image_size']; $s = preg_replace('|(<img[^>]+src="[^"]+/photo/[0-9a-f]+)-[0-9]|', "\$1-" . $ps, $s); } $prep_arr = array('item' => $item, 'html' => $s); call_hooks('prepare_body_final', $prep_arr); return $prep_arr['html']; }
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 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\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') ? $rr['fphoto'] : "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'))); } $notif_content .= replace_macros($tpl, array('$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']) : "images/person-175.jpg", '$fullname' => $rr['name'], '$location_label' => t('Location:'), '$location' => $rr['glocation'], '$location_label' => t('Location:'), '$about' => proxy_parse_html(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' => zrl($rr['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' => $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 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' => $it['photo'], '$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; }