7 use Friendica\Content\Text\BBCode;
8 use Friendica\Core\L10n;
9 use Friendica\Core\System;
10 use Friendica\Database\DBM;
11 use Friendica\Model\Item;
13 function tagrm_post(App $a) {
16 goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
19 if ((x($_POST,'submit')) && ($_POST['submit'] === L10n::t('Cancel'))) {
20 goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
23 $tag = ((x($_POST,'tag')) ? hex2bin(notags(trim($_POST['tag']))) : '');
24 $item = ((x($_POST,'item')) ? intval($_POST['item']) : 0 );
26 $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
31 if (!DBM::is_result($r)) {
32 goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
35 $arr = explode(',', $r[0]['tag']);
36 for ($x = 0; $x < count($arr); $x ++) {
37 if ($arr[$x] === $tag) {
43 $tag_str = implode(',',$arr);
45 Item::update(['tag' => $tag_str], ['id' => $item]);
47 info(L10n::t('Tag removed') . EOL );
48 goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
55 function tagrm_content(App $a) {
60 goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
64 $item = (($a->argc > 1) ? intval($a->argv[1]) : 0);
66 goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
70 $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
75 if (!DBM::is_result($r)) {
76 goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
79 $arr = explode(',', $r[0]['tag']);
82 goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
85 $o .= '<h3>' . L10n::t('Remove Item Tag') . '</h3>';
87 $o .= '<p id="tag-remove-desc">' . L10n::t('Select a tag to remove: ') . '</p>';
89 $o .= '<form id="tagrm" action="tagrm" method="post" >';
90 $o .= '<input type="hidden" name="item" value="' . $item . '" />';
93 foreach ($arr as $x) {
94 $o .= '<li><input type="checkbox" name="tag" value="' . bin2hex($x) . '" >' . BBCode::convert($x) . '</input></li>';
98 $o .= '<input id="tagrm-submit" type="submit" name="submit" value="' . L10n::t('Remove') .'" />';
99 $o .= '<input id="tagrm-cancel" type="submit" name="submit" value="' . L10n::t('Cancel') .'" />';