Merge remote branch 'upstream/master'
Conflicts: include/bb2diaspora.php
This commit is contained in:
commit
bfca7f47ef
282 changed files with 35083 additions and 2632 deletions
|
@ -183,13 +183,15 @@ function admin_page_summary(&$a) {
|
|||
Array( t('Normal Account'), 0),
|
||||
Array( t('Soapbox Account'), 0),
|
||||
Array( t('Community/Celebrity Account'), 0),
|
||||
Array( t('Automatic Friend Account'), 0)
|
||||
Array( t('Automatic Friend Account'), 0),
|
||||
Array( t('Blog Account'), 0),
|
||||
Array( t('Private Forum'), 0)
|
||||
);
|
||||
|
||||
$users=0;
|
||||
foreach ($r as $u){ $accounts[$u['page-flags']][1] = $u['count']; $users+= $u['count']; }
|
||||
|
||||
logger('accounts: ' . print_r($accounts,true));
|
||||
logger('accounts: ' . print_r($accounts,true),LOGGER_DATA);
|
||||
|
||||
$r = q("SELECT COUNT(id) as `count` FROM `register`");
|
||||
$pending = $r[0]['count'];
|
||||
|
|
75
mod/babel.php
Normal file
75
mod/babel.php
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
require_once('include/bbcode.php');
|
||||
require_once('library/markdown.php');
|
||||
require_once('include/bb2diaspora.php');
|
||||
require_once('include/html2bbcode.php');
|
||||
|
||||
function visible_lf($s) {
|
||||
return str_replace("\n",'<br />', $s);
|
||||
}
|
||||
|
||||
function babel_content(&$a) {
|
||||
|
||||
$o .= '<h3>Babel Diagnostic</h3>';
|
||||
|
||||
$o .= '<form action="babel" method="post">';
|
||||
$o .= t('Source (bbcode) text:') . EOL . '<textarea name="text" >' . htmlspecialchars($_REQUEST['text']) .'</textarea>' . EOL;
|
||||
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
|
||||
|
||||
$o .= '<br /><br />';
|
||||
|
||||
$o .= '<form action="babel" method="post">';
|
||||
$o .= t('Source (Diaspora) text to convert to BBcode:') . EOL . '<textarea name="d2bbtext" >' . htmlspecialchars($_REQUEST['d2bbtext']) .'</textarea>' . EOL;
|
||||
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
|
||||
|
||||
$o .= '<br /><br />';
|
||||
|
||||
if(x($_REQUEST,'text')) {
|
||||
|
||||
$text = trim($_REQUEST['text']);
|
||||
$o .= t("Source input: ") . EOL. EOL;
|
||||
$o .= visible_lf($text) . EOL. EOL;
|
||||
|
||||
$html = bbcode($text);
|
||||
$o .= t("bb2html: ") . EOL. EOL;
|
||||
$o .= $html. EOL. EOL;
|
||||
|
||||
$bbcode = html2bbcode($html);
|
||||
$o .= t("bb2html2bb: ") . EOL. EOL;
|
||||
$o .= visible_lf($bbcode) . EOL. EOL;
|
||||
|
||||
$diaspora = bb2diaspora($text);
|
||||
$o .= t("bb2md: ") . EOL. EOL;
|
||||
$o .= visible_lf($diaspora) . EOL. EOL;
|
||||
|
||||
$html = Markdown($diaspora);
|
||||
$o .= t("bb2md2html: ") . EOL. EOL;
|
||||
$o .= $html. EOL. EOL;
|
||||
|
||||
$bbcode = diaspora2bb($diaspora);
|
||||
$o .= t("bb2dia2bb: ") . EOL. EOL;
|
||||
$o .= visible_lf($bbcode) . EOL. EOL;
|
||||
|
||||
$bbcode = html2bbcode($html);
|
||||
$o .= t("bb2md2html2bb: ") . EOL. EOL;
|
||||
$o .= visible_lf($bbcode) . EOL. EOL;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(x($_REQUEST,'d2bbtext')) {
|
||||
|
||||
$d2bbtext = trim($_REQUEST['d2bbtext']);
|
||||
$o .= t("Source input (Diaspora format): ") . EOL. EOL;
|
||||
$o .= visible_lf($d2bbtext) . EOL. EOL;
|
||||
|
||||
|
||||
$bb = diaspora2bb($d2bbtext);
|
||||
$o .= t("diaspora2bb: ") . EOL. EOL;
|
||||
$o .= visible_lf($bb) . EOL. EOL;
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
858
mod/content.php
Normal file
858
mod/content.php
Normal file
|
@ -0,0 +1,858 @@
|
|||
<?php
|
||||
|
||||
// This is a purely experimental module and is not yet generally useful.
|
||||
|
||||
// The eventual goal is to provide a json backend to fetch content and fill the current page.
|
||||
// The page will be filled in on the frontend using javascript.
|
||||
// At the present time this page is based on "network", but the hope is to extend to serving
|
||||
// any content (wall, community, search, etc.).
|
||||
// All search parameters, etc. will be managed in javascript and sent as request params.
|
||||
// Security will be managed on the backend.
|
||||
// There is no "pagination query", but we will manage the "current page" on the client
|
||||
// and provide a link to fetch the next page - until there are no pages left to fetch.
|
||||
|
||||
// With the exception of complex tag and text searches, this prototype is incredibly
|
||||
// fast - e.g. one or two milliseconds to fetch parent items for the current content,
|
||||
// and 10-20 milliseconds to fetch all the child items.
|
||||
|
||||
|
||||
function content_content(&$a, $update = 0) {
|
||||
|
||||
require_once('include/conversation.php');
|
||||
|
||||
|
||||
// Currently security is based on the logged in user
|
||||
|
||||
if(! local_user()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$arr = array('query' => $a->query_string);
|
||||
|
||||
call_hooks('content_content_init', $arr);
|
||||
|
||||
|
||||
$datequery = $datequery2 = '';
|
||||
|
||||
$group = 0;
|
||||
|
||||
$nouveau = false;
|
||||
|
||||
if($a->argc > 1) {
|
||||
for($x = 1; $x < $a->argc; $x ++) {
|
||||
if(is_a_date_arg($a->argv[$x])) {
|
||||
if($datequery)
|
||||
$datequery2 = escape_tags($a->argv[$x]);
|
||||
else {
|
||||
$datequery = escape_tags($a->argv[$x]);
|
||||
$_GET['order'] = 'post';
|
||||
}
|
||||
}
|
||||
elseif($a->argv[$x] === 'new') {
|
||||
$nouveau = true;
|
||||
}
|
||||
elseif(intval($a->argv[$x])) {
|
||||
$group = intval($a->argv[$x]);
|
||||
$def_acl = array('allow_gid' => '<' . $group . '>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$o = '';
|
||||
|
||||
|
||||
|
||||
$contact_id = $a->cid;
|
||||
|
||||
require_once('include/acl_selectors.php');
|
||||
|
||||
$cid = ((x($_GET,'cid')) ? intval($_GET['cid']) : 0);
|
||||
$star = ((x($_GET,'star')) ? intval($_GET['star']) : 0);
|
||||
$bmark = ((x($_GET,'bmark')) ? intval($_GET['bmark']) : 0);
|
||||
$order = ((x($_GET,'order')) ? notags($_GET['order']) : 'comment');
|
||||
$liked = ((x($_GET,'liked')) ? intval($_GET['liked']) : 0);
|
||||
$conv = ((x($_GET,'conv')) ? intval($_GET['conv']) : 0);
|
||||
$spam = ((x($_GET,'spam')) ? intval($_GET['spam']) : 0);
|
||||
$nets = ((x($_GET,'nets')) ? $_GET['nets'] : '');
|
||||
$cmin = ((x($_GET,'cmin')) ? intval($_GET['cmin']) : 0);
|
||||
$cmax = ((x($_GET,'cmax')) ? intval($_GET['cmax']) : 99);
|
||||
$file = ((x($_GET,'file')) ? $_GET['file'] : '');
|
||||
|
||||
|
||||
|
||||
if(x($_GET,'search') || x($_GET,'file'))
|
||||
$nouveau = true;
|
||||
if($cid)
|
||||
$def_acl = array('allow_cid' => '<' . intval($cid) . '>');
|
||||
|
||||
if($nets) {
|
||||
$r = q("select id from contact where uid = %d and network = '%s' and self = 0",
|
||||
intval(local_user()),
|
||||
dbesc($nets)
|
||||
);
|
||||
|
||||
$str = '';
|
||||
if(count($r))
|
||||
foreach($r as $rr)
|
||||
$str .= '<' . $rr['id'] . '>';
|
||||
if(strlen($str))
|
||||
$def_acl = array('allow_cid' => $str);
|
||||
}
|
||||
|
||||
|
||||
$sql_options = (($star) ? " and starred = 1 " : '');
|
||||
$sql_options .= (($bmark) ? " and bookmark = 1 " : '');
|
||||
|
||||
$sql_nets = (($nets) ? sprintf(" and `contact`.`network` = '%s' ", dbesc($nets)) : '');
|
||||
|
||||
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $sql_options ) ";
|
||||
|
||||
if($group) {
|
||||
$r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($group),
|
||||
intval($_SESSION['uid'])
|
||||
);
|
||||
if(! count($r)) {
|
||||
if($update)
|
||||
killme();
|
||||
notice( t('No such group') . EOL );
|
||||
goaway($a->get_baseurl(true) . '/network');
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
$contacts = expand_groups(array($group));
|
||||
if((is_array($contacts)) && count($contacts)) {
|
||||
$contact_str = implode(',',$contacts);
|
||||
}
|
||||
else {
|
||||
$contact_str = ' 0 ';
|
||||
info( t('Group is empty'));
|
||||
}
|
||||
|
||||
$sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND ( `contact-id` IN ( $contact_str ) OR `allow_gid` like '" . protect_sprintf('%<' . intval($group) . '>%') . "' ) and deleted = 0 ) ";
|
||||
$o = '<h2>' . t('Group: ') . $r[0]['name'] . '</h2>' . $o;
|
||||
}
|
||||
elseif($cid) {
|
||||
|
||||
$r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d
|
||||
AND `blocked` = 0 AND `pending` = 0 LIMIT 1",
|
||||
intval($cid)
|
||||
);
|
||||
if(count($r)) {
|
||||
$sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND `contact-id` = " . intval($cid) . " and deleted = 0 ) ";
|
||||
|
||||
}
|
||||
else {
|
||||
killme();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sql_extra3 = '';
|
||||
|
||||
if($datequery) {
|
||||
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery))));
|
||||
}
|
||||
if($datequery2) {
|
||||
$sql_extra3 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
|
||||
}
|
||||
|
||||
$sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` ");
|
||||
$sql_extra3 = (($nouveau) ? '' : $sql_extra3);
|
||||
|
||||
if(x($_GET,'search')) {
|
||||
$search = escape_tags($_GET['search']);
|
||||
if (get_config('system','use_fulltext_engine')) {
|
||||
if(strpos($search,'#') === 0)
|
||||
$sql_extra .= sprintf(" AND (MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ",
|
||||
dbesc(protect_sprintf($search))
|
||||
);
|
||||
else
|
||||
$sql_extra .= sprintf(" AND (MATCH(`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ",
|
||||
dbesc(protect_sprintf($search)),
|
||||
dbesc(protect_sprintf($search))
|
||||
);
|
||||
} else {
|
||||
$sql_extra .= sprintf(" AND ( `item`.`body` like '%s' OR `item`.`tag` like '%s' ) ",
|
||||
dbesc(protect_sprintf('%' . $search . '%')),
|
||||
dbesc(protect_sprintf('%]' . $search . '[%'))
|
||||
);
|
||||
}
|
||||
}
|
||||
if(strlen($file)) {
|
||||
$sql_extra .= file_tag_file_query('item',unxmlify($file));
|
||||
}
|
||||
|
||||
if($conv) {
|
||||
$myurl = $a->get_baseurl() . '/profile/'. $a->user['nickname'];
|
||||
$myurl = substr($myurl,strpos($myurl,'://')+3);
|
||||
$myurl = str_replace('www.','',$myurl);
|
||||
$diasp_url = str_replace('/profile/','/u/',$myurl);
|
||||
if (get_config('system','use_fulltext_engine'))
|
||||
$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ",
|
||||
dbesc(protect_sprintf($myurl)),
|
||||
dbesc(protect_sprintf($myurl)),
|
||||
dbesc(protect_sprintf($diasp_url))
|
||||
);
|
||||
else
|
||||
$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ",
|
||||
dbesc(protect_sprintf('%' . $myurl)),
|
||||
dbesc(protect_sprintf('%' . $myurl . ']%')),
|
||||
dbesc(protect_sprintf('%' . $diasp_url . ']%'))
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
|
||||
|
||||
|
||||
|
||||
if($nouveau) {
|
||||
// "New Item View" - show all items unthreaded in reverse created date order
|
||||
|
||||
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`,
|
||||
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`,
|
||||
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
|
||||
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
|
||||
FROM `item`, `contact`
|
||||
WHERE `item`.`uid` = %d AND `item`.`visible` = 1
|
||||
AND `item`.`deleted` = 0 and `item`.`moderated` = 0
|
||||
$simple_update
|
||||
AND `contact`.`id` = `item`.`contact-id`
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
$sql_extra $sql_nets
|
||||
ORDER BY `item`.`received` DESC $pager_sql ",
|
||||
intval($_SESSION['uid'])
|
||||
);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
// Normal conversation view
|
||||
|
||||
|
||||
if($order === 'post')
|
||||
$ordering = "`created`";
|
||||
else
|
||||
$ordering = "`commented`";
|
||||
|
||||
$start = dba_timer();
|
||||
|
||||
$r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid`
|
||||
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
|
||||
AND `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
AND `item`.`parent` = `item`.`id`
|
||||
$sql_extra3 $sql_extra $sql_nets
|
||||
ORDER BY `item`.$ordering DESC $pager_sql ",
|
||||
intval(local_user())
|
||||
);
|
||||
|
||||
$first = dba_timer();
|
||||
|
||||
|
||||
// Then fetch all the children of the parents that are on this page
|
||||
|
||||
$parents_arr = array();
|
||||
$parents_str = '';
|
||||
|
||||
if(count($r)) {
|
||||
foreach($r as $rr)
|
||||
if(! in_array($rr['item_id'],$parents_arr))
|
||||
$parents_arr[] = $rr['item_id'];
|
||||
$parents_str = implode(', ', $parents_arr);
|
||||
|
||||
$items = q("SELECT `item`.*, `item`.`id` AS `item_id`,
|
||||
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`writable`,
|
||||
`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
|
||||
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
|
||||
FROM `item`, `contact`
|
||||
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
|
||||
AND `item`.`moderated` = 0 AND `contact`.`id` = `item`.`contact-id`
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
AND `item`.`parent` IN ( %s )
|
||||
$sql_extra ",
|
||||
intval(local_user()),
|
||||
dbesc($parents_str)
|
||||
);
|
||||
|
||||
$second = dba_timer();
|
||||
|
||||
$items = conv_sort($items,$ordering);
|
||||
|
||||
} else {
|
||||
$items = array();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
logger('parent dba_timer: ' . sprintf('%01.4f',$first - $start));
|
||||
logger('child dba_timer: ' . sprintf('%01.4f',$second - $first));
|
||||
|
||||
// Set this so that the conversation function can find out contact info for our wall-wall items
|
||||
$a->page_contact = $a->contact;
|
||||
|
||||
$mode = (($nouveau) ? 'network-new' : 'network');
|
||||
|
||||
$o = render_content($a,$items,$mode,false);
|
||||
|
||||
|
||||
header('Content-type: application/json');
|
||||
echo json_encode($o);
|
||||
killme();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function render_content(&$a, $items, $mode, $update, $preview = false) {
|
||||
|
||||
|
||||
require_once('bbcode.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_google($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);
|
||||
|
||||
//$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' => template_escape($profile_name),
|
||||
'sparkle' => $sparkle,
|
||||
'lock' => $lock,
|
||||
'thumb' => $profile_avatar,
|
||||
'title' => template_escape($item['title']),
|
||||
'body' => template_escape($body),
|
||||
'text' => strip_tags(template_escape($body)),
|
||||
'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])),
|
||||
'location' => template_escape($location),
|
||||
'indent' => '',
|
||||
'owner_name' => template_escape($owner_name),
|
||||
'owner_url' => $owner_url,
|
||||
'owner_photo' => $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/' . $nickname . '/' . $item['id'], '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]['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 \x28toggle\x29"), t("like")),
|
||||
'dislike' => array( t("I don't like this \x28toggle\x29"), 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'),
|
||||
'$ww' => (($mode === 'network') ? $commentww : '')
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
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_google($locate));
|
||||
|
||||
$indent = (($toplevelpost) ? '' : ' comment');
|
||||
|
||||
if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0)
|
||||
$indent .= ' 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,
|
||||
$tmp_item = array(
|
||||
// collapse comments in template. I don't like this much...
|
||||
'comment_firstcollapsed' => $comment_firstcollapsed,
|
||||
'comment_lastcollapsed' => $comment_lastcollapsed,
|
||||
// template to use to render item (wall, walltowall, search)
|
||||
'template' => $template,
|
||||
|
||||
'type' => implode("",array_slice(explode("/",$item['verb']),-1)),
|
||||
'tags' => $tags,
|
||||
'body' => template_escape($body),
|
||||
'text' => strip_tags(template_escape($body)),
|
||||
'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' => template_escape($profile_name),
|
||||
'thumb' => $profile_avatar,
|
||||
'osparkle' => $osparkle,
|
||||
'sparkle' => $sparkle,
|
||||
'title' => template_escape($item['title']),
|
||||
'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])),
|
||||
'lock' => $lock,
|
||||
'location' => template_escape($location),
|
||||
'indent' => $indent,
|
||||
'owner_url' => $owner_url,
|
||||
'owner_photo' => $owner_photo,
|
||||
'owner_name' => template_escape($owner_name),
|
||||
'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;
|
||||
|
||||
}
|
|
@ -73,14 +73,12 @@ function directory_content(&$a) {
|
|||
$order = " ORDER BY `name` ASC ";
|
||||
|
||||
|
||||
$r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` 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 ",
|
||||
$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)) {
|
||||
|
||||
$tpl = get_markup_template('directory_item.tpl');
|
||||
|
||||
if(in_array('small', $a->argv))
|
||||
$photo = 'thumb';
|
||||
else
|
||||
|
@ -113,20 +111,60 @@ function directory_content(&$a) {
|
|||
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');
|
||||
|
||||
$entry = replace_macros($tpl,array(
|
||||
'$id' => $rr['id'],
|
||||
'$profile-link' => $profile_link,
|
||||
'$photo' => $a->get_cached_avatar_image($rr[$photo]),
|
||||
'$alt-text' => $rr['name'],
|
||||
'$name' => $rr['name'],
|
||||
'$details' => $pdesc . $details
|
||||
|
||||
'$details' => $pdesc . $details,
|
||||
'$page-type' => $page_type,
|
||||
'$profile' => $profile,
|
||||
'$location' => template_escape($location),
|
||||
'$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;
|
||||
|
||||
|
|
|
@ -280,10 +280,10 @@ function events_content(&$a) {
|
|||
|
||||
$last_date = $d;
|
||||
$edit = ((! $rr['cid']) ? array($a->get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null);
|
||||
$title = strip_tags(bbcode($rr['summary']));
|
||||
$title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
|
||||
if(! $title) {
|
||||
list($title, $_trash) = explode("<br",bbcode($rr['desc']),2);
|
||||
$title = strip_tags($title);
|
||||
$title = strip_tags(html_entity_decode($title,ENT_QUOTES,'UTF-8'));
|
||||
}
|
||||
$html = format_event_html($rr);
|
||||
$rr['desc'] = bbcode($rr['desc']);
|
||||
|
|
17
mod/item.php
17
mod/item.php
|
@ -18,6 +18,7 @@
|
|||
require_once('include/crypto.php');
|
||||
require_once('include/enotify.php');
|
||||
require_once('include/email.php');
|
||||
require_once('Text/LanguageDetect.php');
|
||||
|
||||
function item_post(&$a) {
|
||||
|
||||
|
@ -216,6 +217,15 @@ function item_post(&$a) {
|
|||
$emailcc = notags(trim($_REQUEST['emailcc']));
|
||||
$body = escape_tags(trim($_REQUEST['body']));
|
||||
|
||||
|
||||
$naked_body = preg_replace('/\[(.+?)\]/','',$body);
|
||||
$l = new Text_LanguageDetect;
|
||||
$lng = $l->detectConfidence($naked_body);
|
||||
|
||||
$postopts = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : '');
|
||||
|
||||
logger('mod_item: detect language' . print_r($lng,true) . $naked_body, LOGGER_DATA);
|
||||
|
||||
$private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0);
|
||||
|
||||
// If this is a comment, set the permissions from the parent.
|
||||
|
@ -561,7 +571,7 @@ function item_post(&$a) {
|
|||
$datarray['attach'] = $attachments;
|
||||
$datarray['bookmark'] = intval($bookmark);
|
||||
$datarray['thr-parent'] = $thr_parent;
|
||||
$datarray['postopts'] = '';
|
||||
$datarray['postopts'] = $postopts;
|
||||
$datarray['origin'] = $origin;
|
||||
$datarray['moderated'] = $allow_moderated;
|
||||
|
||||
|
@ -1039,16 +1049,11 @@ function store_diaspora_comment_sig($datarray, $author, $uprvkey, $parent_item,
|
|||
require_once('include/bb2diaspora.php');
|
||||
$signed_body = html_entity_decode(bb2diaspora($datarray['body']));
|
||||
|
||||
// $myaddr = $user['nickname'] . '@' . substr($baseurl, strpos($baseurl,'://') + 3);
|
||||
// if( $author['network'] === NETWORK_DIASPORA)
|
||||
// $diaspora_handle = $author['addr'];
|
||||
// else {
|
||||
// Only works for NETWORK_DFRN
|
||||
$contact_baseurl_start = strpos($author['url'],'://') + 3;
|
||||
$contact_baseurl_length = strpos($author['url'],'/profile') - $contact_baseurl_start;
|
||||
$contact_baseurl = substr($author['url'], $contact_baseurl_start, $contact_baseurl_length);
|
||||
$diaspora_handle = $author['nick'] . '@' . $contact_baseurl;
|
||||
// }
|
||||
|
||||
$signed_text = $datarray['guid'] . ';' . $parent_item['guid'] . ';' . $signed_body . ';' . $diaspora_handle;
|
||||
|
||||
|
|
15
mod/like.php
15
mod/like.php
|
@ -106,17 +106,18 @@ function like_content(&$a) {
|
|||
|
||||
|
||||
$r = q("SELECT * FROM `item` WHERE `verb` = '%s' AND `deleted` = 0
|
||||
AND `contact-id` = %d AND ( `parent` = '%s' OR `parent-uri` = '%s') LIMIT 1",
|
||||
AND `contact-id` = %d AND ( `parent` = '%s' OR `parent-uri` = '%s' OR `thr-parent` = '%s') LIMIT 1",
|
||||
dbesc($activity),
|
||||
intval($contact['id']),
|
||||
dbesc($item_id),
|
||||
dbesc($item_id)
|
||||
dbesc($item_id),
|
||||
dbesc($item['uri'])
|
||||
);
|
||||
if(count($r)) {
|
||||
$like_item = $r[0];
|
||||
|
||||
// Already voted, undo it
|
||||
$r = q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `id` = %d LIMIT 1",
|
||||
$r = q("UPDATE `item` SET `deleted` = 1, `unseen` = 1, `changed` = '%s' WHERE `id` = %d LIMIT 1",
|
||||
dbesc(datetime_convert()),
|
||||
intval($like_item['id'])
|
||||
);
|
||||
|
@ -245,9 +246,6 @@ function store_diaspora_like_retract_sig($activity, $item, $like_item, $contact)
|
|||
if(($activity === ACTIVITY_LIKE) && (! $item['resource-id'])) {
|
||||
$signed_text = $like_item['guid'] . ';' . 'Like';
|
||||
|
||||
// if( $contact['network'] === NETWORK_DIASPORA)
|
||||
// $diaspora_handle = $contact['addr'];
|
||||
// else {
|
||||
// Only works for NETWORK_DFRN
|
||||
$contact_baseurl_start = strpos($contact['url'],'://') + 3;
|
||||
$contact_baseurl_length = strpos($contact['url'],'/profile') - $contact_baseurl_start;
|
||||
|
@ -268,7 +266,6 @@ function store_diaspora_like_retract_sig($activity, $item, $like_item, $contact)
|
|||
if( $r)
|
||||
$authorsig = base64_encode(rsa_sign($signed_text,$r['prvkey'],'sha256'));
|
||||
}
|
||||
// }
|
||||
|
||||
if(! isset($authorsig))
|
||||
$authorsig = '';
|
||||
|
@ -299,9 +296,6 @@ function store_diaspora_like_sig($activity, $post_type, $contact, $post_id) {
|
|||
logger('mod_like: storing diaspora like signature');
|
||||
|
||||
if(($activity === ACTIVITY_LIKE) && ($post_type === t('status'))) {
|
||||
// if( $contact['network'] === NETWORK_DIASPORA)
|
||||
// $diaspora_handle = $contact['addr'];
|
||||
// else {
|
||||
// Only works for NETWORK_DFRN
|
||||
$contact_baseurl_start = strpos($contact['url'],'://') + 3;
|
||||
$contact_baseurl_length = strpos($contact['url'],'/profile') - $contact_baseurl_start;
|
||||
|
@ -322,7 +316,6 @@ function store_diaspora_like_sig($activity, $post_type, $contact, $post_id) {
|
|||
if( $r)
|
||||
$contact_uprvkey = $r['prvkey'];
|
||||
}
|
||||
// }
|
||||
|
||||
$r = q("SELECT guid, parent FROM `item` WHERE id = %d LIMIT 1",
|
||||
intval($post_id)
|
||||
|
|
105
mod/message.php
105
mod/message.php
|
@ -88,6 +88,84 @@ function message_post(&$a) {
|
|||
|
||||
}
|
||||
|
||||
// Note: the code in 'item_extract_images' and 'item_redir_and_replace_images'
|
||||
// is identical to the code in include/conversation.php
|
||||
if(! function_exists('item_extract_images')) {
|
||||
function item_extract_images($body) {
|
||||
|
||||
$saved_image = array();
|
||||
$orig_body = $body;
|
||||
$new_body = '';
|
||||
|
||||
$cnt = 0;
|
||||
$img_start = strpos($orig_body, '[img');
|
||||
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
|
||||
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
|
||||
while(($img_st_close !== false) && ($img_end !== false)) {
|
||||
|
||||
$img_st_close++; // make it point to AFTER the closing bracket
|
||||
$img_end += $img_start;
|
||||
|
||||
if(! strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) {
|
||||
// This is an embedded image
|
||||
|
||||
$saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - ($img_start + $img_st_close));
|
||||
$new_body = $new_body . substr($orig_body, 0, $img_start) . '[!#saved_image' . $cnt . '#!]';
|
||||
|
||||
$cnt++;
|
||||
}
|
||||
else
|
||||
$new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]'));
|
||||
|
||||
$orig_body = substr($orig_body, $img_end + strlen('[/img]'));
|
||||
|
||||
if($orig_body === false) // in case the body ends on a closing image tag
|
||||
$orig_body = '';
|
||||
|
||||
$img_start = strpos($orig_body, '[img');
|
||||
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
|
||||
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
|
||||
}
|
||||
|
||||
$new_body = $new_body . $orig_body;
|
||||
|
||||
return array('body' => $new_body, 'images' => $saved_image);
|
||||
}}
|
||||
|
||||
if(! function_exists('item_redir_and_replace_images')) {
|
||||
function item_redir_and_replace_images($body, $images, $cid) {
|
||||
|
||||
$origbody = $body;
|
||||
$newbody = '';
|
||||
|
||||
for($i = 0; $i < count($images); $i++) {
|
||||
$search = '/\[url\=(.*?)\]\[!#saved_image' . $i . '#!\]\[\/url\]' . '/is';
|
||||
$replace = '[url=' . z_path() . '/redir/' . $cid
|
||||
. '?f=1&url=' . '$1' . '][!#saved_image' . $i . '#!][/url]' ;
|
||||
|
||||
$img_end = strpos($origbody, '[!#saved_image' . $i . '#!][/url]') + strlen('[!#saved_image' . $i . '#!][/url]');
|
||||
$process_part = substr($origbody, 0, $img_end);
|
||||
$origbody = substr($origbody, $img_end);
|
||||
|
||||
$process_part = preg_replace($search, $replace, $process_part);
|
||||
$newbody = $newbody . $process_part;
|
||||
}
|
||||
$newbody = $newbody . $origbody;
|
||||
|
||||
$cnt = 0;
|
||||
foreach($images as $image) {
|
||||
// We're depending on the property of 'foreach' (specified on the PHP website) that
|
||||
// it loops over the array starting from the first element and going sequentially
|
||||
// to the last element
|
||||
$newbody = str_replace('[!#saved_image' . $cnt . '#!]', '[img]' . $image . '[/img]', $newbody);
|
||||
$cnt++;
|
||||
}
|
||||
|
||||
return $newbody;
|
||||
}}
|
||||
|
||||
|
||||
|
||||
function message_content(&$a) {
|
||||
|
||||
$o = '';
|
||||
|
@ -224,6 +302,7 @@ function message_content(&$a) {
|
|||
// list messages
|
||||
|
||||
$o .= $header;
|
||||
|
||||
|
||||
$r = q("SELECT count(*) AS `total` FROM `mail`
|
||||
WHERE `mail`.`uid` = %d GROUP BY `parent-uri` ORDER BY `created` DESC",
|
||||
|
@ -232,7 +311,7 @@ function message_content(&$a) {
|
|||
);
|
||||
if(count($r))
|
||||
$a->set_pager_total($r[0]['total']);
|
||||
|
||||
|
||||
$r = q("SELECT max(`mail`.`created`) AS `mailcreated`, min(`mail`.`seen`) AS `mailseen`,
|
||||
`mail`.* , `contact`.`name`, `contact`.`url`, `contact`.`thumb` , `contact`.`network`,
|
||||
count( * ) as count
|
||||
|
@ -243,6 +322,7 @@ function message_content(&$a) {
|
|||
intval($a->pager['start']),
|
||||
intval($a->pager['itemspage'])
|
||||
);
|
||||
|
||||
if(! count($r)) {
|
||||
info( t('No messages.') . EOL);
|
||||
return $o;
|
||||
|
@ -343,26 +423,9 @@ function message_content(&$a) {
|
|||
}
|
||||
|
||||
|
||||
$Text = $message['body'];
|
||||
$saved_image = '';
|
||||
$img_start = strpos($Text,'[img]data:');
|
||||
$img_end = strpos($Text,'[/img]');
|
||||
|
||||
if($img_start !== false && $img_end !== false && $img_end > $img_start) {
|
||||
$start_fragment = substr($Text,0,$img_start);
|
||||
$img_start += strlen('[img]');
|
||||
$saved_image = substr($Text,$img_start,$img_end - $img_start);
|
||||
$end_fragment = substr($Text,$img_end + strlen('[/img]'));
|
||||
$Text = $start_fragment . '[!#saved_image#!]' . $end_fragment;
|
||||
$search = '/\[url\=(.*?)\]\[!#saved_image#!\]\[\/url\]' . '/is';
|
||||
$replace = '[url=' . z_path() . '/redir/' . $message['contact-id']
|
||||
. '?f=1&url=' . '$1' . '][!#saved_image#!][/url]' ;
|
||||
|
||||
$Text = preg_replace($search,$replace,$Text);
|
||||
|
||||
if(strlen($saved_image))
|
||||
$message['body'] = str_replace('[!#saved_image#!]', '[img]' . $saved_image . '[/img]',$Text);
|
||||
}
|
||||
$extracted = item_extract_images($message['body']);
|
||||
if($extracted['images'])
|
||||
$message['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $message['contact-id']);
|
||||
|
||||
$mails[] = array(
|
||||
'id' => $message['id'],
|
||||
|
|
|
@ -616,7 +616,8 @@ function network_content(&$a, $update = 0) {
|
|||
if($update) {
|
||||
$r = q("SELECT `parent` AS `item_id`, `contact`.`uid` AS `contact_uid`
|
||||
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
|
||||
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND
|
||||
(`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' OR item.verb = '" . ACTIVITY_DISLIKE . "')
|
||||
and `item`.`moderated` = 0 and `item`.`unseen` = 1
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
$sql_extra3 $sql_extra $sql_nets ",
|
||||
|
|
|
@ -743,6 +743,12 @@ function photos_post(&$a) {
|
|||
$ph->orient($src);
|
||||
@unlink($src);
|
||||
|
||||
$max_length = get_config('system','max_image_length');
|
||||
if(! $max_length)
|
||||
$max_length = MAX_IMAGE_LENGTH;
|
||||
if($max_length > 0)
|
||||
$ph->scaleImage($max_length);
|
||||
|
||||
$width = $ph->getWidth();
|
||||
$height = $ph->getHeight();
|
||||
|
||||
|
|
|
@ -204,6 +204,8 @@ function profile_content(&$a, $update = 0) {
|
|||
|
||||
$r = q("SELECT distinct(parent) AS `item_id`, `contact`.`uid` AS `contact-uid`
|
||||
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND
|
||||
(`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' OR item.verb = '" . ACTIVITY_DISLIKE . "')
|
||||
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
|
||||
and `item`.`moderated` = 0 and `item`.`unseen` = 1
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
|
|
|
@ -128,6 +128,7 @@ function profile_photo_post(&$a) {
|
|||
return;
|
||||
}
|
||||
|
||||
$ph->orient($src);
|
||||
@unlink($src);
|
||||
return profile_photo_crop_ui_head($a, $ph);
|
||||
|
||||
|
@ -237,6 +238,12 @@ function profile_photo_content(&$a) {
|
|||
|
||||
if(! function_exists('_crop_ui_head')) {
|
||||
function profile_photo_crop_ui_head(&$a, $ph){
|
||||
$max_length = get_config('system','max_image_length');
|
||||
if(! $max_length)
|
||||
$max_length = MAX_IMAGE_LENGTH;
|
||||
if($max_length > 0)
|
||||
$ph->scaleImage($max_length);
|
||||
|
||||
$width = $ph->getWidth();
|
||||
$height = $ph->getHeight();
|
||||
|
||||
|
|
|
@ -385,9 +385,17 @@ function profile_activity($changed, $value) {
|
|||
$arr['deny_gid'] = $a->user['deny_gid'];
|
||||
|
||||
$i = item_store($arr);
|
||||
if($i)
|
||||
if($i) {
|
||||
|
||||
// give it a permanent link
|
||||
q("update item set plink = '%s' where id = %d limit 1",
|
||||
dbesc($a->get_baseurl() . '/display/' . $a->user['nickname'] . '/' . $i),
|
||||
intval($i)
|
||||
);
|
||||
|
||||
proc_run('php',"include/notifier.php","activity","$i");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,7 +23,9 @@ function share_init(&$a) {
|
|||
$o .= "\xE2\x99\xb2" . ' [url=' . $r[0]['author-link'] . ']' . $r[0]['author-name'] . '[/url]' . "\n";
|
||||
if($r[0]['title'])
|
||||
$o .= '[b]' . $r[0]['title'] . '[/b]' . "\n";
|
||||
$o .= $r[0]['body'] . "\n";
|
||||
$o .= $r[0]['body'] . "\n" ;
|
||||
|
||||
$o .= (($r[0]['plink']) ? '[url=' . $r[0]['plink'] . ']' . t('link') . '[/url]' . "\n" : '');
|
||||
|
||||
echo $o;
|
||||
killme();
|
||||
|
|
|
@ -101,8 +101,15 @@ function wall_upload_post(&$a) {
|
|||
killme();
|
||||
}
|
||||
|
||||
$ph->orient($src);
|
||||
@unlink($src);
|
||||
|
||||
$max_length = get_config('system','max_image_length');
|
||||
if(! $max_length)
|
||||
$max_length = MAX_IMAGE_LENGTH;
|
||||
if($max_length > 0)
|
||||
$ph->scaleImage($max_length);
|
||||
|
||||
$width = $ph->getWidth();
|
||||
$height = $ph->getHeight();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue