From 10754ced3e51f796102005b9661b747c06fd4e0b Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 4 May 2012 06:42:56 -0700 Subject: [PATCH] category removal --- include/text.php | 13 +++++++++---- mod/filerm.php | 8 +++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/include/text.php b/include/text.php index af32b24761..4ae5d13333 100644 --- a/include/text.php +++ b/include/text.php @@ -930,7 +930,7 @@ function prepare_body($item,$attach = false) { foreach($matches as $mtch) { if(strlen($x)) $x .= ','; - $x .= xmlify(file_tag_decode($mtch[1])); + $x .= xmlify(file_tag_decode($mtch[1])) . ' ' . t('[remove]') . ''; } if(strlen($x)) $s .= '
' . t('Categories:') . ' ' . $x . '
'; @@ -1466,12 +1466,16 @@ function file_tag_save_file($uid,$item,$file) { return true; } -function file_tag_unsave_file($uid,$item,$file) { +function file_tag_unsave_file($uid,$item,$file,$cat = false) { $result = false; if(! intval($uid)) return false; - $pattern = '[' . file_tag_encode($file) . ']' ; + if($cat == true) + $pattern = '<' . file_tag_encode($file) . '>' ; + else + $pattern = '[' . file_tag_encode($file) . ']' ; + $r = q("select file from item where id = %d and uid = %d limit 1", intval($item), @@ -1486,13 +1490,14 @@ function file_tag_unsave_file($uid,$item,$file) { intval($uid) ); - $r = q("select file from item where uid = %d " . file_tag_file_query('item',$file), + $r = q("select file from item where uid = %d " . file_tag_file_query('item',$file,(($cat) ? 'category' : 'file')), intval($uid) ); if(! count($r)) { $saved = get_pconfig($uid,'system','filetags'); set_pconfig($uid,'system','filetags',str_replace($pattern,'',$saved)); + } return true; } diff --git a/mod/filerm.php b/mod/filerm.php index c520fec7ac..d2b57d4472 100644 --- a/mod/filerm.php +++ b/mod/filerm.php @@ -7,12 +7,18 @@ function filerm_content(&$a) { } $term = unxmlify(trim($_GET['term'])); + $cat = unxmlify(trim($_GET['cat'])); + + $category = (($cat) ? true : false); + if($category) + $term = $cat; + $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); logger('filerm: tag ' . $term . ' item ' . $item_id); if($item_id && strlen($term)) - file_tag_unsave_file(local_user(),$item_id,$term); + file_tag_unsave_file(local_user(),$item_id,$term, $category); if(x($_SESSION,'return_url')) goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);