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_id = (x($_POST,'item') ? intval($_POST['item']) : 0);
26 $item = Item::selectFirst(['tag'], ['id' => $item_id, 'uid' => local_user()]);
27 if (!DBM::is_result($item)) {
28 goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
31 $arr = explode(',', $item['tag']);
32 for ($x = 0; $x < count($arr); $x ++) {
33 if ($arr[$x] === $tag) {
39 $tag_str = implode(',',$arr);
41 Item::update(['tag' => $tag_str], ['id' => $item_id]);
43 info(L10n::t('Tag removed') . EOL );
44 goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
51 function tagrm_content(App $a)
56 goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
60 $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
62 goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
66 $item = Item::selectFirst(['tag'], ['id' => $item_id, 'uid' => local_user()]);
67 if (!DBM::is_result($item)) {
68 goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
71 $arr = explode(',', $item['tag']);
74 goaway(System::baseUrl() . '/' . $_SESSION['photo_return']);
77 $o .= '<h3>' . L10n::t('Remove Item Tag') . '</h3>';
79 $o .= '<p id="tag-remove-desc">' . L10n::t('Select a tag to remove: ') . '</p>';
81 $o .= '<form id="tagrm" action="tagrm" method="post" >';
82 $o .= '<input type="hidden" name="item" value="' . $item_id . '" />';
85 foreach ($arr as $x) {
86 $o .= '<li><input type="checkbox" name="tag" value="' . bin2hex($x) . '" >' . BBCode::convert($x) . '</input></li>';
90 $o .= '<input id="tagrm-submit" type="submit" name="submit" value="' . L10n::t('Remove') .'" />';
91 $o .= '<input id="tagrm-cancel" type="submit" name="submit" value="' . L10n::t('Cancel') .'" />';