X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=mod%2Ftagrm.php;h=2e7f8b97082436e8061998997f0150d666147fcb;hb=f94a10bf00de699a5f3d22ea74665053a5661175;hp=99d22f3d2aa1bad0904b86040086d01daa451b78;hpb=01f171bce71126f60cf0ef9b447006b34c5a3891;p=friendica.git diff --git a/mod/tagrm.php b/mod/tagrm.php index 99d22f3d2a..2e7f8b9708 100644 --- a/mod/tagrm.php +++ b/mod/tagrm.php @@ -1,15 +1,16 @@ get_baseurl() . '/' . $_SESSION['photo_return']); +function tagrm_post(App $a) { + if (! local_user()) { + goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); + } - if((x($_POST,'submit')) && ($_POST['submit'] === t('Cancel'))) - goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); + if ((x($_POST,'submit')) && ($_POST['submit'] === t('Cancel'))) { + goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); + } $tag = ((x($_POST,'tag')) ? hex2bin(notags(trim($_POST['tag']))) : ''); $item = ((x($_POST,'item')) ? intval($_POST['item']) : 0 ); @@ -19,12 +20,13 @@ function tagrm_post(&$a) { intval(local_user()) ); - if(! count($r)) - goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); + if (! dbm::is_result($r)) { + goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); + } $arr = explode(',', $r[0]['tag']); - for($x = 0; $x < count($arr); $x ++) { - if($arr[$x] === $tag) { + for ($x = 0; $x < count($arr); $x ++) { + if ($arr[$x] === $tag) { unset($arr[$x]); break; } @@ -32,49 +34,50 @@ function tagrm_post(&$a) { $tag_str = implode(',',$arr); - q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", + q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d AND `uid` = %d", dbesc($tag_str), intval($item), intval(local_user()) ); - notice( t('Tag removed') . EOL ); - goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); - + info( t('Tag removed') . EOL ); + goaway(App::get_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(App::get_baseurl() . '/' . $_SESSION['photo_return']); // NOTREACHED } $item = (($a->argc > 1) ? intval($a->argv[1]) : 0); - if(! $item) { - goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); + if (! $item) { + goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); // NOTREACHED } - $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']); + if (! dbm::is_result($r)) { + goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); + } $arr = explode(',', $r[0]['tag']); - if(! count($arr)) - goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']); + if (! count($arr)) { + goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); + } $o .= '