summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTekiMaki <tekimaki@users.sourceforge.net>2007-02-25 22:58:17 +0000
committerTekiMaki <tekimaki@users.sourceforge.net>2007-02-25 22:58:17 +0000
commita0a98225d40024e0fcac1b68f9d319485828e3a6 (patch)
tree32d544c3848b622ef3a55e440c1967416f1304fb
parent8eb1e8eea669639534a40da81ed4d3bb75eafa1a (diff)
downloadliberty-a0a98225d40024e0fcac1b68f9d319485828e3a6.tar.gz
liberty-a0a98225d40024e0fcac1b68f9d319485828e3a6.tar.bz2
liberty-a0a98225d40024e0fcac1b68f9d319485828e3a6.zip
remove antiqueated site_upload_dir preference and use STORAGE defines. previously, site_upload_dir had to be defined, and only worked with same defined name as storage package, typcially 'storage'. also only save of 'site_temp_dir' if it is different from the TEMP_PKG_PATH. Handle using of define defaults for both of those settings. Also, remove ancient junk from kernel/setup_inc.php
-rw-r--r--LibertyAttachable.php26
-rw-r--r--plugins/storage.bitfile.php25
2 files changed, 17 insertions, 34 deletions
diff --git a/LibertyAttachable.php b/LibertyAttachable.php
index 99b8628..6b64585 100644
--- a/LibertyAttachable.php
+++ b/LibertyAttachable.php
@@ -3,7 +3,7 @@
* Management of Liberty Content
*
* @package liberty
- * @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertyAttachable.php,v 1.62 2007/02/24 08:51:08 squareing Exp $
+ * @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertyAttachable.php,v 1.63 2007/02/25 22:58:17 tekimaki Exp $
* @author spider <spider@steelsun.com>
*/
// +----------------------------------------------------------------------+
@@ -87,9 +87,8 @@ class LibertyAttachable extends LibertyContent {
function getStorageBranch( $pSubDir = NULL, $pUserId = NULL, $pPackage = ACTIVE_PACKAGE, $pPermissions = 0755, $pRootDir = NULL ) {
// *PRIVATE FUNCTION. GO AWAY! DO NOT CALL DIRECTLY!!!
global $gBitSystem;
- $baseUrl = null;
$pathParts = array();
- $pathParts = split( '/', $gBitSystem->getConfig( 'site_upload_dir', 'storage/' ) );
+ $pathParts = split( '/', trim( STORAGE_PKG_PATH, '/\\' ) );
if( !$pUserId ) {
$pathParts[] = 'common';
@@ -108,24 +107,11 @@ class LibertyAttachable extends LibertyContent {
$pathParts[] = $subDir;
}
- $pRootDir = !empty( $pRootDir ) ? $pRootDir : BIT_ROOT_PATH;
+ $fullPath = implode( $pathParts, '/' ).'/';
- foreach( $pathParts as $p ) {
- if( !empty( $p ) ) {
- $baseUrl .= $p.'/';
- if( !file_exists( $pRootDir.$baseUrl ) ) {
- $oldu = umask( 0 );
- if( mkdir( $pRootDir.$baseUrl, $pPermissions ) ) {
- umask( $oldu );
- } else {
- // ACK, something went very wrong.
- $baseUrl = FALSE;
- break;
- }
- }
- }
- }
- return $baseUrl;
+ mkdir_p( $fullPath );
+ $ret = substr( $fullPath, strlen( dirname( STORAGE_PKG_PATH ) ) );
+ return $ret;
}
/**
diff --git a/plugins/storage.bitfile.php b/plugins/storage.bitfile.php
index ffb6b85..a04d8fd 100644
--- a/plugins/storage.bitfile.php
+++ b/plugins/storage.bitfile.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Revision: 1.19 $
+ * @version $Revision: 1.20 $
* @package liberty
* @subpackage plugins_storage
*/
@@ -43,20 +43,17 @@ function bit_files_verify( &$pStoreRow ) {
function bit_files_store( &$pStoreRow ) {
global $gBitSystem, $gBitUser;
$ret = NULL;
- $pref = $gBitSystem->getConfig('site_upload_dir');
- if( isset( $pref ) ) {
- if( !empty( $pStoreRow['foreign_id'] ) ) {
- $sql = "UPDATE `".BIT_DB_PREFIX."liberty_files SET `storage_path`=?, `mime_type`=?, `file_size`=? WHERE `file_id` = ?";
- $gBitSystem->mDb->query( $sql, array( $pStoreRow['dest_file_path'], $pStoreRow['type'], $pStoreRow['size'], $pStoreRow['foreign_id'] ) );
- } else {
- $pStoreRow['file_id'] = $gBitSystem->mDb->GenID( 'liberty_files_id_seq' );
- $sql = "INSERT INTO `".BIT_DB_PREFIX."liberty_files` ( `storage_path`, `file_id`, `mime_type`, `file_size`, `user_id` ) VALUES ( ?, ?, ?, ?, ? )";
- $userId = !empty( $pStoreRow['upload']['user_id'] ) ? $pStoreRow['upload']['user_id'] : $gBitUser->mUserId;
- $gBitSystem->mDb->query($sql, array( $pStoreRow['upload']['dest_path'].$pStoreRow['upload']['name'], $pStoreRow['file_id'], $pStoreRow['upload']['type'], $pStoreRow['upload']['size'], $userId ) );
- }
- $sql = "UPDATE `".BIT_DB_PREFIX."liberty_attachments` SET `foreign_id`=? WHERE `attachment_id` = ?";
- $gBitSystem->mDb->query( $sql, array( $pStoreRow['file_id'], $pStoreRow['attachment_id'] ) );
+ if( !empty( $pStoreRow['foreign_id'] ) ) {
+ $sql = "UPDATE `".BIT_DB_PREFIX."liberty_files SET `storage_path`=?, `mime_type`=?, `file_size`=? WHERE `file_id` = ?";
+ $gBitSystem->mDb->query( $sql, array( $pStoreRow['dest_file_path'], $pStoreRow['type'], $pStoreRow['size'], $pStoreRow['foreign_id'] ) );
+ } else {
+ $pStoreRow['file_id'] = $gBitSystem->mDb->GenID( 'liberty_files_id_seq' );
+ $sql = "INSERT INTO `".BIT_DB_PREFIX."liberty_files` ( `storage_path`, `file_id`, `mime_type`, `file_size`, `user_id` ) VALUES ( ?, ?, ?, ?, ? )";
+ $userId = !empty( $pStoreRow['upload']['user_id'] ) ? $pStoreRow['upload']['user_id'] : $gBitUser->mUserId;
+ $gBitSystem->mDb->query($sql, array( $pStoreRow['upload']['dest_path'].$pStoreRow['upload']['name'], $pStoreRow['file_id'], $pStoreRow['upload']['type'], $pStoreRow['upload']['size'], $userId ) );
}
+ $sql = "UPDATE `".BIT_DB_PREFIX."liberty_attachments` SET `foreign_id`=? WHERE `attachment_id` = ?";
+ $gBitSystem->mDb->query( $sql, array( $pStoreRow['file_id'], $pStoreRow['attachment_id'] ) );
return $ret;
}