diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-08-15 17:39:00 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-08-15 17:39:00 +0200 |
commit | 63af75586b53391670c2ccfb48d19f4b6950cab0 (patch) | |
tree | fa5a16539431673c9f51e54bb313ed69a30c60b6 /lib | |
parent | 4954e46bb2ba36c749b638111dc90500e12cedf7 (diff) | |
parent | dd3208fe6fadff3ad831df2fa5220e2184738b21 (diff) | |
download | nextcloud-server-63af75586b53391670c2ccfb48d19f4b6950cab0.tar.gz nextcloud-server-63af75586b53391670c2ccfb48d19f4b6950cab0.zip |
Merge branch 'master' into routing
Diffstat (limited to 'lib')
-rw-r--r-- | lib/backgroundjob/queuedtask.php | 4 | ||||
-rw-r--r-- | lib/base.php | 39 | ||||
-rw-r--r-- | lib/filesystem.php | 43 | ||||
-rw-r--r-- | lib/filesystemview.php | 12 | ||||
-rw-r--r-- | lib/group.php | 19 | ||||
-rw-r--r-- | lib/group/backend.php | 4 | ||||
-rw-r--r-- | lib/group/database.php | 32 | ||||
-rw-r--r-- | lib/group/dummy.php | 4 | ||||
-rw-r--r-- | lib/group/example.php | 4 | ||||
-rw-r--r-- | lib/group/interface.php | 4 | ||||
-rw-r--r-- | lib/l10n/th_TH.php | 25 | ||||
-rw-r--r-- | lib/migrate.php | 2 | ||||
-rw-r--r-- | lib/public/backgroundjob.php | 4 | ||||
-rw-r--r-- | lib/public/user.php | 2 | ||||
-rw-r--r-- | lib/user.php | 12 | ||||
-rw-r--r-- | lib/user/backend.php | 2 | ||||
-rw-r--r-- | lib/user/database.php | 17 | ||||
-rw-r--r-- | lib/user/dummy.php | 2 | ||||
-rw-r--r-- | lib/user/interface.php | 2 | ||||
-rwxr-xr-x | lib/util.php | 2 |
20 files changed, 155 insertions, 80 deletions
diff --git a/lib/backgroundjob/queuedtask.php b/lib/backgroundjob/queuedtask.php index da5d4ddc694..68ba97c1e39 100644 --- a/lib/backgroundjob/queuedtask.php +++ b/lib/backgroundjob/queuedtask.php @@ -81,9 +81,9 @@ class OC_BackgroundJob_QueuedTask{ * @param $parameters all useful data as text * @return id of task */ - public static function add( $task, $klass, $method, $parameters ){ + public static function add( $app, $klass, $method, $parameters ){ $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*queuedtasks (app, klass, method, parameters) VALUES(?,?,?,?)' ); - $result = $stmt->execute(array($app, $klass, $method, $parameters, time)); + $result = $stmt->execute(array($app, $klass, $method, $parameters )); return OC_DB::insertid(); } diff --git a/lib/base.php b/lib/base.php index 3abfdb35668..fb49e9e6706 100644 --- a/lib/base.php +++ b/lib/base.php @@ -180,25 +180,11 @@ class OC{ public static function checkInstalled() { // Redirect to installer if not installed - if (!OC_Config::getValue('installed', false)) { - if (OC::$SUBURI != '/index.php') { - if(!OC::$CLI){ - $url = 'http://'.$_SERVER['SERVER_NAME'].OC::$WEBROOT.'/index.php'; - header("Location: $url"); - } - exit(); - } - // Check for autosetup: - $autosetup_file = OC::$SERVERROOT."/config/autoconfig.php"; - if( file_exists( $autosetup_file )){ - OC_Log::write('core','Autoconfig file found, setting up owncloud...', OC_Log::INFO); - include( $autosetup_file ); - $_POST['install'] = 'true'; - $_POST = array_merge ($_POST, $AUTOCONFIG); - unlink($autosetup_file); + if (!OC_Config::getValue('installed', false) && OC::$SUBURI != '/index.php') { + if(!OC::$CLI){ + $url = 'http://'.$_SERVER['SERVER_NAME'].OC::$WEBROOT.'/index.php'; + header("Location: $url"); } - OC_Util::addScript('setup'); - require_once('setup.php'); exit(); } } @@ -344,10 +330,10 @@ class OC{ stream_wrapper_register('static', 'OC_StaticStreamWrapper'); stream_wrapper_register('close', 'OC_CloseStreamWrapper'); - self::initTemplateEngine(); self::checkInstalled(); self::checkSSL(); self::initSession(); + self::initTemplateEngine(); self::checkUpgrade(); $errors=OC_Util::checkServer(); @@ -378,6 +364,7 @@ class OC{ // Check for blacklisted files OC_Hook::connect('OC_Filesystem','write','OC_Filesystem','isBlacklisted'); + OC_Hook::connect('OC_Filesystem', 'rename', 'OC_Filesystem', 'isBlacklisted'); //make sure temporary files are cleaned up register_shutdown_function(array('OC_Helper','cleanTmp')); @@ -416,6 +403,20 @@ class OC{ * @brief Handle the request */ public static function handleRequest() { + if (!OC_Config::getValue('installed', false)) { + // Check for autosetup: + $autosetup_file = OC::$SERVERROOT."/config/autoconfig.php"; + if( file_exists( $autosetup_file )){ + OC_Log::write('core','Autoconfig file found, setting up owncloud...',OC_Log::INFO); + include( $autosetup_file ); + $_POST['install'] = 'true'; + $_POST = array_merge ($_POST, $AUTOCONFIG); + unlink($autosetup_file); + } + OC_Util::addScript('setup'); + require_once('setup.php'); + exit(); + } // Handle WebDAV if($_SERVER['REQUEST_METHOD']=='PROPFIND'){ header('location: '.OC_Helper::linkToRemote('webdav')); diff --git a/lib/filesystem.php b/lib/filesystem.php index 47626c05ae2..6cba6b1b547 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -273,7 +273,12 @@ class OC_Filesystem{ */ static private function createStorage($class,$arguments){ if(class_exists($class)){ - return new $class($arguments); + try { + return new $class($arguments); + } catch (Exception $exception) { + OC_Log::write('core', $exception->getMessage(), OC_Log::ERROR); + return false; + } }else{ OC_Log::write('core','storage backend '.$class.' not found',OC_Log::ERROR); return false; @@ -363,13 +368,21 @@ class OC_Filesystem{ /** * checks if a file is blacklsited for storage in the filesystem + * Listens to write and rename hooks * @param array $data from hook */ static public function isBlacklisted($data){ $blacklist = array('.htaccess'); - $filename = strtolower(basename($data['path'])); - if(in_array($filename,$blacklist)){ - $data['run'] = false; + if (isset($data['path'])) { + $path = $data['path']; + } else if (isset($data['newpath'])) { + $path = $data['newpath']; + } + if (isset($path)) { + $filename = strtolower(basename($path)); + if (in_array($filename, $blacklist)) { + $data['run'] = false; + } } } @@ -481,6 +494,28 @@ class OC_Filesystem{ } OC_Connector_Sabre_Node::removeETagPropertyForPath($path); } + + public static function normalizePath($path){ + //no windows style slashes + $path=str_replace('\\','/',$path); + //add leading slash + if($path[0]!=='/'){ + $path='/'.$path; + } + //remove trainling slash + if(strlen($path)>1 and substr($path,-1,1)==='/'){ + $path=substr($path,0,-1); + } + //remove duplicate slashes + while(strpos($path,'//')!==false){ + $path=str_replace('//','/',$path); + } + //normalize unicode if possible + if(class_exists('Normalizer')){ + $path=Normalizer::normalize($path); + } + return $path; + } } OC_Hook::connect('OC_Filesystem','post_write', 'OC_Filesystem','removeETagHook'); OC_Hook::connect('OC_Filesystem','post_delete','OC_Filesystem','removeETagHook'); diff --git a/lib/filesystemview.php b/lib/filesystemview.php index faf3f0bd4cc..9d85befdc8c 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -54,10 +54,9 @@ class OC_FilesystemView { if($path[0]!=='/'){ $path='/'.$path; } - return $this->fakeRoot.$path; + return OC_Filesystem::normalizePath($this->fakeRoot.$path); } - - + /** * change the root to a fake toor * @param string fakeRoot @@ -104,7 +103,12 @@ class OC_FilesystemView { if(strpos($path, $this->fakeRoot)!==0) { return null; }else{ - return substr($path, strlen($this->fakeRoot)); + $path=substr($path, strlen($this->fakeRoot)); + if(strlen($path)===0){ + return '/'; + }else{ + return $path; + } } } diff --git a/lib/group.php b/lib/group.php index 7b137f0f8f1..72cf5dc89af 100644 --- a/lib/group.php +++ b/lib/group.php @@ -237,10 +237,10 @@ class OC_Group { * * Returns a list with all groups */ - public static function getGroups(){ - $groups=array(); - foreach(self::$_usedBackends as $backend){ - $groups=array_merge($backend->getGroups(),$groups); + public static function getGroups($search = '', $limit = -1, $offset = 0) { + $groups = array(); + foreach (self::$_usedBackends as $backend) { + $groups = array_merge($backend->getGroups($search, $limit, $offset), $groups); } asort($groups); return $groups; @@ -264,10 +264,10 @@ class OC_Group { * @brief get a list of all users in a group * @returns array with user ids */ - public static function usersInGroup($gid){ + public static function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) { $users=array(); foreach(self::$_usedBackends as $backend){ - $users=array_merge($backend->usersInGroup($gid),$users); + $users = array_merge($backend->usersInGroup($gid, $search, $limit, $offset), $users); } return $users; } @@ -277,10 +277,11 @@ class OC_Group { * @param array $gids * @returns array with user ids */ - public static function usersInGroups($gids){ + public static function usersInGroups($gids, $search = '', $limit = -1, $offset = 0) { $users = array(); - foreach($gids as $gid){ - $users = array_merge(array_diff(self::usersInGroup($gid), $users), $users); + foreach ($gids as $gid) { + // TODO Need to apply limits to groups as total + $users = array_merge(array_diff(self::usersInGroup($gid, $search, $limit, $offset), $users), $users); } return $users; } diff --git a/lib/group/backend.php b/lib/group/backend.php index ebc078f152a..4c7d09bcb16 100644 --- a/lib/group/backend.php +++ b/lib/group/backend.php @@ -105,7 +105,7 @@ abstract class OC_Group_Backend implements OC_Group_Interface { * * Returns a list with all groups */ - public function getGroups(){ + public function getGroups($search = '', $limit = -1, $offset = 0) { return array(); } @@ -122,7 +122,7 @@ abstract class OC_Group_Backend implements OC_Group_Interface { * @brief get a list of all users in a group * @returns array with user ids */ - public function usersInGroup($gid){ + public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) { return array(); } diff --git a/lib/group/database.php b/lib/group/database.php index 2770ec185c4..1cb4171f49f 100644 --- a/lib/group/database.php +++ b/lib/group/database.php @@ -164,15 +164,17 @@ class OC_Group_Database extends OC_Group_Backend { * * Returns a list with all groups */ - public function getGroups(){ - $query = OC_DB::prepare( "SELECT gid FROM `*PREFIX*groups`" ); - $result = $query->execute(); - + public function getGroups($search = '', $limit = -1, $offset = 0) { + if ($limit == -1) { + $query = OC_DB::prepare('SELECT gid FROM *PREFIX*groups WHERE gid LIKE ?'); + } else { + $query = OC_DB::prepare('SELECT gid FROM *PREFIX*groups WHERE gid LIKE ? LIMIT '.$limit.' OFFSET '.$offset); + } + $result = $query->execute(array($search.'%')); $groups = array(); - while( $row = $result->fetchRow()){ - $groups[] = $row["gid"]; + while ($row = $result->fetchRow()) { + $groups[] = $row['gid']; } - return $groups; } @@ -180,12 +182,16 @@ class OC_Group_Database extends OC_Group_Backend { * @brief get a list of all users in a group * @returns array with user ids */ - public function usersInGroup($gid){ - $query=OC_DB::prepare('SELECT uid FROM *PREFIX*group_user WHERE gid=?'); - $users=array(); - $result=$query->execute(array($gid)); - while($row=$result->fetchRow()){ - $users[]=$row['uid']; + public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) { + if ($limit == -1) { + $query = OC_DB::prepare('SELECT uid FROM *PREFIX*group_user WHERE gid = ? AND uid LIKE ?'); + } else { + $query = OC_DB::prepare('SELECT uid FROM *PREFIX*group_user WHERE gid = ? AND uid LIKE ? LIMIT '.$limit.' OFFSET '.$offset); + } + $result = $query->execute(array($gid, $search.'%')); + $users = array(); + while ($row = $result->fetchRow()) { + $users[] = $row['uid']; } return $users; } diff --git a/lib/group/dummy.php b/lib/group/dummy.php index 1243891023f..51eca28f3f4 100644 --- a/lib/group/dummy.php +++ b/lib/group/dummy.php @@ -141,7 +141,7 @@ class OC_Group_Dummy extends OC_Group_Backend { * * Returns a list with all groups */ - public function getGroups(){ + public function getGroups($search = '', $limit = -1, $offset = 0) { return array_keys($this->groups); } @@ -149,7 +149,7 @@ class OC_Group_Dummy extends OC_Group_Backend { * @brief get a list of all users in a group * @returns array with user ids */ - public function usersInGroup($gid){ + public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) { if(isset($this->groups[$gid])){ return $this->groups[$gid]; }else{ diff --git a/lib/group/example.php b/lib/group/example.php index 9c9ece5ac77..76d12629763 100644 --- a/lib/group/example.php +++ b/lib/group/example.php @@ -91,7 +91,7 @@ abstract class OC_Group_Example { * * Returns a list with all groups */ - abstract public static function getGroups(); + abstract public static function getGroups($search = '', $limit = -1, $offset = 0); /** * check if a group exists @@ -104,6 +104,6 @@ abstract class OC_Group_Example { * @brief get a list of all users in a group * @returns array with user ids */ - abstract public static function usersInGroup($gid); + abstract public static function usersInGroup($gid, $search = '', $limit = -1, $offset = 0); } diff --git a/lib/group/interface.php b/lib/group/interface.php index 7cca6061e10..12cc07a5374 100644 --- a/lib/group/interface.php +++ b/lib/group/interface.php @@ -58,7 +58,7 @@ interface OC_Group_Interface { * * Returns a list with all groups */ - public function getGroups(); + public function getGroups($search = '', $limit = -1, $offset = 0); /** * check if a group exists @@ -71,6 +71,6 @@ interface OC_Group_Interface { * @brief get a list of all users in a group * @returns array with user ids */ - public function usersInGroup($gid); + public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0); }
\ No newline at end of file diff --git a/lib/l10n/th_TH.php b/lib/l10n/th_TH.php new file mode 100644 index 00000000000..cb2610fa204 --- /dev/null +++ b/lib/l10n/th_TH.php @@ -0,0 +1,25 @@ +<?php $TRANSLATIONS = array( +"Help" => "ช่วยเหลือ", +"Personal" => "ส่วนตัว", +"Settings" => "ตั้งค่า", +"Users" => "ผู้ใช้งาน", +"Apps" => "แอปฯ", +"Admin" => "ผู้ดูแล", +"ZIP download is turned off." => "คุณสมบัติการดาวน์โหลด zip ถูกปิดการใช้งานไว้", +"Files need to be downloaded one by one." => "ไฟล์สามารถดาวน์โหลดได้ทีละครั้งเท่านั้น", +"Back to Files" => "กลับไปที่ไฟล์", +"Selected files too large to generate zip file." => "ไฟล์ที่เลือกมีขนาดใหญ่เกินกว่าที่จะสร้างเป็นไฟล์ zip", +"Application is not enabled" => "แอพพลิเคชั่นดังกล่าวยังไม่ได้เปิดใช้งาน", +"Authentication error" => "เกิดข้อผิดพลาดในสิทธิ์การเข้าใช้งาน", +"Token expired. Please reload page." => "รหัสยืนยันความถูกต้องหมดอายุแล้ว กรุณาโหลดหน้าเว็บใหม่อีกครั้ง", +"seconds ago" => "วินาทีที่ผ่านมา", +"1 minute ago" => "1 นาทีมาแล้ว", +"%d minutes ago" => "%d นาทีที่ผ่านมา", +"today" => "วันนี้", +"yesterday" => "เมื่อวานนี้", +"%d days ago" => "%d วันที่ผ่านมา", +"last month" => "เดือนที่แล้ว", +"months ago" => "เดือนมาแล้ว", +"last year" => "ปีที่แล้ว", +"years ago" => "ปีที่ผ่านมา" +); diff --git a/lib/migrate.php b/lib/migrate.php index 1b6367ed6ec..917d77eaca0 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -322,7 +322,7 @@ class OC_Migrate{ $objects = scandir( $path ); if( sizeof( $objects ) > 0 ){ foreach( $objects as $file ){ - if( $file == "." || $file == ".." ) + if( $file == "." || $file == ".." || $file == ".htaccess") continue; // go on if( is_dir( $path . '/' . $file ) ){ diff --git a/lib/public/backgroundjob.php b/lib/public/backgroundjob.php index 72f4557eb1a..834bebb5c3c 100644 --- a/lib/public/backgroundjob.php +++ b/lib/public/backgroundjob.php @@ -100,8 +100,8 @@ class BackgroundJob { * @param $parameters all useful data as text * @return id of task */ - public static function addQueuedTask( $task, $klass, $method, $parameters ){ - return \OC_BackgroundJob_QueuedTask::add( $task, $klass, $method, $parameters ); + public static function addQueuedTask( $app, $klass, $method, $parameters ){ + return \OC_BackgroundJob_QueuedTask::add( $app, $klass, $method, $parameters ); } /** diff --git a/lib/public/user.php b/lib/public/user.php index 713e366b968..2fa599488a7 100644 --- a/lib/public/user.php +++ b/lib/public/user.php @@ -51,7 +51,7 @@ class User { * * Get a list of all users. */ - public static function getUsers(){ + public static function getUsers($search = '', $limit = -1, $offset = 0) { return \OC_USER::getUsers(); } diff --git a/lib/user.php b/lib/user.php index 49a0a2a10ce..cbd1400844d 100644 --- a/lib/user.php +++ b/lib/user.php @@ -338,12 +338,12 @@ class OC_User { * * Get a list of all users. */ - public static function getUsers(){ - $users=array(); - foreach(self::$_usedBackends as $backend){ - $backendUsers=$backend->getUsers(); - if(is_array($backendUsers)){ - $users=array_merge($users,$backendUsers); + public static function getUsers($search = '', $limit = -1, $offset = 0) { + $users = array(); + foreach (self::$_usedBackends as $backend) { + $backendUsers = $backend->getUsers($search, $limit, $offset); + if (is_array($backendUsers)) { + $users = array_merge($users, $backendUsers); } } asort($users); diff --git a/lib/user/backend.php b/lib/user/backend.php index daa942d261c..f67908cdac0 100644 --- a/lib/user/backend.php +++ b/lib/user/backend.php @@ -97,7 +97,7 @@ abstract class OC_User_Backend implements OC_User_Interface { * * Get a list of all users. */ - public function getUsers(){ + public function getUsers($search = '', $limit = -1, $offset = 0) { return array(); } diff --git a/lib/user/database.php b/lib/user/database.php index cc27b3ddbfd..1deed517610 100644 --- a/lib/user/database.php +++ b/lib/user/database.php @@ -154,13 +154,16 @@ class OC_User_Database extends OC_User_Backend { * * Get a list of all users. */ - public function getUsers(){ - $query = OC_DB::prepare( "SELECT uid FROM *PREFIX*users" ); - $result = $query->execute(); - - $users=array(); - while( $row = $result->fetchRow()){ - $users[] = $row["uid"]; + public function getUsers($search = '', $limit = -1, $offset = 0) { + if ($limit == -1) { + $query = OC_DB::prepare('SELECT uid FROM *PREFIX*users WHERE uid LIKE ?'); + } else { + $query = OC_DB::prepare('SELECT uid FROM *PREFIX*users WHERE uid LIKE ? LIMIT '.$limit.' OFFSET '.$offset); + } + $result = $query->execute(array($search.'%')); + $users = array(); + while ($row = $result->fetchRow()) { + $users[] = $row['uid']; } return $users; } diff --git a/lib/user/dummy.php b/lib/user/dummy.php index a946d4e6214..da3edfb2df4 100644 --- a/lib/user/dummy.php +++ b/lib/user/dummy.php @@ -100,7 +100,7 @@ class OC_User_Dummy extends OC_User_Backend { * * Get a list of all users. */ - public function getUsers(){ + public function getUsers($search = '', $limit = -1, $offset = 0) { return array_keys($this->users); } diff --git a/lib/user/interface.php b/lib/user/interface.php index dc3685dc20d..a4903898fb1 100644 --- a/lib/user/interface.php +++ b/lib/user/interface.php @@ -48,7 +48,7 @@ interface OC_User_Interface { * * Get a list of all users. */ - public function getUsers(); + public function getUsers($search = '', $limit = -1, $offset = 0); /** * @brief check if a user exists diff --git a/lib/util.php b/lib/util.php index 732acbb9205..0ef030e4401 100755 --- a/lib/util.php +++ b/lib/util.php @@ -66,7 +66,7 @@ class OC_Util { * @return array */ public static function getVersion(){ - return array(4,81,2); + return array(4,81,3); } /** |