another try to avoid dubble photo deletion. allow to set a photo caption and simple status body (if create status post is enabled) on upload
This commit is contained in:
parent
3432771150
commit
ab8b4d5c36
@ -815,6 +815,12 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
|
||||
if($arr['item'])
|
||||
$args['item'] = $arr['item'];
|
||||
|
||||
if($arr['body'])
|
||||
$args['body'] = $arr['body'];
|
||||
|
||||
if($arr['description'])
|
||||
$args['description'] = $arr['description'];
|
||||
|
||||
$p = photo_upload($channel,$observer,$args);
|
||||
if($p['success']) {
|
||||
$ret['body'] = $p['body'];
|
||||
@ -1282,12 +1288,11 @@ function attach_delete($channel_id, $resource, $is_photo = 0) {
|
||||
);
|
||||
if($x) {
|
||||
drop_item($x[0]['id'],false,(($x[0]['item_hidden']) ? DROPITEM_NORMAL : DROPITEM_PHASE1),true);
|
||||
|
||||
q("DELETE FROM photo WHERE uid = %d AND resource_id = '%s'",
|
||||
intval($channel_id),
|
||||
dbesc($resource)
|
||||
);
|
||||
}
|
||||
q("DELETE FROM photo WHERE uid = %d AND resource_id = '%s'",
|
||||
intval($channel_id),
|
||||
dbesc($resource)
|
||||
);
|
||||
}
|
||||
|
||||
// update the parent folder's lastmodified timestamp
|
||||
|
@ -7,6 +7,7 @@
|
||||
require_once('include/permissions.php');
|
||||
require_once('include/items.php');
|
||||
require_once('include/photo/photo_driver.php');
|
||||
require_once('include/text.php');
|
||||
|
||||
/**
|
||||
* @brief
|
||||
@ -18,6 +19,8 @@ require_once('include/photo/photo_driver.php');
|
||||
*/
|
||||
function photo_upload($channel, $observer, $args) {
|
||||
|
||||
$a = get_app();
|
||||
|
||||
$ret = array('success' => false);
|
||||
$channel_id = $channel['channel_id'];
|
||||
$account_id = $channel['channel_account_id'];
|
||||
@ -186,8 +189,8 @@ function photo_upload($channel, $observer, $args) {
|
||||
$p['description'] = $args['description'];
|
||||
|
||||
$r0 = $ph->save($p);
|
||||
$r0width = $ph->getWidth();
|
||||
$r0height = $ph->getHeight();
|
||||
$r0width = $ph->getWidth();
|
||||
$r0height = $ph->getHeight();
|
||||
if(! $r0)
|
||||
$errors = true;
|
||||
|
||||
@ -199,8 +202,8 @@ function photo_upload($channel, $observer, $args) {
|
||||
|
||||
$p['scale'] = 1;
|
||||
$r1 = $ph->save($p);
|
||||
$r1width = $ph->getWidth();
|
||||
$r1height = $ph->getHeight();
|
||||
$r1width = $ph->getWidth();
|
||||
$r1height = $ph->getHeight();
|
||||
if(! $r1)
|
||||
$errors = true;
|
||||
|
||||
@ -209,8 +212,8 @@ function photo_upload($channel, $observer, $args) {
|
||||
|
||||
$p['scale'] = 2;
|
||||
$r2 = $ph->save($p);
|
||||
$r2width = $ph->getWidth();
|
||||
$r2height = $ph->getHeight();
|
||||
$r2width = $ph->getWidth();
|
||||
$r2height = $ph->getHeight();
|
||||
if(! $r2)
|
||||
$errors = true;
|
||||
|
||||
@ -219,8 +222,8 @@ function photo_upload($channel, $observer, $args) {
|
||||
|
||||
$p['scale'] = 3;
|
||||
$r3 = $ph->save($p);
|
||||
$r3width = $ph->getWidth();
|
||||
$r3height = $ph->getHeight();
|
||||
$r3width = $ph->getWidth();
|
||||
$r3height = $ph->getHeight();
|
||||
if(! $r3)
|
||||
$errors = true;
|
||||
|
||||
@ -246,10 +249,12 @@ function photo_upload($channel, $observer, $args) {
|
||||
}
|
||||
}
|
||||
|
||||
$title = (($args['filename']) ? $args['filename'] : '');
|
||||
$title = (($args['description']) ? $args['description'] : $args['filename']);
|
||||
|
||||
$large_photos = feature_enabled($channel['channel_id'], 'large_photos');
|
||||
|
||||
linkify_tags($a, $args['body'], $channel_id);
|
||||
|
||||
if($large_photos) {
|
||||
$scale = 1;
|
||||
$width = $r1width;
|
||||
@ -360,7 +365,7 @@ function photo_upload($channel, $observer, $args) {
|
||||
$arr['item_thread_top'] = 1;
|
||||
$arr['item_private'] = intval($acl->is_private());
|
||||
$arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
|
||||
$arr['body'] = (($object) ? '' : $body);
|
||||
$arr['body'] = (($object) ? $args['body'] : $body . $args['body']);
|
||||
|
||||
$result = item_store($arr);
|
||||
$item_id = $result['item_id'];
|
||||
|
@ -183,14 +183,14 @@ function photos_post(&$a) {
|
||||
);
|
||||
|
||||
if($r) {
|
||||
|
||||
/*
|
||||
q("DELETE FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s'",
|
||||
intval($page_owner_uid),
|
||||
dbesc($r[0]['resource_id'])
|
||||
);
|
||||
|
||||
*/
|
||||
attach_delete($page_owner_uid, $r[0]['resource_id'], 1 );
|
||||
|
||||
/*
|
||||
$i = q("SELECT * FROM `item` WHERE `resource_id` = '%s' AND resource_type = 'photo' and `uid` = %d LIMIT 1",
|
||||
dbesc($r[0]['resource_id']),
|
||||
intval($page_owner_uid)
|
||||
@ -199,6 +199,7 @@ function photos_post(&$a) {
|
||||
drop_item($i[0]['id'],true,DROPITEM_PHASE1);
|
||||
$url = $a->get_baseurl();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
goaway($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . $_SESSION['album_return']);
|
||||
@ -622,7 +623,9 @@ function photos_content(&$a) {
|
||||
'$nickname' => $a->data['channel']['channel_address'],
|
||||
'$newalbum_label' => t('Enter an album name'),
|
||||
'$newalbum_placeholder' => t('or select an existing album (doubleclick)'),
|
||||
'$visible' => array('visible', t('Create a status post for this upload'), 0, '', array(t('No'), t('Yes'))),
|
||||
'$visible' => array('visible', t('Create a status post for this upload'), 0,'', array(t('No'), t('Yes')), 'onclick="showHideBodyTextarea();"'),
|
||||
'$caption' => array('description', t('Caption (optional):')),
|
||||
'$body' => array('body', t('Description (optional):'),'', 'Description will only appear in the status post'),
|
||||
'$albums' => $albums['albums'],
|
||||
'$selname' => $selname,
|
||||
'$permissions' => t('Permissions'),
|
||||
|
@ -33,4 +33,4 @@
|
||||
position: absolute;
|
||||
left: -9999px;
|
||||
top: -9999px;
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,9 @@
|
||||
var ispublic = aStr.everybody;
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function() {
|
||||
$("#photo-edit-newtag").contact_autocomplete(baseurl + '/acl', 'p', false, function(data) {
|
||||
$("#photo-edit-newtag").val('@' + data.name);
|
||||
});
|
||||
|
||||
$("#photo-edit-newtag").contact_autocomplete(baseurl + '/acl', 'p', false, function(data) {
|
||||
$("#photo-edit-newtag").val('@' + data.name);
|
||||
});
|
||||
|
||||
$('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
|
||||
@ -24,4 +23,14 @@ $(document).ready(function() {
|
||||
$('#jot-public').show();
|
||||
}
|
||||
}).trigger('change');
|
||||
});
|
||||
|
||||
showHideBodyTextarea();
|
||||
|
||||
});
|
||||
|
||||
function showHideBodyTextarea() {
|
||||
if( $('#id_visible').is(':checked'))
|
||||
$('#body-textarea').slideDown();
|
||||
else
|
||||
$('#body-textarea').slideUp();
|
||||
}
|
||||
|
@ -21,7 +21,11 @@
|
||||
<div class="form-group">
|
||||
<input id="photos-upload-choose" type="file" name="userfile" />
|
||||
</div>
|
||||
{{include file="field_input.tpl" field=$caption}}
|
||||
{{include file="field_checkbox.tpl" field=$visible}}
|
||||
<div id="body-textarea">
|
||||
{{include file="field_textarea.tpl" field=$body}}
|
||||
</div>
|
||||
<div class="pull-right btn-group form-group">
|
||||
<div class="btn-group">
|
||||
{{if $lockstate}}
|
||||
@ -37,8 +41,11 @@
|
||||
<div class="clear"></div>
|
||||
|
||||
{{if $uploader}}
|
||||
|
||||
{{include file="field_input.tpl" field=$caption}}
|
||||
{{include file="field_checkbox.tpl" field=$visible}}
|
||||
<div id="body-textarea">
|
||||
{{include file="field_textarea.tpl" field=$body}}
|
||||
</div>
|
||||
<div id="photos-upload-perms" class="btn-group pull-right">
|
||||
{{if $lockstate}}
|
||||
<button class="btn btn-default btn-sm" data-toggle="modal" data-target="#aclModal" onclick="return false;">
|
||||
|
Reference in New Issue
Block a user