From b9bdad51658a81e044957d3c327aa3ff1cbad408 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 13 Apr 2012 22:59:47 +0200 Subject: make sure temporary files are being removed, fixes oc-450 --- lib/files.php | 4 ++-- lib/helper.php | 42 ++++++++++++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/files.php b/lib/files.php index 051cfd4b81c..01558a68588 100644 --- a/lib/files.php +++ b/lib/files.php @@ -63,7 +63,7 @@ class OC_Files { $executionTime = intval(ini_get('max_execution_time')); set_time_limit(0); $zip = new ZipArchive(); - $filename = get_temp_dir().'/ownCloud_'.mt_rand(10000,99999).'.zip'; + $filename = OC_Helper::tmpFile('.zip'); if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==TRUE) { exit("cannot open <$filename>\n"); } @@ -84,7 +84,7 @@ class OC_Files { $executionTime = intval(ini_get('max_execution_time')); set_time_limit(0); $zip = new ZipArchive(); - $filename = get_temp_dir().'/ownCloud_'.mt_rand(10000,99999).'.zip'; + $filename = OC_Helper::tmpFile('.zip'); if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==TRUE) { exit("cannot open <$filename>\n"); } diff --git a/lib/helper.php b/lib/helper.php index f5626bccaa7..2026286352a 100755 --- a/lib/helper.php +++ b/lib/helper.php @@ -27,7 +27,7 @@ class OC_Helper { private static $mimetypes=array(); private static $tmpFiles=array(); - + /** * @brief Creates an url * @param $app app @@ -123,7 +123,7 @@ class OC_Helper { }elseif( file_exists( OC::$SERVERROOT."/core/img/$image" )){ return OC::$WEBROOT."/core/img/$image"; }else{ - echo('image not found: image:'.$image.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); + echo('image not found: image:'.$image.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); die(); } } @@ -188,7 +188,7 @@ class OC_Helper { $bytes = round( $bytes / 1024, 1 ); return "$bytes GB"; } - + /** * @brief Make a computer file size * @param $str file size in a fancy format @@ -224,9 +224,9 @@ class OC_Helper { $bytes = round($bytes, 2); - return $bytes; + return $bytes; } - + /** * @brief Recusive editing of file permissions * @param $path path to file or folder @@ -276,7 +276,7 @@ class OC_Helper { copy($src, $dest); } } - + /** * @brief Recusive deletion of folders * @param string $dir path to the folder @@ -294,6 +294,9 @@ class OC_Helper { }elseif(file_exists($dir)){ unlink($dir); } + if(file_exists($dir)) { + return false; + } } /** @@ -349,7 +352,7 @@ class OC_Helper { } return $mimeType; } - + /** * @brief Checks $_REQUEST contains a var for the $s key. If so, returns the html-escaped value of this var; otherwise returns the default value provided by $d. * @param $s name of the var to escape, if set. @@ -357,16 +360,16 @@ class OC_Helper { * @returns the print-safe value. * */ - + //FIXME: should also check for value validation (i.e. the email is an email). public static function init_var($s, $d="") { $r = $d; if(isset($_REQUEST[$s]) && !empty($_REQUEST[$s])) $r = stripslashes(htmlspecialchars($_REQUEST[$s])); - + return $r; } - + /** * returns "checked"-attribut if request contains selected radio element OR if radio element is the default one -- maybe? * @param string $s Name of radio-button element name @@ -422,7 +425,7 @@ class OC_Helper { } return false; } - + /** * copy the contents of one stream to another * @param resource source @@ -439,7 +442,7 @@ class OC_Helper { } return $count; } - + /** * create a temporary file with an unique filename * @param string postfix @@ -467,14 +470,25 @@ class OC_Helper { self::$tmpFiles[]=$path; return $path.'/'; } - + /** * remove all files created by self::tmpFile */ public static function cleanTmp(){ + $leftoversFile='/tmp/oc-not-deleted'; + if(file_exists($leftoversFile)){ + $leftovers=file($leftoversFile); + foreach($leftovers as $file) { + self::rmdirr($file); + } + unlink($leftoversFile); + } + foreach(self::$tmpFiles as $file){ if(file_exists($file)){ - self::rmdirr($file); + if(!self::rmdirr($file)) { + file_put_contents($leftoversFile, $file."\n", FILE_APPEND); + } } } } -- cgit v1.2.3 From 74f0bebfc8e6bb8b547792e8c181f8da08e3bfa5 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 13 Apr 2012 23:01:37 +0200 Subject: don't fail on missing extension --- lib/filesystemview.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/filesystemview.php b/lib/filesystemview.php index 9d530c7ad63..3045fc8b88c 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -283,7 +283,11 @@ class OC_FilesystemView { if(OC_Filesystem::isValidPath($path)){ $source=$this->fopen($path,'r'); if($source){ - $extention=substr($path,strrpos($path,'.')); + $extention=''; + $extOffset=strpos($path,'.'); + if($extOffset !== false) { + $extention=substr($path,strrpos($path,'.')); + } $tmpFile=OC_Helper::tmpFile($extention); file_put_contents($tmpFile,$source); return $tmpFile; -- cgit v1.2.3 From 9ef34cd8316a456d29ae3871f70f098c3a141bd9 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 13 Apr 2012 23:02:29 +0200 Subject: typo --- lib/filesystemview.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/filesystemview.php b/lib/filesystemview.php index 3045fc8b88c..95873bd87cf 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -283,12 +283,12 @@ class OC_FilesystemView { if(OC_Filesystem::isValidPath($path)){ $source=$this->fopen($path,'r'); if($source){ - $extention=''; + $extension=''; $extOffset=strpos($path,'.'); if($extOffset !== false) { - $extention=substr($path,strrpos($path,'.')); + $extension=substr($path,strrpos($path,'.')); } - $tmpFile=OC_Helper::tmpFile($extention); + $tmpFile=OC_Helper::tmpFile($extension); file_put_contents($tmpFile,$source); return $tmpFile; } -- cgit v1.2.3 From d8e54acbf3856b3917912a73481ffb482a1a25e8 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 13 Apr 2012 22:52:06 +0200 Subject: test cases for user backends --- lib/user/dummy.php | 114 ++++++++++++++++++++++++++++++++++++++++++++ tests/lib/user/backend.php | 89 ++++++++++++++++++++++++++++++++++ tests/lib/user/database.php | 45 +++++++++++++++++ tests/lib/user/dummy.php | 27 +++++++++++ 4 files changed, 275 insertions(+) create mode 100644 lib/user/dummy.php create mode 100644 tests/lib/user/backend.php create mode 100644 tests/lib/user/database.php create mode 100644 tests/lib/user/dummy.php (limited to 'lib') diff --git a/lib/user/dummy.php b/lib/user/dummy.php new file mode 100644 index 00000000000..cfc96c5c52d --- /dev/null +++ b/lib/user/dummy.php @@ -0,0 +1,114 @@ +. +* +*/ + +/** + * dummy user backend, does not keep state, only for testing use + */ +class OC_User_Dummy extends OC_User_Backend { + private $users=array(); + /** + * @brief Create a new user + * @param $uid The username of the user to create + * @param $password The password of the new user + * @returns true/false + * + * Creates a new user. Basic checking of username is done in OC_User + * itself, not in its subclasses. + */ + public function createUser($uid, $password){ + if(isset($this->users[$uid])){ + return false; + }else{ + $this->users[$uid]=$password; + return true; + } + } + + /** + * @brief delete a user + * @param $uid The username of the user to delete + * @returns true/false + * + * Deletes a user + */ + public function deleteUser( $uid ){ + if(isset($this->users[$uid])){ + unset($this->users[$uid]); + return true; + }else{ + return false; + } + } + + /** + * @brief Set password + * @param $uid The username + * @param $password The new password + * @returns true/false + * + * Change the password of a user + */ + public function setPassword($uid, $password){ + if(isset($this->users[$uid])){ + $this->users[$uid]=$password; + return true; + }else{ + return false; + } + } + + /** + * @brief Check if the password is correct + * @param $uid The username + * @param $password The password + * @returns true/false + * + * Check if the password is correct without logging in the user + */ + public function checkPassword($uid, $password){ + if(isset($this->users[$uid])){ + return ($this->users[$uid]==$password); + }else{ + 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_keys($this->users); + } + + /** + * @brief check if a user exists + * @param string $uid the username + * @return boolean + */ + public function userExists($uid){ + return isset($this->users[$uid]); + } +} diff --git a/tests/lib/user/backend.php b/tests/lib/user/backend.php new file mode 100644 index 00000000000..5dab5afb186 --- /dev/null +++ b/tests/lib/user/backend.php @@ -0,0 +1,89 @@ +. +* +*/ + +abstract class Test_User_Backend extends UnitTestCase { + /** + * @var OC_User_Backend $backend + */ + protected $backend; + + /** + * get a new unique user name + * test cases can override this in order to clean up created user + * @return array + */ + public function getUser(){ + return uniqid('test_'); + } + + public function testAddRemove(){ + //get the number of groups we start with, in case there are exising groups + $startCount=count($this->backend->getUsers()); + + $name1=$this->getUser(); + $name2=$this->getUser(); + $this->backend->createUser($name1,''); + $count=count($this->backend->getUsers())-$startCount; + $this->assertEqual(1,$count); + $this->assertTrue((array_search($name1,$this->backend->getUsers())!==false)); + $this->assertFalse((array_search($name2,$this->backend->getUsers())!==false)); + $this->backend->createUser($name2,''); + $count=count($this->backend->getUsers())-$startCount; + $this->assertEqual(2,$count); + $this->assertTrue((array_search($name1,$this->backend->getUsers())!==false)); + $this->assertTrue((array_search($name2,$this->backend->getUsers())!==false)); + + $this->backend->deleteUser($name2); + $count=count($this->backend->getUsers())-$startCount; + $this->assertEqual(1,$count); + $this->assertTrue((array_search($name1,$this->backend->getUsers())!==false)); + $this->assertFalse((array_search($name2,$this->backend->getUsers())!==false)); + } + + public function testLogin(){ + $name1=$this->getUser(); + $name2=$this->getUser(); + + $this->assertFalse($this->backend->userExists($name1)); + $this->assertFalse($this->backend->userExists($name2)); + + $this->backend->createUser($name1,'pass1'); + $this->backend->createUser($name2,'pass2'); + + $this->assertTrue($this->backend->userExists($name1)); + $this->assertTrue($this->backend->userExists($name2)); + + $this->assertTrue($this->backend->checkPassword($name1,'pass1')); + $this->assertTrue($this->backend->checkPassword($name2,'pass2')); + + $this->assertFalse($this->backend->checkPassword($name1,'pass2')); + $this->assertFalse($this->backend->checkPassword($name2,'pass1')); + + $this->assertFalse($this->backend->checkPassword($name1,'dummy')); + $this->assertFalse($this->backend->checkPassword($name2,'foobar')); + + $this->backend->setPassword($name1,'newpass1'); + $this->assertFalse($this->backend->checkPassword($name1,'pass1')); + $this->assertTrue($this->backend->checkPassword($name1,'newpass1')); + $this->assertFalse($this->backend->checkPassword($name2,'newpass1')); + } +} diff --git a/tests/lib/user/database.php b/tests/lib/user/database.php new file mode 100644 index 00000000000..b2fcce93c5b --- /dev/null +++ b/tests/lib/user/database.php @@ -0,0 +1,45 @@ +. +* +*/ + +class Test_User_Database extends Test_User_Backend { + private $user=array(); + /** + * get a new unique user name + * test cases can override this in order to clean up created user + * @return array + */ + public function getUser(){ + $user=uniqid('test_'); + $this->users[]=$user; + return $user; + } + + public function setUp(){ + $this->backend=new OC_User_Dummy(); + } + + public function tearDown(){ + foreach($this->users as $user){ + $this->backend->deleteUser($user); + } + } +} diff --git a/tests/lib/user/dummy.php b/tests/lib/user/dummy.php new file mode 100644 index 00000000000..062f55ba079 --- /dev/null +++ b/tests/lib/user/dummy.php @@ -0,0 +1,27 @@ +. +* +*/ + +class Test_User_Dummy extends Test_User_Backend { + public function setUp(){ + $this->backend=new OC_User_Dummy(); + } +} -- cgit v1.2.3 From 3babb8c22cf5d08ad4c4d79efee26fd1fb9a8472 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sat, 14 Apr 2012 11:29:44 +0200 Subject: improve flexibility of search providers a bit --- apps/bookmarks/lib/search.php | 4 ++-- apps/calendar/lib/search.php | 4 ++-- apps/contacts/lib/search.php | 4 ++-- apps/gallery/appinfo/app.php | 4 ++-- apps/media/lib_media.php | 4 ++-- lib/search.php | 30 +++++++++++++++++++++++++++--- lib/search/provider.php | 6 ++++-- lib/search/provider/file.php | 4 ++-- 8 files changed, 43 insertions(+), 17 deletions(-) (limited to 'lib') diff --git a/apps/bookmarks/lib/search.php b/apps/bookmarks/lib/search.php index 235587855d9..d7e32558617 100644 --- a/apps/bookmarks/lib/search.php +++ b/apps/bookmarks/lib/search.php @@ -20,8 +20,8 @@ * */ -class OC_Search_Provider_Bookmarks implements OC_Search_Provider{ - static function search($query){ +class OC_Search_Provider_Bookmarks extends OC_Search_Provider{ + function search($query){ $results=array(); $offset = 0; diff --git a/apps/calendar/lib/search.php b/apps/calendar/lib/search.php index 8405866392d..da5fa35bc21 100644 --- a/apps/calendar/lib/search.php +++ b/apps/calendar/lib/search.php @@ -1,6 +1,6 @@ OC_Helper::imagePath('core', 'places/picture.svg'), 'name' => $l->t('Pictures'))); - class OC_GallerySearchProvider implements OC_Search_Provider{ - static function search($query){ +class OC_GallerySearchProvider extends OC_Search_Provider{ + function search($query){ $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ? AND album_name LIKE ?'); $result = $stmt->execute(array(OC_User::getUser(),'%'.$query.'%')); $results=array(); diff --git a/apps/media/lib_media.php b/apps/media/lib_media.php index 9de291e8da2..a4e5a5dfebc 100644 --- a/apps/media/lib_media.php +++ b/apps/media/lib_media.php @@ -82,8 +82,8 @@ class OC_MEDIA{ } } -class OC_MediaSearchProvider implements OC_Search_Provider{ - static function search($query){ +class OC_MediaSearchProvider extends OC_Search_Provider{ + function search($query){ require_once('lib_collection.php'); $artists=OC_MEDIA_COLLECTION::getArtists($query); $albums=OC_MEDIA_COLLECTION::getAlbums(0,$query); diff --git a/lib/search.php b/lib/search.php index 6b33fa38140..12055418687 100644 --- a/lib/search.php +++ b/lib/search.php @@ -26,13 +26,22 @@ */ class OC_Search{ static private $providers=array(); + static private $registeredProviders=array(); + + /** + * remove all registered search providers + */ + public static function clearProviders(){ + self::$providers=array(); + self::$registeredProviders=array(); + } /** * register a new search provider to be used * @param string $provider class name of a OC_Search_Provider */ - public static function registerProvider($provider){ - self::$providers[]=$provider; + public static function registerProvider($class,$options=array()){ + self::$registeredProviders[]=array('class'=>$class,'options'=>$options); } /** @@ -41,10 +50,25 @@ class OC_Search{ * @return array An array of OC_Search_Result's */ public static function search($query){ + self::initProviders(); $results=array(); foreach(self::$providers as $provider){ - $results=array_merge($results, $provider::search($query)); + $results=array_merge($results, $provider->search($query)); } return $results; } + + /** + * create instances of all the registered search providers + */ + private static function initProviders(){ + if(count(self::$providers)>0){ + return; + } + foreach(self::$registeredProviders as $provider){ + $class=$provider['class']; + $options=$provider['options']; + self::$providers[]=new $class($options); + } + } } diff --git a/lib/search/provider.php b/lib/search/provider.php index 9487ca51f2b..838ab696d04 100644 --- a/lib/search/provider.php +++ b/lib/search/provider.php @@ -2,11 +2,13 @@ /** * provides search functionalty */ -interface OC_Search_Provider { +class OC_Search_Provider { + public function __construct($options){} + /** * search for $query * @param string $query * @return array An array of OC_Search_Result's */ - static function search($query); + public function search($query){} } diff --git a/lib/search/provider/file.php b/lib/search/provider/file.php index 3bdb3bcd2af..a37af495599 100644 --- a/lib/search/provider/file.php +++ b/lib/search/provider/file.php @@ -1,7 +1,7 @@ Date: Sat, 14 Apr 2012 11:42:11 +0200 Subject: remove outdated code --- lib/remote/cloud.php | 204 --------------------------------------------------- 1 file changed, 204 deletions(-) delete mode 100644 lib/remote/cloud.php (limited to 'lib') diff --git a/lib/remote/cloud.php b/lib/remote/cloud.php deleted file mode 100644 index a9c74e8bf5f..00000000000 --- a/lib/remote/cloud.php +++ /dev/null @@ -1,204 +0,0 @@ -cookiefile){ - $this->cookiefile=get_temp_dir().'/remoteCloudCookie'.uniqid(); - } - $url=$this->path.='/files/api.php'; - $fields_string="action=$action&"; - if(is_array($parameters)){ - foreach($parameters as $key=>$value){ - $fields_string.=$key.'='.$value.'&'; - } - rtrim($fields_string,'&'); - } - $ch=curl_init(); - curl_setopt($ch,CURLOPT_URL,$url); - curl_setopt($ch,CURLOPT_POST,count($parameters)); - curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string); - curl_setopt($ch, CURLOPT_COOKIEFILE,$this->cookiefile); - curl_setopt($ch, CURLOPT_COOKIEJAR,$this->cookiefile); - curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); - $result=curl_exec($ch); - $result=trim($result); - $info=curl_getinfo($ch); - $httpCode=$info['http_code']; - curl_close($ch); - if($httpCode==200 or $httpCode==0){ - return json_decode($result,$assoc); - }else{ - return false; - } - } - - public function __construct($path,$user,$password){ - $this->path=$path; - $this->connected=$this->apiCall('login',array('username'=>$user,'password'=>$password)); - } - - /** - * check if we are stull logged in on the remote cloud - * - */ - public function isLoggedIn(){ - if(!$this->connected){ - return false; - } - return $this->apiCall('checklogin'); - } - - public function __get($name){ - switch($name){ - case 'connected': - return $this->connected; - } - } - - /** - * disconnect from the remote cloud - * - */ - public function disconnect(){ - $this->connected=false; - if(is_file($this->cookiefile)){ - unlink($this->cookiefile); - } - $this->cookiefile=false; - } - - /** - * create a new file or directory - * @param string $dir - * @param string $name - * @param string $type - */ - public function newFile($dir,$name,$type){ - if(!$this->connected){ - return false; - } - return $this->apiCall('new',array('dir'=>$dir,'name'=>$name,'type'=>$type),true); - } - - /** - * deletes a file or directory - * @param string $dir - * @param string $file - */ - public function delete($dir,$name){ - if(!$this->connected){ - return false; - } - return $this->apiCall('delete',array('dir'=>$dir,'file'=>$name),true); - } - - /** - * moves a file or directory - * @param string $sorceDir - * @param string $sorceFile - * @param string $targetDir - * @param string $targetFile - */ - public function move($sourceDir,$sourceFile,$targetDir,$targetFile){ - if(!$this->connected){ - return false; - } - return $this->apiCall('move',array('sourcedir'=>$sourceDir,'source'=>$sourceFile,'targetdir'=>$targetDir,'target'=>$targetFile),true); - } - - /** - * copies a file or directory - * @param string $sorceDir - * @param string $sorceFile - * @param string $targetDir - * @param string $targetFile - */ - public function copy($sourceDir,$sourceFile,$targetDir,$targetFile){ - if(!$this->connected){ - return false; - } - return $this->apiCall('copy',array('sourcedir'=>$sourceDir,'source'=>$sourceFile,'targetdir'=>$targetDir,'target'=>$targetFile),true); - } - - /** - * get a file tree - * @param string $dir - */ - public function getTree($dir){ - if(!$this->connected){ - return false; - } - return $this->apiCall('gettree',array('dir'=>$dir),true); - } - - /** - * get the files inside a directory of the remote cloud - * @param string $dir - */ - public function getFiles($dir){ - if(!$this->connected){ - return false; - } - return $this->apiCall('getfiles',array('dir'=>$dir),true); - } - - /** - * get a remove file and save it in a temporary file and return the path of the temporary file - * @param string $dir - * @param string $file - * @return string - */ - public function getFile($dir, $file){ - if(!$this->connected){ - return false; - } - $ch=curl_init(); - if(!$this->cookiefile){ - $this->cookiefile=get_temp_dir().'/remoteCloudCookie'.uniqid(); - } - $tmpfile=tempnam(get_temp_dir(),'remoteCloudFile'); - $fp=fopen($tmpfile,'w+'); - $url=$this->path.="/files/api.php?action=get&dir=$dir&file=$file"; - curl_setopt($ch,CURLOPT_URL,$url); - curl_setopt($ch, CURLOPT_COOKIEFILE,$this->cookiefile); - curl_setopt($ch, CURLOPT_COOKIEJAR,$this->cookiefile); - curl_setopt($ch, CURLOPT_FILE, $fp); - curl_exec($ch); - fclose($fp); - curl_close($ch); - return $tmpfile; - } - - public function sendFile($sourceDir,$sourceFile,$targetDir,$targetFile){ - $source=$sourceDir.'/'.$sourceFile; - $tmp=OC_Filesystem::toTmpFile($source); - return $this->sendTmpFile($tmp,$targetDir,$targetFile); - } - - public function sendTmpFile($tmp,$targetDir,$targetFile){ - $token=sha1(uniqid().$tmp); - $file=get_temp_dir().'/'.'remoteCloudFile'.$token; - rename($tmp,$file); - if( OC_Config::getValue( "forcessl", false ) or isset($_SERVER['HTTPS']) and $_SERVER['HTTPS'] == 'on') { - $url = "https://". $_SERVER['SERVER_NAME'] . OC::$WEBROOT; - }else{ - $url = "http://". $_SERVER['SERVER_NAME'] . OC::$WEBROOT; - } - return $this->apiCall('pull',array('dir'=>$targetDir,'file'=>$targetFile,'token'=>$token,'source'=>$url),true); - } -} - -- cgit v1.2.3 From d3bf01376150ffd5de18cdc53f5e66b0c4979526 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sat, 14 Apr 2012 12:54:33 +0200 Subject: prevent users with the same name but different casing from being created --- lib/user/database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/user/database.php b/lib/user/database.php index 3eade276dd9..c1bac1bb0b5 100644 --- a/lib/user/database.php +++ b/lib/user/database.php @@ -172,7 +172,7 @@ class OC_User_Database extends OC_User_Backend { * @return boolean */ public function userExists($uid){ - $query = OC_DB::prepare( "SELECT * FROM `*PREFIX*users` WHERE uid = ?" ); + $query = OC_DB::prepare( "SELECT * FROM `*PREFIX*users` WHERE uid LIKE ?" ); $result = $query->execute( array( $uid )); return $result->numRows() > 0; -- cgit v1.2.3 From d8864d4f4bd54a314b1d7c7945578b95f24477d1 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sat, 14 Apr 2012 12:57:03 +0200 Subject: show error when installing an app has failed --- lib/app.php | 11 ++++++++--- settings/ajax/disableapp.php | 2 +- settings/ajax/enableapp.php | 8 +++++--- settings/js/apps.js | 12 ++++++++++-- 4 files changed, 24 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/app.php b/lib/app.php index 1c81fbd4242..807d8955d8f 100755 --- a/lib/app.php +++ b/lib/app.php @@ -139,13 +139,18 @@ class OC_App{ if(!is_numeric($app)){ OC_Installer::installShippedApp($app); }else{ - $download=OC_OCSClient::getApplicationDownload($app,1); - if(isset($download['downloadlink']) and $download['downloadlink']<>'') { + $download=OC_OCSClient::getApplicationDownload($app,1); + if(isset($download['downloadlink']) and $download['downloadlink']!='') { $app=OC_Installer::installApp(array('source'=>'http','href'=>$download['downloadlink'])); } } } - OC_Appconfig::setValue( $app, 'enabled', 'yes' ); + if($app!==false){ + OC_Appconfig::setValue( $app, 'enabled', 'yes' ); + return true; + }else{ + return false; + } } /** diff --git a/settings/ajax/disableapp.php b/settings/ajax/disableapp.php index 06dd3c2ac6b..53e9be379e1 100644 --- a/settings/ajax/disableapp.php +++ b/settings/ajax/disableapp.php @@ -6,4 +6,4 @@ OC_JSON::setContentTypeHeader(); OC_App::disable($_POST['appid']); -?> +OC_JSON::success(); diff --git a/settings/ajax/enableapp.php b/settings/ajax/enableapp.php index 639df2aecc0..cb116ebe4e8 100644 --- a/settings/ajax/enableapp.php +++ b/settings/ajax/enableapp.php @@ -5,6 +5,8 @@ require_once('../../lib/base.php'); OC_JSON::checkAdminUser(); OC_JSON::setContentTypeHeader(); -OC_App::enable($_POST['appid']); - -?> +if(OC_App::enable($_POST['appid'])){ + OC_JSON::success(); +}else{ + OC_JSON::error(); +} diff --git a/settings/js/apps.js b/settings/js/apps.js index e2f882c6fec..0f9181a2c75 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -28,10 +28,18 @@ $(document).ready(function(){ var active=$(this).data('active'); if(app){ if(active){ - $.post(OC.filePath('settings','ajax','disableapp.php'),{appid:app}); + $.post(OC.filePath('settings','ajax','disableapp.php'),{appid:app},function(result){ + if(!result || result.status!='succes'){ + OC.dialogs.alert('Error','Error while enabling app'); + } + },'json'); $('#leftcontent li[data-id="'+app+'"]').removeClass('active'); }else{ - $.post(OC.filePath('settings','ajax','enableapp.php'),{appid:app}); + $.post(OC.filePath('settings','ajax','enableapp.php'),{appid:app},function(result){ + if(!result || result.status!='succes'){ + OC.dialogs.alert('Error','Error while disabling app'); + } + },'json'); $('#leftcontent li[data-id="'+app+'"]').addClass('active'); } active=!active; -- cgit v1.2.3 From c069aa62a4217200ac007da93cdeb39e44b30748 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Sat, 14 Apr 2012 12:31:48 +0000 Subject: Fix annoying error in log --- lib/migrate.php | 301 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 151 insertions(+), 150 deletions(-) (limited to 'lib') diff --git a/lib/migrate.php b/lib/migrate.php index dff3abe9e93..1ce86198994 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -25,8 +25,8 @@ * provides an interface to migrate users and whole ownclouds */ class OC_Migrate{ - - + + // Array of OC_Migration_Provider objects static private $providers=array(); // User id of the user to import/export @@ -47,7 +47,7 @@ class OC_Migrate{ static private $zippath=false; // Holds the OC_Migration_Content object static private $content=false; - + /** * register a new migration provider * @param OC_Migrate_Provider $provider @@ -55,28 +55,28 @@ class OC_Migrate{ public static function registerProvider($provider){ self::$providers[]=$provider; } - - /** + + /** * @breif finds and loads the providers */ static private function findProviders(){ // Find the providers $apps = OC_App::getAllApps(); - + foreach($apps as $app){ $path = OC::$SERVERROOT . '/apps/' . $app . '/appinfo/migrate.php'; if( file_exists( $path ) ){ - include( $path ); - } - } + include( $path ); + } + } } - + /** * @breif exports a user, or owncloud instance * @param optional $uid string user id of user to export if export type is user, defaults to current * @param ootional $type string type of export, defualts to user * @param otional $path string path to zip output folder - * @return false on error, path to zip on success + * @return false on error, path to zip on success */ public static function export( $uid=null, $type='user', $path=null ){ $datadir = OC_Config::getValue( 'datadirectory' ); @@ -84,47 +84,48 @@ class OC_Migrate{ $types = array( 'user', 'instance', 'system', 'userfiles' ); if( !in_array( $type, $types ) ){ OC_Log::write( 'migration', 'Invalid export type', OC_Log::ERROR ); - return json_encode( array( array( 'success' => false ) ) ); + return json_encode( array( array( 'success' => false ) ) ); } self::$exporttype = $type; // Userid? if( self::$exporttype == 'user' ){ // Check user exists - if( !is_null($uid) ){ - if( !OC_User_Database::userExists( $uid ) ){ + if( !is_null($uid) ){ + $db = new OC_User_Database; + if( !$db->userExists( $uid ) ){ OC_Log::write('migration', 'User: '.$uid.' is not in the database and so cannot be exported.', OC_Log::ERROR); - return json_encode( array( 'success' => false ) ); + return json_encode( array( 'success' => false ) ); } self::$uid = $uid; } else { - self::$uid = OC_User::getUser(); - } + self::$uid = OC_User::getUser(); + } } // Calculate zipname if( self::$exporttype == 'user' ){ - $zipname = 'oc_export_' . self::$uid . '_' . date("y-m-d_H-i-s") . '.zip'; + $zipname = 'oc_export_' . self::$uid . '_' . date("y-m-d_H-i-s") . '.zip'; } else { $zipname = 'oc_export_' . self::$exporttype . '_' . date("y-m-d_H-i-s") . '.zip'; } // Calculate path if( self::$exporttype == 'user' ){ - self::$zippath = $datadir . '/' . self::$uid . '/' . $zipname; + self::$zippath = $datadir . '/' . self::$uid . '/' . $zipname; } else { if( !is_null( $path ) ){ // Validate custom path if( !file_exists( $path ) || !is_writeable( $path ) ){ OC_Log::write( 'migration', 'Path supplied is invalid.', OC_Log::ERROR ); - return json_encode( array( 'success' => false ) ); + return json_encode( array( 'success' => false ) ); } - self::$zippath = $path . $zipname; + self::$zippath = $path . $zipname; } else { // Default path - self::$zippath = get_temp_dir() . '/' . $zipname; + self::$zippath = get_temp_dir() . '/' . $zipname; } } // Create the zip object if( !self::createZip() ){ - return json_encode( array( 'success' => false ) ); + return json_encode( array( 'success' => false ) ); } // Do the export self::findProviders(); @@ -134,20 +135,20 @@ class OC_Migrate{ // Connect to the db self::$dbpath = $datadir . '/' . self::$uid . '/migration.db'; if( !self::connectDB() ){ - return json_encode( array( 'success' => false ) ); + return json_encode( array( 'success' => false ) ); } self::$content = new OC_Migration_Content( self::$zip, self::$MDB2 ); // Export the app info - $exportdata = self::exportAppData(); + $exportdata = self::exportAppData(); // Add the data dir to the zip self::$content->addDir( $datadir . '/' . self::$uid, true, '/' ); - break; + break; case 'instance': self::$content = new OC_Migration_Content( self::$zip ); // Creates a zip that is compatable with the import function $dbfile = tempnam( "/tmp", "owncloud_export_data_" ); OC_DB::getDbStructure( $dbfile, 'MDB2_SCHEMA_DUMP_ALL'); - + // Now add in *dbname* and *dbprefix* $dbexport = file_get_contents( $dbfile ); $dbnamestring = "\n\n " . OC_Config::getValue( "dbname", "owncloud" ); @@ -158,14 +159,14 @@ class OC_Migrate{ self::$content->addFromString( $dbexport, "dbexport.xml" ); // Add user data foreach(OC_User::getUsers() as $user){ - self::$content->addDir( $datadir . '/' . $user . '/', true, "/userdata/" ); + self::$content->addDir( $datadir . '/' . $user . '/', true, "/userdata/" ); } break; case 'userfiles': self::$content = new OC_Migration_Content( self::$zip ); // Creates a zip with all of the users files foreach(OC_User::getUsers() as $user){ - self::$content->addDir( $datadir . '/' . $user . '/', true, "/" ); + self::$content->addDir( $datadir . '/' . $user . '/', true, "/" ); } break; case 'system': @@ -178,70 +179,70 @@ class OC_Migrate{ break; } if( !$info = self::getExportInfo( $exportdata ) ){ - return json_encode( array( 'success' => false ) ); + return json_encode( array( 'success' => false ) ); } // Add the export info json to the export zip self::$content->addFromString( $info, 'export_info.json' ); if( !self::$content->finish() ){ - return json_encode( array( 'success' => false ) ); + return json_encode( array( 'success' => false ) ); } - return json_encode( array( 'success' => true, 'data' => self::$zippath ) ); + return json_encode( array( 'success' => true, 'data' => self::$zippath ) ); } - + /** * @breif imports a user, or owncloud instance * @param $path string path to zip * @param optional $type type of import (user or instance) - * @param optional $uid userid of new user + * @param optional $uid userid of new user */ public static function import( $path, $type='user', $uid=null ){ OC_Util::checkAdminUser(); $datadir = OC_Config::getValue( 'datadirectory' ); // Extract the zip if( !$extractpath = self::extractZip( $path ) ){ - return json_encode( array( 'success' => false ) ); + return json_encode( array( 'success' => false ) ); } // Get export_info.json $scan = scandir( $extractpath ); // Check for export_info.json if( !in_array( 'export_info.json', $scan ) ){ OC_Log::write( 'migration', 'Invalid import file, export_info.json note found', OC_Log::ERROR ); - return json_encode( array( 'success' => false ) ); + return json_encode( array( 'success' => false ) ); } $json = json_decode( file_get_contents( $extractpath . 'export_info.json' ) ); if( $json->exporttype != $type ){ OC_Log::write( 'migration', 'Invalid import file', OC_Log::ERROR ); - return json_encode( array( 'success' => false ) ); + return json_encode( array( 'success' => false ) ); } self::$exporttype = $type; - + // Have we got a user if type is user if( self::$exporttype == 'user' ){ if( !$uid ){ self::$uid = $json->exporteduser; - } else { + } else { self::$uid = $uid; } } - + // Handle export types switch( self::$exporttype ){ case 'user': // Check user availability if( OC_User::userExists( self::$uid ) ){ OC_Log::write( 'migration', 'User already exists', OC_Log::ERROR ); - return json_encode( array( 'success' => false ) ); + return json_encode( array( 'success' => false ) ); } $run = true; OC_Hook::emit( "OC_User", "pre_createUser", array( "run" => &$run, "uid" => self::$uid, "password" => $json->hash )); if( !$run ){ // Something stopped the user creation OC_Log::write( 'migration', 'User creation failed', OC_Log::ERROR ); - return json_encode( array( 'success' => false ) ); + return json_encode( array( 'success' => false ) ); } // Create the user if( !self::createUser( self::$uid, $json->hash ) ){ - return json_encode( array( 'success' => false ) ); + return json_encode( array( 'success' => false ) ); } // Emit the post_createUser hook (password is already hashed, will cause problems OC_Hook::emit( "OC_User", "post_createUser", array( "uid" => self::$uid, "password" => $json->hash )); @@ -249,19 +250,19 @@ class OC_Migrate{ $path = $datadir . '/' . self::$uid; if( !mkdir( $path, 0755, true ) ){ OC_Log::write( 'migration', 'Failed to create users data dir: '.$path, OC_Log::ERROR ); - return json_encode( array( 'success' => false ) ); + return json_encode( array( 'success' => false ) ); } // Copy data if( !self::copy_r( $extractpath . $json->exporteduser, $datadir . '/' . self::$uid ) ){ - return json_encode( array( 'success' => false ) ); + return json_encode( array( 'success' => false ) ); } - // Import user app data + // Import user app data if( !$appsimported = self::importAppData( $extractpath . $json->exporteduser . '/migration.db', $json, self::$uid ) ){ - return json_encode( array( 'success' => false ) ); + return json_encode( array( 'success' => false ) ); } // All done! if( !self::unlink_r( $extractpath ) ){ - OC_Log::write( 'migration', 'Failed to delete the extracted zip', OC_Log::ERROR ); + OC_Log::write( 'migration', 'Failed to delete the extracted zip', OC_Log::ERROR ); } return json_encode( array( 'success' => true, 'data' => $appsimported ) ); break; @@ -270,57 +271,57 @@ class OC_Migrate{ * EXPERIMENTAL // Check for new data dir and dbexport before doing anything // TODO - + // Delete current data folder. OC_Log::write( 'migration', "Deleting current data dir", OC_Log::INFO ); if( !self::unlink_r( $datadir, false ) ){ OC_Log::write( 'migration', 'Failed to delete the current data dir', OC_Log::ERROR ); - return json_encode( array( 'success' => false ) ); + return json_encode( array( 'success' => false ) ); } - + // Copy over data if( !self::copy_r( $extractpath . 'userdata', $datadir ) ){ OC_Log::write( 'migration', 'Failed to copy over data directory', OC_Log::ERROR ); - return json_encode( array( 'success' => false ) ); + return json_encode( array( 'success' => false ) ); } - + // Import the db if( !OC_DB::replaceDB( $extractpath . 'dbexport.xml' ) ){ - return json_encode( array( 'success' => false ) ); + return json_encode( array( 'success' => false ) ); } // Done - return json_encode( 'success' => true ); + return json_encode( 'success' => true ); */ - break; + break; } - + } - + /** * @breif recursively deletes a directory * @param $dir string path of dir to delete * $param optional $deleteRootToo bool delete the root directory * @return bool */ - private static function unlink_r( $dir, $deleteRootToo=true ){ - if( !$dh = @opendir( $dir ) ){ - return false; - } + private static function unlink_r( $dir, $deleteRootToo=true ){ + if( !$dh = @opendir( $dir ) ){ + return false; + } while (false !== ($obj = readdir($dh))){ - if($obj == '.' || $obj == '..') { - continue; - } - if (!@unlink($dir . '/' . $obj)){ - self::unlink_r($dir.'/'.$obj, true); - } - } - closedir($dh); - if ( $deleteRootToo ) { - @rmdir($dir); - } - return true; - } - + if($obj == '.' || $obj == '..') { + continue; + } + if (!@unlink($dir . '/' . $obj)){ + self::unlink_r($dir.'/'.$obj, true); + } + } + closedir($dh); + if ( $deleteRootToo ) { + @rmdir($dir); + } + return true; + } + /** * @breif copies recursively * @param $path string path to source folder @@ -349,12 +350,12 @@ class OC_Migrate{ return copy( $path, $dest ); } else { return false; - } + } } - + /** * @breif tries to extract the import zip - * @param $path string path to the zip + * @param $path string path to the zip * @return string path to extract location (with a trailing slash) or false on failure */ static private function extractZip( $path ){ @@ -362,20 +363,20 @@ class OC_Migrate{ // Validate path if( !file_exists( $path ) ){ OC_Log::write( 'migration', 'Zip not found', OC_Log::ERROR ); - return false; + return false; } if ( self::$zip->open( $path ) != TRUE ) { OC_Log::write( 'migration', "Failed to open zip file", OC_Log::ERROR ); return false; } - $to = get_temp_dir() . '/oc_import_' . self::$exporttype . '_' . date("y-m-d_H-i-s") . '/'; + $to = get_temp_dir() . '/oc_import_' . self::$exporttype . '_' . date("y-m-d_H-i-s") . '/'; if( !self::$zip->extractTo( $to ) ){ - return false; + return false; } - self::$zip->close(); + self::$zip->close(); return $to; } - + /** * @brief connects to a MDB2 database scheme * @returns bool @@ -393,16 +394,16 @@ class OC_Migrate{ return true; } - + /** * @breif creates a migration.db in the users data dir with their app data in * @return bool whether operation was successfull */ private static function exportAppData( ){ - + $success = true; $return = array(); - + // Foreach provider foreach( self::$providers as $provider ){ $success = true; @@ -413,35 +414,35 @@ class OC_Migrate{ if( is_array( $tables ) ){ // Save the table names foreach($tables as $table){ - $return['apps'][$provider->getID()]['tables'][] = $table; - } + $return['apps'][$provider->getID()]['tables'][] = $table; + } } else { // It failed to create the tables $success = false; - } + } } - + // Run the export function? if( $success ){ // Set the provider properties $provider->setData( self::$uid, self::$content ); - $return['apps'][$provider->getID()]['success'] = $provider->export(); + $return['apps'][$provider->getID()]['success'] = $provider->export(); } else { - $return['apps'][$provider->getID()]['success'] = false; - $return['apps'][$provider->getID()]['message'] = 'failed to create the app tables'; + $return['apps'][$provider->getID()]['success'] = false; + $return['apps'][$provider->getID()]['message'] = 'failed to create the app tables'; } - + // Now add some app info the the return array $appinfo = OC_App::getAppInfo( $provider->getID() ); $return['apps'][$provider->getID()]['version'] = $appinfo['version']; - + } - + return $return; - + } - - + + /** * @breif generates json containing export info, and merges any data supplied * @param optional $array array of data to include in the returned json @@ -464,11 +465,11 @@ class OC_Migrate{ OC_Log::write( 'migration', 'Failed to get the users password hash', OC_log::ERROR); return false; } - $info['hash'] = $hash; - $info['exporteduser'] = self::$uid; + $info['hash'] = $hash; + $info['exporteduser'] = self::$uid; } if( !is_array( $array ) ){ - OC_Log::write( 'migration', 'Supplied $array was not an array in getExportInfo()', OC_Log::ERROR ); + OC_Log::write( 'migration', 'Supplied $array was not an array in getExportInfo()', OC_Log::ERROR ); } // Merge in other data $info = array_merge( $info, (array)$array ); @@ -476,7 +477,7 @@ class OC_Migrate{ $json = json_encode( $info ); return $json; } - + /** * @breif connects to migration.db, or creates if not found * @param $db optional path to migration.db, defaults to user data dir @@ -487,19 +488,19 @@ class OC_Migrate{ self::$dbpath = !is_null( $path ) ? $path : self::$dbpath; if( !self::$dbpath ){ OC_Log::write( 'migration', 'connectDB() was called without dbpath being set', OC_Log::ERROR ); - return false; + return false; } // Already connected if(!self::$MDB2){ require_once('MDB2.php'); - + $datadir = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ); - + // DB type if( class_exists( 'SQLite3' ) ){ $dbtype = 'sqlite3'; } else if( is_callable( 'sqlite_open' ) ){ - $dbtype = 'sqlite'; + $dbtype = 'sqlite'; } else { OC_Log::write( 'migration', 'SQLite not found', OC_Log::ERROR ); return false; @@ -533,53 +534,53 @@ class OC_Migrate{ self::$MDB2->setFetchMode(MDB2_FETCHMODE_ASSOC); } return true; - + } - + /** * @breif creates the tables in migration.db from an apps database.xml * @param $appid string id of the app * @return bool whether the operation was successful */ static private function createAppTables( $appid ){ - + if( !self::connectScheme() ){ - return false; + return false; } - - // There is a database.xml file + + // There is a database.xml file $content = file_get_contents( OC::$SERVERROOT . '/apps/' . $appid . '/appinfo/database.xml' ); - + $file2 = 'static://db_scheme'; // TODO get the relative path to migration.db from the data dir // For now just cheat $path = pathinfo( self::$dbpath ); $content = str_replace( '*dbname*', self::$uid.'/migration', $content ); $content = str_replace( '*dbprefix*', '', $content ); - + $xml = new SimpleXMLElement($content); foreach($xml->table as $table){ - $tables[] = (string)$table->name; - } - + $tables[] = (string)$table->name; + } + file_put_contents( $file2, $content ); - + // Try to create tables $definition = self::$schema->parseDatabaseDefinitionFile( $file2 ); unlink( $file2 ); - + // Die in case something went wrong if( $definition instanceof MDB2_Schema_Error ){ OC_Log::write( 'migration', 'Failed to parse database.xml for: '.$appid, OC_Log::FATAL ); OC_Log::write( 'migration', $definition->getMessage().': '.$definition->getUserInfo(), OC_Log::FATAL ); return false; } - + $definition['overwrite'] = true; - + $ret = self::$schema->createDatabase( $definition ); - + // Die in case something went wrong if( $ret instanceof MDB2_Error ){ OC_Log::write( 'migration', 'Failed to create tables for: '.$appid, OC_Log::FATAL ); @@ -600,16 +601,16 @@ class OC_Migrate{ // Check if properties are set if( !self::$zippath ){ OC_Log::write('migration', 'createZip() called but $zip and/or $zippath have not been set', OC_Log::ERROR); - return false; + return false; } if ( self::$zip->open( self::$zippath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE ) !== TRUE ) { OC_Log::write('migration', 'Failed to create the zip with error: '.self::$zip->getStatusString(), OC_Log::ERROR); return false; } else { - return true; - } + return true; + } } - + /** * @breif returns an array of apps that support migration * @return array @@ -620,11 +621,11 @@ class OC_Migrate{ $path = OC::$SERVERROOT . '/apps/' . $app . '/lib/migrate.php'; if( file_exists( $path ) ){ $supportsmigration[] = $app; - } + } } - return $supportsmigration; + return $supportsmigration; } - + /** * @breif imports a new user * @param $db string path to migration.db @@ -639,55 +640,55 @@ class OC_Migrate{ if(!self::connectDB( $db )){ OC_Log::write('migration','Failed to connect to migration.db',OC_Log::ERROR); return false; - } + } } else { - OC_Log::write('migration','Migration.db not found at: '.$db, OC_Log::FATAL ); + OC_Log::write('migration','Migration.db not found at: '.$db, OC_Log::FATAL ); return false; } - + // Find providers self::findProviders(); // Generate importinfo array - $importinfo = array( + $importinfo = array( 'olduid' => $info->exporteduser, 'newuid' => self::$uid ); - + foreach( self::$providers as $provider){ // Is the app in the export? $id = $provider->getID(); if( isset( $info->apps->$id ) ){ // Is the app installed if( !OC_App::isEnabled( $id ) ){ - OC_Log::write( 'migration', 'App: ' . $id . ' is not installed, can\'t import data.', OC_Log::INFO ); - $appsstatus[$id] = 'notsupported'; + OC_Log::write( 'migration', 'App: ' . $id . ' is not installed, can\'t import data.', OC_Log::INFO ); + $appsstatus[$id] = 'notsupported'; } else { // Did it succeed on export? if( $info->apps->$id->success ){ // Give the provider the content object if( !self::connectDB( $db ) ){ - return false; + return false; } $content = new OC_Migration_Content( self::$zip, self::$MDB2 ); $provider->setData( self::$uid, $content, $info ); // Then do the import if( !$appsstatus[$id] = $provider->import( $info->apps->$id, $importinfo ) ){ // Failed to import app - OC_Log::write( 'migration', 'Failed to import app data for user: ' . self::$uid . ' for app: ' . $id, OC_Log::ERROR ); + OC_Log::write( 'migration', 'Failed to import app data for user: ' . self::$uid . ' for app: ' . $id, OC_Log::ERROR ); } } else { // Add to failed list - $appsstatus[$id] = false; + $appsstatus[$id] = false; } - } - } + } + } } - + return $appsstatus; - + } - + /* * @breif creates a new user in the database * @param $uid string user_id of the user to be created @@ -695,20 +696,20 @@ class OC_Migrate{ * @return bool result of user creation */ public static function createUser( $uid, $hash ){ - + // Check if userid exists if(OC_User::userExists( $uid )){ return false; } - + // Create the user $query = OC_DB::prepare( "INSERT INTO `*PREFIX*users` ( `uid`, `password` ) VALUES( ?, ? )" ); $result = $query->execute( array( $uid, $hash)); if( !$result ){ - OC_Log::write('migration', 'Failed to create the new user "'.$uid.""); + OC_Log::write('migration', 'Failed to create the new user "'.$uid.""); } return $result ? true : false; - + } } -- cgit v1.2.3 From bfdbdd9b20fd8196487315eeaa040a77ef90c531 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sat, 14 Apr 2012 14:22:45 +0200 Subject: remove outdated file --- lib/connect.php | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 lib/connect.php (limited to 'lib') diff --git a/lib/connect.php b/lib/connect.php deleted file mode 100644 index 22e48750a62..00000000000 --- a/lib/connect.php +++ /dev/null @@ -1,40 +0,0 @@ -. -* -*/ - -/** - * Class for connecting multiply ownCloud installations - * - */ -class OC_Connect{ - static private $clouds=array(); - - static function connect($path,$user,$password){ - $cloud=new OC_REMOTE_CLOUD($path,$user,$password); - if($cloud->connected){ - self::$clouds[$path]=$cloud; - return $cloud; - }else{ - return false; - } - } -} -- cgit v1.2.3 From 926b2b78fe444f5facfb21a625a6cd01123d2fb2 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sat, 14 Apr 2012 16:27:58 +0200 Subject: keep version numbers in their own files for faster reading --- apps/admin_dependencies_chk/appinfo/info.xml | 1 - apps/admin_dependencies_chk/appinfo/version | 1 + apps/admin_migrate/appinfo/info.xml | 1 - apps/admin_migrate/appinfo/version | 1 + apps/bookmarks/appinfo/info.xml | 1 - apps/bookmarks/appinfo/version | 1 + apps/calendar/appinfo/info.xml | 1 - apps/calendar/appinfo/version | 1 + apps/contacts/appinfo/info.xml | 1 - apps/contacts/appinfo/version | 1 + apps/external/appinfo/info.xml | 1 - apps/external/appinfo/version | 1 + apps/files_archive/appinfo/info.xml | 1 - apps/files_archive/appinfo/version | 1 + apps/files_encryption/appinfo/info.xml | 1 - apps/files_encryption/appinfo/version | 1 + apps/files_external/appinfo/info.xml | 1 - apps/files_external/appinfo/version | 1 + apps/files_imageviewer/appinfo/info.xml | 1 - apps/files_imageviewer/appinfo/version | 1 + apps/files_pdfviewer/appinfo/info.xml | 1 - apps/files_pdfviewer/appinfo/version | 1 + apps/files_sharing/appinfo/info.xml | 1 - apps/files_sharing/appinfo/version | 1 + apps/files_texteditor/appinfo/info.xml | 1 - apps/files_texteditor/appinfo/version | 1 + apps/files_versioning/appinfo/info.xml | 1 - apps/files_versioning/appinfo/version | 1 + apps/gallery/appinfo/info.xml | 1 - apps/gallery/appinfo/version | 1 + apps/media/appinfo/info.xml | 1 - apps/media/appinfo/version | 1 + apps/remoteStorage/appinfo/info.xml | 1 - apps/remoteStorage/appinfo/version | 1 + apps/user_ldap/appinfo/info.xml | 1 - apps/user_ldap/appinfo/version | 1 + apps/user_migrate/appinfo/info.xml | 1 - apps/user_migrate/appinfo/version | 1 + apps/user_openid/appinfo/info.xml | 1 - apps/user_openid/appinfo/version | 1 + apps/user_webfinger/appinfo/info.xml | 1 - apps/user_webfinger/appinfo/version | 1 + lib/app.php | 19 ++++++++++++++++--- 43 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 apps/admin_dependencies_chk/appinfo/version create mode 100644 apps/admin_migrate/appinfo/version create mode 100644 apps/bookmarks/appinfo/version create mode 100644 apps/calendar/appinfo/version create mode 100644 apps/contacts/appinfo/version create mode 100644 apps/external/appinfo/version create mode 100644 apps/files_archive/appinfo/version create mode 100644 apps/files_encryption/appinfo/version create mode 100644 apps/files_external/appinfo/version create mode 100644 apps/files_imageviewer/appinfo/version create mode 100644 apps/files_pdfviewer/appinfo/version create mode 100644 apps/files_sharing/appinfo/version create mode 100644 apps/files_texteditor/appinfo/version create mode 100644 apps/files_versioning/appinfo/version create mode 100644 apps/gallery/appinfo/version create mode 100644 apps/media/appinfo/version create mode 100644 apps/remoteStorage/appinfo/version create mode 100644 apps/user_ldap/appinfo/version create mode 100644 apps/user_migrate/appinfo/version create mode 100644 apps/user_openid/appinfo/version create mode 100644 apps/user_webfinger/appinfo/version (limited to 'lib') diff --git a/apps/admin_dependencies_chk/appinfo/info.xml b/apps/admin_dependencies_chk/appinfo/info.xml index a9c1c68c5d4..d5f8bd3783d 100644 --- a/apps/admin_dependencies_chk/appinfo/info.xml +++ b/apps/admin_dependencies_chk/appinfo/info.xml @@ -2,7 +2,6 @@ admin_dependencies_chk Owncloud dependencies info - 0.01 AGPL Brice Maron (eMerzh) 2 diff --git a/apps/admin_dependencies_chk/appinfo/version b/apps/admin_dependencies_chk/appinfo/version new file mode 100644 index 00000000000..d1c6331b310 --- /dev/null +++ b/apps/admin_dependencies_chk/appinfo/version @@ -0,0 +1 @@ +0.01 \ No newline at end of file diff --git a/apps/admin_migrate/appinfo/info.xml b/apps/admin_migrate/appinfo/info.xml index 67fc3f9c5a0..51721579002 100644 --- a/apps/admin_migrate/appinfo/info.xml +++ b/apps/admin_migrate/appinfo/info.xml @@ -3,7 +3,6 @@ admin_migrate ownCloud Instance Migration Import/Export your owncloud instance - 0.1 AGPL Thomas Schmidt and Tom Needham 2 diff --git a/apps/admin_migrate/appinfo/version b/apps/admin_migrate/appinfo/version new file mode 100644 index 00000000000..ceab6e11ece --- /dev/null +++ b/apps/admin_migrate/appinfo/version @@ -0,0 +1 @@ +0.1 \ No newline at end of file diff --git a/apps/bookmarks/appinfo/info.xml b/apps/bookmarks/appinfo/info.xml index 862ab805a60..39779483d85 100644 --- a/apps/bookmarks/appinfo/info.xml +++ b/apps/bookmarks/appinfo/info.xml @@ -3,7 +3,6 @@ bookmarks Bookmarks Bookmark manager for ownCloud - 0.2 AGPL Arthur Schiwon, Marvin Thomas Rabe 2 diff --git a/apps/bookmarks/appinfo/version b/apps/bookmarks/appinfo/version new file mode 100644 index 00000000000..2f4536184bc --- /dev/null +++ b/apps/bookmarks/appinfo/version @@ -0,0 +1 @@ +0.2 \ No newline at end of file diff --git a/apps/calendar/appinfo/info.xml b/apps/calendar/appinfo/info.xml index 4ac3c5bf099..101840aa1fa 100644 --- a/apps/calendar/appinfo/info.xml +++ b/apps/calendar/appinfo/info.xml @@ -2,7 +2,6 @@ calendar Calendar - 0.2.1 AGPL Georg Ehrke, Bart Visscher, Jakob Sack 2 diff --git a/apps/calendar/appinfo/version b/apps/calendar/appinfo/version new file mode 100644 index 00000000000..7dff5b89211 --- /dev/null +++ b/apps/calendar/appinfo/version @@ -0,0 +1 @@ +0.2.1 \ No newline at end of file diff --git a/apps/contacts/appinfo/info.xml b/apps/contacts/appinfo/info.xml index 0e2b1336006..55ddf42ccc1 100644 --- a/apps/contacts/appinfo/info.xml +++ b/apps/contacts/appinfo/info.xml @@ -2,7 +2,6 @@ contacts Contacts - 0.1 AGPL Jakob Sack 2 diff --git a/apps/contacts/appinfo/version b/apps/contacts/appinfo/version new file mode 100644 index 00000000000..ceab6e11ece --- /dev/null +++ b/apps/contacts/appinfo/version @@ -0,0 +1 @@ +0.1 \ No newline at end of file diff --git a/apps/external/appinfo/info.xml b/apps/external/appinfo/info.xml index 05f5709916d..83130f17e62 100644 --- a/apps/external/appinfo/info.xml +++ b/apps/external/appinfo/info.xml @@ -3,7 +3,6 @@ external External Show external Application in the ownCloud menu - 1.0 AGPL Frank Karlitschek 2 diff --git a/apps/external/appinfo/version b/apps/external/appinfo/version new file mode 100644 index 00000000000..9f8e9b69a33 --- /dev/null +++ b/apps/external/appinfo/version @@ -0,0 +1 @@ +1.0 \ No newline at end of file diff --git a/apps/files_archive/appinfo/info.xml b/apps/files_archive/appinfo/info.xml index 236b5a64b05..b04498aa089 100644 --- a/apps/files_archive/appinfo/info.xml +++ b/apps/files_archive/appinfo/info.xml @@ -3,7 +3,6 @@ files_archive Archive support Transparent opening of archives - 0.1 AGPL Robin Appelman 3 diff --git a/apps/files_archive/appinfo/version b/apps/files_archive/appinfo/version new file mode 100644 index 00000000000..ceab6e11ece --- /dev/null +++ b/apps/files_archive/appinfo/version @@ -0,0 +1 @@ +0.1 \ No newline at end of file diff --git a/apps/files_encryption/appinfo/info.xml b/apps/files_encryption/appinfo/info.xml index 691b265bf60..c2e1aa96043 100644 --- a/apps/files_encryption/appinfo/info.xml +++ b/apps/files_encryption/appinfo/info.xml @@ -3,7 +3,6 @@ files_encryption Encryption Server side encryption of files - 0.1 AGPL Robin Appelman 3 diff --git a/apps/files_encryption/appinfo/version b/apps/files_encryption/appinfo/version new file mode 100644 index 00000000000..ceab6e11ece --- /dev/null +++ b/apps/files_encryption/appinfo/version @@ -0,0 +1 @@ +0.1 \ No newline at end of file diff --git a/apps/files_external/appinfo/info.xml b/apps/files_external/appinfo/info.xml index fb58297ff17..1918925389d 100644 --- a/apps/files_external/appinfo/info.xml +++ b/apps/files_external/appinfo/info.xml @@ -3,7 +3,6 @@ files_external External storage support Mount external storage sources - 0.1 AGPL Robin Appelman 3 diff --git a/apps/files_external/appinfo/version b/apps/files_external/appinfo/version new file mode 100644 index 00000000000..ceab6e11ece --- /dev/null +++ b/apps/files_external/appinfo/version @@ -0,0 +1 @@ +0.1 \ No newline at end of file diff --git a/apps/files_imageviewer/appinfo/info.xml b/apps/files_imageviewer/appinfo/info.xml index 00b55c254dd..dbc78ffba0f 100644 --- a/apps/files_imageviewer/appinfo/info.xml +++ b/apps/files_imageviewer/appinfo/info.xml @@ -3,7 +3,6 @@ files_imageviewer Image Viewer Simple image viewer for owncloud - 1.0 AGPL Robin Appelman 2 diff --git a/apps/files_imageviewer/appinfo/version b/apps/files_imageviewer/appinfo/version new file mode 100644 index 00000000000..9f8e9b69a33 --- /dev/null +++ b/apps/files_imageviewer/appinfo/version @@ -0,0 +1 @@ +1.0 \ No newline at end of file diff --git a/apps/files_pdfviewer/appinfo/info.xml b/apps/files_pdfviewer/appinfo/info.xml index f133f1900d7..0e81729a8bc 100755 --- a/apps/files_pdfviewer/appinfo/info.xml +++ b/apps/files_pdfviewer/appinfo/info.xml @@ -3,7 +3,6 @@ files_pdfviewer PDF Viewer Inline PDF viewer (pdfjs-based) - 0.1 GPL Joan Creus 2 diff --git a/apps/files_pdfviewer/appinfo/version b/apps/files_pdfviewer/appinfo/version new file mode 100644 index 00000000000..ceab6e11ece --- /dev/null +++ b/apps/files_pdfviewer/appinfo/version @@ -0,0 +1 @@ +0.1 \ No newline at end of file diff --git a/apps/files_sharing/appinfo/info.xml b/apps/files_sharing/appinfo/info.xml index 8fda775520b..490ffaca890 100644 --- a/apps/files_sharing/appinfo/info.xml +++ b/apps/files_sharing/appinfo/info.xml @@ -3,7 +3,6 @@ files_sharing Share Files File sharing between users - 0.1 AGPL Michael Gapczynski 2 diff --git a/apps/files_sharing/appinfo/version b/apps/files_sharing/appinfo/version new file mode 100644 index 00000000000..ceab6e11ece --- /dev/null +++ b/apps/files_sharing/appinfo/version @@ -0,0 +1 @@ +0.1 \ No newline at end of file diff --git a/apps/files_texteditor/appinfo/info.xml b/apps/files_texteditor/appinfo/info.xml index da1cdba15dd..83c057f38fd 100644 --- a/apps/files_texteditor/appinfo/info.xml +++ b/apps/files_texteditor/appinfo/info.xml @@ -3,7 +3,6 @@ files_texteditor Text Editor Simple plain text editor based on Ace editor. - 0.3 AGPL Tom Needham 2 diff --git a/apps/files_texteditor/appinfo/version b/apps/files_texteditor/appinfo/version new file mode 100644 index 00000000000..1d71ef97443 --- /dev/null +++ b/apps/files_texteditor/appinfo/version @@ -0,0 +1 @@ +0.3 \ No newline at end of file diff --git a/apps/files_versioning/appinfo/info.xml b/apps/files_versioning/appinfo/info.xml index 4c67894f9f9..b9f56f674a0 100644 --- a/apps/files_versioning/appinfo/info.xml +++ b/apps/files_versioning/appinfo/info.xml @@ -2,7 +2,6 @@ files_versioning Versioning and Backup - 1.0.0 GPLv2 Craig Roberts 3 diff --git a/apps/files_versioning/appinfo/version b/apps/files_versioning/appinfo/version new file mode 100644 index 00000000000..afaf360d37f --- /dev/null +++ b/apps/files_versioning/appinfo/version @@ -0,0 +1 @@ +1.0.0 \ No newline at end of file diff --git a/apps/gallery/appinfo/info.xml b/apps/gallery/appinfo/info.xml index 4c8c1cee242..7dc85374b0b 100644 --- a/apps/gallery/appinfo/info.xml +++ b/apps/gallery/appinfo/info.xml @@ -2,7 +2,6 @@ gallery Pictures - 0.4 AGPL Bartek Przybylski 2 diff --git a/apps/gallery/appinfo/version b/apps/gallery/appinfo/version new file mode 100644 index 00000000000..e6adf3fc7bb --- /dev/null +++ b/apps/gallery/appinfo/version @@ -0,0 +1 @@ +0.4 \ No newline at end of file diff --git a/apps/media/appinfo/info.xml b/apps/media/appinfo/info.xml index 4a642bf889d..01145d4a944 100644 --- a/apps/media/appinfo/info.xml +++ b/apps/media/appinfo/info.xml @@ -3,7 +3,6 @@ media Media Media player and server for ownCloud - 0.3 AGPL Robin Appelman 2 diff --git a/apps/media/appinfo/version b/apps/media/appinfo/version new file mode 100644 index 00000000000..1d71ef97443 --- /dev/null +++ b/apps/media/appinfo/version @@ -0,0 +1 @@ +0.3 \ No newline at end of file diff --git a/apps/remoteStorage/appinfo/info.xml b/apps/remoteStorage/appinfo/info.xml index 1f9618a3334..1875e70a300 100644 --- a/apps/remoteStorage/appinfo/info.xml +++ b/apps/remoteStorage/appinfo/info.xml @@ -3,7 +3,6 @@ remoteStorage remoteStorage compatibility Enables you to use ownCloud as their remote storage for unhosted applications. This app requires the Webfinger app to be installed and enabled correctly. More info on the website of the unhosted movement. - 0.6 AGPL or MIT Michiel de Jong 2 diff --git a/apps/remoteStorage/appinfo/version b/apps/remoteStorage/appinfo/version new file mode 100644 index 00000000000..490f510fc27 --- /dev/null +++ b/apps/remoteStorage/appinfo/version @@ -0,0 +1 @@ +0.6 \ No newline at end of file diff --git a/apps/user_ldap/appinfo/info.xml b/apps/user_ldap/appinfo/info.xml index 99830dd1ffd..fe7e61fb5c3 100644 --- a/apps/user_ldap/appinfo/info.xml +++ b/apps/user_ldap/appinfo/info.xml @@ -3,7 +3,6 @@ user_ldap LDAP user backend Authenticate Users by LDAP - 0.1 AGPL Dominik Schmidt 2 diff --git a/apps/user_ldap/appinfo/version b/apps/user_ldap/appinfo/version new file mode 100644 index 00000000000..ceab6e11ece --- /dev/null +++ b/apps/user_ldap/appinfo/version @@ -0,0 +1 @@ +0.1 \ No newline at end of file diff --git a/apps/user_migrate/appinfo/info.xml b/apps/user_migrate/appinfo/info.xml index 6abcb4af92c..4c3646f770c 100644 --- a/apps/user_migrate/appinfo/info.xml +++ b/apps/user_migrate/appinfo/info.xml @@ -3,7 +3,6 @@ user_migrate User Account Migration Migrate your user accounts - 0.1 AGPL Tom Needham 2 diff --git a/apps/user_migrate/appinfo/version b/apps/user_migrate/appinfo/version new file mode 100644 index 00000000000..ceab6e11ece --- /dev/null +++ b/apps/user_migrate/appinfo/version @@ -0,0 +1 @@ +0.1 \ No newline at end of file diff --git a/apps/user_openid/appinfo/info.xml b/apps/user_openid/appinfo/info.xml index 721db1877e3..6214229c0a1 100644 --- a/apps/user_openid/appinfo/info.xml +++ b/apps/user_openid/appinfo/info.xml @@ -3,7 +3,6 @@ user_openid OpenID user backend Allow login through OpenID - 0.1 AGPL Robin Appelman 2 diff --git a/apps/user_openid/appinfo/version b/apps/user_openid/appinfo/version new file mode 100644 index 00000000000..ceab6e11ece --- /dev/null +++ b/apps/user_openid/appinfo/version @@ -0,0 +1 @@ +0.1 \ No newline at end of file diff --git a/apps/user_webfinger/appinfo/info.xml b/apps/user_webfinger/appinfo/info.xml index d47fb723a3a..fe1d4371863 100644 --- a/apps/user_webfinger/appinfo/info.xml +++ b/apps/user_webfinger/appinfo/info.xml @@ -3,7 +3,6 @@ user_webfinger Webfinger Provide WebFinger for all users so they get a user address like user@owncloudinstance which can be used for external applications. Other apps can provide information for webfinger requests, such as remoteStorage compatibility. - 0.3 AGPL or MIT Michiel de Jong, Florian Hülsmann 2 diff --git a/apps/user_webfinger/appinfo/version b/apps/user_webfinger/appinfo/version new file mode 100644 index 00000000000..1d71ef97443 --- /dev/null +++ b/apps/user_webfinger/appinfo/version @@ -0,0 +1 @@ +0.3 \ No newline at end of file diff --git a/lib/app.php b/lib/app.php index 807d8955d8f..b499e1a8ef2 100755 --- a/lib/app.php +++ b/lib/app.php @@ -307,6 +307,20 @@ class OC_App{ return $list; } + + /** + * get the last version of the app, either from appinfo/version or from appinfo/info.xml + */ + public static function getAppVersion($appid){ + $file=OC::$APPSROOT.'/apps/'.$appid.'/appinfo/version'; + $version=@file_get_contents($file); + if($version){ + return $version; + }else{ + $appData=self::getAppInfo($appid); + return $appData['version']; + } + } /** * @brief Read app metadata from the info.xml file @@ -441,9 +455,8 @@ class OC_App{ // The rest comes here $versions = self::getAppVersions(); foreach( $versions as $app=>$installedVersion ){ - $appInfo=OC_App::getAppInfo($app); - if (isset($appInfo['version'])) { - $currentVersion=$appInfo['version']; + $currentVersion=OC_App::getAppVersion($app); + if ($currentVersion) { if (version_compare($currentVersion, $installedVersion, '>')) { OC_App::updateApp($app); OC_Appconfig::setValue($app,'installed_version',$appInfo['version']); -- cgit v1.2.3 From 721311c9099780ecc22b6b186ed79dc5c9c92271 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sat, 14 Apr 2012 16:28:36 +0200 Subject: some minor optimizations --- lib/db.php | 38 +++++++++++++++++++++++++++----------- lib/l10n.php | 13 +++++-------- 2 files changed, 32 insertions(+), 19 deletions(-) (limited to 'lib') diff --git a/lib/db.php b/lib/db.php index 9364b9e0015..d2552bff8f6 100644 --- a/lib/db.php +++ b/lib/db.php @@ -36,7 +36,25 @@ class OC_DB { static private $affected=0; static private $result=false; static private $inTransaction=false; + static private $prefix=null; + static private $type=null; + /** + * check which backend we should use + * @return BACKEND_MDB2 or BACKEND_PDO + */ + private static function getDBBackend(){ + $backend=self::BACKEND_MDB2; + if(class_exists('PDO') && OC_Config::getValue('installed', false)){//check if we can use PDO, else use MDB2 (instalation always needs to be done my mdb2) + $type = OC_Config::getValue( "dbtype", "sqlite" ); + if($type=='sqlite3') $type='sqlite'; + $drivers=PDO::getAvailableDrivers(); + if(array_search($type,$drivers)!==false){ + $backend=self::BACKEND_PDO; + } + } + } + /** * @brief connects to the database * @returns true if connection can be established or nothing (die()) @@ -48,15 +66,7 @@ class OC_DB { return; } if(is_null($backend)){ - $backend=self::BACKEND_MDB2; - if(class_exists('PDO') && OC_Config::getValue('installed', false)){//check if we can use PDO, else use MDB2 (instalation always needs to be done my mdb2) - $type = OC_Config::getValue( "dbtype", "sqlite" ); - if($type=='sqlite3') $type='sqlite'; - $drivers=PDO::getAvailableDrivers(); - if(array_search($type,$drivers)!==false){ - $backend=self::BACKEND_PDO; - } - } + $backend=self::getDBBackend(); } if($backend==self::BACKEND_PDO){ self::connectPDO(); @@ -423,8 +433,14 @@ class OC_DB { private static function processQuery( $query ){ self::connect(); // We need Database type and table prefix - $type = OC_Config::getValue( "dbtype", "sqlite" ); - $prefix = OC_Config::getValue( "dbtableprefix", "oc_" ); + if(is_null(self::$type)){ + self::$type=OC_Config::getValue( "dbtype", "oc_" ); + } + $type = self::$type; + if(is_null(self::$prefix)){ + self::$prefix=OC_Config::getValue( "dbtableprefix", "oc_" ); + } + $prefix = self::$prefix; // differences in escaping of table names ('`' for mysql) and getting the current timestamp if( $type == 'sqlite' || $type == 'sqlite3' ){ diff --git a/lib/l10n.php b/lib/l10n.php index 636326f9864..00bff08bf7f 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -261,17 +261,14 @@ class OC_L10N{ public static function findAvailableLanguages($app=null){ $available=array('en');//english is always available $dir = self::findI18nDir($app); - if(file_exists($dir)){ - $dh = opendir($dir); - while(($file = readdir($dh)) !== false){ - if(substr($file, -4, 4) == '.php' and (strlen($file) == 6 || strlen($file) == 9)){ + if(is_dir($dir)){ + $files=scandir($dir); + foreach($files as $file){ + if(substr($file, -4, 4) == '.php'){ $i = substr($file, 0, -4); - if($i != ''){ - $available[] = $i; - } + $available[] = $i; } } - closedir($dh); } return $available; } -- cgit v1.2.3 From b1bcc60d83866627b1b28a0eda336e0f246dbe8e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sat, 14 Apr 2012 16:44:15 +0200 Subject: reuse OC_L10N objects --- apps/admin_dependencies_chk/appinfo/app.php | 2 +- apps/admin_dependencies_chk/settings.php | 2 +- apps/bookmarks/bookmarksHelper.php | 2 +- apps/bookmarks/templates/bookmarklet.php | 2 +- apps/calendar/ajax/calendar/new.form.php | 1 - apps/calendar/ajax/calendar/overview.php | 2 +- apps/calendar/ajax/event/delete.php | 2 -- apps/calendar/ajax/event/new.php | 2 -- apps/calendar/ajax/events.php | 2 +- apps/calendar/ajax/import/dialog.php | 1 - apps/calendar/ajax/settings/guesstimezone.php | 2 +- apps/calendar/ajax/settings/settimezone.php | 2 +- apps/calendar/appinfo/app.php | 2 +- apps/calendar/lib/app.php | 2 +- apps/contacts/lib/app.php | 2 +- apps/gallery/appinfo/app.php | 2 +- apps/gallery/templates/index.php | 2 +- apps/gallery/templates/view_album.php | 2 +- apps/media/appinfo/app.php | 2 +- core/ajax/translations.php | 2 +- core/lostpassword/index.php | 2 +- core/strings.php | 2 +- files/ajax/upload.php | 2 +- files/appinfo/app.php | 2 +- lib/app.php | 2 +- lib/files.php | 4 ++-- lib/json.php | 6 +++--- lib/l10n.php | 20 ++++++++++++++++++++ lib/template.php | 4 ++-- settings/ajax/lostpassword.php | 2 +- settings/ajax/openid.php | 2 +- settings/ajax/setlanguage.php | 2 +- settings/personal.php | 2 +- 33 files changed, 52 insertions(+), 38 deletions(-) (limited to 'lib') diff --git a/apps/admin_dependencies_chk/appinfo/app.php b/apps/admin_dependencies_chk/appinfo/app.php index e2169b5dd77..f282b103c87 100644 --- a/apps/admin_dependencies_chk/appinfo/app.php +++ b/apps/admin_dependencies_chk/appinfo/app.php @@ -1,5 +1,5 @@ 14, diff --git a/apps/admin_dependencies_chk/settings.php b/apps/admin_dependencies_chk/settings.php index ce90dd604ca..ea1ce9fb3dc 100644 --- a/apps/admin_dependencies_chk/settings.php +++ b/apps/admin_dependencies_chk/settings.php @@ -20,7 +20,7 @@ * License along with this library. If not, see . * */ -$l=new OC_L10N('admin_dependencies_chk'); +$l=OC_L10N::get('admin_dependencies_chk'); $tmpl = new OC_Template( 'admin_dependencies_chk', 'settings'); $modules = array(); diff --git a/apps/bookmarks/bookmarksHelper.php b/apps/bookmarks/bookmarksHelper.php index 7ada69014fb..f1464be79de 100644 --- a/apps/bookmarks/bookmarksHelper.php +++ b/apps/bookmarks/bookmarksHelper.php @@ -94,7 +94,7 @@ function addBookmark($url, $title, $tags='') { } if(empty($title)) { - $l = new OC_L10N('bookmarks'); + $l = OC_L10N::get('bookmarks'); $title = $l->t('unnamed'); } diff --git a/apps/bookmarks/templates/bookmarklet.php b/apps/bookmarks/templates/bookmarklet.php index 5ea67f04df2..f7074462a79 100644 --- a/apps/bookmarks/templates/bookmarklet.php +++ b/apps/bookmarks/templates/bookmarklet.php @@ -1,7 +1,7 @@ ' . $l->t('Drag this to your browser bookmarks and click it, when you want to bookmark a webpage quickly:') . '' . '' . $l->t('Read later') . ''; diff --git a/apps/calendar/ajax/calendar/new.form.php b/apps/calendar/ajax/calendar/new.form.php index 6e7423cbe92..fa014351f77 100644 --- a/apps/calendar/ajax/calendar/new.form.php +++ b/apps/calendar/ajax/calendar/new.form.php @@ -7,7 +7,6 @@ */ require_once('../../../../lib/base.php'); -$l10n = new OC_L10N('calendar'); OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); $calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions(); diff --git a/apps/calendar/ajax/calendar/overview.php b/apps/calendar/ajax/calendar/overview.php index 2f73f5d0710..dd55f3e018f 100644 --- a/apps/calendar/ajax/calendar/overview.php +++ b/apps/calendar/ajax/calendar/overview.php @@ -7,7 +7,7 @@ */ require_once('../../../../lib/base.php'); -$l10n = new OC_L10N('calendar'); +$l10n = OC_L10N::get('calendar'); OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); $output = new OC_TEMPLATE("calendar", "part.choosecalendar"); diff --git a/apps/calendar/ajax/event/delete.php b/apps/calendar/ajax/event/delete.php index 862dec6bf5b..5fc12900ef3 100644 --- a/apps/calendar/ajax/event/delete.php +++ b/apps/calendar/ajax/event/delete.php @@ -7,8 +7,6 @@ */ require_once('../../../../lib/base.php'); -$l10n = new OC_L10N('calendar'); - OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); diff --git a/apps/calendar/ajax/event/new.php b/apps/calendar/ajax/event/new.php index 59fda79da73..7070bbf05d7 100644 --- a/apps/calendar/ajax/event/new.php +++ b/apps/calendar/ajax/event/new.php @@ -8,8 +8,6 @@ require_once('../../../../lib/base.php'); -$l10n = new OC_L10N('calendar'); - OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php index c62f93c540e..d053df2e4c1 100755 --- a/apps/calendar/ajax/events.php +++ b/apps/calendar/ajax/events.php @@ -8,7 +8,7 @@ require_once ('../../../lib/base.php'); require_once('when/When.php'); -$l = new OC_L10N('calendar'); +$l = OC_L10N::get('calendar'); $unnamed = $l->t('unnamed'); function create_return_event($event, $vevent){ $return_event = array(); diff --git a/apps/calendar/ajax/import/dialog.php b/apps/calendar/ajax/import/dialog.php index 2e002092150..16ec54d14a2 100644 --- a/apps/calendar/ajax/import/dialog.php +++ b/apps/calendar/ajax/import/dialog.php @@ -9,7 +9,6 @@ require_once('../../../../lib/base.php'); OC_JSON::checkLoggedIn(); OC_Util::checkAppEnabled('calendar'); -$l10n = new OC_L10N('calendar'); $tmpl = new OC_Template('calendar', 'part.import'); $tmpl->assign('path', $_POST['path']); $tmpl->assign('filename', $_POST['filename']); diff --git a/apps/calendar/ajax/settings/guesstimezone.php b/apps/calendar/ajax/settings/guesstimezone.php index d45a70e1ce3..c02b8d10b8d 100755 --- a/apps/calendar/ajax/settings/guesstimezone.php +++ b/apps/calendar/ajax/settings/guesstimezone.php @@ -10,7 +10,7 @@ require_once('../../../../lib/base.php'); OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('calendar'); -$l = new OC_L10N('calendar'); +$l = OC_L10N::get('calendar'); $lat = $_GET['lat']; $lng = $_GET['long']; diff --git a/apps/calendar/ajax/settings/settimezone.php b/apps/calendar/ajax/settings/settimezone.php index c639753fe2f..8dda28335f7 100644 --- a/apps/calendar/ajax/settings/settimezone.php +++ b/apps/calendar/ajax/settings/settimezone.php @@ -9,7 +9,7 @@ // Init owncloud require_once('../../../../lib/base.php'); -$l=new OC_L10N('calendar'); +$l=OC_L10N::get('calendar'); // Check if we are a user OC_JSON::checkLoggedIn(); diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php index f297c4d16d4..1fece8077ac 100644 --- a/apps/calendar/appinfo/app.php +++ b/apps/calendar/appinfo/app.php @@ -1,5 +1,5 @@ 20, diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php index 9bec5db1b91..cf654b68c0b 100644 --- a/apps/gallery/templates/index.php +++ b/apps/gallery/templates/index.php @@ -7,7 +7,7 @@ OC_Util::addStyle('files', 'files'); OC_Util::addScript('files_imageviewer', 'jquery.mousewheel-3.0.4.pack'); OC_Util::addScript('files_imageviewer', 'jquery.fancybox-1.3.4.pack'); OC_Util::addStyle( 'files_imageviewer', 'jquery.fancybox-1.3.4' ); -$l = new OC_L10N('gallery'); +$l = OC_L10N::get('gallery'); ?>
diff --git a/apps/gallery/templates/view_album.php b/apps/gallery/templates/view_album.php index 6b513a672d5..f938e487954 100644 --- a/apps/gallery/templates/view_album.php +++ b/apps/gallery/templates/view_album.php @@ -5,7 +5,7 @@ OC_Util::addScript('gallery', 'album_cover'); OC_Util::addScript('files_imageviewer', 'jquery.mousewheel-3.0.4.pack'); OC_Util::addScript('files_imageviewer', 'jquery.fancybox-1.3.4.pack'); OC_Util::addStyle( 'files_imageviewer', 'jquery.fancybox-1.3.4' ); -$l = new OC_L10N('gallery'); +$l = OC_L10N::get('gallery'); ?>