summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Bello <tylerbello@users.sourceforge.net>2009-05-26 18:52:42 +0000
committerTyler Bello <tylerbello@users.sourceforge.net>2009-05-26 18:52:42 +0000
commit7e5868760ca9bb92a4a1950707f858eca0fb2dca (patch)
tree39d6f8a527c6d1fa450b1a61c70fda5f25feb978
parenta41f6f3f0a18d5b067965f3931fd4e5d3b5b6a63 (diff)
downloadliberty-7e5868760ca9bb92a4a1950707f858eca0fb2dca.tar.gz
liberty-7e5868760ca9bb92a4a1950707f858eca0fb2dca.tar.bz2
liberty-7e5868760ca9bb92a4a1950707f858eca0fb2dca.zip
fix in getStorageBranch, incorrect split call leading to double slashes at end of path causing mkdir_p to fail
-rw-r--r--LibertyAttachable.php31
1 files changed, 17 insertions, 14 deletions
diff --git a/LibertyAttachable.php b/LibertyAttachable.php
index 2696fa8..08758d1 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.169 2008/12/25 10:50:46 squareing Exp $
+ * @version $Header: /cvsroot/bitweaver/_bit_liberty/LibertyAttachable.php,v 1.170 2009/05/26 18:52:42 tylerbello Exp $
* @author spider <spider@steelsun.com>
*/
// +----------------------------------------------------------------------+
@@ -57,10 +57,10 @@ class LibertyAttachable extends LibertyContent {
*/
function getStoragePath( $pSubDir = NULL, $pUserId = NULL, $pPackage = ACTIVE_PACKAGE, $pPermissions = 0755, $pRootDir = NULL ) {
$ret = null;
- if( $storageUrl = LibertyAttachable::getStorageBranch( $pSubDir, $pUserId, $pPackage, $pPermissions, $pRootDir ) ) {
- //$ret = BIT_ROOT_PATH.$storageUrl;
+
+ if( $storageUrl = LibertyAttachable::getStorageBranch( $pSubDir, $pUserId, $pPackage, $pPermissions, $pRootDir, empty($pRootDir) ) ) {
$ret = ( !empty( $pRootDir ) ? $pRootDir : BIT_ROOT_PATH ).$storageUrl;
- //$ret = $storageUrl;
+ mkdir_p($ret);
}
return $ret;
}
@@ -118,15 +118,15 @@ class LibertyAttachable extends LibertyContent {
* @author Christian Fowler<spider@steelsun.com>
* @param $pSubDir any desired directory below the StoragePath. this will be created if it doesn't exist
* @param $pUserId indicates the 'users/.../<user_id>' branch or use the 'common' branch if null
- * @param $pRootDir override BIT_ROOT_DIR with a custom absolute path - useful for areas where no we access should be allowed
+ * @param $pRootDir **deprecated, unused, will be removed in future relase**.
* @return string full path on local filsystem to store files.
*/
- function getStorageBranch( $pSubDir = NULL, $pUserId = NULL, $pPackage = ACTIVE_PACKAGE, $pPermissions = 0755, $pRootDir = NULL ) {
+ function getStorageBranch( $pSubDir = NULL, $pUserId = NULL, $pPackage = ACTIVE_PACKAGE, $pPermissions = 0755, $pRootDir = NULL, $pCreateDir = true ) {
// *PRIVATE FUNCTION. GO AWAY! DO NOT CALL DIRECTLY!!!
global $gBitSystem;
$pathParts = array();
$pathParts = split( '/', trim( STORAGE_PKG_PATH, '/\\' ) );
-
+
if( !$pUserId ) {
$pathParts[] = 'common';
} else {
@@ -139,15 +139,18 @@ class LibertyAttachable extends LibertyContent {
$pathParts[] = $pPackage;
}
// In case $pSubDir is multiple levels deep we'll need to mkdir each directory if they don't exist
- $pSubDirParts = split('/',$pSubDir);
- foreach ($pSubDirParts as $subDir) {
- $pathParts[] = $subDir;
+ if(!empty($pSubDir)){
+ $pSubDirParts = split('/',$pSubDir);
+ foreach ($pSubDirParts as $subDir) {
+ $pathParts[] = $subDir;
+ }
}
- $fullPath = implode( $pathParts, '/' ).'/';
-
- mkdir_p( $fullPath );
- $ret = substr( $fullPath, strlen( dirname( STORAGE_PKG_PATH ) ) );
+ $fullPath = '/'.implode( $pathParts, '/' ).'/';
+ if($pCreateDir){
+ mkdir_p( $fullPath );
+ }
+ $ret = substr( $fullPath, strlen( dirname( STORAGE_PKG_PATH ) )+ 1 );
return $ret;
}
// }}}