mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 02:15:19 +00:00
photo move to another album - resurrected from a temporary branch where the work had gotten lost
This commit is contained in:
parent
6e149a2dd3
commit
de03f7f9ce
3 changed files with 83 additions and 32 deletions
|
@ -50,7 +50,7 @@ class Photos extends \Zotlabs\Web\Controller {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function post() {
|
function post() {
|
||||||
|
|
||||||
logger('mod-photos: photos_post: begin' , LOGGER_DEBUG);
|
logger('mod-photos: photos_post: begin' , LOGGER_DEBUG);
|
||||||
|
|
||||||
|
@ -105,24 +105,6 @@ class Photos extends \Zotlabs\Web\Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* RENAME photo album
|
|
||||||
*/
|
|
||||||
|
|
||||||
$newalbum = notags(trim($_REQUEST['albumname']));
|
|
||||||
if($newalbum != $album) {
|
|
||||||
|
|
||||||
// @fixme - syncronise with DAV or disallow completely
|
|
||||||
|
|
||||||
goaway(z_root() . '/' . $_SESSION['photo_return']);
|
|
||||||
|
|
||||||
// $x = photos_album_rename($page_owner_uid,$album,$newalbum);
|
|
||||||
// if($x) {
|
|
||||||
// $newurl = str_replace(bin2hex($album),bin2hex($newalbum),$_SESSION['photo_return']);
|
|
||||||
// goaway(z_root() . '/' . $newurl);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DELETE photo album and all its photos
|
* DELETE photo album and all its photos
|
||||||
*/
|
*/
|
||||||
|
@ -229,15 +211,25 @@ class Photos extends \Zotlabs\Web\Controller {
|
||||||
|
|
||||||
goaway(z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . $_SESSION['album_return']);
|
goaway(z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/album/' . $_SESSION['album_return']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if((argc() > 2) && array_key_exists('move_to_album',$_POST)) {
|
||||||
if((\App::$argc > 2) && ((x($_POST,'desc') !== false) || (x($_POST,'newtag') !== false)) || (x($_POST,'albname') !== false)) {
|
$m = q("select folder from attach where hash = '%s' and uid = %d limit 1",
|
||||||
|
dbesc(argv(2)),
|
||||||
|
intval($page_owner_uid)
|
||||||
|
);
|
||||||
|
if(($m) && ($m[0]['folder'] != $_POST['move_to_album'])) {
|
||||||
|
attach_move($page_owner_uid,argv(2),$_POST['move_to_album']);
|
||||||
|
if(! ($_POST['desc'] && $_POST['newtag']))
|
||||||
|
goaway(z_root() . '/' . $_SESSION['photo_return']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if((argc() > 2) && ((x($_POST,'desc') !== false) || (x($_POST,'newtag') !== false))) {
|
||||||
|
|
||||||
$desc = ((x($_POST,'desc')) ? notags(trim($_POST['desc'])) : '');
|
$desc = ((x($_POST,'desc')) ? notags(trim($_POST['desc'])) : '');
|
||||||
$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'])) : '');
|
|
||||||
$is_nsfw = ((x($_POST,'adult')) ? intval($_POST['adult']) : 0);
|
$is_nsfw = ((x($_POST,'adult')) ? intval($_POST['adult']) : 0);
|
||||||
|
|
||||||
$acl->set_from_array($_POST);
|
$acl->set_from_array($_POST);
|
||||||
|
@ -245,10 +237,6 @@ class Photos extends \Zotlabs\Web\Controller {
|
||||||
|
|
||||||
$resource_id = argv(2);
|
$resource_id = argv(2);
|
||||||
|
|
||||||
if(! strlen($albname))
|
|
||||||
$albname = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
|
|
||||||
|
|
||||||
|
|
||||||
if((x($_POST,'rotate') !== false) &&
|
if((x($_POST,'rotate') !== false) &&
|
||||||
( (intval($_POST['rotate']) == 1) || (intval($_POST['rotate']) == 2) )) {
|
( (intval($_POST['rotate']) == 1) || (intval($_POST['rotate']) == 2) )) {
|
||||||
logger('rotate');
|
logger('rotate');
|
||||||
|
@ -464,14 +452,15 @@ class Photos extends \Zotlabs\Web\Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
goaway(z_root() . '/' . $_SESSION['photo_return']);
|
|
||||||
return; // NOTREACHED
|
|
||||||
|
|
||||||
$sync = attach_export_data(\App::$data['channel'],$resource_id);
|
$sync = attach_export_data(\App::$data['channel'],$resource_id);
|
||||||
|
|
||||||
if($sync)
|
if($sync)
|
||||||
build_sync_packet($page_owner_uid,array('file' => array($sync)));
|
build_sync_packet($page_owner_uid,array('file' => array($sync)));
|
||||||
|
|
||||||
|
goaway(z_root() . '/' . $_SESSION['photo_return']);
|
||||||
|
return; // NOTREACHED
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1023,12 +1012,22 @@ class Photos extends \Zotlabs\Web\Controller {
|
||||||
|
|
||||||
$edit = null;
|
$edit = null;
|
||||||
if($can_post) {
|
if($can_post) {
|
||||||
|
|
||||||
|
$m = q("select folder from attach where hash = '%s' and uid = %d limit 1",
|
||||||
|
dbesc($ph[0]['resource_id']),
|
||||||
|
intval($ph[0]['uid'])
|
||||||
|
);
|
||||||
|
if($m)
|
||||||
|
$album_hash = $m[0]['folder'];
|
||||||
|
|
||||||
$album_e = $ph[0]['album'];
|
$album_e = $ph[0]['album'];
|
||||||
$caption_e = $ph[0]['description'];
|
$caption_e = $ph[0]['description'];
|
||||||
$aclselect_e = (($_is_owner) ? populate_acl($ph[0], true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_storage')) : '');
|
$aclselect_e = (($_is_owner) ? populate_acl($ph[0], true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_storage')) : '');
|
||||||
$albums = ((array_key_exists('albums', \App::$data)) ? \App::$data['albums'] : photos_albums_list(\App::$data['channel'],\App::$data['observer']));
|
$albums = ((array_key_exists('albums', \App::$data)) ? \App::$data['albums'] : photos_albums_list(\App::$data['channel'],\App::$data['observer']));
|
||||||
|
|
||||||
$_SESSION['album_return'] = bin2hex($ph[0]['album']);
|
$_SESSION['album_return'] = bin2hex($ph[0]['album']);
|
||||||
|
|
||||||
|
$folder_list = attach_folder_select_list($ph[0]['uid']);
|
||||||
|
|
||||||
$edit = array(
|
$edit = array(
|
||||||
'edit' => t('Edit photo'),
|
'edit' => t('Edit photo'),
|
||||||
|
@ -1037,6 +1036,7 @@ class Photos extends \Zotlabs\Web\Controller {
|
||||||
'rotateccw' => t('Rotate CCW (left)'),
|
'rotateccw' => t('Rotate CCW (left)'),
|
||||||
'albums' => $albums['albums'],
|
'albums' => $albums['albums'],
|
||||||
'album' => $album_e,
|
'album' => $album_e,
|
||||||
|
'album_select' => [ 'move_to_album', t('Move photo to album'), $album_hash, '', $folder_list ],
|
||||||
'newalbum_label' => t('Enter a new album name'),
|
'newalbum_label' => t('Enter a new album name'),
|
||||||
'newalbum_placeholder' => t('or select an existing one (doubleclick)'),
|
'newalbum_placeholder' => t('or select an existing one (doubleclick)'),
|
||||||
'nickname' => \App::$data['channel']['channel_address'],
|
'nickname' => \App::$data['channel']['channel_address'],
|
||||||
|
|
|
@ -2165,3 +2165,51 @@ function attach_move($channel_id,$resource_id,$new_folder_hash) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function attach_folder_select_list($channel_id) {
|
||||||
|
|
||||||
|
$r = q("select * from attach where is_dir = 1 and uid = %d",
|
||||||
|
intval($channel_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
$out = [];
|
||||||
|
$out[''] = '/';
|
||||||
|
|
||||||
|
if($r) {
|
||||||
|
foreach($r as $rv) {
|
||||||
|
$x = attach_folder_rpaths($r,$rv);
|
||||||
|
if($x)
|
||||||
|
$out[$x[0]] = $x[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
function attach_folder_rpaths($all_folders,$that_folder) {
|
||||||
|
|
||||||
|
$path = '/' . $that_folder['filename'];
|
||||||
|
$current_hash = $that_folder['hash'];
|
||||||
|
$parent_hash = $that_folder['folder'];
|
||||||
|
$error = false;
|
||||||
|
$found = false;
|
||||||
|
|
||||||
|
if($parent_hash) {
|
||||||
|
do {
|
||||||
|
foreach($all_folders as $selected) {
|
||||||
|
if(! $selected['is_dir'])
|
||||||
|
continue;
|
||||||
|
if($selected['hash'] == $parent_hash) {
|
||||||
|
$path = '/' . $selected['filename'] . $path;
|
||||||
|
$current_hash = $selected['hash'];
|
||||||
|
$parent_hash = $selected['folder'];
|
||||||
|
$found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(! $found)
|
||||||
|
$error = true;
|
||||||
|
}
|
||||||
|
while((! $found) && (! $error) && ($parent_hash != ''));
|
||||||
|
}
|
||||||
|
return (($error) ? false : [ $current_hash , $path ]);
|
||||||
|
|
||||||
|
}
|
|
@ -78,6 +78,9 @@
|
||||||
<label id="photo-edit-tags-label" for="photo-edit-newtag">{{$edit.tag_label}}</label>
|
<label id="photo-edit-tags-label" for="photo-edit-newtag">{{$edit.tag_label}}</label>
|
||||||
<input name="newtag" id="photo-edit-newtag" class="form-control" title="{{$edit.help_tags}}" type="text" />
|
<input name="newtag" id="photo-edit-newtag" class="form-control" title="{{$edit.help_tags}}" type="text" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
{{include file="field_select.tpl" field=$edit.album_select}}
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<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>
|
||||||
|
|
Loading…
Reference in a new issue