aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mod/photos.php16
-rw-r--r--mod/tagrm.php41
2 files changed, 34 insertions, 23 deletions
diff --git a/mod/photos.php b/mod/photos.php
index 003f7239d..cc0a963de 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -319,6 +319,7 @@ function photos_post(&$a) {
$old_inform = $r[0]['inform'];
}
+
// make sure the linked item has the same permissions as the photo regardless of any other changes
$x = q("update item set allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', item_private = %d
where id = %d limit 1",
@@ -380,6 +381,7 @@ function photos_post(&$a) {
if($success['replaced']) {
$tagged[] = $tag;
+
$post_tags[] = array(
'uid' => $a->profile['profile_uid'],
'type' => $success['termtype'],
@@ -397,8 +399,14 @@ function photos_post(&$a) {
);
if($r) {
+ $r = fetch_post_tags($r,true);
$datarray = $r[0];
- $datarray['term'] = $post_tags;
+ if($post_tags) {
+ if((! array_key_exists('term',$datarray)) || (! is_array($datarray['term'])))
+ $datarray['term'] = $post_tags;
+ else
+ $datarray['term'] = array_merge($datarray['term'],$post_tags);
+ }
item_store_update($datarray,$execflag);
}
@@ -910,21 +918,19 @@ function photos_content(&$a) {
$r = conv_sort($r,'commented');
}
-
-
$tags = array();
if($link_item['term']) {
$cnt = 0;
- foreach($link_item['term'] as $t)
+ foreach($link_item['term'] as $t) {
$tags[$cnt] = array(0 => format_term_for_display($t));
if($can_post && ($ph[0]['uid'] == $owner_uid)) {
$tags[$cnt][1] = 'tagrm?f=&item=' . $link_item['id'];
$tags[$cnt][2] = t('Remove');
}
$cnt ++;
+ }
}
-
if((local_user()) && (local_user() == $link_item['uid'])) {
q("UPDATE `item` SET item_flags = (item_flags ^ %d) WHERE parent = %d and uid = %d and (item_flags & %d)",
intval(ITEM_UNSEEN),
diff --git a/mod/tagrm.php b/mod/tagrm.php
index 957cf0d71..930d449b7 100644
--- a/mod/tagrm.php
+++ b/mod/tagrm.php
@@ -19,24 +19,27 @@ function tagrm_post(&$a) {
intval(local_user())
);
- if(! count($r))
+ if(! $r)
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
- $arr = explode(',', $r[0]['tag']);
- for($x = 0; $x < count($arr); $x ++) {
- if($arr[$x] === $tag) {
- unset($arr[$x]);
- break;
+ $r = fetch_post_tags($r,true);
+
+ $item = $r[0];
+ $new_tags = array();
+
+ if($item['term']) {
+ for($x = 0; $x < count($item['term']); $x ++) {
+ if($item['term'][$x]['term'] !== hex2bin($tag))
+ $new_tags[] = $item['term'][$x];
}
}
- $tag_str = implode(',',$arr);
+ if($new_tags)
+ $item['term'] = $new_tags;
+ else
+ unset($item['term']);
- q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
- dbesc($tag_str),
- intval($item),
- intval(local_user())
- );
+ item_store_update($item);
info( t('Tag removed') . EOL );
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
@@ -56,7 +59,7 @@ function tagrm_content(&$a) {
// NOTREACHED
}
- $item = (($a->argc > 1) ? intval($a->argv[1]) : 0);
+ $item = intval($_GET['item']);
if(! $item) {
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
// NOTREACHED
@@ -68,12 +71,14 @@ function tagrm_content(&$a) {
intval(local_user())
);
- if(! count($r))
+
+ if(! $r)
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
- $arr = explode(',', $r[0]['tag']);
+ $r = fetch_post_tags($r,true);
+
- if(! count($arr))
+ if(! count($r[0]['term']))
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
$o .= '<h3>' . t('Remove Item Tag') . '</h3>';
@@ -85,8 +90,8 @@ function tagrm_content(&$a) {
$o .= '<ul>';
- foreach($arr as $x) {
- $o .= '<li><input type="checkbox" name="tag" value="' . bin2hex($x) . '" >' . bbcode($x) . '</input></li>';
+ foreach($r[0]['term'] as $x) {
+ $o .= '<li><input type="checkbox" name="tag" value="' . bin2hex($x['term']) . '" >' . bbcode($x['term']) . '</input></li>';
}
$o .= '</ul>';