Example #1
0
function file_tag_unsave_file($uid, $item, $file, $cat = false)
{
    require_once "include/files.php";
    $result = false;
    if (!intval($uid)) {
        return false;
    }
    if ($cat == true) {
        $pattern = '<' . file_tag_encode($file) . '>';
        $termtype = TERM_CATEGORY;
    } else {
        $pattern = '[' . file_tag_encode($file) . ']';
        $termtype = TERM_FILE;
    }
    $r = q("select file from item where id = %d and uid = %d limit 1", intval($item), intval($uid));
    if (!count($r)) {
        return false;
    }
    q("update item set file = '%s' where id = %d and uid = %d", dbesc(str_replace($pattern, '', $r[0]['file'])), intval($item), intval($uid));
    create_files_from_item($item);
    $r = q("SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d", dbesc($file), intval(TERM_OBJ_POST), intval($termtype), intval($uid));
    //$r = q("select file from item where uid = %d and deleted = 0 " . file_tag_file_query('item',$file,(($cat) ? 'category' : 'file')),
    //);
    if (!count($r)) {
        $saved = get_pconfig($uid, 'system', 'filetags');
        set_pconfig($uid, 'system', 'filetags', str_replace($pattern, '', $saved));
    }
    return true;
}
Example #2
0
function file_tag_unsave_file($uid, $item, $file, $cat = false)
{
    $result = false;
    if (!intval($uid)) {
        return false;
    }
    if ($cat == true) {
        $pattern = '<' . file_tag_encode($file) . '>';
    } else {
        $pattern = '[' . file_tag_encode($file) . ']';
    }
    $r = q("select file from item where id = %d and uid = %d limit 1", intval($item), intval($uid));
    if (!count($r)) {
        return false;
    }
    q("update item set file = '%s' where id = %d and uid = %d limit 1", dbesc(str_replace($pattern, '', $r[0]['file'])), intval($item), intval($uid));
    $r = q("select file from item where uid = %d and deleted = 0 " . file_tag_file_query('item', $file, $cat ? 'category' : 'file'), intval($uid));
    if (!count($r)) {
        $saved = get_pconfig($uid, 'system', 'filetags');
        set_pconfig($uid, 'system', 'filetags', str_replace($pattern, '', $saved));
    }
    return true;
}