diff options
author | Mike Macgirvin <mike@macgirvin.com> | 2010-11-02 16:24:23 -0700 |
---|---|---|
committer | Mike Macgirvin <mike@macgirvin.com> | 2010-11-02 16:24:23 -0700 |
commit | 26f97b8284f6cf10d00e28a0dc1453c1b8d5caf0 (patch) | |
tree | ba14f748eada8e0e9e13ed0c89a436e9554ec027 /mod | |
parent | d8630dbdd8217ff31581bc521ceb1cd6be9b999c (diff) | |
download | volse-hubzilla-26f97b8284f6cf10d00e28a0dc1453c1b8d5caf0.tar.gz volse-hubzilla-26f97b8284f6cf10d00e28a0dc1453c1b8d5caf0.tar.bz2 volse-hubzilla-26f97b8284f6cf10d00e28a0dc1453c1b8d5caf0.zip |
like,dislike for photos (still needs a bit of tweaking)
Diffstat (limited to 'mod')
-rw-r--r-- | mod/photos.php | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/mod/photos.php b/mod/photos.php index 28cc805ad..63300ebee 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -52,12 +52,17 @@ function photos_post(&$a) { killme(); } - - $r = q("SELECT `contact`.* `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` + $r = q("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` WHERE `user`.`uid` = %d AND `self` = 1 LIMIT 1", intval(local_user()) ); + if(! count($r)) { + notice( t('Contact information unavailable') . EOL); + logger('photos_post: unable to locate contact record for logged in user. uid=' . local_user()); + killme(); + } + $contact_record = $r[0]; @@ -710,11 +715,12 @@ function photos_content(&$a) { $r = q("SELECT COUNT(*) AS `total` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 - AND NOT `item`.`type` IN ( 'remote', 'net-comment') - AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 + AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 + AND `item`.`uid` = %d $sql_extra ", dbesc($i1[0]['uri']), - dbesc($i1[0]['uri']) + dbesc($i1[0]['uri']), + intval($i1[0]['uid']) ); @@ -728,12 +734,13 @@ function photos_content(&$a) { `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `parent-uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 - AND NOT `item`.`type` IN ( 'remote', 'net-comment') AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 + AND `item`.`uid` = %d $sql_extra ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ", dbesc($i1[0]['uri']), dbesc($i1[0]['uri']), + intval($i1[0]['uid']), intval($a->pager['start']), intval($a->pager['itemspage']) @@ -779,6 +786,8 @@ function photos_content(&$a) { $tpl = load_view_file('view/photo_item.tpl'); $return_url = $a->cmd; + $like_tpl = load_view_file('view/like.tpl'); + if(can_write_wall($a,$a->data['user']['uid'])) { if($i1[0]['last-child']) { $o .= replace_macros($cmnt_tpl,array( @@ -795,16 +804,41 @@ function photos_content(&$a) { } } + $alike = array(); + $dlike = array(); // display comments if(count($r)) { + + foreach($r as $item) { + like_puller($a,$item,$alike,'like'); + like_puller($a,$item,$dlike,'dislike'); + } + + $likebuttons = ''; + + if(can_write_wall($a,$a->data['user']['uid'])) + $likebuttons = replace_macros($like_tpl,array('$id' => $i1[0]['id'])); + + $like = ((isset($alike[$i1[0]['id']])) ? format_like($alike[$i1[0]['id']],$alike[$i1[0]['id'] . '-l'],'like',$i1[0]['id']) : ''); + $dislike = ((isset($dlike[$i1[0]['id']])) ? format_like($dlike[$i1[0]['id']],$dlike[$i1[0]['id'] . '-l'],'dislike',$i1[0]['id']) : ''); + + $o .= $likebuttons; + $o .= $like; + $o .= $dislike; + foreach($r as $item) { $comment = ''; $template = $tpl; - + $sparkle = ''; + + if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) && ($item['id'] != $item['parent'])) + continue; + $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; if(can_write_wall($a,$a->data['user']['uid'])) { + if($item['last-child']) { $comment = replace_macros($cmnt_tpl,array( '$return_path' => $return_url, |