X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fphotos.php;h=79a51fd4c97effa9dbab099d5d7fe8bf9fee79e4;hb=7ab366b9c3653160dbe68fe2d096e4174547ff84;hp=9a3a402a4b1a169aff24c0bd89934e338a4ffdb9;hpb=e60c729b516695181ce670219ce6e1a98913ffb2;p=friendica.git
diff --git a/mod/photos.php b/mod/photos.php
index 9a3a402a4b..79a51fd4c9 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -4,14 +4,18 @@ require_once('include/items.php');
require_once('include/acl_selectors.php');
require_once('include/bbcode.php');
require_once('include/security.php');
-
+require_once('include/redir.php');
+require_once('include/tags.php');
function photos_init(&$a) {
+ if($a->argc > 1)
+ auto_redir($a, $a->argv[1]);
if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
return;
}
+
$o = '';
if($a->argc > 1) {
@@ -25,6 +29,12 @@ function photos_init(&$a) {
$a->data['user'] = $r[0];
+ $o .= '
';
+ $o .= '
' . $a->data['user']['username'] . '
';
+ $o .= '
';
+ $o .= '
';
+
+
$sql_extra = permissions_sql($a->data['user']['uid']);
$albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d $sql_extra order by created desc",
@@ -34,11 +44,6 @@ function photos_init(&$a) {
if(count($albums)) {
$a->data['albums'] = $albums;
- $o .= '';
- $o .= '
' . $a->data['user']['username'] . '
';
- $o .= '
';
- $o .= '
';
-
$albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true);
if($albums_visible) {
@@ -161,6 +166,11 @@ function photos_post(&$a) {
return; // NOTREACHED
}
+ // Check if the user has responded to a delete confirmation query
+ if($_REQUEST['canceled']) {
+ goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ }
+
$newalbum = notags(trim($_POST['albumname']));
if($newalbum != $album) {
q("UPDATE `photo` SET `album` = '%s' WHERE `album` = '%s' AND `uid` = %d",
@@ -176,6 +186,25 @@ function photos_post(&$a) {
if($_POST['dropalbum'] == t('Delete Album')) {
+ // Check if we should do HTML-based delete confirmation
+ if($_REQUEST['confirm']) {
+ $drop_url = $a->query_string;
+ $extra_inputs = array(
+ array('name' => 'albumname', 'value' => $_POST['albumname']),
+ );
+ $a->page['content'] = replace_macros(get_markup_template('confirm.tpl'), array(
+ '$method' => 'post',
+ '$message' => t('Do you really want to delete this photo album and all its photos?'),
+ '$extra_inputs' => $extra_inputs,
+ '$confirm' => t('Delete Album'),
+ '$confirm_url' => $drop_url,
+ '$confirm_name' => 'dropalbum', // Needed so that confirmation will bring us back into this if statement
+ '$cancel' => t('Cancel'),
+ ));
+ $a->error = 1; // Set $a->error so the other module functions don't execute
+ return;
+ }
+
$res = array();
// get the list of photos we are about to delete
@@ -223,6 +252,7 @@ function photos_post(&$a) {
dbesc($rr['parent-uri']),
intval($page_owner_uid)
);
+ create_tags_from_itemuri($rr['parent-uri'], $page_owner_uid);
$drop_id = intval($rr['id']);
@@ -237,10 +267,32 @@ function photos_post(&$a) {
return; // NOTREACHED
}
+
+ // Check if the user has responded to a delete confirmation query for a single photo
+ if(($a->argc > 2) && $_REQUEST['canceled']) {
+ goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ }
+
if(($a->argc > 2) && (x($_POST,'delete')) && ($_POST['delete'] == t('Delete Photo'))) {
// same as above but remove single photo
+ // Check if we should do HTML-based delete confirmation
+ if($_REQUEST['confirm']) {
+ $drop_url = $a->query_string;
+ $a->page['content'] = replace_macros(get_markup_template('confirm.tpl'), array(
+ '$method' => 'post',
+ '$message' => t('Do you really want to delete this photo?'),
+ '$extra_inputs' => array(),
+ '$confirm' => t('Delete Photo'),
+ '$confirm_url' => $drop_url,
+ '$confirm_name' => 'delete', // Needed so that confirmation will bring us back into this if statement
+ '$cancel' => t('Cancel'),
+ ));
+ $a->error = 1; // Set $a->error so the other module functions don't execute
+ return;
+ }
+
if($visitor) {
$r = q("SELECT `id`, `resource-id` FROM `photo` WHERE `contact-id` = %d AND `uid` = %d AND `resource-id` = '%s' LIMIT 1",
intval($visitor),
@@ -270,6 +322,7 @@ function photos_post(&$a) {
dbesc($i[0]['uri']),
intval($page_owner_uid)
);
+ create_tags_from_itemuri($i[0]['uri'], $page_owner_uid);
$url = $a->get_baseurl();
$drop_id = intval($i[0]['id']);
@@ -279,7 +332,7 @@ function photos_post(&$a) {
}
}
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ goaway($a->get_baseurl() . '/photos/' . $a->data['user']['nickname']);
return; // NOTREACHED
}
@@ -330,7 +383,7 @@ function photos_post(&$a) {
$ph->scaleImage(640);
$width = $ph->getWidth();
$height = $ph->getHeight();
-
+
$x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 1 limit 1",
dbesc($ph->imageString()),
intval($height),
@@ -352,7 +405,7 @@ function photos_post(&$a) {
dbesc($resource_id),
intval($page_owner_uid)
);
- }
+ }
}
}
}
@@ -554,6 +607,7 @@ function photos_post(&$a) {
intval($item_id),
intval($page_owner_uid)
);
+ create_tags_from_item($item_id);
$best = 0;
foreach($p as $scales) {
@@ -599,7 +653,7 @@ function photos_post(&$a) {
$arr['tag'] = $tagged[4];
$arr['inform'] = $tagged[2];
$arr['origin'] = 1;
- $arr['body'] = '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]' . ' ' . t('was tagged in a') . ' ' . '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . t('photo') . '[/url]' . ' ' . t('by') . ' ' . '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]' ;
+ $arr['body'] = sprintf( t('%1$s was tagged in %2$s by %3$s'), '[url=' . $tagged[1] . ']' . $tagged[0] . '[/url]', '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . t('a photo') . '[/url]', '[url=' . $owner_record['url'] . ']' . $owner_record['name'] . '[/url]') ;
$arr['body'] .= "\n\n" . '[url=' . $a->get_baseurl() . '/photos/' . $owner_record['nickname'] . '/image/' . $p[0]['resource-id'] . ']' . '[img]' . $a->get_baseurl() . "/photo/" . $p[0]['resource-id'] . '-' . $best . '.' . $ext . '[/img][/url]' . "\n" ;
$arr['object'] = '