X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=mod%2Ftagrm.php;h=db0b765799ba7ab9582e9e1b9b4ac2cf9f450be3;hb=f85af78097d2ab73a9ee4b020a6a366f3a147de3;hp=2e7f8b97082436e8061998997f0150d666147fcb;hpb=8e12b159d947fb27ad6bdd5e06e3a90c1713687e;p=friendica.git diff --git a/mod/tagrm.php b/mod/tagrm.php index 2e7f8b9708..db0b765799 100644 --- a/mod/tagrm.php +++ b/mod/tagrm.php @@ -1,30 +1,34 @@ $item_id, 'uid' => local_user()]); + if (!DBA::isResult($item)) { + goaway(System::baseUrl() . '/' . $_SESSION['photo_return']); } - $arr = explode(',', $r[0]['tag']); + $arr = explode(',', $item['tag']); for ($x = 0; $x < count($arr); $x ++) { if ($arr[$x] === $tag) { unset($arr[$x]); @@ -34,68 +38,58 @@ function tagrm_post(App $a) { $tag_str = implode(',',$arr); - q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d AND `uid` = %d", - dbesc($tag_str), - intval($item), - intval(local_user()) - ); + Item::update(['tag' => $tag_str], ['id' => $item_id]); - info( t('Tag removed') . EOL ); - goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); + info(L10n::t('Tag removed') . EOL ); + goaway(System::baseUrl() . '/' . $_SESSION['photo_return']); // NOTREACHED - } -function tagrm_content(App $a) { - +function tagrm_content(App $a) +{ $o = ''; - if (! local_user()) { - goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); + if (!local_user()) { + goaway(System::baseUrl() . '/' . $_SESSION['photo_return']); // NOTREACHED } - $item = (($a->argc > 1) ? intval($a->argv[1]) : 0); - if (! $item) { - goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); + $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); + if (!$item_id) { + goaway(System::baseUrl() . '/' . $_SESSION['photo_return']); // NOTREACHED } - $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($item), - intval(local_user()) - ); - - if (! dbm::is_result($r)) { - goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); + $item = Item::selectFirst(['tag'], ['id' => $item_id, 'uid' => local_user()]); + if (!DBA::isResult($item)) { + goaway(System::baseUrl() . '/' . $_SESSION['photo_return']); } - $arr = explode(',', $r[0]['tag']); + $arr = explode(',', $item['tag']); - if (! count($arr)) { - goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); + if (!count($arr)) { + goaway(System::baseUrl() . '/' . $_SESSION['photo_return']); } - $o .= '
' . t('Select a tag to remove: ') . '
'; + $o .= '' . L10n::t('Select a tag to remove: ') . '
'; $o .= ''; return $o; - }