Merge branch 'master' of kde:owncloud
This commit is contained in:
commit
f2229e0427
5 changed files with 47 additions and 55 deletions
|
@ -1,5 +1,7 @@
|
|||
ErrorDocument 404 //owncloud/core/templates/404.php
|
||||
php_value upload_max_filesize 512M
|
||||
php_value post_max_size 512M
|
||||
SetEnv htaccessWorking true
|
||||
<IfModule mod_php5.c>
|
||||
php_value upload_max_filesize 512M
|
||||
php_value post_max_size 512M
|
||||
SetEnv htaccessWorking true
|
||||
</IfModule>
|
||||
Options -Indexes
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
<?php
|
||||
|
||||
require_once('apps/files_sharing/lib_share.php');
|
||||
require_once('apps/files_sharing/sharedstorage.php');
|
||||
|
||||
OC_Filesystem::registerStorageType("shared", "OC_Filestorage_Shared", array("datadir"=>"string"));
|
||||
OC::$CLASSPATH['OC_Share'] = "apps/files_sharing/lib_share.php";
|
||||
OC_Hook::connect("OC_Filesystem", "post_delete", "OC_Share", "deleteItem");
|
||||
OC_Hook::connect("OC_Filesystem", "post_rename", "OC_Share", "renameItem");
|
||||
OC_Filesystem::registerStorageType("shared", "OC_Filestorage_Shared", array("datadir" => "string"));
|
||||
OC_Util::addScript("files_sharing", "share");
|
||||
OC_Util::addScript("3rdparty", "chosen/chosen.jquery.min");
|
||||
OC_Util::addStyle( 'files_sharing', 'sharing' );
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
OC_Hook::connect("OC_FILESYSTEM","post_delete", "OC_Share", "deleteItem");
|
||||
OC_Hook::connect("OC_FILESYSTEM","post_rename", "OC_Share", "renameItem");
|
||||
|
||||
/**
|
||||
* This class manages shared items within the database.
|
||||
*/
|
||||
|
@ -177,6 +174,7 @@ class OC_Share {
|
|||
$query = OC_DB::prepare("SELECT uid_shared_with, permissions FROM *PREFIX*sharing WHERE source = ? AND uid_owner = ?");
|
||||
return $query->execute(array($source, OC_User::getUser()))->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all items the current user is sharing
|
||||
* @return An array with all items the user is sharing
|
||||
|
@ -185,7 +183,7 @@ class OC_Share {
|
|||
$query = OC_DB::prepare("SELECT uid_shared_with, source, permissions FROM *PREFIX*sharing WHERE uid_owner = ?");
|
||||
return $query->execute(array(OC_User::getUser()))->fetchAll();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the items within a shared folder that have their own entry for the purpose of name, location, or permissions that differ from the folder itself
|
||||
*
|
||||
|
@ -204,7 +202,7 @@ class OC_Share {
|
|||
$query = OC_DB::prepare("SELECT uid_owner, source, target, permissions FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? OR SUBSTR(target, 1, ?) = ? AND uid_shared_with ".self::getUsersAndGroups());
|
||||
return $query->execute(array($length, $folder, $length, $folder))->fetchAll();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the source and target parent folders of the specified target location
|
||||
* @param $target The target location of the item
|
||||
|
@ -301,18 +299,6 @@ class OC_Share {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source location to a new value
|
||||
* @param $oldSource The current source location
|
||||
* @param $newTarget The new source location
|
||||
*/
|
||||
public static function setSource($oldSource, $newSource) {
|
||||
$oldSource = self::cleanPath($oldSource);
|
||||
$newSource = self::cleanPath($newSource);
|
||||
$query = OC_DB::prepare("UPDATE *PREFIX*sharing SET source = REPLACE(source, ?, ?) WHERE uid_owner = ?");
|
||||
$query->execute(array($oldSource, $newSource, OC_User::getUser()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the target location to a new value
|
||||
*
|
||||
|
@ -327,7 +313,7 @@ class OC_Share {
|
|||
$query = OC_DB::prepare("UPDATE *PREFIX*sharing SET target = REPLACE(target, ?, ?) WHERE uid_shared_with ".self::getUsersAndGroups());
|
||||
$query->execute(array($oldTarget, $newTarget));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change the permissions for the specified item and user
|
||||
*
|
||||
|
@ -342,7 +328,7 @@ class OC_Share {
|
|||
$query = OC_DB::prepare("UPDATE *PREFIX*sharing SET permissions = ? WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ? AND uid_shared_with ".self::getUsersAndGroups($uid_shared_with));
|
||||
$query->execute(array($permissions, strlen($source), $source, OC_User::getUser()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unshare the item, removes it from all specified users
|
||||
*
|
||||
|
@ -356,13 +342,14 @@ class OC_Share {
|
|||
$query = OC_DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ? AND uid_shared_with ".self::getUsersAndGroups($uid_shared_with));
|
||||
$query->execute(array(strlen($source), $source, OC_User::getUser()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unshare the item from the current user, removes it only from the database and doesn't touch the source file
|
||||
*
|
||||
* You must use the pullOutOfFolder() function to unshare a file inside a shared folder and set $newTarget to nothing
|
||||
* You must use the pullOutOfFolder() function before you call unshareFromMySelf() and set the delete parameter to false to unshare from self a file inside a shared folder
|
||||
*
|
||||
* @param $target The target location of the item
|
||||
* @param $delete (Optional) If true delete the entry from the database, if false the permission is set to UNSHARED
|
||||
*/
|
||||
public static function unshareFromMySelf($target, $delete = true) {
|
||||
$target = self::cleanPath($target);
|
||||
|
@ -377,25 +364,23 @@ class OC_Share {
|
|||
|
||||
/**
|
||||
* Remove the item from the database, the owner deleted the file
|
||||
* @param $arguments Array of arguments passed from OC_HOOK
|
||||
* @param $arguments Array of arguments passed from OC_Hook
|
||||
*/
|
||||
public static function deleteItem($arguments) {
|
||||
$source = "/".OC_User::getUser()."/files".$arguments['path'];
|
||||
$source = self::cleanPath($source);
|
||||
$source = "/".OC_User::getUser()."/files".self::cleanPath($arguments['path']);
|
||||
$query = OC_DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ?");
|
||||
$query->execute(array(strlen($source), $source, OC_User::getUser()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename the item in the database, the owner renamed the file
|
||||
* @param $arguments Array of arguments passed from OC_HOOK
|
||||
* @param $arguments Array of arguments passed from OC_Hook
|
||||
*/
|
||||
public static function renameItem($arguments) {
|
||||
$oldSource = "/".OC_User::getUser()."/files".$arguments['oldpath'];
|
||||
$oldSource = self::cleanPath($oldSource);
|
||||
$newSource = "/".OC_User::getUser()."/files".$arguments['newpath'];
|
||||
$newSource = self::cleanPath($newSource);
|
||||
self::setSource($oldSource, $newSource);
|
||||
$oldSource = "/".OC_User::getUser()."/files".self::cleanPath($arguments['oldpath']);
|
||||
$newSource = "/".OC_User::getUser()."/files".self::cleanPath($arguments['newpath']);
|
||||
$query = OC_DB::prepare("UPDATE *PREFIX*sharing SET source = REPLACE(source, ?, ?) WHERE uid_owner = ?");
|
||||
$query->execute(array($oldSource, $newSource, OC_User::getUser()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -79,37 +79,37 @@ class OC_Filestorage_Shared extends OC_Filestorage {
|
|||
|
||||
public function opendir($path) {
|
||||
if ($path == "" || $path == "/") {
|
||||
global $FAKEDIRS;
|
||||
$path = $this->datadir.$path;
|
||||
$sharedItems = OC_Share::getItemsInFolder($path);
|
||||
if (empty($sharedItems)) {
|
||||
return false;
|
||||
}
|
||||
$files = array();
|
||||
foreach ($sharedItems as $item) {
|
||||
// If item is in the root of the shared storage provider add it to the fakedirs
|
||||
if (dirname($item['target'])."/" == $path) {
|
||||
$files[] = basename($item['target']);
|
||||
} else {
|
||||
global $FAKEDIRS;
|
||||
$files = array();
|
||||
foreach ($sharedItems as $item) {
|
||||
// If item is in the root of the shared storage provider and the item exists add it to the fakedirs
|
||||
if (dirname($item['target'])."/" == $path && $this->file_exists(basename($item['target']))) {
|
||||
$files[] = basename($item['target']);
|
||||
}
|
||||
}
|
||||
$FAKEDIRS['shared'] = $files;
|
||||
return opendir('fakedir://shared');
|
||||
}
|
||||
$FAKEDIRS['shared'] = $files;
|
||||
return opendir('fakedir://shared');
|
||||
} else {
|
||||
$source = $this->getSource($path);
|
||||
if ($source) {
|
||||
$storage = OC_Filesystem::getStorage($source);
|
||||
$dh = $storage->opendir($this->getInternalPath($source));
|
||||
// Remove any duplicate or trailing '/'
|
||||
$path = rtrim($this->datadir.$path, "/");
|
||||
$path = preg_replace('{(/)\1+}', "/", $path);
|
||||
$modifiedItems = OC_Share::getItemsInFolder($source);
|
||||
if ($modifiedItems && $dh) {
|
||||
global $FAKEDIRS;
|
||||
$sources = array();
|
||||
$targets = array();
|
||||
// Remove any duplicate or trailing '/'
|
||||
$path = preg_replace('{(/)\1+}', "/", $path);
|
||||
$targetFolder = rtrim($this->datadir.$path, "/");
|
||||
foreach ($modifiedItems as $item) {
|
||||
// If the item is in the current directory and has a different name than the source, add it to the arrays
|
||||
if (dirname($item['target']) == $path) {
|
||||
// If the item is in the current directory and the item exists add it to the arrays
|
||||
if (dirname($item['target']) == $targetFolder && $this->file_exists($path."/".basename($item['target']))) {
|
||||
// If the item was unshared from self, add it it to the arrays
|
||||
if ($item['permissions'] == OC_Share::UNSHARED) {
|
||||
$sources[] = basename($item['source']);
|
||||
|
@ -124,6 +124,7 @@ class OC_Filestorage_Shared extends OC_Filestorage {
|
|||
if (empty($sources)) {
|
||||
return $dh;
|
||||
} else {
|
||||
global $FAKEDIRS;
|
||||
$files = array();
|
||||
while (($filename = readdir($dh)) !== false) {
|
||||
if ($filename != "." && $filename != "..") {
|
||||
|
|
|
@ -273,12 +273,14 @@ class OC_Setup {
|
|||
* create .htaccess files for apache hosts
|
||||
*/
|
||||
private static function createHtaccess() {
|
||||
global $SERVERROOT;
|
||||
global $WEBROOT;
|
||||
$SERVERROOT=OC::$SERVERROOT;
|
||||
$WEBROOT=OC::$WEBROOT;
|
||||
$content = "ErrorDocument 404 /$WEBROOT/core/templates/404.php\n";//custom 404 error page
|
||||
$content.= "php_value upload_max_filesize 20M\n";//upload limit
|
||||
$content.= "php_value post_max_size 20M\n";
|
||||
$content.= "SetEnv htaccessWorking true\n";
|
||||
$content.= '<IfModule mod_php5.c>';
|
||||
$content.= 'php_value upload_max_filesize 512M';//upload limit
|
||||
$content.= 'php_value post_max_size 512M';
|
||||
$content.= 'SetEnv htaccessWorking true';
|
||||
$content.= '</IfModule>';
|
||||
$content.= "Options -Indexes\n";
|
||||
@file_put_contents($SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it
|
||||
|
||||
|
|
Loading…
Reference in a new issue