diff options
author | Mike Macgirvin <mike@macgirvin.com> | 2010-09-17 03:10:19 -0700 |
---|---|---|
committer | Mike Macgirvin <mike@macgirvin.com> | 2010-09-17 03:10:19 -0700 |
commit | a50947a4bc3f779df8fa4e6777bc025fcefc8d21 (patch) | |
tree | 2196406c0c64494f5a4b604c695db6bbcd81897d /mod | |
parent | c5031139ebb46ce4994d3bd62059ae4eaba71359 (diff) | |
download | volse-hubzilla-a50947a4bc3f779df8fa4e6777bc025fcefc8d21.tar.gz volse-hubzilla-a50947a4bc3f779df8fa4e6777bc025fcefc8d21.tar.bz2 volse-hubzilla-a50947a4bc3f779df8fa4e6777bc025fcefc8d21.zip |
like, dislike, activity streams, etc.
Diffstat (limited to 'mod')
-rw-r--r-- | mod/dfrn_notify.php | 53 | ||||
-rw-r--r-- | mod/dfrn_poll.php | 2 | ||||
-rw-r--r-- | mod/display.php | 67 | ||||
-rw-r--r-- | mod/like.php | 171 | ||||
-rw-r--r-- | mod/network.php | 56 | ||||
-rw-r--r-- | mod/profile.php | 52 |
6 files changed, 363 insertions, 38 deletions
diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 80cd1a2fd..61ea77c29 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -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'); - - 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($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)); + + 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), diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 4b8a7f112..66e196844 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -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(); diff --git a/mod/display.php b/mod/display.php index 639a30eb7..6149c3d5b 100644 --- a/mod/display.php +++ b/mod/display.php @@ -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; -}
\ No newline at end of file +} + diff --git a/mod/like.php b/mod/like.php new file mode 100644 index 000000000..d52b3a324 --- /dev/null +++ b/mod/like.php @@ -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 +}
\ No newline at end of file diff --git a/mod/network.php b/mod/network.php index cdd8a4976..7eb93f435 100644 --- a/mod/network.php +++ b/mod/network.php @@ -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,13 +113,38 @@ 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 = ''; $template = $tpl; $commentww = ''; @@ -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 )); } diff --git a/mod/profile.php b/mod/profile.php index 1520afff7..18201e821 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -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 )); |