diff --git a/mod/item.php b/mod/item.php index 5f53eccf33..ca6f703b3f 100644 --- a/mod/item.php +++ b/mod/item.php @@ -175,6 +175,13 @@ function item_post(&$a) { dbesc(($parent == $post_id) ? $uri : $parent_item['uri']), intval($post_id) ); + // photo comments turn the corresponding item visible to the profile wall + if(! $parent_item['visible']) { + $r = q("UPDATE `item` SET `visible = 1 WHERE `id` = %d LIMIT 1", + intval($parent_item['id']) + ); + } + } $url = $a->get_baseurl(); diff --git a/mod/photos.php b/mod/photos.php index 4a502b9fbc..6894483ae2 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -345,23 +345,27 @@ function photos_content(&$a) { if($datatype == 'image') { + require_once('security.php'); + require_once('bbcode.php'); + // fetch item containing image, then comments - $r = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' + + $ph = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s' $sql_extra ORDER BY `scale` ASC ", intval($a->data['user']['uid']), dbesc($datum) ); - if(! count($r)) { + if(! count($ph)) { notice( t('Photo not available') . EOL ); return; } - if(count($r) == 1) - $hires = $lores = $r[0]; - if(count($r) > 1) { - $hires = $r[0]; - $lores = $r[1]; + if(count($ph) == 1) + $hires = $lores = $ph[0]; + if(count($ph) > 1) { + $hires = $ph[0]; + $lores = $ph[1]; } $o .= ''; + // Do we have an item for this photo? + $i1 = q("SELECT * FROM `item` WHERE `resource-id` = '%s' $sql_extra LIMIT 1", + dbesc($datum) + ); + if(count($i1)) { +//dbg(2); + $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 + $sql_extra ", + dbesc($i1[0]['uri']), + dbesc($i1[0]['uri']) + + ); + + if(count($r)) + $a->set_pager_total($r[0]['total']); + + + $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, + `contact`.`name`, `contact`.`photo`, `contact`.`url`, + `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 `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 + $sql_extra + ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ", + dbesc($i1[0]['uri']), + dbesc($i1[0]['uri']), + intval($a->pager['start']), + intval($a->pager['itemspage']) + + ); + +// require_once('view/acl_selectors.php'); + + $o .= '
'; + + if(strlen($i1[0]['tag'])) { + // parse tags and add links + $o .= '