From ca97130a296bcf0d17b63d07f328c841731b3e58 Mon Sep 17 00:00:00 2001 From: Florian Steinel Date: Thu, 13 Oct 2016 16:02:18 +0200 Subject: add column display_path to inserts into attachment, as this column is a not null column Conflicts: Zotlabs/Storage/Directory.php include/attach.php amend 54def92bcf75c08cd8dec3921e5ef26f23d85ffc display_path --- Zotlabs/Storage/Directory.php | 6 ++++-- include/attach.php | 28 ++++++++++++++++++---------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index ad450b2dd..b196e4d2d 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -244,8 +244,8 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { $deny_gid = $c[0]['channel_deny_gid']; } - $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, folder, os_storage, filetype, filesize, revision, is_photo, content, created, edited, allow_cid, allow_gid, deny_cid, deny_gid ) - VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", + $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, folder, os_storage, filetype, filesize, revision, is_photo, content, created, edited, os_path, display_path, allow_cid, allow_gid, deny_cid, deny_gid ) + VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", intval($c[0]['channel_account_id']), intval($c[0]['channel_id']), dbesc($hash), @@ -260,6 +260,8 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { dbesc($f), dbesc(datetime_convert()), dbesc(datetime_convert()), + dbesc((($this->os_path) ? $this->os_path . '/' : '')), + dbesc((($this->red_path) ? $this->red_path . '/' : '')), dbesc($allow_cid), dbesc($allow_gid), dbesc($deny_cid), diff --git a/include/attach.php b/include/attach.php index 4e8b3c056..0deda3205 100644 --- a/include/attach.php +++ b/include/attach.php @@ -704,6 +704,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { // not yet used $os_path = ''; + $display_path = ''; if($src) @file_put_contents($os_basepath . $os_relpath,@file_get_contents($src)); @@ -719,7 +720,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $edited = $created; if($options === 'replace') { - $r = q("update attach set filename = '%s', filetype = '%s', folder = '%s', filesize = %d, os_storage = %d, is_photo = %d, content = '%s', edited = '%s', os_path = '%s' where id = %d and uid = %d", + $r = q("update attach set filename = '%s', filetype = '%s', folder = '%s', filesize = %d, os_storage = %d, is_photo = %d, content = '%s', edited = '%s', os_path = '%s', display_path = '%s' where id = %d and uid = %d", dbesc($filename), dbesc($mimetype), dbesc($folder_hash), @@ -729,13 +730,14 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { dbesc($os_basepath . $os_relpath), dbesc($created), dbesc($os_path), + dbesc($display_path), intval($existing_id), intval($channel_id) ); } elseif($options === 'revise') { - $r = q("insert into attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, os_path, allow_cid, allow_gid, deny_cid, deny_gid ) - VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", + $r = q("insert into attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, os_path, display_path, allow_cid, allow_gid, deny_cid, deny_gid ) + VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", intval($x[0]['aid']), intval($channel_id), dbesc($x[0]['hash']), @@ -751,6 +753,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { dbesc($created), dbesc($created), dbesc($os_path), + dbesc($display_path), dbesc($x[0]['allow_cid']), dbesc($x[0]['allow_gid']), dbesc($x[0]['deny_cid']), @@ -758,8 +761,8 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { ); } elseif($options === 'update') { - $r = q("update attach set filename = '%s', filetype = '%s', folder = '%s', edited = '%s', os_storage = %d, is_photo = %d, os_path = '%s', - allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s' where id = %d and uid = %d", + $r = q("update attach set filename = '%s', filetype = '%s', folder = '%s', edited = '%s', os_storage = %d, is_photo = %d, os_path = '%s', + display_path = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s' where id = %d and uid = %d", dbesc((array_key_exists('filename',$arr)) ? $arr['filename'] : $x[0]['filename']), dbesc((array_key_exists('filetype',$arr)) ? $arr['filetype'] : $x[0]['filetype']), dbesc(($folder_hash) ? $folder_hash : $x[0]['folder']), @@ -767,6 +770,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { dbesc((array_key_exists('os_storage',$arr)) ? $arr['os_storage'] : $x[0]['os_storage']), dbesc((array_key_exists('is_photo',$arr)) ? $arr['is_photo'] : $x[0]['is_photo']), dbesc((array_key_exists('os_path',$arr)) ? $arr['os_path'] : $x[0]['os_path']), + dbesc((array_key_exists('display_path',$arr)) ? $arr['display_path'] : $x[0]['display_path']), dbesc((array_key_exists('allow_cid',$arr)) ? $arr['allow_cid'] : $x[0]['allow_cid']), dbesc((array_key_exists('allow_gid',$arr)) ? $arr['allow_gid'] : $x[0]['allow_gid']), dbesc((array_key_exists('deny_cid',$arr)) ? $arr['deny_cid'] : $x[0]['deny_cid']), @@ -776,8 +780,9 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { ); } else { - $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, os_path, allow_cid, allow_gid,deny_cid, deny_gid ) - VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", + + $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, os_path, display_path, allow_cid, allow_gid,deny_cid, deny_gid ) + VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", intval($channel['channel_account_id']), intval($channel_id), dbesc($hash), @@ -793,6 +798,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { dbesc($created), dbesc($created), dbesc($os_path), + dbesc($display_path), dbesc(($arr && array_key_exists('allow_cid',$arr)) ? $arr['allow_cid'] : $str_contact_allow), dbesc(($arr && array_key_exists('allow_gid',$arr)) ? $arr['allow_gid'] : $str_group_allow), dbesc(($arr && array_key_exists('deny_cid',$arr)) ? $arr['deny_cid'] : $str_contact_deny), @@ -1037,8 +1043,8 @@ function attach_mkdir($channel, $observer_hash, $arr = null) { $created = datetime_convert(); - $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, filesize, revision, folder, os_storage, is_dir, content, created, edited, allow_cid, allow_gid, deny_cid, deny_gid ) - VALUES ( %d, %d, '%s', '%s', '%s', '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", + $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, filesize, revision, folder, os_storage, is_dir, content, created, edited, os_path, display_path, allow_cid, allow_gid, deny_cid, deny_gid ) + VALUES ( %d, %d, '%s', '%s', '%s', '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", intval($channel['channel_account_id']), intval($channel_id), dbesc($arr['hash']), @@ -1053,6 +1059,8 @@ function attach_mkdir($channel, $observer_hash, $arr = null) { dbesc($path), dbesc($created), dbesc($created), + dbesc($path), + dbesc($path), dbesc(($arr && array_key_exists('allow_cid',$arr)) ? $arr['allow_cid'] : $channel['channel_allow_cid']), dbesc(($arr && array_key_exists('allow_gid',$arr)) ? $arr['allow_gid'] : $channel['channel_allow_gid']), dbesc(($arr && array_key_exists('deny_cid',$arr)) ? $arr['deny_cid'] : $channel['channel_deny_cid']), @@ -2233,4 +2241,4 @@ function attach_folder_rpaths($all_folders,$that_folder) { } return (($error) ? false : [ $current_hash , $path ]); -} \ No newline at end of file +} -- cgit v1.2.3 From f84530c285cf8bbb1f820614a20e698a388111c0 Mon Sep 17 00:00:00 2001 From: Florian Steinel Date: Sat, 22 Oct 2016 08:07:27 +0200 Subject: attach_mkdir use $os_path and $display_path initilized to an empty string --- include/attach.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/attach.php b/include/attach.php index 0deda3205..e2e214ce3 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1043,6 +1043,10 @@ function attach_mkdir($channel, $observer_hash, $arr = null) { $created = datetime_convert(); + // not yet used + $os_path = ''; + $display_path = ''; + $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, filesize, revision, folder, os_storage, is_dir, content, created, edited, os_path, display_path, allow_cid, allow_gid, deny_cid, deny_gid ) VALUES ( %d, %d, '%s', '%s', '%s', '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", intval($channel['channel_account_id']), @@ -1059,8 +1063,8 @@ function attach_mkdir($channel, $observer_hash, $arr = null) { dbesc($path), dbesc($created), dbesc($created), - dbesc($path), - dbesc($path), + dbesc($os_path), + dbesc($display_path), dbesc(($arr && array_key_exists('allow_cid',$arr)) ? $arr['allow_cid'] : $channel['channel_allow_cid']), dbesc(($arr && array_key_exists('allow_gid',$arr)) ? $arr['allow_gid'] : $channel['channel_allow_gid']), dbesc(($arr && array_key_exists('deny_cid',$arr)) ? $arr['deny_cid'] : $channel['channel_deny_cid']), -- cgit v1.2.3 From 43de0e7f169abc2f9669bcda4c3808e20cfe46a0 Mon Sep 17 00:00:00 2001 From: Florian Steinel Date: Sat, 22 Oct 2016 08:17:26 +0200 Subject: until we've settled on what they should be, set os_path and display_path to an emtpy string --- Zotlabs/Storage/Directory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index b196e4d2d..5d078b04e 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -260,8 +260,8 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { dbesc($f), dbesc(datetime_convert()), dbesc(datetime_convert()), - dbesc((($this->os_path) ? $this->os_path . '/' : '')), - dbesc((($this->red_path) ? $this->red_path . '/' : '')), + '', //TODO: use os_path + '', //TODO: use display_path dbesc($allow_cid), dbesc($allow_gid), dbesc($deny_cid), -- cgit v1.2.3