X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=mod%2Ftagrm.php;h=dbe6f108776986528d25d1561bef238a5eacc301;hb=796056a6feaf305dd9fb7c97bb43cdbc75ad0641;hp=d4b483a522f970afec8f66a84cd481591cd2282d;hpb=f962ecdd6483679879d7608a47dbf8549a431a8f;p=friendica.git diff --git a/mod/tagrm.php b/mod/tagrm.php index d4b483a522..dbe6f10877 100644 --- a/mod/tagrm.php +++ b/mod/tagrm.php @@ -1,30 +1,36 @@ get_baseurl() . '/' . $_SESSION['photo_return']); - - - if((x($_POST,'submit')) && ($_POST['submit'] === t('Cancel'))) - goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); - - $tag = ((x($_POST,'tag')) ? hex2bin(notags(trim($_POST['tag']))) : ''); - $item = ((x($_POST,'item')) ? intval($_POST['item']) : 0 ); + if (x($_POST,'submit') && ($_POST['submit'] === L10n::t('Cancel'))) { + goaway(System::baseUrl() . '/' . $_SESSION['photo_return']); + } - $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($item), - intval(local_user()) - ); + $tag = (x($_POST,'tag') ? hex2bin(notags(trim($_POST['tag']))) : ''); + $item_id = (x($_POST,'item') ? intval($_POST['item']) : 0); - if(! count($r)) - goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); + $item = Item::selectFirst(['tag'], ['id' => $item_id, 'uid' => local_user()]); + if (!DBM::is_result($item)) { + goaway(System::baseUrl() . '/' . $_SESSION['photo_return']); + } - $arr = explode(',', $r[0]['tag']); - for($x = 0; $x < count($arr); $x ++) { - if($arr[$x] === $tag) { + $arr = explode(',', $item['tag']); + for ($x = 0; $x < count($arr); $x ++) { + if ($arr[$x] === $tag) { unset($arr[$x]); break; } @@ -32,68 +38,58 @@ function tagrm_post(&$a) { $tag_str = implode(',',$arr); - q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", - dbesc($tag_str), - intval($item), - intval(local_user()) - ); + Item::update(['tag' => $tag_str], ['id' => $item_id]); - info( t('Tag removed') . EOL ); - goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); - - // NOTREACHED + info(L10n::t('Tag removed') . EOL ); + goaway(System::baseUrl() . '/' . $_SESSION['photo_return']); + // NOTREACHED } -function tagrm_content(&$a) { - +function tagrm_content(App $a) +{ $o = ''; - if(! local_user()) { - goaway($a->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($a->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 } + $item = Item::selectFirst(['tag'], ['id' => $item_id, 'uid' => local_user()]); + if (!DBM::is_result($item)) { + goaway(System::baseUrl() . '/' . $_SESSION['photo_return']); + } - $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($item), - intval(local_user()) - ); - - if(! count($r)) - goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); - - $arr = explode(',', $r[0]['tag']); + $arr = explode(',', $item['tag']); - if(! count($arr)) - goaway($a->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; - }