aboutsummaryrefslogtreecommitdiffstats
path: root/mod/photos.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/photos.php')
-rw-r--r--mod/photos.php64
1 files changed, 29 insertions, 35 deletions
diff --git a/mod/photos.php b/mod/photos.php
index e88d1497e..68077a5b1 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -135,14 +135,13 @@ function photos_post(&$a) {
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
}
- $r = q("select id, item_restrict from item where resource_id in ( $str ) and resource_type = 'photo' and uid = %d",
+ $r = q("select id from item where resource_id in ( $str ) and resource_type = 'photo' and uid = %d " . item_normal(),
intval($page_owner_uid)
);
if($r) {
foreach($r as $i) {
drop_item($i['id'],false,DROPITEM_PHASE1,true /* force removal of linked items */);
- if(! $item_restrict)
- proc_run('php','include/notifier.php','drop',$i['id']);
+ proc_run('php','include/notifier.php','drop',$i['id']);
}
}
@@ -180,19 +179,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 +194,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 +283,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)
);
@@ -402,8 +390,9 @@ function photos_post(&$a) {
*/
$_REQUEST['source'] = 'photos';
+ require_once('include/attach.php');
- $r = photo_upload($a->channel,$a->get_observer(), $_REQUEST);
+ $r = attach_store($a->channel,get_observer_hash(), $_REQUEST);
if(! $r['success']) {
notice($r['message'] . EOL);
}
@@ -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)
@@ -851,9 +842,10 @@ function photos_content(&$a) {
$linked_items = fetch_post_tags($linked_items,true);
$link_item = $linked_items[0];
+ $item_normal = item_normal();
$r = q("select * from item where parent_mid = '%s'
- and item_restrict = 0 and uid = %d $sql_extra ",
+ $item_normal and uid = %d $sql_extra ",
dbesc($link_item['mid']),
intval($link_item['uid'])
@@ -878,8 +870,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 +917,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 +1143,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 +1159,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'])
);