Now term table is used for categories and putting items to folder

This commit is contained in:
Michael Vogel 2014-03-16 17:16:01 +01:00
parent bbf9378a49
commit 9496537e5f
2 changed files with 34 additions and 9 deletions

View file

@ -2013,10 +2013,12 @@ function file_tag_update_pconfig($uid,$file_old,$file_new,$type = 'file') {
if($type == 'file') { if($type == 'file') {
$lbracket = '['; $lbracket = '[';
$rbracket = ']'; $rbracket = ']';
$termtype = TERM_FILE;
} }
else { else {
$lbracket = '<'; $lbracket = '<';
$rbracket = '>'; $rbracket = '>';
$termtype = TERM_CATEGORY;
} }
$filetags_updated = $saved; $filetags_updated = $saved;
@ -2042,9 +2044,15 @@ function file_tag_update_pconfig($uid,$file_old,$file_new,$type = 'file') {
} }
foreach($deleted_tags as $key => $tag) { foreach($deleted_tags as $key => $tag) {
$r = q("select file from item where uid = %d " . file_tag_file_query('item',$tag,$type), $r = q("SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d",
intval($uid) dbesc($tag),
); intval(TERM_OBJ_POST),
intval($termtype),
intval($uid));
//$r = q("select file from item where uid = %d " . file_tag_file_query('item',$tag,$type),
// intval($uid)
//);
if(count($r)) { if(count($r)) {
unset($deleted_tags[$key]); unset($deleted_tags[$key]);
@ -2067,6 +2075,8 @@ function file_tag_update_pconfig($uid,$file_old,$file_new,$type = 'file') {
} }
function file_tag_save_file($uid,$item,$file) { function file_tag_save_file($uid,$item,$file) {
require_once("include/files.php");
$result = false; $result = false;
if(! intval($uid)) if(! intval($uid))
return false; return false;
@ -2081,6 +2091,9 @@ function file_tag_save_file($uid,$item,$file) {
intval($item), intval($item),
intval($uid) intval($uid)
); );
create_files_from_item($item);
$saved = get_pconfig($uid,'system','filetags'); $saved = get_pconfig($uid,'system','filetags');
if((! strlen($saved)) || (! stristr($saved,'[' . file_tag_encode($file) . ']'))) if((! strlen($saved)) || (! stristr($saved,'[' . file_tag_encode($file) . ']')))
set_pconfig($uid,'system','filetags',$saved . '[' . file_tag_encode($file) . ']'); set_pconfig($uid,'system','filetags',$saved . '[' . file_tag_encode($file) . ']');
@ -2090,14 +2103,19 @@ function file_tag_save_file($uid,$item,$file) {
} }
function file_tag_unsave_file($uid,$item,$file,$cat = false) { function file_tag_unsave_file($uid,$item,$file,$cat = false) {
require_once("include/files.php");
$result = false; $result = false;
if(! intval($uid)) if(! intval($uid))
return false; return false;
if($cat == true) if($cat == true) {
$pattern = '<' . file_tag_encode($file) . '>' ; $pattern = '<' . file_tag_encode($file) . '>' ;
else $termtype = TERM_CATEGORY;
} else {
$pattern = '[' . file_tag_encode($file) . ']' ; $pattern = '[' . file_tag_encode($file) . ']' ;
$termtype = TERM_FILE;
}
$r = q("select file from item where id = %d and uid = %d limit 1", $r = q("select file from item where id = %d and uid = %d limit 1",
@ -2113,9 +2131,16 @@ function file_tag_unsave_file($uid,$item,$file,$cat = false) {
intval($uid) intval($uid)
); );
$r = q("select file from item where uid = %d and deleted = 0 " . file_tag_file_query('item',$file,(($cat) ? 'category' : 'file')), create_files_from_item($item);
intval($uid)
); $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)) { if(! count($r)) {
$saved = get_pconfig($uid,'system','filetags'); $saved = get_pconfig($uid,'system','filetags');