From 95de759766d4ea06b2b331131078a9f908ff2054 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 26 Oct 2014 21:37:59 -0700 Subject: a couple of photo tag issues --- mod/tagrm.php | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'mod/tagrm.php') 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 .= '

' . t('Remove Item Tag') . '

'; @@ -85,8 +90,8 @@ function tagrm_content(&$a) { $o .= ''; -- cgit v1.2.3