2010-11-08 23:37:58 +01:00
|
|
|
<?php
|
|
|
|
|
2012-12-28 22:51:50 +01:00
|
|
|
require_once('include/bbcode.php');
|
2010-11-08 23:37:58 +01:00
|
|
|
|
|
|
|
function tagrm_post(&$a) {
|
|
|
|
|
|
|
|
if(! local_user())
|
2016-12-19 14:26:13 +01:00
|
|
|
goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
|
2010-11-08 23:37:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
if((x($_POST,'submit')) && ($_POST['submit'] === t('Cancel')))
|
2016-12-19 14:26:13 +01:00
|
|
|
goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
|
2010-11-08 23:37:58 +01:00
|
|
|
|
|
|
|
$tag = ((x($_POST,'tag')) ? hex2bin(notags(trim($_POST['tag']))) : '');
|
|
|
|
$item = ((x($_POST,'item')) ? intval($_POST['item']) : 0 );
|
|
|
|
|
|
|
|
$r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
|
|
|
intval($item),
|
|
|
|
intval(local_user())
|
|
|
|
);
|
|
|
|
|
2016-12-13 10:44:13 +01:00
|
|
|
if(! dbm::is_result($r))
|
2016-12-19 14:26:13 +01:00
|
|
|
goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
|
2010-11-08 23:37:58 +01:00
|
|
|
|
|
|
|
$arr = explode(',', $r[0]['tag']);
|
|
|
|
for($x = 0; $x < count($arr); $x ++) {
|
|
|
|
if($arr[$x] === $tag) {
|
|
|
|
unset($arr[$x]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$tag_str = implode(',',$arr);
|
|
|
|
|
2014-03-11 23:52:32 +01:00
|
|
|
q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d AND `uid` = %d",
|
2010-11-08 23:37:58 +01:00
|
|
|
dbesc($tag_str),
|
|
|
|
intval($item),
|
|
|
|
intval(local_user())
|
|
|
|
);
|
|
|
|
|
2011-05-23 11:39:57 +02:00
|
|
|
info( t('Tag removed') . EOL );
|
2016-12-19 14:26:13 +01:00
|
|
|
goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
|
2016-02-07 15:11:34 +01:00
|
|
|
|
2016-02-05 21:52:39 +01:00
|
|
|
// NOTREACHED
|
2016-02-07 15:11:34 +01:00
|
|
|
|
2010-11-08 23:37:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-07 15:11:34 +01:00
|
|
|
|
2010-11-08 23:37:58 +01:00
|
|
|
function tagrm_content(&$a) {
|
|
|
|
|
|
|
|
$o = '';
|
|
|
|
|
|
|
|
if(! local_user()) {
|
2016-12-19 14:26:13 +01:00
|
|
|
goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
|
2010-11-08 23:37:58 +01:00
|
|
|
// NOTREACHED
|
|
|
|
}
|
|
|
|
|
|
|
|
$item = (($a->argc > 1) ? intval($a->argv[1]) : 0);
|
|
|
|
if(! $item) {
|
2016-12-19 14:26:13 +01:00
|
|
|
goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
|
2010-11-08 23:37:58 +01:00
|
|
|
// NOTREACHED
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
|
|
|
intval($item),
|
|
|
|
intval(local_user())
|
|
|
|
);
|
|
|
|
|
2016-12-13 10:44:13 +01:00
|
|
|
if(! dbm::is_result($r))
|
2016-12-19 14:26:13 +01:00
|
|
|
goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
|
2010-11-08 23:37:58 +01:00
|
|
|
|
|
|
|
$arr = explode(',', $r[0]['tag']);
|
|
|
|
|
|
|
|
if(! count($arr))
|
2016-12-19 14:26:13 +01:00
|
|
|
goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
|
2010-11-08 23:37:58 +01:00
|
|
|
|
|
|
|
$o .= '<h3>' . t('Remove Item Tag') . '</h3>';
|
|
|
|
|
|
|
|
$o .= '<p id="tag-remove-desc">' . t('Select a tag to remove: ') . '</p>';
|
|
|
|
|
|
|
|
$o .= '<form id="tagrm" action="tagrm" method="post" >';
|
|
|
|
$o .= '<input type="hidden" name="item" value="' . $item . '" />';
|
|
|
|
$o .= '<ul>';
|
|
|
|
|
|
|
|
|
|
|
|
foreach($arr as $x) {
|
|
|
|
$o .= '<li><input type="checkbox" name="tag" value="' . bin2hex($x) . '" >' . bbcode($x) . '</input></li>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$o .= '</ul>';
|
|
|
|
$o .= '<input id="tagrm-submit" type="submit" name="submit" value="' . t('Remove') .'" />';
|
|
|
|
$o .= '<input id="tagrm-cancel" type="submit" name="submit" value="' . t('Cancel') .'" />';
|
|
|
|
$o .= '</form>';
|
|
|
|
|
|
|
|
return $o;
|
2016-02-07 15:11:34 +01:00
|
|
|
|
2011-05-23 11:39:57 +02:00
|
|
|
}
|