diff options
Diffstat (limited to 'mod/photos.php')
-rw-r--r-- | mod/photos.php | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/mod/photos.php b/mod/photos.php index 296aab67f..3338e22ab 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -180,19 +180,8 @@ function photos_post(&$a) { intval($page_owner_uid) ); if(count($i)) { - q("UPDATE `item` SET item_restrict = (item_restrict | %d), `edited` = '%s', `changed` = '%s' WHERE `parent_mid` = '%s' AND `uid` = %d", - intval(ITEM_DELETED), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc($i[0]['mid']), - intval($page_owner_uid) - ); - + drop_item($i[0]['id'],true,DROPITEM_PHASE1); $url = $a->get_baseurl(); - $drop_id = intval($i[0]['id']); - - if($i[0]['visible']) - proc_run('php',"include/notifier.php","drop","$drop_id"); } } @@ -206,7 +195,7 @@ function photos_post(&$a) { $rawtags = ((x($_POST,'newtag')) ? notags(trim($_POST['newtag'])) : ''); $item_id = ((x($_POST,'item_id')) ? intval($_POST['item_id']) : 0); $albname = ((x($_POST,'albname')) ? notags(trim($_POST['albname'])) : ''); - $adult = ((x($_POST,'adult')) ? intval($_POST['adult']) : 0); + $is_nsfw = ((x($_POST,'adult')) ? intval($_POST['adult']) : 0); $str_group_allow = perms2str($_POST['group_allow']); $str_contact_allow = perms2str($_POST['contact_allow']); $str_group_deny = perms2str($_POST['group_deny']); @@ -295,10 +284,10 @@ function photos_post(&$a) { $item_private = (($str_contact_allow || $str_group_allow || $str_contact_deny || $str_group_deny) ? true : false); - $old_adult = (($p[0]['photo_flags'] & PHOTO_ADULT) ? 1 : 0); - if($old_adult != $adult) { - $r = q("update photo set photo_flags = ( photo_flags ^ %d) where resource_id = '%s' and uid = %d", - intval(PHOTO_ADULT), + $old_is_nsfw = $p[0]['is_nsfw']; + if($old_is_nsfw != $is_nsfw) { + $r = q("update photo set is_nsfw = %d where resource_id = '%s' and uid = %d", + intval($is_nsfw), dbesc($resource_id), intval($page_owner_uid) ); @@ -589,11 +578,12 @@ function photos_content(&$a) { $album = hex2bin($datum); $r = q("SELECT `resource_id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s' - AND `scale` <= 4 and ((photo_flags = %d) or (photo_flags & %d ) > 0) $sql_extra GROUP BY `resource_id`", + AND `scale` <= 4 and photo_usage IN ( %d, %d ) and is_nsfw = %d $sql_extra GROUP BY `resource_id`", intval($owner_uid), dbesc($album), intval(PHOTO_NORMAL), - intval(($unsafe) ? (PHOTO_PROFILE|PHOTO_ADULT) : PHOTO_PROFILE) + intval(PHOTO_PROFILE), + intval($unsafe) ); if(count($r)) { $a->set_pager_total(count($r)); @@ -609,13 +599,14 @@ function photos_content(&$a) { $r = q("SELECT p.resource_id, p.id, p.filename, p.type, p.scale, p.description, p.created FROM photo p INNER JOIN - (SELECT resource_id, max(scale) scale FROM photo WHERE uid = %d AND album = '%s' AND scale <= 4 AND (photo_flags = %d or photo_flags = %d ) $sql_extra GROUP BY resource_id) ph + (SELECT resource_id, max(scale) scale FROM photo WHERE uid = %d AND album = '%s' AND scale <= 4 AND photo_usage IN ( %d, %d ) and is_nsfw = %d $sql_extra GROUP BY resource_id) ph ON (p.resource_id = ph.resource_id AND p.scale = ph.scale) ORDER BY created $order LIMIT %d OFFSET %d", intval($owner_uid), dbesc($album), - intvaL(PHOTO_NORMAL), - intval(($unsafe) ? (PHOTO_PROFILE|PHOTO_ADULT) : PHOTO_PROFILE), + intval(PHOTO_NORMAL), + intval(PHOTO_PROFILE), + intval($unsafe), intval($a->pager['itemspage']), intval($a->pager['start']) ); @@ -731,7 +722,7 @@ function photos_content(&$a) { // fetch image, item containing image, then comments - $ph = q("SELECT aid,uid,xchan,resource_id,created,edited,title,`description`,album,filename,`type`,height,width,`size`,scale,profile,photo_flags,allow_cid,allow_gid,deny_cid,deny_gid FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s' + $ph = q("SELECT aid,uid,xchan,resource_id,created,edited,title,`description`,album,filename,`type`,height,width,`size`,scale,photo_usage,is_nsfw,allow_cid,allow_gid,deny_cid,deny_gid FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s' $sql_extra ORDER BY `scale` ASC ", intval($owner_uid), dbesc($datum) @@ -878,8 +869,8 @@ function photos_content(&$a) { } } - if((local_channel()) && (local_channel() == $link_item['uid'])) { - q("UPDATE `item` SET item_unseen = 0 WHERE item_unseen = 1 AND parent = %d AND uid = %d ", + if((local_channel()) && (local_user() == $link_item['uid'])) { + q("UPDATE `item` SET item_unseen = 0 WHERE parent = %d and uid = %d and item_unseen = 1", intval($link_item['parent']), intval(local_channel()) ); @@ -925,7 +916,7 @@ function photos_content(&$a) { 'help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com'), 'item_id' => ((count($linked_items)) ? $link_item['id'] : 0), 'adult_enabled' => feature_enabled($owner_uid,'adult_photo_flagging'), - 'adult' => array('adult',t('Flag as adult in album view'), (($ph[0]['photo_flags'] & PHOTO_ADULT) ? 1 : 0),''), + 'adult' => array('adult',t('Flag as adult in album view'), intval($ph[0]['is_nsfw']),''), 'submit' => t('Submit'), 'delete' => t('Delete Photo') ); @@ -1151,12 +1142,13 @@ function photos_content(&$a) { //$o = ''; $r = q("SELECT `resource_id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' - and ((photo_flags = %d) or (photo_flags & %d) > 0) $sql_extra GROUP BY `resource_id`", + and photo_usage in ( %d, %d ) and is_nsfw = %d $sql_extra GROUP BY `resource_id`", intval($a->data['channel']['channel_id']), dbesc('Contact Photos'), dbesc( t('Contact Photos')), intval(PHOTO_NORMAL), - intval(($unsafe) ? (PHOTO_PROFILE|PHOTO_ADULT) : PHOTO_PROFILE) + intval(PHOTO_PROFILE), + intval($unsafe) ); if(count($r)) { $a->set_pager_total(count($r)); @@ -1166,13 +1158,14 @@ function photos_content(&$a) { $r = q("SELECT p.resource_id, p.id, p.filename, p.type, p.album, p.scale, p.created FROM photo p INNER JOIN (SELECT resource_id, max(scale) scale FROM photo WHERE uid=%d AND album != '%s' AND album != '%s' - AND (photo_flags = %d or ( photo_flags & %d ) > 0 ) $sql_extra group by resource_id) ph + AND photo_usage IN ( %d, %d ) and is_nsfw = %d $sql_extra group by resource_id) ph ON (p.resource_id = ph.resource_id and p.scale = ph.scale) ORDER by p.created DESC LIMIT %d OFFSET %d", intval($a->data['channel']['channel_id']), dbesc('Contact Photos'), dbesc( t('Contact Photos')), intval(PHOTO_NORMAL), - intval(($unsafe) ? (PHOTO_PROFILE|PHOTO_ADULT) : PHOTO_PROFILE), + intval(PHOTO_PROFILE), + intval($unsafe), intval($a->pager['itemspage']), intval($a->pager['start']) ); |