From ac2e0cd6e450607585fbac2ec00a952744a4a36b Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Tue, 8 May 2012 09:07:11 +0200 Subject: [PATCH 01/18] Implement default functions in OC_User backend Simplifies calling these functions, and makes code simpler functions: deleteUser getUsers userExists --- apps/user_openid/user_openid.php | 2 +- lib/user.php | 20 ++++++---------- lib/user/backend.php | 40 +++++++++++++++++++++++++------- lib/user/example.php | 30 ------------------------ 4 files changed, 40 insertions(+), 52 deletions(-) diff --git a/apps/user_openid/user_openid.php b/apps/user_openid/user_openid.php index 8deb42f68c8..710d400aa57 100755 --- a/apps/user_openid/user_openid.php +++ b/apps/user_openid/user_openid.php @@ -24,7 +24,7 @@ require_once('class.openid.v3.php'); /** - * Class for user management in a SQL Database (e.g. MySQL, SQLite) + * Class for user OpenId backend */ class OC_USER_OPENID extends OC_User_Backend { /** diff --git a/lib/user.php b/lib/user.php index 816caff8dd8..ad5198d0374 100644 --- a/lib/user.php +++ b/lib/user.php @@ -161,9 +161,7 @@ class OC_User { if( $run ){ //delete the user from all backends foreach(self::$_usedBackends as $backend){ - if($backend->implementsActions(OC_USER_BACKEND_DELETE_USER)){ - $backend->deleteUser($uid); - } + $backend->deleteUser($uid); } // We have to delete the user from all groups foreach( OC_Group::getUserGroups( $uid ) as $i ){ @@ -323,11 +321,9 @@ class OC_User { public static function getUsers(){ $users=array(); foreach(self::$_usedBackends as $backend){ - if($backend->implementsActions(OC_USER_BACKEND_GET_USERS)){ - $backendUsers=$backend->getUsers(); - if(is_array($backendUsers)){ - $users=array_merge($users,$backendUsers); - } + $backendUsers=$backend->getUsers(); + if(is_array($backendUsers)){ + $users=array_merge($users,$backendUsers); } } return $users; @@ -340,11 +336,9 @@ class OC_User { */ public static function userExists($uid){ foreach(self::$_usedBackends as $backend){ - if($backend->implementsActions(OC_USER_BACKEND_USER_EXISTS)){ - $result=$backend->userExists($uid); - if($result===true){ - return true; - } + $result=$backend->userExists($uid); + if($result===true){ + return true; } } return false; diff --git a/lib/user/backend.php b/lib/user/backend.php index 4afdf152150..8c954338fb1 100644 --- a/lib/user/backend.php +++ b/lib/user/backend.php @@ -32,11 +32,8 @@ define('OC_USER_BACKEND_NOT_IMPLEMENTED', -501); * actions that user backends can define */ define('OC_USER_BACKEND_CREATE_USER', 0x000001); -define('OC_USER_BACKEND_DELETE_USER', 0x000010); -define('OC_USER_BACKEND_SET_PASSWORD', 0x000100); -define('OC_USER_BACKEND_CHECK_PASSWORD', 0x001000); -define('OC_USER_BACKEND_GET_USERS', 0x010000); -define('OC_USER_BACKEND_USER_EXISTS', 0x100000); +define('OC_USER_BACKEND_SET_PASSWORD', 0x000010); +define('OC_USER_BACKEND_CHECK_PASSWORD', 0x000100); /** @@ -47,11 +44,8 @@ abstract class OC_User_Backend { protected $possibleActions = array( OC_USER_BACKEND_CREATE_USER => 'createUser', - OC_USER_BACKEND_DELETE_USER => 'deleteUser', OC_USER_BACKEND_SET_PASSWORD => 'setPassword', OC_USER_BACKEND_CHECK_PASSWORD => 'checkPassword', - OC_USER_BACKEND_GET_USERS => 'getUsers', - OC_USER_BACKEND_USER_EXISTS => 'userExists' ); /** @@ -83,4 +77,34 @@ abstract class OC_User_Backend { public function implementsActions($actions){ return (bool)($this->getSupportedActions() & $actions); } + + /** + * @brief delete a user + * @param $uid The username of the user to delete + * @returns true/false + * + * Deletes a user + */ + public function deleteUser( $uid ){ + return false; + } + + /** + * @brief Get a list of all users + * @returns array with all uids + * + * Get a list of all users. + */ + public function getUsers(){ + return array(); + } + + /** + * @brief check if a user exists + * @param string $uid the username + * @return boolean + */ + public function userExists($uid){ + return false; + } } diff --git a/lib/user/example.php b/lib/user/example.php index 7481014de77..270b72e389b 100644 --- a/lib/user/example.php +++ b/lib/user/example.php @@ -39,17 +39,6 @@ abstract class OC_User_Example extends OC_User_Backend { return OC_USER_BACKEND_NOT_IMPLEMENTED; } - /** - * @brief delete a user - * @param $uid The username of the user to delete - * @returns true/false - * - * Deletes a user - */ - public function deleteUser( $uid ){ - return OC_USER_BACKEND_NOT_IMPLEMENTED; - } - /** * @brief Set password * @param $uid The username @@ -73,23 +62,4 @@ abstract class OC_User_Example extends OC_User_Backend { public function checkPassword($uid, $password){ return OC_USER_BACKEND_NOT_IMPLEMENTED; } - - /** - * @brief Get a list of all users - * @returns array with all uids - * - * Get a list of all users. - */ - public function getUsers(){ - return OC_USER_BACKEND_NOT_IMPLEMENTED; - } - - /** - * @brief check if a user exists - * @param string $uid the username - * @return boolean - */ - public function userExists($uid){ - return OC_USER_BACKEND_NOT_IMPLEMENTED; - } } From e77ba0280a0ebceef348750f5ff9738012e2b8fb Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Tue, 8 May 2012 17:46:35 +0200 Subject: [PATCH 02/18] Implement default functions in OC_Group backend Simplifies calling these functions, and makes code simpler functions: inGroup getUserGroups getGroups usersInGroup --- lib/group.php | 14 +---------- lib/group/backend.php | 58 +++++++++++++++++++++++++++++++++---------- lib/group/example.php | 7 ++++++ 3 files changed, 53 insertions(+), 26 deletions(-) diff --git a/lib/group.php b/lib/group.php index 9b2959d1f73..bc98e877ade 100644 --- a/lib/group.php +++ b/lib/group.php @@ -84,7 +84,7 @@ class OC_Group { OC_Hook::emit( "OC_Group", "pre_createGroup", array( "run" => &$run, "gid" => $gid )); if($run){ - //create the user in the first backend that supports creating users + //create the group in the first backend that supports creating groups foreach(self::$_usedBackends as $backend){ if(!$backend->implementsActions(OC_GROUP_BACKEND_CREATE_GROUP)) continue; @@ -141,9 +141,6 @@ class OC_Group { */ public static function inGroup( $uid, $gid ){ foreach(self::$_usedBackends as $backend){ - if(!$backend->implementsActions(OC_GROUP_BACKEND_IN_GROUP)) - continue; - if($backend->inGroup($uid,$gid)){ return true; } @@ -224,9 +221,6 @@ class OC_Group { public static function getUserGroups( $uid ){ $groups=array(); foreach(self::$_usedBackends as $backend){ - if(!$backend->implementsActions(OC_GROUP_BACKEND_GET_USER_GROUPS)) - continue; - $groups=array_merge($backend->getUserGroups($uid),$groups); } return $groups; @@ -241,9 +235,6 @@ class OC_Group { public static function getGroups(){ $groups=array(); foreach(self::$_usedBackends as $backend){ - if(!$backend->implementsActions(OC_GROUP_BACKEND_GET_GROUPS)) - continue; - $groups=array_merge($backend->getGroups(),$groups); } return $groups; @@ -270,9 +261,6 @@ class OC_Group { public static function usersInGroup($gid){ $users=array(); foreach(self::$_usedBackends as $backend){ - if(!$backend->implementsActions(OC_GROUP_BACKEND_GET_USERS)) - continue; - $users=array_merge($backend->usersInGroup($gid),$users); } return $users; diff --git a/lib/group/backend.php b/lib/group/backend.php index af6c53c8035..7984a6a8355 100644 --- a/lib/group/backend.php +++ b/lib/group/backend.php @@ -31,12 +31,8 @@ define('OC_GROUP_BACKEND_NOT_IMPLEMENTED', -501); */ define('OC_GROUP_BACKEND_CREATE_GROUP', 0x00000001); define('OC_GROUP_BACKEND_DELETE_GROUP', 0x00000010); -define('OC_GROUP_BACKEND_IN_GROUP', 0x00000100); -define('OC_GROUP_BACKEND_ADD_TO_GROUP', 0x00001000); -define('OC_GROUP_BACKEND_REMOVE_FROM_GOUP', 0x00010000); -define('OC_GROUP_BACKEND_GET_USER_GROUPS', 0x00100000); -define('OC_GROUP_BACKEND_GET_USERS', 0x01000000); -define('OC_GROUP_BACKEND_GET_GROUPS', 0x10000000); +define('OC_GROUP_BACKEND_ADD_TO_GROUP', 0x00000100); +define('OC_GROUP_BACKEND_REMOVE_FROM_GOUP', 0x00001000); /** * Abstract base class for user management @@ -45,12 +41,8 @@ abstract class OC_Group_Backend { protected $possibleActions = array( OC_GROUP_BACKEND_CREATE_GROUP => 'createGroup', OC_GROUP_BACKEND_DELETE_GROUP => 'deleteGroup', - OC_GROUP_BACKEND_IN_GROUP => 'inGroup', OC_GROUP_BACKEND_ADD_TO_GROUP => 'addToGroup', OC_GROUP_BACKEND_REMOVE_FROM_GOUP => 'removeFromGroup', - OC_GROUP_BACKEND_GET_USER_GROUPS => 'getUserGroups', - OC_GROUP_BACKEND_GET_USERS => 'usersInGroup', - OC_GROUP_BACKEND_GET_GROUPS => 'getGroups' ); /** @@ -83,15 +75,55 @@ abstract class OC_Group_Backend { return (bool)($this->getSupportedActions() & $actions); } + /** + * @brief is user in group? + * @param $uid uid of the user + * @param $gid gid of the group + * @returns true/false + * + * Checks whether the user is member of a group or not. + */ + public static function inGroup($uid, $gid){ + return in_array($gid, $this->getUserGroups($uid)); + } + + /** + * @brief Get all groups a user belongs to + * @param $uid Name of the user + * @returns array with group names + * + * This function fetches all groups a user belongs to. It does not check + * if the user exists at all. + */ + public static function getUserGroups($uid){ + return array(); + } + + /** + * @brief get a list of all groups + * @returns array with group names + * + * Returns a list with all groups + */ + public static function getGroups(){ + return array(); + } + /** * check if a group exists * @param string $gid * @return bool */ public function groupExists($gid){ - if(!$this->implementsActions(OC_GROUP_BACKEND_GET_GROUPS)){ - return false; - } return in_array($gid, $this->getGroups()); } + + /** + * @brief get a list of all users in a group + * @returns array with user ids + */ + public static function usersInGroup($gid){ + return array(); + } + } diff --git a/lib/group/example.php b/lib/group/example.php index a88159f91be..11a14b5e785 100644 --- a/lib/group/example.php +++ b/lib/group/example.php @@ -93,6 +93,13 @@ abstract class OC_Group_Example { */ public static function getGroups(){} + /** + * check if a group exists + * @param string $gid + * @return bool + */ + public function groupExists($gid){} + /** * @brief get a list of all users in a group * @returns array with user ids From b022ccb86371e774b63a8000f7ea2207c2da225e Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Wed, 9 May 2012 17:40:59 +0200 Subject: [PATCH 03/18] Whitespace fixes --- apps/gallery/js/album_cover.js | 16 ++++++++-------- apps/gallery/lib/album.php | 26 ++++++++++++-------------- lib/files.php | 4 ++-- lib/util.php | 3 +-- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/apps/gallery/js/album_cover.js b/apps/gallery/js/album_cover.js index d1809462f2f..905034f6fd1 100644 --- a/apps/gallery/js/album_cover.js +++ b/apps/gallery/js/album_cover.js @@ -78,14 +78,14 @@ function albumClickHandler(r) { for (var i in r.photos) { Albums.photos.push(r.photos[i]); } - Albums.shared = r.shared; - if (Albums.shared) { - Albums.recursive = r.recursive; - Albums.token = r.token; - } else { - Albums.recursive = false; - Albums.token = ''; - } + Albums.shared = r.shared; + if (Albums.shared) { + Albums.recursive = r.recursive; + Albums.token = r.token; + } else { + Albums.recursive = false; + Albums.token = ''; + } $(document).ready(function(){ var targetDiv = $('#gallery_list'); targetDiv.html(''); diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php index 27d40cdb91f..ac6cacbe01f 100755 --- a/apps/gallery/lib/album.php +++ b/apps/gallery/lib/album.php @@ -79,7 +79,7 @@ class OC_Gallery_Album { $sql .= ' AND parent_path = ?'; $args[] = $parent; } - $order = OCP\Config::getUserValue($owner, 'gallery', 'order', 'ASC'); + $order = OCP\Config::getUserValue($owner, 'gallery', 'order', 'ASC'); $sql .= ' ORDER BY album_name ' . $order; $stmt = OCP\DB::prepare($sql); @@ -98,19 +98,17 @@ class OC_Gallery_Album { } public static function getAlbumSize($id){ - $sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos WHERE album_id = ?'; - $stmt = OCP\DB::prepare($sql); - $result=$stmt->execute(array($id))->fetchRow(); - return $result['size']; + $sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos WHERE album_id = ?'; + $stmt = OCP\DB::prepare($sql); + $result=$stmt->execute(array($id))->fetchRow(); + return $result['size']; } - public static function getIntermediateGallerySize($path) { - $path .= '%'; - $sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos photos, *PREFIX*gallery_albums albums WHERE photos.album_id = albums.album_id AND uid_owner = ? AND file_path LIKE ?'; - $stmt = OCP\DB::prepare($sql); - $result = $stmt->execute(array(OCP\USER::getUser(), $path))->fetchRow(); - return $result['size']; - } + public static function getIntermediateGallerySize($path) { + $path .= '%'; + $sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos photos, *PREFIX*gallery_albums albums WHERE photos.album_id = albums.album_id AND uid_owner = ? AND file_path LIKE ?'; + $stmt = OCP\DB::prepare($sql); + $result = $stmt->execute(array(OCP\USER::getUser(), $path))->fetchRow(); + return $result['size']; + } } - -?> diff --git a/lib/files.php b/lib/files.php index 5d4d73630eb..d837bf7aa2c 100644 --- a/lib/files.php +++ b/lib/files.php @@ -32,11 +32,11 @@ class OC_Files { * get the content of a directory * @param dir $directory */ - public static function getDirectoryContent($directory, $mimetype_filter = ''){ + public static function getDirectoryContent($directory, $mimetype_filter = ''){ if(strpos($directory,OC::$CONFIG_DATADIRECTORY)===0){ $directory=substr($directory,strlen(OC::$CONFIG_DATADIRECTORY)); } - $files=OC_FileCache::getFolderContent($directory, '', $mimetype_filter); + $files=OC_FileCache::getFolderContent($directory, '', $mimetype_filter); foreach($files as &$file){ $file['directory']=$directory; $file['type']=($file['mimetype']=='httpd/unix-directory')?'dir':'file'; diff --git a/lib/util.php b/lib/util.php index e4546d6ac3d..ff117998713 100644 --- a/lib/util.php +++ b/lib/util.php @@ -31,7 +31,7 @@ class OC_Util { // Create root dir. if(!is_dir($CONFIG_DATADIRECTORY_ROOT)){ $success=@mkdir($CONFIG_DATADIRECTORY_ROOT); - if(!$success) { + if(!$success) { $tmpl = new OC_Template( '', 'error', 'guest' ); $tmpl->assign('errors',array(1=>array('error'=>"Can't create data directory (".$CONFIG_DATADIRECTORY_ROOT.")",'hint'=>"You can usually fix this by giving the webserver write access to the ownCloud directory '".OC::$SERVERROOT."' (in a terminal, use the command 'chown -R www-data:www-data /path/to/your/owncloud/install/data' "))); $tmpl->printPage(); @@ -50,7 +50,6 @@ class OC_Util { self::$rootMounted=true; } if( $user != "" ){ //if we aren't logged in, there is no use to set up the filesystem - OC::$CONFIG_DATADIRECTORY = $CONFIG_DATADIRECTORY_ROOT."/$user/$root"; if( !is_dir( OC::$CONFIG_DATADIRECTORY )){ mkdir( OC::$CONFIG_DATADIRECTORY, 0755, true ); From c2230580c14b08877210a9c0bcfe6f4b0a806bf5 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Wed, 9 May 2012 17:41:44 +0200 Subject: [PATCH 04/18] Remove unused OC static variable CONFIG_DATADIRECTORY_ROOT --- lib/base.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/base.php b/lib/base.php index 14f2439ecbd..e7ca51740c6 100644 --- a/lib/base.php +++ b/lib/base.php @@ -50,10 +50,6 @@ class OC{ * the folder that stores that data files for the filesystem of the user (e.g. /srv/http/owncloud/data/myusername/files) */ public static $CONFIG_DATADIRECTORY = ''; - /** - * the folder that stores the data for the root filesystem (e.g. /srv/http/owncloud/data) - */ - public static $CONFIG_DATADIRECTORY_ROOT = ''; /** * The installation path of the 3rdparty folder on the server (e.g. /srv/http/owncloud/3rdparty) */ From 9a66b869c0db189338ccf0333183108bf81a7786 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Wed, 9 May 2012 22:47:57 +0200 Subject: [PATCH 05/18] Gallery: Use App storage instead of contructing our own path --- apps/gallery/ajax/galleryOp.php | 3 ++- apps/gallery/ajax/sharing.php | 6 ++++-- apps/gallery/index.php | 4 ---- apps/gallery/lib/album.php | 5 ++--- apps/gallery/lib/photo.php | 20 ++++++++++---------- apps/gallery/lib/scanner.php | 3 ++- 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/apps/gallery/ajax/galleryOp.php b/apps/gallery/ajax/galleryOp.php index 0cd825f3e50..b49e52f0bd2 100755 --- a/apps/gallery/ajax/galleryOp.php +++ b/apps/gallery/ajax/galleryOp.php @@ -42,7 +42,8 @@ function handleRemove($name) { function handleGetThumbnails($albumname) { OCP\Response::enableCaching(3600 * 24); // 24 hour - $thumbnail = OC::$CONFIG_DATADIRECTORY.'/../gallery/'.urldecode($albumname).'.png'; + $view = OCP\App::getStorage('gallery'); + $thumbnail = $view->fopen(urldecode($albumname).'.png', 'r'); header('Content-Type: '.OC_Image::getMimeTypeForFile($thumbnail)); OCP\Response::sendFile($thumbnail); } diff --git a/apps/gallery/ajax/sharing.php b/apps/gallery/ajax/sharing.php index 1223320120b..304757b9e91 100755 --- a/apps/gallery/ajax/sharing.php +++ b/apps/gallery/ajax/sharing.php @@ -80,7 +80,8 @@ function handleGetThumbnail($token, $imgpath) { function handleGetAlbumThumbnail($token, $albumname) { $owner = OC_Gallery_Sharing::getTokenOwner($token); - $file = OCP\Config::getSystemValue("datadirectory").'/'. $owner .'/gallery/'.$albumname.'.png'; + $view = OCP\App::getStorage('gallery'); + $file = $view->fopen($albumname.'.png', 'r'); $image = new OC_Image($file); if ($image->valid()) { $image->centerCrop(); @@ -93,7 +94,8 @@ function handleGetAlbumThumbnail($token, $albumname) function handleGetPhoto($token, $photo) { $owner = OC_Gallery_Sharing::getTokenOwner($token); - $file = OCP\Config::getSystemValue( "datadirectory", OC::$SERVERROOT."/data" ).'/'.$owner.'/files'.urldecode($photo); + $view = OCP\App::getStorage('files'); + $file = $view->fopen(urldecode($photo), 'r'); header('Content-Type: '.OC_Image::getMimeTypeForFile($file)); OCP\Response::sendFile($file); } diff --git a/apps/gallery/index.php b/apps/gallery/index.php index e47fb3db5d6..a9fe200c4e4 100755 --- a/apps/gallery/index.php +++ b/apps/gallery/index.php @@ -27,10 +27,6 @@ OCP\User::checkLoggedIn(); OCP\App::checkAppEnabled('gallery'); OCP\App::setActiveNavigationEntry( 'gallery_index' ); -if (!file_exists(OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery')) { - mkdir(OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery'); -} - if (!isset($_GET['view'])) { $result = OC_Gallery_Album::find(OCP\USER::getUser()); diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php index ac6cacbe01f..7b9036742a6 100755 --- a/apps/gallery/lib/album.php +++ b/apps/gallery/lib/album.php @@ -92,9 +92,8 @@ class OC_Gallery_Album { } public static function changeThumbnailPath($oldname, $newname) { - - $thumbpath = OC::$CONFIG_DATADIRECTORY.'/../gallery/'; - rename($thumbpath.$oldname.'.png', $thumbpath.$newname.'.png'); + $view = OCP\App::getStorage('gallery'); + $view->rename($oldname.'.png', $newname.'.png'); } public static function getAlbumSize($id){ diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php index 99384af621a..b4b37236b0e 100755 --- a/apps/gallery/lib/photo.php +++ b/apps/gallery/lib/photo.php @@ -68,17 +68,17 @@ class OC_Gallery_Photo { public static function getThumbnail($image_name, $owner = null) { if (!$owner) $owner = OCP\USER::getUser(); - $save_dir = OCP\Config::getSystemValue("datadirectory").'/'. $owner .'/gallery/'; - $save_dir .= dirname($image_name). '/'; - $image_path = $image_name; - $thumb_file = $save_dir . basename($image_name); - if (!is_dir($save_dir)) { - mkdir($save_dir, 0777, true); + $view = OCP\App::getStorage('gallery'); + $save_dir = dirname($image_name); + if (!$view->is_dir($save_dir)) { + $view->mkdir($save_dir); } - if (file_exists($thumb_file)) { - $image = new OC_Image($thumb_file); + $view->chroot($view->getRoot().'/'.$save_dir); + $thumb_file = basename($image_name); + if ($view->file_exists($thumb_file)) { + $image = new OC_Image($view->fopen($thumb_file, 'r')); } else { - $image_path = OC_Filesystem::getLocalFile($image_path); + $image_path = OC_Filesystem::getLocalFile($image_name); if(!file_exists($image_path)) { return null; } @@ -86,7 +86,7 @@ class OC_Gallery_Photo { if ($image->valid()) { $image->centerCrop(200); $image->fixOrientation(); - $image->save($thumb_file); + $image->save($view->getLocalFile($thumb_file)); } } if ($image->valid()) { diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php index 7a137cb3f50..e11ba1da454 100755 --- a/apps/gallery/lib/scanner.php +++ b/apps/gallery/lib/scanner.php @@ -81,7 +81,8 @@ class OC_Gallery_Scanner { $image->destroy(); } } - imagepng($thumbnail, OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery/' . $albumName.'.png'); + $view = OCP\App::getStorage('gallery'); + imagepng($thumbnail, $view->getLocalFile($albumName.'.png')); imagedestroy($thumbnail); } From 97233b77cd0cfb7671e8914fd047642988ea425b Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 11 May 2012 21:31:51 +0200 Subject: [PATCH 06/18] Remove DOCUMENTROOT static var, and make SUBURI var private --- lib/base.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/base.php b/lib/base.php index e7ca51740c6..f01e1f5be6c 100644 --- a/lib/base.php +++ b/lib/base.php @@ -30,10 +30,6 @@ class OC{ * Assoziative array for autoloading. classname => filename */ public static $CLASSPATH = array(); - /** - * $_SERVER['DOCUMENTROOT'] but without symlinks - */ - public static $DOCUMENTROOT = ''; /** * The installation path for owncloud on the server (e.g. /srv/http/owncloud) */ @@ -41,7 +37,7 @@ class OC{ /** * the current request path relative to the owncloud root (e.g. files/index.php) */ - public static $SUBURI = ''; + private static $SUBURI = ''; /** * the owncloud root path for http requests (e.g. owncloud/) */ @@ -122,7 +118,7 @@ class OC{ public static function initPaths(){ // calculate the documentroot - OC::$DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']); + $DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']); OC::$SERVERROOT=str_replace("\\",'/',substr(__FILE__,0,-13)); OC::$SUBURI=substr(realpath($_SERVER["SCRIPT_FILENAME"]),strlen(OC::$SERVERROOT)); $scriptName=$_SERVER["SCRIPT_NAME"]; @@ -138,7 +134,7 @@ class OC{ } OC::$WEBROOT=substr($scriptName,0,strlen($scriptName)-strlen(OC::$SUBURI)); // try a new way to detect the WEBROOT which is simpler and also works with the app directory outside the owncloud folder. let´s see if this works for everybody -// OC::$WEBROOT=substr(OC::$SERVERROOT,strlen(OC::$DOCUMENTROOT)); +// OC::$WEBROOT=substr(OC::$SERVERROOT,strlen($DOCUMENTROOT)); if(OC::$WEBROOT!='' and OC::$WEBROOT[0]!=='/'){ From 2ad6b5048e05fd5c28600845bbabde3a3f4537f7 Mon Sep 17 00:00:00 2001 From: Sam Tuke Date: Tue, 15 May 2012 16:24:06 +0100 Subject: [PATCH 07/18] fixed 'delete' label so it doesn't break translations --- apps/files/templates/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 72e45d53275..1308645746e 100755 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -53,7 +53,7 @@ t( 'Size' ); ?> - t( 'Modified' ); ?>t('Delete all')?> <?php echo $l->t('Delete')?>" /> + t( 'Modified' ); ?>t('Delete')?> <?php echo $l->t('Delete')?>" /> From a00c5ac78ccbd581ba043d173d3f85aaf21b03dd Mon Sep 17 00:00:00 2001 From: Sam Tuke Date: Fri, 11 May 2012 13:17:37 +0100 Subject: [PATCH 08/18] fixed some include path issues imroved wording of history page revert instructions cleaned up js call to ajax getVersions.php --- apps/files_versions/ajax/getVersions.php | 36 +++-------------- apps/files_versions/appinfo/app.php | 3 -- apps/files_versions/js/versions.js | 47 +++++++++-------------- apps/files_versions/templates/history.php | 2 +- 4 files changed, 25 insertions(+), 63 deletions(-) diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php index 5949c32ed16..8ef17d5a25c 100755 --- a/apps/files_versions/ajax/getVersions.php +++ b/apps/files_versions/ajax/getVersions.php @@ -1,8 +1,10 @@ diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js index 0508ab4cdec..2c92dfa3c65 100644 --- a/apps/files_versions/js/versions.js +++ b/apps/files_versions/js/versions.js @@ -14,28 +14,17 @@ $(document).ready(function(){ FileActions.register('file','History',function(){return OC.imagePath('core','actions/history')},function(filename){ if (scanFiles.scanning){return;}//workaround to prevent additional http request block scanning feedback - + var file = $('#dir').val()+'/'+filename; createVersionsDropdown(filename, file) - $.ajax({ - type: 'GET', - url: OC.linkTo('files_versions', 'ajax/getVersions.php'), - dataType: 'json', - data: {source: file}, - async: false, - success: function(versions) { - if (versions) { - } - } - }); - }); } }); function createVersionsDropdown(filename, files) { + var historyUrl = '../apps/files_versions/history.php?path='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); var html = '