like, dislike, activity streams, etc.

This commit is contained in:
Mike Macgirvin 2010-09-17 03:10:19 -07:00
parent c5031139eb
commit a50947a4bc
25 changed files with 564 additions and 77 deletions

View File

@ -47,7 +47,9 @@ define ( 'ACTIVITY_OBJ_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'photo' );
define ( 'ACTIVITY_OBJ_P_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'profile-photo' );
define ( 'ACTIVITY_OBJ_ALBUM', NAMESPACE_ACTIVITY_SCHEMA . 'photo-album' );
define ( 'GRAVITY_PARENT', 0);
define ( 'GRAVITY_LIKE', 3);
define ( 'GRAVITY_COMMENT', 6);
if(! class_exists('App')) {
@ -850,3 +852,24 @@ function allowed_url($url) {
return $found;
}}
if(! function_exists('format_like')) {
function format_like($cnt,$arr,$type,$id) {
if($cnt == 1)
$o .= $arr[0] . (($type == 'like') ? t(' likes this.') : t(' doesn\'t like this.')) . EOL ;
else {
$o .= '<span class="fakelink" onclick="openClose(\'' . $type . 'list-' . $id . '\');" >'
. $cnt . ' ' . t('people') . '</span> ' . (($type == 'like') ? t('like this.') : t('don\'t like this.')) . EOL ;
$total = count($arr);
if($total >= 75)
$arr = array_slice($arr,0,74);
if($total < 75)
$arr[count($arr)-1] = t('and') . ' ' . $arr[count($arr)-1];
$str = implode(', ', $arr);
if($total >= 75)
$str .= t(', and ') . $total - 75 . t(' other people');
$str .= (($type == 'like') ? t(' like this.') : t(' don\'t like this.'));
$o .= '<div id="' . $type . 'list-' . $id . '" style="display: none;" >' . $str . '</div>';
}
return $o;
}}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 B

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 119 B

View File

@ -1,9 +1,9 @@
<?php
require_once('bbcode.php');
function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update) {
function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update, $direction = 0) {
require_once('bbcode.php');
// default permissions - anonymous user
@ -32,13 +32,31 @@ function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update) {
else
killme();
if($dfrn_id != '*') {
if($dfrn_id && $dfrn_id != '*') {
$r = q("SELECT * FROM `contact` WHERE ( `issued-id` = '%s' OR ( `duplex` = 1 AND `dfrn-id` = '%s' )) AND `uid` = %d LIMIT 1",
dbesc($dfrn_id),
dbesc($dfrn_id),
$sql_extra = '';
switch($direction) {
case (-1):
$sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($dfrn_id));
$my_id = $dfrn_id;
break;
case 0:
$sql_extra = sprintf(" AND `issued-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
$my_id = '1:' . $dfrn_id;
break;
case 1:
$sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id));
$my_id = '0:' . $dfrn_id;
break;
default:
return false;
break; // NOTREACHED
}
$r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `contact`.`uid` = %d $sql_extra LIMIT 1",
intval($owner_id)
);
if(! count($r))
return false;
@ -82,7 +100,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update) {
`contact`.`id` AS `contact-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 NOT `item`.`type` IN ( 'remote', 'net-comment' ) AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`wall` = 1 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND ( `item`.`edited` > '%s' OR `item`.`changed` > '%s' )
$sql_extra
ORDER BY `parent` %s, `created` ASC LIMIT 0, 300",
@ -193,10 +211,23 @@ function construct_verb($item) {
function construct_activity($item) {
if($item['type'] == 'activity') {
if($item['object']) {
$o = '<as:object>' . "\r\n";
$r = @simplexml_load_string($item['object']);
if($r->type)
$o .= '<as:object-type>' . $r->type . '</as:object-type>' . "\r\n";
if($r->id)
$o .= '<id>' . $r->id . '</id>' . "\r\n";
if($r->link)
$o .= '<link rel="alternate" type="text/html" href="' . $r->link . '" />' . "\r\n";
if($r->title)
$o .= '<title>' . $r->title . '</title>' . "\r\n";
if($r->content)
$o .= '<content type="html" >' . bbcode($r->content) . '</content>' . "\r\n";
$o .= '</as:object>' . "\r\n";
return $o;
}
return '';
}
@ -300,9 +331,42 @@ function get_atom_elements($item) {
$res['verb'] = unxmlify($rawverb[0]['data']);
$rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'object');
if($rawobj) {
$res['object-type'] = $rawobj[0]['object-type'][0]['data'];
$res['object'] = $rawobj[0];
$res['object'] = '<object>' . "\n";
if($rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
$res['object-type'] = $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'];
$res['object'] .= '<type>' . $rawobj[0]['child'][NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n";
}
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
$res['object'] .= '<id>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n";
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'][0]['attribs']['']['rel'] == 'alternate')
$res['object'] .= '<link>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link'][0]['attribs']['']['href'] . '</link>' . "\n";
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'])
$res['object'] .= '<title>' . $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['title'][0]['data'] . '</title>' . "\n";
if($rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data']) {
$body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['content'][0]['data'];
if(! $body)
$body = $rawobj[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['summary'][0]['data'];
if(strpos($body,'<')) {
$body = preg_replace('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s',
'[youtube]$1[/youtube]', $body);
$config = HTMLPurifier_Config::createDefault();
$config->set('Core.DefinitionCache', null);
$purifier = new HTMLPurifier($config);
$body = $purifier->purify($body);
}
$body = html2bbcode($body);
$res['object'] .= '<content>' . $body . '</content>' . "\n";
}
$res['object'] .= '</object>' . "\n";
}
return $res;

View File

@ -36,6 +36,7 @@
var livetime = null;
var msie = false;
var stopped = false;
var timer = null;
$(document).ready(function() {
$.ajaxSetup({cache: false});
@ -77,12 +78,12 @@
});
}) ;
}
setTimeout(NavUpdate,30000);
timer = setTimeout(NavUpdate,30000);
}
function liveUpdate() {
if((src == null) || (stopped)) { return; }
if((src == null) || (stopped)) { $('.like-rotator').hide(); return; }
if($('.comment-edit-text-full').length) {
livetime = setTimeout(liveUpdate, 10000);
return;
@ -102,6 +103,8 @@
$('#' + ident + ' ' + '.wall-item-ago').replaceWith($(this).find('.wall-item-ago'));
$('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($(this).find('.wall-item-comment-wrapper'));
$('#' + ident + ' ' + '.wall-item-like').replaceWith($(this).find('.wall-item-like'));
$('#' + ident + ' ' + '.wall-item-dislike').replaceWith($(this).find('.wall-item-dislike'));
$('#' + ident + ' ' + '.my-comment-photo').each(function() {
$(this).attr('src',$(this).attr('dst'));
});
@ -110,6 +113,7 @@
}
prev = ident;
});
$('.like-rotator').hide();
});
}
@ -129,3 +133,20 @@
$(node).css('width',16);
$(node).css('height',16);
}
// Since ajax is asynchronous, we will give a few seconds for
// the first ajax call (setting like/dislike), then run the
// updater to pick up any changes and display on the page.
// The updater will turn any rotators off when it's done.
// This function will have returned long before any of these
// events have completed and therefore there won't be any
// visible feedback that anything changed without all this
// trickery. This still could cause confusion if the "like" ajax call
// is delayed and NavUpdate runs before it completes.
function dolike(ident,verb) {
$('#like-rotator-' + ident.toString()).show();
$.get('like/' + ident.toString() + '?verb=' + verb );
if(timer) clearTimeout(timer);
timer = setTimeout(NavUpdate,3000);
}

View File

@ -13,6 +13,7 @@
require_once("session.php");
require_once("datetime.php");
require_once('include/items.php');
if($argc < 3)
exit;
@ -114,6 +115,8 @@
$recipients = array_diff($recipients,$deny);
$conversant_str = dbesc(implode(', ',$conversants));
}
$r = q("SELECT * FROM `contact` WHERE `id` IN ( $conversant_str ) AND `blocked` = 0 AND `pending` = 0");
@ -161,14 +164,13 @@
}
else {
require_once('include/items.php');
$verb = construct_verb($item);
$actobj = construct_activity($item);
if($followup) {
foreach($items as $item) {
$verb = construct_verb($item);
$actobj = construct_activity($item);
if($item['id'] == $item_id) {
$atom .= replace_macros($cmnt_template, array(
'$name' => xmlify($owner['name']),
@ -203,6 +205,10 @@
else {
foreach($contacts as $contact) {
if($item['contact-id'] == $contact['id']) {
$verb = construct_verb($item);
$actobj = construct_activity($item);
if($item['parent'] == $item['id']) {
$atom .= replace_macros($item_template, array(
'$name' => xmlify($contact['name']),
@ -220,7 +226,7 @@
'$verb' => xmlify($verb),
'$actobj' => $actobj,
'$content' => xmlify($item['body']),
'$comment_allow' => (($item['last-child'] && ($contact['rel']) && ($contact['rel'] != REL_FAN)) ? 1 : 0)
'$comment_allow' => (($item['last-child']) ? 1 : 0)
));
}
else {

View File

@ -348,6 +348,11 @@
$datarray['parent-uri'] = $parent_uri;
$datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $contact['id'];
if(($datarray['verb'] == ACTIVITY_LIKE) || ($datarray['verb'] == ACTIVITY_DISLIKE)) {
$datarray['type'] = 'activity';
$datarray['gravity'] = GRAVITY_LIKE;
}
$r = item_store($datarray);
continue;
}

View File

@ -208,6 +208,10 @@ function dfrn_notify_post(&$a) {
$datarray['parent-uri'] = $parent_uri;
$datarray['uid'] = $importer['importer_uid'];
$datarray['contact-id'] = $importer['id'];
if(($datarray['verb'] == ACTIVITY_LIKE) || ($datarray['verb'] == ACTIVITY_DISLIKE)) {
$datarray['type'] = 'activity';
$datarray['gravity'] = GRAVITY_LIKE;
}
$posted_id = item_store($datarray);
if($posted_id) {
@ -228,26 +232,28 @@ function dfrn_notify_post(&$a) {
intval($posted_id)
);
$php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
if($datarray['type'] == 'remote-comment') {
$php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"comment-import\" \"$posted_id\" &",
array(),$foo));
proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"comment-import\" \"$posted_id\" &",
array(),$foo));
if(($importer['notify-flags'] & NOTIFY_COMMENT) && (! $importer['self'])) {
require_once('bbcode.php');
$from = stripslashes($datarray['author-name']);
$tpl = file_get_contents('view/cmnt_received_eml.tpl');
$email_tpl = replace_macros($tpl, array(
'$sitename' => $a->config['sitename'],
'$siteurl' => $a->get_baseurl(),
'$username' => $importer['username'],
'$email' => $importer['email'],
'$from' => $from,
'$body' => strip_tags(bbcode(stripslashes($datarray['body'])))
));
$res = mail($importer['email'], $from . t(" commented on your item at ") . $a->config['sitename'],
$email_tpl,t("From: Administrator@") . $a->get_hostname() );
if(($importer['notify-flags'] & NOTIFY_COMMENT) && (! $importer['self'])) {
require_once('bbcode.php');
$from = stripslashes($datarray['author-name']);
$tpl = file_get_contents('view/cmnt_received_eml.tpl');
$email_tpl = replace_macros($tpl, array(
'$sitename' => $a->config['sitename'],
'$siteurl' => $a->get_baseurl(),
'$username' => $importer['username'],
'$email' => $importer['email'],
'$from' => $from,
'$body' => strip_tags(bbcode(stripslashes($datarray['body'])))
));
$res = mail($importer['email'], $from . t(" commented on your item at ") . $a->config['sitename'],
$email_tpl,t("From: Administrator@") . $a->get_hostname() );
}
}
}
xml_status(0);
@ -280,11 +286,16 @@ function dfrn_notify_post(&$a) {
$datarray['parent-uri'] = $parent_uri;
$datarray['uid'] = $importer['importer_uid'];
$datarray['contact-id'] = $importer['id'];
if(($datarray['verb'] == ACTIVITY_LIKE) || ($datarray['verb'] == ACTIVITY_DISLIKE)) {
$datarray['type'] = 'activity';
$datarray['gravity'] = GRAVITY_LIKE;
}
$r = item_store($datarray);
// find out if our user is involved in this conversation and wants to be notified.
if($importer['notify-flags'] & NOTIFY_COMMENT) {
if(($datarray['type'] != 'activity') && ($importer['notify-flags'] & NOTIFY_COMMENT)) {
$myconv = q("SELECT `author-link` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d",
dbesc($parent_uri),

View File

@ -201,7 +201,7 @@ function dfrn_poll_post(&$a) {
}
else {
$o = get_feed_for($a,$dfrn_id, $a->argv[1], $last_update);
$o = get_feed_for($a,$dfrn_id, $a->argv[1], $last_update, $direction);
echo $o;
killme();

View File

@ -93,7 +93,7 @@ function display_content(&$a) {
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`parent` = ( SELECT `parent` FROM `item` WHERE ( `id` = '%s' OR `uri` = '%s' ))
$sql_extra
ORDER BY `parent` DESC, `id` ASC ",
ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ",
intval($a->profile['uid']),
dbesc($item_id),
dbesc($item_id)
@ -101,19 +101,49 @@ function display_content(&$a) {
$cmnt_tpl = file_get_contents('view/comment_item.tpl');
$like_tpl = file_get_contents('view/like.tpl');
$tpl = file_get_contents('view/wall_item.tpl');
$wallwall = file_get_contents('view/wallwall_item.tpl');
$return_url = $_SESSION['return_url'] = $a->cmd;
$alike = array();
$dlike = array();
if(count($r)) {
foreach($r as $item) {
if(($item['verb'] == ACTIVITY_LIKE) && ($item['id'] != $item['parent'])) {
$url = $item['url'];
if(($item['rel'] == REL_VIP || $item['rel'] == REL_BUD) && (! $item['self']))
$url = $a->get_baseurl() . '/redir/' . $item['contact-id'];
if(! is_array($alike[$item['parent'] . '-l']))
$alike[$item['parent'] . '-l'] = array();
$alike[$item['parent']] ++;
$alike[$item['parent'] . '-l'][] = '<a href="'. $url . '">' . $item['name'] . '</a>';
}
if(($item['verb'] == ACTIVITY_DISLIKE) && ($item['id'] != $item['parent'])) {
$url = $item['url'];
if(($item['rel'] == REL_VIP || $item['rel'] == REL_BUD) && (! $item['self']))
$url = $a->get_baseurl() . '/redir/' . $item['contact-id'];
if(! is_array($dlike[$item['parent'] . '-l']))
$dlike[$item['parent'] . '-l'] = array();
$dlike[$item['parent']] ++;
$dlike[$item['parent'] . '-l'][] = '<a href="'. $url . '">' . $item['name'] . '</a>';
}
}
foreach($r as $item) {
$comment = '';
$template = $tpl;
$redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
if((($item['verb'] == ACTIVITY_LIKE) || ($item['verb'] == ACTIVITY_DISLIKE)) && ($item['id'] != $item['parent']))
continue;
if(can_write_wall($a,$a->profile['uid'])) {
if($item['last-child']) {
@ -175,6 +205,15 @@ function display_content(&$a) {
if(($item['contact-id'] == $_SESSION['visitor_id']) || ($item['uid'] == get_uid()))
$drop = replace_macros(file_get_contents('view/wall_item_drop.tpl'), array('$id' => $item['id']));
$like = (($alike[$item['id']]) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
$dislike = (($dlike[$item['id']]) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
$likebuttons = '';
if($item['id'] == $item['parent']) {
$likebuttons = replace_macros($like_tpl,array('$id' => $item['id']));
}
$o .= replace_macros($template,array(
'$id' => $item['item_id'],
@ -190,10 +229,32 @@ function display_content(&$a) {
'$owner_photo' => $owner_photo,
'$owner_name' => $owner_name,
'$drop' => $drop,
'$vote' => $likebuttons,
'$like' => $like,
'$dislike' => $dislike,
'$comment' => $comment
));
}
}
else {
$r = q("SELECT `id` FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
dbesc($item_id),
dbesc($item_id)
);
if(count($r)) {
if($r[0]['deleted']) {
notice( t('Item has been removed.') . EOL );
}
else {
notice( t('Permission denied.') . EOL );
}
}
else {
notice( t('Item not found.') . EOL );
}
}
return $o;
}
}

171
mod/like.php Normal file
View File

@ -0,0 +1,171 @@
<?php
require_once('include/security.php');
require_once('include/bbcode.php');
require_once('include/items.php');
function like_content(&$a) {
if(! local_user() && ! remote_user()) {
return;
}
$verb = notags(trim($_GET['verb']));
if(! $verb)
$verb = 'like';
switch($verb) {
case 'like':
$activity = ACTIVITY_LIKE;
break;
case 'dislike':
$activity = ACTIVITY_DISLIKE;
break;
case 'unlike':
$activity = ACTIVITY_LIKE;
break;
case 'undislike':
$activity = ACTIVITY_DISLIKE;
break;
default:
return;
break;
}
$item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0);
$r = q("SELECT * FROM `item` WHERE ( `id` = '%s' OR `uri` = '%s') AND `id` = `parent` LIMIT 1",
dbesc($item_id),
dbesc($item_id)
);
if(! $item_id || (! count($r))) {
return;
}
$item = $r[0];
$owner_uid = $item['uid'];
if(! can_write_wall($a,$owner_uid)) {
return;
}
$r = q("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1",
intval($owner_uid)
);
if(count($r))
$owner = $r[0];
if(! $owner) {
return;
}
if((local_user()) && (get_uid() == $owner_uid)) {
$contact = $owner;
}
else {
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($_SESSION['visitor_id']),
intval($owner_uid)
);
if(count($r))
$contact = $r[0];
}
if(! $contact) {
return;
}
$r = q("SELECT `id` FROM `item` WHERE `verb` = '%s' AND `deleted` = 0
AND `contact-id` = %d AND ( `parent` = '%s' OR `parent-uri` = '%s') LIMIT 1",
dbesc($activity),
intval($contact['id']),
dbesc($item_id),
dbesc($item_id)
);
if(count($r)) {
// Already voted, undo it
$r = q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `id` = %d LIMIT 1",
dbesc(datetime_convert()),
intval($r[0]['id'])
);
$php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"like\" \"$post_id\" > notify.out &",
array(),$foo));
return;
}
$uri = item_new_uri($a->get_hostname(),$owner_uid);
$post_type = (($item['resource-id']) ? t('photo') : t('status'));
$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
$link = $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'];
$body = $item['body'];
$obj = <<< EOT
<object>
<type>$objtype</type>
<local>1</local>
<id>{$item['uri']}</id>
<link>$link</link>
<title></title>
<content>$body</content>
</object>
EOT;
if($verb == 'like')
$bodyverb = t('likes');
if($verb == 'dislike')
$bodyverb = t('doesn\'t like');
if(! isset($bodyverb))
return;
$arr = array();
$arr['uri'] = $uri;
$arr['uid'] = $owner_uid;
$arr['contact-id'] = $contact['id'];
$arr['type'] = 'activity';
$arr['wall'] = 1;
$arr['gravity'] = GRAVITY_LIKE;
$arr['parent'] = $item['id'];
$arr['parent-uri'] = $item['uri'];
$arr['owner-name'] = $owner['name'];
$arr['owner-link'] = $owner['url'];
$arr['owner-avatar'] = $owner['thumb'];
$arr['author-name'] = $contact['name'];
$arr['author-link'] = $contact['url'];
$arr['author-avatar'] = $contact['thumb'];
$arr['body'] = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]' . ' ' . t('likes') . ' '
. '[url=' . $owner['url'] . ']' . $owner['name'] . t('\'s') . '[/url]' . ' '
. '[url=' . $a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]' ;
$arr['verb'] = $activity;
$arr['object-type'] = $objtype;
$arr['object'] = $obj;
$arr['allow_cid'] = $item['allow_cid'];
$arr['allow_gid'] = $item['allow_gid'];
$arr['deny_cid'] = $item['deny_cid'];
$arr['deny_gid'] = $item['deny_gid'];
$arr['visible'] = 1;
$arr['unseen'] = 1;
$arr['last-child'] = 0;
$post_id = item_store($arr);
$php_path = ((strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
proc_close(proc_open("\"$php_path\" \"include/notifier.php\" \"like\" \"$post_id\" > notify.out &",
array(),$foo));
return; // NOTREACHED
}

View File

@ -66,7 +66,7 @@ function network_content(&$a, $update = false) {
// that belongs to you, hence you can see all of it. We will filter by group if
// desired.
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `type` IN ('wall', 'photo', 'remote' )) ";
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` ) ";
if($group) {
$r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
@ -81,7 +81,7 @@ function network_content(&$a, $update = false) {
$contacts = expand_groups(array($group));
$contact_str = implode(',',$contacts);
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `type` IN ('wall', 'photo', 'remote') AND `contact-id` IN ( $contact_str )) ";
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `contact-id` IN ( $contact_str )) ";
$o = '<h4>' . t('Group: ') . $r[0]['name'] . '</h4>' . $o;
}
@ -98,14 +98,14 @@ function network_content(&$a, $update = false) {
$a->set_pager_total($r[0]['total']);
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
`contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
`contact`.`id` AS `cid`, `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 `contact`.`blocked` = 0 AND `contact`.`pending` = 0
$sql_extra
ORDER BY `parent` DESC, `created` ASC LIMIT %d ,%d ",
ORDER BY `parent` DESC, `gravity` ASC, `created` ASC LIMIT %d ,%d ",
intval($_SESSION['uid']),
intval($a->pager['start']),
intval($a->pager['itemspage'])
@ -113,11 +113,36 @@ function network_content(&$a, $update = false) {
$cmnt_tpl = file_get_contents('view/comment_item.tpl');
$like_tpl = file_get_contents('view/like.tpl');
$tpl = file_get_contents('view/wall_item.tpl');
$wallwall = file_get_contents('view/wallwall_item.tpl');
$alike = array();
$dlike = array();
if(count($r)) {
foreach($r as $item) {
if(($item['verb'] == ACTIVITY_LIKE) && ($item['id'] != $item['parent'])) {
$url = $item['url'];
if(($item['rel'] == REL_VIP || $item['rel'] == REL_BUD) && (! $item['self']))
$url = $a->get_baseurl() . '/redir/' . $item['contact-id'];
if(! is_array($alike[$item['parent'] . '-l']))
$alike[$item['parent'] . '-l'] = array();
$alike[$item['parent']] ++;
$alike[$item['parent'] . '-l'][] = '<a href="'. $url . '">' . $item['name'] . '</a>';
}
if(($item['verb'] == ACTIVITY_DISLIKE) && ($item['id'] != $item['parent'])) {
$url = $item['url'];
if(($item['rel'] == REL_VIP || $item['rel'] == REL_BUD) && (! $item['self']))
$url = $a->get_baseurl() . '/redir/' . $item['contact-id'];
if(! is_array($dlike[$item['parent'] . '-l']))
$dlike[$item['parent'] . '-l'] = array();
$dlike[$item['parent']] ++;
$dlike[$item['parent'] . '-l'][] = '<a href="'. $url . '">' . $item['name'] . '</a>';
}
}
foreach($r as $item) {
$comment = '';
@ -127,12 +152,14 @@ function network_content(&$a, $update = false) {
$profile_url = $item['url'];
$redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
if((($item['verb'] == ACTIVITY_LIKE) || ($item['verb'] == ACTIVITY_DISLIKE)) && ($item['id'] != $item['parent']))
continue;
// Top-level wall post not written by the wall owner (wall-to-wall)
// First figure out who owns it.
if(($item['parent'] == $item['item_id']) && (! $item['self'])) {
if($item['type'] == 'wall') {
// I do. Put me on the left of the wall-to-wall notice.
$owner_url = $a->contact['url'];
@ -149,8 +176,7 @@ function network_content(&$a, $update = false) {
$template = $wallwall;
$commentww = 'ww';
// If it is our contact, use a friendly redirect link
if(($item['owner-link'] == $item['url']) && ($item['rel'] == DIRECTION_IN || $item['rel'] == DIRECTION_BOTH))
$owner_url = $redirect_url;
if(($item['owner-link'] == $item['url']) && ($item['rel'] == REL_VIP || $item['rel'] == REL_BUD))
$owner_url = $redirect_url;
}
@ -161,6 +187,10 @@ function network_content(&$a, $update = false) {
else
$return_url = $_SESSION['return_url'] = $a->cmd;
$likebuttons = '';
if($item['id'] == $item['parent']) {
$likebuttons = replace_macros($like_tpl,array('$id' => $item['id']));
}
if($item['last-child']) {
$comment = replace_macros($cmnt_tpl,array(
@ -181,7 +211,7 @@ function network_content(&$a, $update = false) {
if(($item['contact-uid'] == $_SESSION['uid']) && ($item['rel'] == DIRECTION_IN || $item['rel'] == DIRECTION_BOTH) && (! $item['self'] ))
if(($item['rel'] == REL_VIP || $item['rel'] == REL_BUD) && (! $item['self'] ))
$profile_url = $redirect_url;
$photo = $item['photo'];
@ -203,6 +233,11 @@ function network_content(&$a, $update = false) {
$profile_link = $item['author-link'];
}
$like = (($alike[$item['id']]) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
$dislike = (($dlike[$item['id']]) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
// Build the HTML
$o .= replace_macros($template,array(
@ -219,6 +254,9 @@ function network_content(&$a, $update = false) {
'$owner_photo' => $owner_photo,
'$owner_name' => $owner_name,
'$drop' => $drop,
'$vote' => $likebuttons,
'$like' => $like,
'$dislike' => $dislike,
'$comment' => $comment
));
}

View File

@ -203,7 +203,7 @@ function profile_content(&$a, $update = false) {
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `type` != 'remote')
AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `wall` = 1 )
$sql_extra ",
intval($a->profile['profile_uid'])
@ -219,9 +219,9 @@ function profile_content(&$a, $update = false) {
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `type` != 'remote')
AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `wall` = 1 )
$sql_extra
ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ",
ORDER BY `parent` DESC, `gravity` ASC, `id` ASC LIMIT %d ,%d ",
intval($a->profile['profile_uid']),
intval($a->pager['start']),
intval($a->pager['itemspage'])
@ -231,6 +231,8 @@ function profile_content(&$a, $update = false) {
$cmnt_tpl = file_get_contents('view/comment_item.tpl');
$like_tpl = file_get_contents('view/like.tpl');
$tpl = file_get_contents('view/wall_item.tpl');
if($update)
@ -238,15 +240,50 @@ function profile_content(&$a, $update = false) {
else
$return_url = $_SESSION['return_url'] = $a->cmd;
$alike = array();
$dlike = array();
if(count($r)) {
foreach($r as $item) {
if(($item['verb'] == ACTIVITY_LIKE) && ($item['id'] != $item['parent'])) {
$url = $item['url'];
if(($item['rel'] == REL_VIP || $item['rel'] == REL_BUD) && (! $item['self']))
$url = $a->get_baseurl() . '/redir/' . $item['contact-id'];
if(! is_array($alike[$item['parent'] . '-l']))
$alike[$item['parent'] . '-l'] = array();
$alike[$item['parent']] ++;
$alike[$item['parent'] . '-l'][] = '<a href="'. $url . '">' . $item['name'] . '</a>';
}
if(($item['verb'] == ACTIVITY_DISLIKE) && ($item['id'] != $item['parent'])) {
$url = $item['url'];
if(($item['rel'] == REL_VIP || $item['rel'] == REL_BUD) && (! $item['self']))
$url = $a->get_baseurl() . '/redir/' . $item['contact-id'];
if(! is_array($dlike[$item['parent'] . '-l']))
$dlike[$item['parent'] . '-l'] = array();
$dlike[$item['parent']] ++;
$dlike[$item['parent'] . '-l'][] = '<a href="'. $url . '">' . $item['name'] . '</a>';
}
}
foreach($r as $item) {
$comment = '';
$likebuttons = '';
$template = $tpl;
$redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
if((($item['verb'] == ACTIVITY_LIKE) || ($item['verb'] == ACTIVITY_DISLIKE)) && ($item['id'] != $item['parent']))
continue;
if(can_write_wall($a,$a->profile['profile_uid'])) {
if($item['id'] == $item['parent']) {
$likebuttons = replace_macros($like_tpl,array('$id' => $item['id']));
}
if($item['last-child']) {
$comment = replace_macros($cmnt_tpl,array(
'$return_path' => $_SESSION['return_url'],
@ -287,6 +324,10 @@ function profile_content(&$a, $update = false) {
$drop = replace_macros(file_get_contents('view/wall_item_drop.tpl'), array('$id' => $item['id']));
$like = (($alike[$item['id']]) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
$dislike = (($dlike[$item['id']]) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
$o .= replace_macros($template,array(
'$id' => $item['item_id'],
'$profile_url' => $profile_link,
@ -298,6 +339,9 @@ function profile_content(&$a, $update = false) {
'$location' => (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : ''),
'$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
'$drop' => $drop,
'$like' => $like,
'$vote' => $likebuttons,
'$dislike' => $dislike,
'$comment' => $comment
));

View File

@ -5,7 +5,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
$o = '';
$o .= "<select name=\"{$selname}[]\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" />\r\n";
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" >\r\n";
$r = q("SELECT * FROM `group` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `name` ASC",
$_SESSION['uid']
@ -39,11 +39,11 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
if($privmail) {
$sql_extra = sprintf(" AND `rel` = %d ", intval(DIRECTION_BOTH));
$o .= "<select name=\"$selname\" class=\"$selclass\" size=\"$size\" />\r\n";
$o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\" >\r\n";
}
else {
$sql_extra = '';
$o .= "<select name=\"{$selname}[]\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" />\r\n";
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" >\r\n";
}
$r = q("SELECT `id`, `name`, `url` FROM `contact`

View File

@ -18,6 +18,6 @@
<input type="submit" id="comment-edit-submit-$id" class="comment-edit-submit" name="submit" value="Submit" />
</div>
<div id="comment-edit-end"></div>
<div class="comment-edit-end"></div>
</form>
</div>

View File

@ -107,5 +107,6 @@ tinyMCE.init({
}
}
</script>

View File

@ -1,19 +1,19 @@
<div id="profile-jot-wrapper" >
<div id="profile-jot-banner-wrapper">
<div id="profile-jot-desc" >What's on your mind?</div>
<div id="character-counter" class="grey"></div>
</div>
<div id="profile-jot-banner-end"></div>
<form id="profile-jot-form" action="item" method="post" >
<input type="hidden" name="type" value="wall" />
<input type="hidden" name="profile_uid" value="$profile_uid" />
<input type="hidden" name="return" value="$return_path" />
<input type="hidden" name="location" id="jot-location" value="$defloc" />
<div id="profile-jot-banner-wrapper">
<div id="profile-jot-desc" >What's on your mind?</div>
<div id="character-counter" class="grey"></div>
</div>
<div id="profile-jot-banner-end"></div>
<textarea rows="5" cols="64" class="profile-jot-text" id="profile-jot-text" name="body" ></textarea>
<form id="profile-jot-form" action="item" method="post" >
<input type="hidden" name="type" value="wall" />
<input type="hidden" name="profile_uid" value="$profile_uid" />
<input type="hidden" name="return" value="$return_path" />
<input type="hidden" name="location" id="jot-location" value="$defloc" />
<textarea rows="5" cols="64" class="profile-jot-text" id="profile-jot-text" name="body" ></textarea>
</div>
<div id="profile-jot-submit-wrapper" >
<input type="submit" id="profile-jot-submit" name="submit" value="Submit" />
<div id="profile-upload-wrapper" style="display: $visitor;" >
@ -35,6 +35,7 @@
<div id="profile-jot-perms-end"></div>
<div id="profile-jot-acl-wrapper" style="display: none;" >$acl</div>
</div>
<div id="profile-jot-end"></div>
</form>
</div>

5
view/like.tpl Normal file
View File

@ -0,0 +1,5 @@
<div class="wall-item-like-buttons" id="wall-item-like-buttons-$id">
<img src="images/like.gif" alt="I like this" title="I like this [toggle]" onclick="dolike($id,'like');" />
<img src="images/dislike.gif" alt="I don't like this" title="I don't like this [toggle]" onclick="dolike($id,'dislike');" />
<img id="like-rotator-$id" class="like-rotator" src="images/rotator.gif" alt="Please wait" title="Please wait" style="display: none;" />
</div>

View File

@ -4,3 +4,4 @@
<a href="$url?tab=profile" id="profile-tab-profile-link" class="profile-tabs" >Profile</a>
<a href="$phototab" id="profile-tab-photos-link" class="profile-tabs" >Photos</a>
<div id="profile-tabs-end"></div>
</div>

View File

@ -45,7 +45,7 @@ $profile_in_dir
$profile_in_net_dir
<div id="settings-default-perms" class="settings-default-perms" >
<div id="settings-default-perms-menu" onClick="openClose('settings-default-perms-select');" />$permissions</div>
<div id="settings-default-perms-menu" onClick="openClose('settings-default-perms-select');" >$permissions</div>
<div id="settings-default-perms-menu-end"></div>
<div id="settings-default-perms-select" style="display: none;" >

View File

@ -8,6 +8,22 @@ a:hover {
color: #0000FF;
text-decoration: underline;
}
.fakelink, .fakelink:visited {
color: #8888FF;
text-decoration: none;
cursor: pointer;
margin-top: 15px;
margin-bottom: 15px;
}
.fakelink:hover {
color: #0000FF;
text-decoration: underline;
cursor: pointer;
}
img {
border: none;
}
@ -649,6 +665,9 @@ input#dfrn-url {
font-size: 0.8em;
}
.wall-item-like-buttons img {
cursor: pointer;
}
.wall-item-delete-wrapper {
float: right;
margin-top: 20px;

View File

@ -30,6 +30,17 @@ a:hover {
color: #0000FF;
text-decoration: underline;
}
.fakelink, .fakelink:visited {
color: #8888FF;
}
.fakelink:hover {
color: #0000FF;
}
.wall-item-content-wrapper.comment {
background: #FFCC55;
}

View File

@ -9,6 +9,7 @@
<a href="$profile_url" title="View $name's profile" class="wall-item-name-link"><span class="wall-item-name" id="wall-item-name-$id" >$name</span></a>
<div class="wall-item-ago" id="wall-item-ago-$id">$ago</div>
<div class="wall-item-location" id="wall-item-location-$id">$location</div>
$vote
</div>
<div class="wall-item-content" id="wall-item-content-$id" >
<div class="wall-item-title" id="wall-item-title-$id">$title</div>
@ -17,7 +18,8 @@
$drop
</div>
<div class="wall-item-wrapper-end"></div>
<div class="wall-item-like" id="wall-item-like-$id">$like</div>
<div class="wall-item-dislike" id="wall-item-dislike-$id">$dislike</div>
<div class="wall-item-comment-wrapper" >
$comment
</div>

View File

@ -1 +1,2 @@
<div class="wall-item-delete-wrapper" id="wall-item-delete-wrapper-$id" ><a href="item/drop/$id" onclick="return confirmDelete();" ><img src="images/b_drophide.gif" alt="Delete" title="Delete" id="wall-item-delete-icon-$id" class="wall-item-delete-icon" onmouseover="imgbright(this);" onmouseout="imgdull(this);" ></a></div><div class="wall-item-delete-end"></div>
<div class="wall-item-delete-wrapper" id="wall-item-delete-wrapper-$id" ><a href="item/drop/$id" onclick="return confirmDelete();" ><img src="images/b_drophide.gif" alt="Delete" title="Delete" id="wall-item-delete-icon-$id" class="wall-item-delete-icon" onmouseover="imgbright(this);" onmouseout="imgdull(this);" ></a></div>
<div class="wall-item-delete-end"></div>

View File

@ -12,7 +12,7 @@
<a href="$profile_url" title="View $name's profile" class="wall-item-name-link"><span class="wall-item-name" id="wall-item-name-$id" >$name</span></a> to <a href="$owner_url" title="View $owner_name's profile" class="wall-item-name-link"><span class="wall-item-name" id="wall-item-ownername-$id">$owner_name</span></a> via Wall-To-Wall:<br />
<div class="wall-item-ago" id="wall-item-ago-$id">$ago</div>
<div class="wall-item-location" id="wall-item-location-$id">$location</div>
$vote
</div>
<div class="wall-item-content" id="wall-item-content-$id" >
<div class="wall-item-title" id="wall-item-title-$id">$title</div>
@ -21,6 +21,8 @@
$drop
<div class="wall-item-wrapper-end"></div>
<div class="wall-item-like" id="wall-item-like-$id">$like</div>
<div class="wall-item-dislike" id="wall-item-dislike-$id">$dislike</div>
<div class="wall-item-comment-separator"></div>
<div class="wall-item-comment-wrapper" >
$comment