diff --git a/include/items.php b/include/items.php index b016fa180c..7daf4042ca 100644 --- a/include/items.php +++ b/include/items.php @@ -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 diff --git a/mod/display.php b/mod/display.php index b451d69300..c08b0ca92a 100644 --- a/mod/display.php +++ b/mod/display.php @@ -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']) ? '' . $item['location'] . '' : ''); $coord = (($item['coord']) ? '' . $item['coord'] . '' : ''); if($coord) { diff --git a/mod/photos.php b/mod/photos.php index 8f33ac067d..fcff73a97b 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -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 .= ''; } + + 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 .= '