Provide a way to mark photos as adult and hide them from the default album view. Still need a button or setting to enable "unsafe viewing". This has no effect anywhere but in the album views. They can still be viewed by flipping through the individual photos with 'prev' and 'next'. We probably need a comprehensive strategy for how to deal with n-s-f-w photos in albums so consider this a band-aid which requires additional work and integration with other facilities which access these photos. It is entirely optional.

This commit is contained in:
friendica 2014-11-06 17:27:28 -08:00
parent 91d255a056
commit 1fbd1a79c7
4 changed files with 45 additions and 32 deletions

View File

@ -230,6 +230,7 @@ define ( 'PHOTO_NORMAL', 0x0000 );
define ( 'PHOTO_PROFILE', 0x0001 ); define ( 'PHOTO_PROFILE', 0x0001 );
define ( 'PHOTO_XCHAN', 0x0002 ); define ( 'PHOTO_XCHAN', 0x0002 );
define ( 'PHOTO_THING', 0x0004 ); define ( 'PHOTO_THING', 0x0004 );
define ( 'PHOTO_ADULT', 0x0008 );
/** /**
* Menu types * Menu types

View File

@ -263,7 +263,7 @@ function poller_run($argv, $argc){
); );
$contacts = q("SELECT abook_id, abook_flags, abook_updated, abook_connected, abook_closeness, abook_xchan, abook_channel $contacts = q("SELECT abook_id, abook_flags, abook_network, abook_updated, abook_connected, abook_closeness, abook_xchan, abook_channel
FROM abook LEFT JOIN account on abook_account = account_id where 1 FROM abook LEFT JOIN account on abook_account = account_id where 1
$sql_extra $sql_extra
AND (( abook_flags & %d ) OR ( abook_flags = %d )) AND (( abook_flags & %d ) OR ( abook_flags = %d ))
@ -305,6 +305,7 @@ function poller_run($argv, $argc){
$update = true; $update = true;
} }
else { else {
// if we've never connected with them, start the mark for death countdown from now // if we've never connected with them, start the mark for death countdown from now
if($c == NULL_DATE) { if($c == NULL_DATE) {
@ -351,12 +352,17 @@ function poller_run($argv, $argc){
$update = true; $update = true;
} }
} }
if((! $update) && (! $force)) if((! $update) && (! $force))
continue; continue;
// we handled feed contacts earlier - now filter out anything else that
// doesn't require polling to keep the process count down.
if($contact['abook_network'] !== 'zot')
continue;
proc_run('php','include/onepoll.php',$contact['abook_id']); proc_run('php','include/onepoll.php',$contact['abook_id']);
if($interval) if($interval)
@time_sleep_until(microtime(true) + (float) $interval); @time_sleep_until(microtime(true) + (float) $interval);

View File

@ -206,6 +206,7 @@ function photos_post(&$a) {
$rawtags = ((x($_POST,'newtag')) ? notags(trim($_POST['newtag'])) : ''); $rawtags = ((x($_POST,'newtag')) ? notags(trim($_POST['newtag'])) : '');
$item_id = ((x($_POST,'item_id')) ? intval($_POST['item_id']) : 0); $item_id = ((x($_POST,'item_id')) ? intval($_POST['item_id']) : 0);
$albname = ((x($_POST,'albname')) ? notags(trim($_POST['albname'])) : ''); $albname = ((x($_POST,'albname')) ? notags(trim($_POST['albname'])) : '');
$adult = ((x($_POST,'adult')) ? intval($_POST['adult']) : 0);
$str_group_allow = perms2str($_POST['group_allow']); $str_group_allow = perms2str($_POST['group_allow']);
$str_contact_allow = perms2str($_POST['contact_allow']); $str_contact_allow = perms2str($_POST['contact_allow']);
$str_group_deny = perms2str($_POST['group_deny']); $str_group_deny = perms2str($_POST['group_deny']);
@ -273,13 +274,13 @@ function photos_post(&$a) {
} }
} }
$p = q("SELECT * FROM `photo` WHERE `resource_id` = '%s' AND `uid` = %d and ( photo_flags = %d or photo_flags = %d ) ORDER BY `scale` DESC", $p = q("SELECT * FROM `photo` WHERE `resource_id` = '%s' AND `uid` = %d and ((photo_flags = %d) or (photo_flags & %d )) ORDER BY `scale` DESC",
dbesc($resource_id), dbesc($resource_id),
intval($page_owner_uid), intval($page_owner_uid),
intval(PHOTO_NORMAL), intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE) intval(PHOTO_PROFILE)
); );
if(count($p)) { if($p) {
$ext = $phototypes[$p[0]['type']]; $ext = $phototypes[$p[0]['type']];
$r = q("UPDATE `photo` SET `description` = '%s', `album` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' WHERE `resource_id` = '%s' AND `uid` = %d", $r = q("UPDATE `photo` SET `description` = '%s', `album` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' WHERE `resource_id` = '%s' AND `uid` = %d",
@ -296,6 +297,14 @@ function photos_post(&$a) {
$item_private = (($str_contact_allow || $str_group_allow || $str_contact_deny || $str_group_deny) ? true : false); $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),
dbesc($resource_id),
intval($page_owner_uid)
);
}
/* Don't make the item visible if the only change was the album name */ /* Don't make the item visible if the only change was the album name */
@ -451,6 +460,7 @@ function photos_content(&$a) {
return; return;
} }
$unsafe = ((array_key_exists('unsafe',$_REQUEST) && $_REQUEST['unsafe']) ? 1 : 0);
require_once('include/bbcode.php'); require_once('include/bbcode.php');
require_once('include/security.php'); require_once('include/security.php');
@ -598,6 +608,8 @@ function photos_content(&$a) {
if($datatype === 'album') { if($datatype === 'album') {
if((strlen($datum) & 1) || (! ctype_xdigit($datum))) { if((strlen($datum) & 1) || (! ctype_xdigit($datum))) {
notice( t('Album name could not be decoded') . EOL); notice( t('Album name could not be decoded') . EOL);
logger('mod_photos: illegal album encoding: ' . $datum); logger('mod_photos: illegal album encoding: ' . $datum);
@ -607,11 +619,11 @@ function photos_content(&$a) {
$album = hex2bin($datum); $album = hex2bin($datum);
$r = q("SELECT `resource_id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s' $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 ) $sql_extra GROUP BY `resource_id`", AND `scale` <= 4 and ((photo_flags = %d) or (photo_flags & %d )) $sql_extra GROUP BY `resource_id`",
intval($owner_uid), intval($owner_uid),
dbesc($album), dbesc($album),
intval(PHOTO_NORMAL), intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE) intval(($unsafe) ? (PHOTO_PROFILE|PHOTO_ADULT) : PHOTO_PROFILE)
); );
if(count($r)) { if(count($r)) {
$a->set_pager_total(count($r)); $a->set_pager_total(count($r));
@ -626,11 +638,11 @@ function photos_content(&$a) {
$order = 'DESC'; $order = 'DESC';
$r = q("SELECT `resource_id`, `id`, `filename`, type, max(`scale`) AS `scale`, `description` FROM `photo` WHERE `uid` = %d AND `album` = '%s' $r = q("SELECT `resource_id`, `id`, `filename`, type, max(`scale`) AS `scale`, `description` 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` ORDER BY `created` $order LIMIT %d , %d", AND `scale` <= 4 and ((photo_flags = %d) or (photo_flags & %d )) $sql_extra GROUP BY `resource_id` ORDER BY `created` $order LIMIT %d , %d",
intval($owner_uid), intval($owner_uid),
dbesc($album), dbesc($album),
intvaL(PHOTO_NORMAL), intvaL(PHOTO_NORMAL),
intval(PHOTO_PROFILE), intval(($unsafe) ? (PHOTO_PROFILE|PHOTO_ADULT) : PHOTO_PROFILE),
intval($a->pager['start']), intval($a->pager['start']),
intval($a->pager['itemspage']) intval($a->pager['itemspage'])
); );
@ -750,25 +762,18 @@ function photos_content(&$a) {
// fetch image, item containing image, then comments // 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,profile,photo_flags,allow_cid,allow_gid,deny_cid,deny_gid FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s'
and (photo_flags = %d or photo_flags = %d ) $sql_extra ORDER BY `scale` ASC ", $sql_extra ORDER BY `scale` ASC ",
intval($owner_uid), intval($owner_uid),
dbesc($datum), dbesc($datum)
intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE)
); );
if(! $ph) { if(! $ph) {
/* Check again - this time without specifying permissions */ /* Check again - this time without specifying permissions */
$ph = q("SELECT id FROM photo WHERE uid = %d AND resource_id = '%s' $ph = q("SELECT id FROM photo WHERE uid = %d AND resource_id = '%s' LIMIT 1",
and ( photo_flags = %d or photo_flags = %d )
LIMIT 1",
intval($owner_uid), intval($owner_uid),
dbesc($datum), dbesc($datum)
intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE)
); );
if($ph) if($ph)
notice( t('Permission denied. Access to this item may be restricted.') . EOL); notice( t('Permission denied. Access to this item may be restricted.') . EOL);
@ -789,11 +794,9 @@ function photos_content(&$a) {
$prvnxt = q("SELECT `resource_id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0 $prvnxt = q("SELECT `resource_id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
and ( photo_flags = %d or photo_flags = %d ) $sql_extra ORDER BY `created` $order ", $sql_extra ORDER BY `created` $order ",
dbesc($ph[0]['album']), dbesc($ph[0]['album']),
intval($owner_uid), intval($owner_uid)
intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE)
); );
if(count($prvnxt)) { if(count($prvnxt)) {
@ -946,6 +949,7 @@ function photos_content(&$a) {
'aclselect' => $aclselect_e, 'aclselect' => $aclselect_e,
'help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com'), 'help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com'),
'item_id' => ((count($linked_items)) ? $link_item['id'] : 0), 'item_id' => ((count($linked_items)) ? $link_item['id'] : 0),
'adult' => array('adult',t('Flag as adult in album view'), (($ph[0]['photo_flags'] & PHOTO_ADULT) ? 1 : 0),''),
'submit' => t('Submit'), 'submit' => t('Submit'),
'delete' => t('Delete Photo') 'delete' => t('Delete Photo')
); );
@ -1153,12 +1157,12 @@ function photos_content(&$a) {
//$o = ''; //$o = '';
$r = q("SELECT `resource_id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $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 ) $sql_extra GROUP BY `resource_id`", and ((photo_flags = %d) or (photo_flags & %d)) $sql_extra GROUP BY `resource_id`",
intval($a->data['channel']['channel_id']), intval($a->data['channel']['channel_id']),
dbesc('Contact Photos'), dbesc('Contact Photos'),
dbesc( t('Contact Photos')), dbesc( t('Contact Photos')),
intval(PHOTO_NORMAL), intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE) intval(($unsafe) ? (PHOTO_PROFILE|PHOTO_ADULT) : PHOTO_PROFILE)
); );
if(count($r)) { if(count($r)) {
$a->set_pager_total(count($r)); $a->set_pager_total(count($r));
@ -1167,13 +1171,13 @@ function photos_content(&$a) {
$r = q("SELECT `resource_id`, `id`, `filename`, type, `album`, max(`scale`) AS `scale` FROM `photo` $r = q("SELECT `resource_id`, `id`, `filename`, type, `album`, max(`scale`) AS `scale` FROM `photo`
WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
and ( photo_flags = %d or photo_flags = %d ) and ( (photo_flags = %d) or (photo_flags & %d ))
$sql_extra GROUP BY `resource_id` ORDER BY `created` DESC LIMIT %d , %d", $sql_extra GROUP BY `resource_id` ORDER BY `created` DESC LIMIT %d , %d",
intval($a->data['channel']['channel_id']), intval($a->data['channel']['channel_id']),
dbesc('Contact Photos'), dbesc('Contact Photos'),
dbesc( t('Contact Photos')), dbesc( t('Contact Photos')),
intval(PHOTO_NORMAL), intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE), intval(($unsafe) ? (PHOTO_PROFILE|PHOTO_ADULT) : PHOTO_PROFILE),
intval($a->pager['start']), intval($a->pager['start']),
intval($a->pager['itemspage']) intval($a->pager['itemspage'])
); );

View File

@ -59,7 +59,9 @@
<label class="radio-inline" id="photo-edit-rotate-cw-label" for="photo-edit-rotate-cw"><input id="photo-edit-rotate-cw" type="radio" name="rotate" value="1" />{{$edit.rotatecw}}</label> <label class="radio-inline" id="photo-edit-rotate-cw-label" for="photo-edit-rotate-cw"><input id="photo-edit-rotate-cw" type="radio" name="rotate" value="1" />{{$edit.rotatecw}}</label>
<label class="radio-inline" id="photo-edit-rotate-ccw-label" for="photo-edit-rotate-ccw"><input id="photo-edit-rotate-ccw" type="radio" name="rotate" value="2" />{{$edit.rotateccw}}</label> <label class="radio-inline" id="photo-edit-rotate-ccw-label" for="photo-edit-rotate-ccw"><input id="photo-edit-rotate-ccw" type="radio" name="rotate" value="2" />{{$edit.rotateccw}}</label>
</div> </div>
<div class="form-group">
{{include file="field_checkbox.tpl" field=$edit.adult}}
</div>
{{$edit.aclselect}} {{$edit.aclselect}}
<div class="form-group pull-left"> <div class="form-group pull-left">