show like/dislike when no comments yet, bit of lint

This commit is contained in:
Friendika 2010-11-03 19:47:07 -07:00
parent a90e5f438b
commit b3856a797b
4 changed files with 80 additions and 49 deletions

View file

@ -548,6 +548,8 @@ function item_store($arr) {
dbesc_array($arr);
logger('item_store: ' . print_r($arr,true), LOGGER_DATA);
$r = q("INSERT INTO `item` (`"
. implode("`, `", array_keys($arr))
. "`) VALUES ('"
@ -576,13 +578,17 @@ function item_store($arr) {
$arr['uri'], // already dbesc'd
intval($arr['uid'])
);
if(count($r))
if(count($r)) {
$current_post = $r[0]['id'];
logger('item_store: created item ' . $current_post);
}
else
return 0;
if($parent_missing) {
logger('item_store: item parent was not found - ignoring item');
// perhaps the parent was deleted, but in any case, this thread is dead
// and unfortunately our brand new item now has to be destroyed

View file

@ -128,8 +128,13 @@ function display_content(&$a) {
}
foreach($r as $item) {
$comment = '';
$template = $tpl;
$comment = '';
$owner_url = '';
$owner_photo = '';
$owner_name = '';
$redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
@ -215,8 +220,9 @@ function display_content(&$a) {
else
$drop = replace_macros(load_view_file('view/wall_fake_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']) : '');
$like = ((isset($alike[$item['id']])) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
$dislike = ((isset($dlike[$item['id']])) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
$location = (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
$coord = (($item['coord']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
if($coord) {

View file

@ -7,6 +7,8 @@ require_once('include/bbcode.php');
function photos_init(&$a) {
$o = '';
if($a->argc > 1) {
$nick = $a->argv[1];
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
@ -36,6 +38,9 @@ function photos_init(&$a) {
}
$o .= '</ul>';
}
if(! x($a->page,'aside'))
$a->page['aside'] = '';
$a->page['aside'] .= $o;
}
return;
@ -213,23 +218,26 @@ function photos_post(&$a) {
$arr = array();
$arr['uid'] = local_user();
$arr['uri'] = $uri;
$arr['parent-uri'] = $uri;
$arr['type'] = 'photo';
$arr['wall'] = 1;
$arr['resource-id'] = $p[0]['resource-id'];
$arr['contact-id'] = $contact_record['id'];
$arr['owner-name'] = $contact_record['name'];
$arr['owner-link'] = $contact_record['url'];
$arr['owner-avatar'] = $contact_record['thumb'];
$arr['title'] = $title;
$arr['allow_cid'] = $p[0]['allow_cid'];
$arr['allow_gid'] = $p[0]['allow_gid'];
$arr['deny_cid'] = $p[0]['deny_cid'];
$arr['deny_gid'] = $p[0]['deny_gid'];
$arr['last-child'] = 1;
$arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
$arr['uid'] = local_user();
$arr['uri'] = $uri;
$arr['parent-uri'] = $uri;
$arr['type'] = 'photo';
$arr['wall'] = 1;
$arr['resource-id'] = $p[0]['resource-id'];
$arr['contact-id'] = $contact_record['id'];
$arr['owner-name'] = $contact_record['name'];
$arr['owner-link'] = $contact_record['url'];
$arr['owner-avatar'] = $contact_record['thumb'];
$arr['author-name'] = $contact_record['name'];
$arr['author-link'] = $contact_record['url'];
$arr['author-avatar'] = $contact_record['thumb'];
$arr['title'] = $title;
$arr['allow_cid'] = $p[0]['allow_cid'];
$arr['allow_gid'] = $p[0]['allow_gid'];
$arr['deny_cid'] = $p[0]['deny_cid'];
$arr['deny_gid'] = $p[0]['deny_gid'];
$arr['last-child'] = 1;
$arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
. '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.jpg' . '[/img]'
. '[/url]';
@ -391,7 +399,7 @@ function photos_post(&$a) {
if((! count($r)) || ($album == t('Profile Photos')))
$visible = 1;
else
$visibile = 0;
$visible = 0;
$str_group_allow = perms2str($_POST['group_allow']);
@ -448,24 +456,27 @@ function photos_post(&$a) {
$arr = array();
$arr['uid'] = local_user();
$arr['uri'] = $uri;
$arr['parent-uri'] = $uri;
$arr['type'] = 'photo';
$arr['wall'] = 1;
$arr['resource-id'] = $photo_hash;
$arr['contact-id'] = $contact_record['id'];
$arr['owner-name'] = $contact_record['name'];
$arr['owner-link'] = $contact_record['url'];
$arr['owner-avatar'] = $contact_record['thumb'];
$arr['title'] = $title;
$arr['allow_cid'] = $str_contact_allow;
$arr['allow_gid'] = $str_group_allow;
$arr['deny_cid'] = $str_contact_deny;
$arr['deny_gid'] = $str_group_deny;
$arr['last-child'] = 1;
$arr['visible'] = $visible;
$arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $contact_record['nickname'] . '/image/' . $photo_hash . ']'
$arr['uid'] = local_user();
$arr['uri'] = $uri;
$arr['parent-uri'] = $uri;
$arr['type'] = 'photo';
$arr['wall'] = 1;
$arr['resource-id'] = $photo_hash;
$arr['contact-id'] = $contact_record['id'];
$arr['owner-name'] = $contact_record['name'];
$arr['owner-link'] = $contact_record['url'];
$arr['owner-avatar'] = $contact_record['thumb'];
$arr['author-name'] = $contact_record['name'];
$arr['author-link'] = $contact_record['url'];
$arr['author-avatar'] = $contact_record['thumb'];
$arr['title'] = '';
$arr['allow_cid'] = $str_contact_allow;
$arr['allow_gid'] = $str_group_allow;
$arr['deny_cid'] = $str_contact_deny;
$arr['deny_gid'] = $str_group_deny;
$arr['last-child'] = 1;
$arr['visible'] = $visible;
$arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $contact_record['nickname'] . '/image/' . $photo_hash . ']'
. '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.jpg" . '[/img]'
. '[/url]';
@ -637,7 +648,7 @@ function photos_content(&$a) {
$a->set_pager_total(count($r));
$r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
$r = q("SELECT `resource-id`, `id`, `filename`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
$sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
intval($a->data['user']['uid']),
dbesc($album),
@ -817,6 +828,17 @@ function photos_content(&$a) {
$like_tpl = load_view_file('view/like.tpl');
$likebuttons = '';
if(can_write_wall($a,$a->data['user']['uid']))
$likebuttons = replace_macros($like_tpl,array('$id' => $i1[0]['id']));
if(! count($r)) {
$o .= '<div id="photo-like-div">';
$o .= $likebuttons;
$o .= '</div>';
}
if(can_write_wall($a,$a->data['user']['uid'])) {
if($i1[0]['last-child']) {
$o .= replace_macros($cmnt_tpl,array(
@ -844,11 +866,6 @@ function photos_content(&$a) {
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']) : '');
@ -929,6 +946,7 @@ function photos_content(&$a) {
}
// Default - show recent photos with upload link (if applicable)
$o = '';
$r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s'
$sql_extra GROUP BY `resource-id`",
@ -939,7 +957,8 @@ function photos_content(&$a) {
$a->set_pager_total(count($r));
$r = q("SELECT `resource-id`, `album`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s'
$r = q("SELECT `resource-id`, `id`, `filename`, `album`, max(`scale`) AS `scale` FROM `photo`
WHERE `uid` = %d AND `album` != '%s'
$sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
intval($a->data['user']['uid']),
dbesc( t('Contact Photos')),
@ -964,7 +983,7 @@ function photos_content(&$a) {
'$phototitle' => t('View Photo'),
'$imgsrc' => $a->get_baseurl() . '/photo/'
. $rr['resource-id'] . '-' . $rr['scale'] . '.jpg',
'$albumlink' => $a->get_baseurl . '/photos/'
'$albumlink' => $a->get_baseurl() . '/photos/'
. $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
'$albumname' => $rr['album'],
'$albumalt' => t('View Album'),

View file

@ -87,7 +87,7 @@ function pubsub_post(&$a) {
$xml = file_get_contents('php://input');
logger('pubsub: feed arrived from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $a->cmd );
logger('pubsub: data: ' . $xml, $LOGGER_DATA);
logger('pubsub: data: ' . $xml, LOGGER_DATA);
$nick = (($a->argc > 1) ? notags(trim($a->argv[1])) : '');
$contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);