From 86dd023448a1aed54a076df9533ecdf50c4dcd97 Mon Sep 17 00:00:00 2001 From: Alessandro Cosentino Date: Tue, 7 Jun 2011 15:48:21 -0400 Subject: [PATCH 001/111] Adding clear logs functions --- apps/files_publiclink/js/admin.js | 2 +- config/.gitignore | 0 css/styles.css | 1 + lib/log.php | 14 +++++++++++++- log/index.php | 18 ++++++++++++++++-- log/js/log.js | 5 ++++- log/templates/index.php | 14 +++++++++++++- 7 files changed, 48 insertions(+), 6 deletions(-) mode change 100644 => 100755 config/.gitignore diff --git a/apps/files_publiclink/js/admin.js b/apps/files_publiclink/js/admin.js index 017c62cb42..9a0bad604a 100644 --- a/apps/files_publiclink/js/admin.js +++ b/apps/files_publiclink/js/admin.js @@ -48,5 +48,5 @@ $(document).ready(function() { } } }); - }) + }); }); \ No newline at end of file diff --git a/config/.gitignore b/config/.gitignore old mode 100644 new mode 100755 diff --git a/css/styles.css b/css/styles.css index 2790c5c049..5027a6b6fe 100644 --- a/css/styles.css +++ b/css/styles.css @@ -269,6 +269,7 @@ p.actions a.delete, div.actions a.delete { background-image:url('../img/delete.p #logs_options span { margin:0 2em 0 0.5em; font-weight:bold; } #logs_options label { margin:0 1em 0 0; } #logs_options input[type="submit"] { float:right; margin:0 2em 0 0; } +#logs_options input[type="submit"].nofloat { float:none; margin:0 2em 0 0; } #logs_options input[type="text"] { margin:0; padding:0; border:1px solid #ccc; text-align:right; } li.error{ list-style:none; width:640px; margin:4em auto; padding:1em 1em 1em 4em; background-color:#fee; background-image:url('../img/task-attention.png'); background-position:0.8em 0.8em; background-repeat:no-repeat; border:1px solid #ccc; -moz-border-radius:10px; -webkit-border-radius:10px; border-radius:10px; } diff --git a/lib/log.php b/lib/log.php index aebeba7d4b..894575ef05 100644 --- a/lib/log.php +++ b/lib/log.php @@ -79,7 +79,7 @@ class OC_LOG { * - app: only entries for this app */ public static function get( $filter = array()){ - $queryString='SELECT * FROM *PREFIX*log WHERE 1=1 '; + $queryString='SELECT * FROM *PREFIX*log WHERE 1=1 ORDER BY moment DESC'; $params=array(); if(isset($filter['from'])){ $queryString.='AND moment>? '; @@ -120,6 +120,18 @@ class OC_LOG { $query->execute(array($date)); return true; } + + /** + * @brief removes all log entries + * @returns true/false + * + * This function deletes all log entries. + */ + public static function deleteAll(){ + $query=OC_DB::prepare("DELETE FROM *PREFIX*log"); + $query->execute(); + return true; + } /** * @brief filter an array of log entries on action diff --git a/log/index.php b/log/index.php index 675396a4d1..db476b8560 100644 --- a/log/index.php +++ b/log/index.php @@ -37,8 +37,10 @@ OC_UTIL::addScript( "log", "log" ); $allActions=array('login','logout','read','write','create','delete'); -//check for a submited config -if(isset($_POST['size'])){ +$removeBeforeDate = 0; + +//check for a submitted config +if(isset($_POST['save'])){ $selectedActions=array(); foreach($allActions as $action){ if(isset($_POST[$action]) and $_POST[$action]=='on'){ @@ -48,10 +50,22 @@ if(isset($_POST['size'])){ OC_PREFERENCES::setValue($_SESSION['user_id'],'log','actions',implode(',',$selectedActions)); OC_PREFERENCES::setValue($_SESSION['user_id'],'log','pagesize',$_POST['size']); } +//clear log entries +else if(isset($_POST['clear'])){ + $removeBeforeDate=(isset($_POST['removeBeforeDate']))?$_POST['removeBeforeDate']:0; + if($removeBeforeDate!==0){ + $removeBeforeDate=strtotime($removeBeforeDate); + OC_LOG::deleteBefore($removeBeforeDate); + } +} +else if(isset($_POST['clearall'])){ + OC_LOG::deleteAll(); +} OC_APP::setActiveNavigationEntry( 'log' ); $logs=OC_LOG::get(); + $selectedActions=explode(',',OC_PREFERENCES::getValue($_SESSION['user_id'],'log','actions',implode(',',$allActions))); $logs=OC_LOG::filterAction($logs,$selectedActions); diff --git a/log/js/log.js b/log/js/log.js index 47c20b3e86..5ec75b94f4 100644 --- a/log/js/log.js +++ b/log/js/log.js @@ -18,4 +18,7 @@ $(document).ready(function() { } } }); -}); \ No newline at end of file + $('#removeBeforeDate').datepicker({ + dateFormat:'MM d, yy', + }); +}); diff --git a/log/templates/index.php b/log/templates/index.php index 1e294091e3..efd32ca057 100644 --- a/log/templates/index.php +++ b/log/templates/index.php @@ -14,7 +14,7 @@

Show :  entries per page. - +

@@ -37,4 +37,16 @@ +
+
+

+ Clear log entries before + + + + +

+
+
+ From 5a284afae6afc5060f901837b1adf96cbc2b3e03 Mon Sep 17 00:00:00 2001 From: Alessandro Cosentino Date: Tue, 7 Jun 2011 15:59:53 -0400 Subject: [PATCH 002/111] Small modifications to clear logs functions --- log/index.php | 2 -- log/js/log.js | 1 + log/templates/index.php | 4 +++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/log/index.php b/log/index.php index db476b8560..56bbbadb99 100644 --- a/log/index.php +++ b/log/index.php @@ -37,8 +37,6 @@ OC_UTIL::addScript( "log", "log" ); $allActions=array('login','logout','read','write','create','delete'); -$removeBeforeDate = 0; - //check for a submitted config if(isset($_POST['save'])){ $selectedActions=array(); diff --git a/log/js/log.js b/log/js/log.js index 5ec75b94f4..42ae1b4c85 100644 --- a/log/js/log.js +++ b/log/js/log.js @@ -22,3 +22,4 @@ $(document).ready(function() { dateFormat:'MM d, yy', }); }); + diff --git a/log/templates/index.php b/log/templates/index.php index efd32ca057..5f398b1dbc 100644 --- a/log/templates/index.php +++ b/log/templates/index.php @@ -37,6 +37,8 @@ + +

@@ -49,4 +51,4 @@

- + From 5425c3d1e919f305930176aef6f531eb2d42f7dd Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 12 Jun 2011 00:50:13 +0200 Subject: [PATCH 003/111] fix delTree --- lib/filestorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/filestorage.php b/lib/filestorage.php index 157e44ff29..819ad2e60b 100644 --- a/lib/filestorage.php +++ b/lib/filestorage.php @@ -377,7 +377,7 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{ if ($item == '.' || $item == '..') continue; if(is_file($dir.'/'.$item)){ if(unlink($dir.'/'.$item)){ - $this->clearFolderSizeCache($path); + $this->clearFolderSizeCache($dir); } }elseif(is_dir($dir.'/'.$item)){ if (!$this->delTree($dirRelative. "/" . $item)){ From 2a5ee9512ee88da53dcba862a32279bdc7096bfb Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 12 Jun 2011 00:57:43 +0200 Subject: [PATCH 004/111] allow tear down of filesystem. also fix a bug when chrooting to '/' --- lib/base.php | 7 ++++++- lib/filesystem.php | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/base.php b/lib/base.php index a3ffb6b1a6..50c41dc085 100644 --- a/lib/base.php +++ b/lib/base.php @@ -145,7 +145,7 @@ class OC_UTIL { if( $user != "" ){ //if we aren't logged in, there is no use to set up the filesystem //first set up the local "root" storage and the backupstorage if needed - $rootStorage=OC_FILESYSTEM::createStorage('local',array('datadir'=>$CONFIG_DATADIRECTORY)); + $rootStorage=OC_FILESYSTEM::createStorage('local',array('datadir'=>$CONFIG_DATADIRECTORY_ROOT)); // if( OC_CONFIG::getValue( "enablebackup", false )){ // // This creates the Directorys recursively // if(!is_dir( "$CONFIG_BACKUPDIRECTORY/$user/$root" )){ @@ -182,6 +182,11 @@ class OC_UTIL { } } + public static function tearDownFS(){ + OC_FILESYSTEM::tearDown(); + self::$fsSetup=false; + } + /** * get the current installed version of ownCloud * @return array diff --git a/lib/filesystem.php b/lib/filesystem.php index 2b5c3a56b6..27a937f5e4 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -67,6 +67,16 @@ class OC_FILESYSTEM{ return array_keys(self::$storageTypes); } + /** + * tear down the filesystem, removing all storage providers + */ + static public function tearDown(){ + foreach(self::$storages as $mountpoint=>$storage){ + unset(self::$storages[$mountpoint]); + } + $fakeRoot=''; + } + /** * create a new storage of a specific type * @param string type @@ -91,8 +101,10 @@ class OC_FILESYSTEM{ * @return bool */ static public function chroot($fakeRoot){ - if($fakeRoot[0]!=='/'){ - $fakeRoot='/'.$fakeRoot; + if(!$fakeRoot==''){ + if($fakeRoot[0]!=='/'){ + $fakeRoot='/'.$fakeRoot; + } } self::$fakeRoot=$fakeRoot; } From bb5a2a917b78fb13657ac9ebbcc067bd02b22126 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 12 Jun 2011 00:58:47 +0200 Subject: [PATCH 005/111] test case library and start of filesystem test --- lib/testcase.php | 93 +++++++++++++++++++++++++++++++++++++++ tests/index.php | 79 +++++++++++++++++++++++++++++++++ tests/lib/filesystem.php | 31 +++++++++++++ tests/templates/index.php | 11 +++++ 4 files changed, 214 insertions(+) create mode 100644 lib/testcase.php create mode 100644 tests/index.php create mode 100644 tests/lib/filesystem.php create mode 100644 tests/templates/index.php diff --git a/lib/testcase.php b/lib/testcase.php new file mode 100644 index 0000000000..19494dc2f1 --- /dev/null +++ b/lib/testcase.php @@ -0,0 +1,93 @@ +. +* +*/ + + +/** + * base class for unit tests + */ +class OC_TestCase{ + private $tests; //array of all tests in this test case + + public function __construct(){ + $this->tests=array(); + $this->results=array(); + $functions=get_class_methods(get_class($this)); + $exclude=get_class_methods('OC_TestCase'); + foreach($functions as $function){ + if(array_search($function,$exclude)===false){ + $this->tests[]=$function; + } + } + } + + public function getTests(){ + return $this->tests; + } + + /** + * function that gets called before each test + */ + private function setup(){ + } + + /** + * function that gets called after each test + */ + private function tearDown(){ + } + + /** + * check if the result equals the expected result + * @param mixed $expected the expected result + * @param mixed $result the actual result + * @param string $error (optional) the error message to display if the result isn't expected + */ + protected function assertEquals($expected,$result,$error=''){ + if($expected!==$result){ + if($expected===true){ + $expected='true'; + } + if($expected===false){ + $expected='false'; + } + if($result===true){ + $result='true'; + } + if($result===false){ + $result='false'; + } + if($error==''){ + $error="Unexpected result, expected '$expected' but was '$result'"; + } + throw new Exception($error); + } + } + + /** + * fail the test + * @param string $error the error message + */ + protected function fail($error){ + throw new Exception($error); + } +} \ No newline at end of file diff --git a/tests/index.php b/tests/index.php new file mode 100644 index 0000000000..5e0dbc2c83 --- /dev/null +++ b/tests/index.php @@ -0,0 +1,79 @@ +. +* +*/ + + +/** + * run all test cases + */ + $RUNTIME_NOSETUPFS=true; +require_once('../lib/base.php'); +require_once('testcase.php'); +require_once('template.php'); + +$testCases=loadFiles(__DIR__,array('index.php','templates')); + +$testResults=array(); +foreach($testCases as $testCaseClass){ + $testCase=new $testCaseClass(); + $results=array(); + foreach($testCase->getTests() as $test){ + $testCase->setup(); + try{ + $testCase->$test(); + $results[$test]='Ok'; + }catch(Exception $e){ + $results[$test]=$e->getMessage(); + } + $testCase->tearDown(); + } + $testResults[$testCaseClass]=$results; +} + +$tmpl = new OC_TEMPLATE( 'tests', 'index'); +$tmpl->assign('tests',$testResults); +$tmpl->printPage(); + +/** + * recursively load all files in a folder + * @param string $path + * @param array $exclude list of files to exclude + */ +function loadFiles($path,$exclude=false){ + $results=array(); + if(!$exclude){ + $exclude=array(); + } + $dh=opendir($path); + while($file=readdir($dh)){ + if($file!='.' && $file!='..' && array_search($file,$exclude)===false){ + if(is_file($path.'/'.$file)){ + $result=require_once($path.'/'.$file); + $results[]=$result; + }else{ + $subResults=loadFiles($path.'/'.$file); + $results=array_merge($results,$subResults); + } + } + } + return $results; +} +?> \ No newline at end of file diff --git a/tests/lib/filesystem.php b/tests/lib/filesystem.php new file mode 100644 index 0000000000..a1ded471a6 --- /dev/null +++ b/tests/lib/filesystem.php @@ -0,0 +1,31 @@ +assertEquals(true, OC_FILESYSTEM::is_dir('/'),'Root is not a directory'); + } + + public function fileExists(){ + $this->assertEquals(false, OC_FILESYSTEM::file_exists('/dummy'),'Unexpected result with non-existing file'); + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + $this->assertEquals(true, OC_FILESYSTEM::file_exists('/dummy'),'Unexpected result with existing file'); + } + + public function mkdir(){ + OC_FILESYSTEM::mkdir('/dummy'); + $this->assertEquals(true, OC_FILESYSTEM::file_exists('/dummy'),'No such file or directory after creating folder'); + $this->assertEquals(true, OC_FILESYSTEM::is_dir('/dummy'),'File created instead of filder'); + } + + public function tearDown(){ + OC_FILESYSTEM::chroot(''); + OC_FILESYSTEM::delTree('/testuser'); + OC_UTIL::tearDownFS(); + } +} +return 'OC_FILEYSYSTEM_Test'; +?> \ No newline at end of file diff --git a/tests/templates/index.php b/tests/templates/index.php new file mode 100644 index 0000000000..b8d3dac066 --- /dev/null +++ b/tests/templates/index.php @@ -0,0 +1,11 @@ +$results):?> +

+
    + $result):?> +
  • + + + + +
+ \ No newline at end of file From e179ef5547a19153ee285d9866b8bf3af91a8eca Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 12 Jun 2011 02:55:13 +0200 Subject: [PATCH 006/111] test cases for OC_FILESYSTEM --- tests/lib/filesystem.php | 202 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 197 insertions(+), 5 deletions(-) diff --git a/tests/lib/filesystem.php b/tests/lib/filesystem.php index a1ded471a6..73b0069519 100644 --- a/tests/lib/filesystem.php +++ b/tests/lib/filesystem.php @@ -4,6 +4,11 @@ class OC_FILEYSYSTEM_Test extends OC_TestCase public function setup(){ OC_UTIL::setupFS('testuser','testcase'); } + public function tearDown(){ + OC_FILESYSTEM::chroot(''); + OC_FILESYSTEM::delTree('/testuser'); + OC_UTIL::tearDownFS(); + } public function isDir(){ $this->assertEquals(true, OC_FILESYSTEM::is_dir('/'),'Root is not a directory'); @@ -20,11 +25,198 @@ class OC_FILEYSYSTEM_Test extends OC_TestCase $this->assertEquals(true, OC_FILESYSTEM::file_exists('/dummy'),'No such file or directory after creating folder'); $this->assertEquals(true, OC_FILESYSTEM::is_dir('/dummy'),'File created instead of filder'); } - - public function tearDown(){ - OC_FILESYSTEM::chroot(''); - OC_FILESYSTEM::delTree('/testuser'); - OC_UTIL::tearDownFS(); + + public function rmdir(){ + OC_FILESYSTEM::mkdir('/dummy'); + OC_FILESYSTEM::rmdir('/dummy'); + $this->assertEquals(false, OC_FILESYSTEM::file_exists('/dummy'),'Folder still exists after removing'); + } + + public function isFile(){ + $this->assertEquals(false, OC_FILESYSTEM::is_file('/'),'Root is a file'); + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + $this->assertEquals(true, OC_FILESYSTEM::is_file('/dummy'),'Created file is not said to be a file'); + } + + public function opendir(){ + OC_FILESYSTEM::file_put_contents('/dummy1','foo'); + OC_FILESYSTEM::file_put_contents('/dummy2','foo'); + $dh=OC_FILESYSTEM::opendir('/'); + if(!$dh){ + $this->fail('Failed to open root'); + } + $dummy1Found=false; + $dummy2Found=false; + while($file=readdir($dh)){ + if($file=='dummy1'){ + $dummy1Found=true; + }elseif($file=='dummy2'){ + $dummy2Found=true; + }elseif($file!='.' and $file!='..'){ + $this->fail('Unexpected filename when reading opened dir'); + } + } + $this->assertEquals(true,$dummy1Found,'Not all files found when reading opened dir'); + $this->assertEquals(true,$dummy2Found,'Not all files found when reading opened dir'); + } + + public function filesize(){ + OC_FILESYSTEM::file_put_contents('/dummy','1234567890'); + $this->assertEquals(10, OC_FILESYSTEM::filesize('/dummy'),'Unexpected filesize'); + } + + public function stat(){ + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + $time=time(); + $stat=OC_FILESYSTEM::stat('/dummy'); + $this->assertEquals(true,abs($time-$stat['atime'])<1,'Unexpected access time');//there can be small difference between those values due to running time + $this->assertEquals(true,abs($time-$stat['ctime'])<1,'Unexpected creation time'); + $this->assertEquals(true,abs($time-$stat['mtime'])<1,'Unexpected modified time'); + $this->assertEquals(3,$stat['size'],'Unexpected filesize'); + } + + public function filetype(){ + OC_FILESYSTEM::file_put_contents('/dummyFile','foo'); + OC_FILESYSTEM::mkdir('/dummyFolder'); + $this->assertEquals('file', OC_FILESYSTEM::filetype('/dummyFile'),'Unexpected filetype of file'); + $this->assertEquals('dir', OC_FILESYSTEM::filetype('/dummyFolder'),'Unexpected filetype of folder'); + } + + public function readfile(){ + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + ob_clean(); + ob_start(); + OC_FILESYSTEM::readfile('/dummy'); + $this->assertEquals('foo', ob_get_contents(),'Unexpected output of readfile'); + ob_end_clean(); + } + + public function isReadable(){ + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + $this->assertEquals(true, OC_FILESYSTEM::is_readable('/dummy'),'Can\'t read created file'); + } + + public function isWritable(){ + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + $this->assertEquals(true, OC_FILESYSTEM::is_writeable('/dummy'),'Can\'t write created file'); + } + + public function fileatime(){ + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + $time=time(); + $this->assertEquals(true,abs($time-OC_FILESYSTEM::fileatime('/dummy'))<1,'Unexpected access time');//there can be small difference between those values due to running time + } + + public function filectime(){ + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + $time=time(); + $this->assertEquals(true,abs($time-OC_FILESYSTEM::filectime('/dummy'))<1,'Unexpected creation time');//there can be small difference between those values due to running time + } + + public function filemtime(){ + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + $time=time(); + $this->assertEquals(true,abs($time-OC_FILESYSTEM::filemtime('/dummy'))<1,'Unexpected modified time');//there can be small difference between those values due to running time + } + + public function fileGetContents(){ + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + $this->assertEquals('foo', OC_FILESYSTEM::file_get_contents('/dummy'),'Unexpected content of file'); + } + + public function unlink(){ + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + OC_FILESYSTEM::unlink('/dummy'); + $this->assertEquals(false, OC_FILESYSTEM::file_exists('/dummy'),'File still exists after deletion'); + } + + public function rename(){ + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + OC_FILESYSTEM::rename('/dummy','/bar'); + $this->assertEquals(true, OC_FILESYSTEM::file_exists('/bar'),'New file doesnt exists after moving'); + $this->assertEquals(false, OC_FILESYSTEM::file_exists('/dummy'),'Old file still exists after moving'); + $this->assertEquals('foo', OC_FILESYSTEM::file_get_contents('/bar'),'Unexpected content of file after moving'); + } + + public function copy(){ + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + OC_FILESYSTEM::copy('/dummy','/bar'); + $this->assertEquals(true, OC_FILESYSTEM::file_exists('/bar'),'New file doesnt exists after copying'); + $this->assertEquals(true, OC_FILESYSTEM::file_exists('/dummy'),'Old file doesnt exists after copying'); + $this->assertEquals('foo', OC_FILESYSTEM::file_get_contents('/bar'),'Unexpected content of file after copying'); + } + + public function fopen(){ + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + $fh=OC_FILESYSTEM::fopen('/dummy','r'); + if(!$fh){ + $this->fail('Cant open file for reading'); + } + $content=fread($fh,3); + $this->assertEquals('foo', $content,'Unexpected content of file'); + fclose($fh); + $fh=OC_FILESYSTEM::fopen('/dummy','a'); + fwrite($fh,'bar',3); + fclose($fh); + $this->assertEquals('foobar', OC_FILESYSTEM::file_get_contents('/dummy'),'Unexpected content of file after appending'); + $fh=OC_FILESYSTEM::fopen('/dummy','w'); + fwrite($fh,'bar',3); + fclose($fh); + $this->assertEquals('bar', OC_FILESYSTEM::file_get_contents('/dummy'),'Unexpected content of file after writing'); + } + + public function toTmpFile(){ + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + $tmp=OC_FILESYSTEM::toTmpFile('/dummy'); + $this->assertEquals('foo', file_get_contents($tmp),'Unexpected content of temporary file'); + unlink($tmp); + } + + public function fromTmpFile(){ + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + $tmp=OC_FILESYSTEM::toTmpFile('/dummy'); + OC_FILESYSTEM::fromTmpFile($tmp,'/bar'); + $this->assertEquals('foo', OC_FILESYSTEM::file_get_contents('/bar'),'Unexpected content of new file'); + $this->assertEquals(false, file_exists($tmp),'Temporary file still exists'); + } + + public function getMimeType(){ + OC_FILESYSTEM::file_put_contents('/dummy','some plain text'); + $this->assertEquals('text/plain', OC_FILESYSTEM::getMimeType('/dummy'),'Unexpected mimetype of pain text file'); + OC_FILESYSTEM::file_put_contents('/dummy',"\n"); + $this->assertEquals('application/xml', OC_FILESYSTEM::getMimeType('/dummy'),'Unexpected mimetype of xml file'); + } + + public function delTree(){ + OC_FILESYSTEM::mkdir('/dummy'); + OC_FILESYSTEM::file_put_contents('/dummy/bar','foo'); + OC_FILESYSTEM::delTree('/dummy'); + $this->assertEquals(false, OC_FILESYSTEM::file_exists('/dummy/bar'),'File in deleted folder still exists'); + $this->assertEquals(false, OC_FILESYSTEM::file_exists('/dummy'),'Deleted folder still exists'); + } + + public function getTree(){ + OC_FILESYSTEM::mkdir('/dummy'); + OC_FILESYSTEM::file_put_contents('/dummy/bar','foo'); + $expected=array('/dummy','/dummy/bar'); + $this->assertEquals($expected, OC_FILESYSTEM::getTree('/dummy'),'Unexpected filelist returned'); + } + + public function hash(){ + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + $this->assertEquals(md5('foo'), OC_FILESYSTEM::hash('md5','/dummy'),'Unexpected md5 hash of file'); + } + + public function freeSpace(){ + $oldSpace=OC_FILESYSTEM::free_space('/'); + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + $newSpace=OC_FILESYSTEM::free_space('/'); + $this->assertEquals(true, $newSpace<$oldSpace,'free space not smaller after creating a non empty file'); + } + + public function search(){ + OC_FILESYSTEM::file_put_contents('/dummy','foo'); + $this->assertEquals(array('/dummy'),OC_FILESYSTEM::search('my'),'unexpected file list after search'); } } return 'OC_FILEYSYSTEM_Test'; From 964b51879eaffed13287a1e450e6f37171be2e62 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 12 Jun 2011 17:51:31 +0200 Subject: [PATCH 007/111] add option to remove tables install from database structure --- lib/database.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/lib/database.php b/lib/database.php index 728e735904..0f0950d05a 100644 --- a/lib/database.php +++ b/lib/database.php @@ -321,5 +321,43 @@ class OC_DB { return $query; } + + /** + * @brief drop a table + * @param string $tableNamme the table to drop + */ + public static function dropTable($tableName){ + self::connect(); + self::$DBConnection->loadModule('Manager'); + self::$DBConnection->dropTable($tableName); + } + + /** + * remove all tables defined in a database structure xml file + * @param string $file the xml file describing the tables + */ + public static function removeDBStructure($file){ + $CONFIG_DBNAME = OC_CONFIG::getValue( "dbname", "owncloud" ); + $CONFIG_DBTABLEPREFIX = OC_CONFIG::getValue( "dbtableprefix", "oc_" ); + self::connectScheme(); + + // read file + $content = file_get_contents( $file ); + + // Make changes and save them to a temporary file + $file2 = tempnam( sys_get_temp_dir(), 'oc_db_scheme_' ); + $content = str_replace( '*dbname*', $CONFIG_DBNAME, $content ); + $content = str_replace( '*dbprefix*', $CONFIG_DBTABLEPREFIX, $content ); + file_put_contents( $file2, $content ); + + // get the tables + $definition = self::$schema->parseDatabaseDefinitionFile( $file2 ); + + // Delete our temporary file + unlink( $file2 ); + foreach($definition['tables'] as $name=>$table){ + self::dropTable($name); + } + } } ?> \ No newline at end of file From 600219c8c0bec3f3998e0170dd3363ac6cc7824e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 13 Jun 2011 04:05:41 +0200 Subject: [PATCH 008/111] sqlite3 driver for mdb2 the only problem that I found with it so far is that it gives a database locked error on login, the rest seems to work fine but more testing is required. --- lib/MDB2/Driver/Datatype/sqlite3.php | 412 ++++++++ lib/MDB2/Driver/Function/sqlite3.php | 161 +++ lib/MDB2/Driver/Manager/sqlite3.php | 1364 ++++++++++++++++++++++++++ lib/MDB2/Driver/Native/sqlite3.php | 58 ++ lib/MDB2/Driver/Reverse/sqlite3.php | 607 ++++++++++++ lib/MDB2/Driver/sqlite3.php | 1024 +++++++++++++++++++ 6 files changed, 3626 insertions(+) create mode 100644 lib/MDB2/Driver/Datatype/sqlite3.php create mode 100644 lib/MDB2/Driver/Function/sqlite3.php create mode 100644 lib/MDB2/Driver/Manager/sqlite3.php create mode 100644 lib/MDB2/Driver/Native/sqlite3.php create mode 100644 lib/MDB2/Driver/Reverse/sqlite3.php create mode 100644 lib/MDB2/Driver/sqlite3.php diff --git a/lib/MDB2/Driver/Datatype/sqlite3.php b/lib/MDB2/Driver/Datatype/sqlite3.php new file mode 100644 index 0000000000..378d5540cb --- /dev/null +++ b/lib/MDB2/Driver/Datatype/sqlite3.php @@ -0,0 +1,412 @@ + + */ +class MDB2_Driver_Datatype_sqlite3 extends MDB2_Driver_Datatype_Common +{ + // {{{ _getCollationFieldDeclaration() + + /** + * Obtain DBMS specific SQL code portion needed to set the COLLATION + * of a field declaration to be used in statements like CREATE TABLE. + * + * @param string $collation name of the collation + * + * @return string DBMS specific SQL code portion needed to set the COLLATION + * of a field declaration. + */ + function _getCollationFieldDeclaration($collation) + { + return 'COLLATE '.$collation; + } + + // }}} + // {{{ getTypeDeclaration() + + /** + * Obtain DBMS specific SQL code portion needed to declare an text type + * field to be used in statements like CREATE TABLE. + * + * @param array $field associative array with the name of the properties + * of the field being declared as array indexes. Currently, the types + * of supported field properties are as follows: + * + * length + * Integer value that determines the maximum length of the text + * field. If this argument is missing the field should be + * declared to have the longest length allowed by the DBMS. + * + * default + * Text value to be used as default for this field. + * + * notnull + * Boolean flag that indicates whether this field is constrained + * to not be set to null. + * @return string DBMS specific SQL code portion that should be used to + * declare the specified field. + * @access public + */ + function getTypeDeclaration($field) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + switch ($field['type']) { + case 'text': + $length = !empty($field['length']) + ? $field['length'] : false; + $fixed = !empty($field['fixed']) ? $field['fixed'] : false; + return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$db->options['default_text_field_length'].')') + : ($length ? 'VARCHAR('.$length.')' : 'TEXT'); + case 'clob': + if (!empty($field['length'])) { + $length = $field['length']; + if ($length <= 255) { + return 'TINYTEXT'; + } elseif ($length <= 65532) { + return 'TEXT'; + } elseif ($length <= 16777215) { + return 'MEDIUMTEXT'; + } + } + return 'LONGTEXT'; + case 'blob': + if (!empty($field['length'])) { + $length = $field['length']; + if ($length <= 255) { + return 'TINYBLOB'; + } elseif ($length <= 65532) { + return 'BLOB'; + } elseif ($length <= 16777215) { + return 'MEDIUMBLOB'; + } + } + return 'LONGBLOB'; + case 'integer': + if (!empty($field['length'])) { + $length = $field['length']; + if ($length <= 2) { + return 'SMALLINT'; + } elseif ($length == 3 || $length == 4) { + return 'INTEGER'; + } elseif ($length > 4) { + return 'BIGINT'; + } + } + return 'INTEGER'; + case 'boolean': + return 'BOOLEAN'; + case 'date': + return 'DATE'; + case 'time': + return 'TIME'; + case 'timestamp': + return 'DATETIME'; + case 'float': + return 'DOUBLE'.($db->options['fixed_float'] ? '('. + ($db->options['fixed_float']+2).','.$db->options['fixed_float'].')' : ''); + case 'decimal': + $length = !empty($field['length']) ? $field['length'] : 18; + $scale = !empty($field['scale']) ? $field['scale'] : $db->options['decimal_places']; + return 'DECIMAL('.$length.','.$scale.')'; + } + return ''; + } + + // }}} + // {{{ _getIntegerDeclaration() + + /** + * Obtain DBMS specific SQL code portion needed to declare an integer type + * field to be used in statements like CREATE TABLE. + * + * @param string $name name the field to be declared. + * @param string $field associative array with the name of the properties + * of the field being declared as array indexes. + * Currently, the types of supported field + * properties are as follows: + * + * unsigned + * Boolean flag that indicates whether the field + * should be declared as unsigned integer if + * possible. + * + * default + * Integer value to be used as default for this + * field. + * + * notnull + * Boolean flag that indicates whether this field is + * constrained to not be set to null. + * @return string DBMS specific SQL code portion that should be used to + * declare the specified field. + * @access protected + */ + function _getIntegerDeclaration($name, $field) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $default = $autoinc = ''; + if (!empty($field['autoincrement'])) { + $autoinc = ' PRIMARY KEY AUTOINCREMENT'; + } elseif (array_key_exists('default', $field)) { + if ($field['default'] === '') { + $field['default'] = empty($field['notnull']) ? null : 0; + } + $default = ' DEFAULT '.$this->quote($field['default'], 'integer'); + } + + $notnull = empty($field['notnull']) ? '' : ' NOT NULL'; + $unsigned = empty($field['unsigned']) ? '' : ' UNSIGNED'; + $name = $db->quoteIdentifier($name, true); + if($autoinc){ + return $name.' '.$this->getTypeDeclaration($field).$autoinc; + }else{ + return $name.' '.$this->getTypeDeclaration($field).$unsigned.$default.$notnull.$autoinc; + } + } + + // }}} + // {{{ matchPattern() + + /** + * build a pattern matching string + * + * @access public + * + * @param array $pattern even keys are strings, odd are patterns (% and _) + * @param string $operator optional pattern operator (LIKE, ILIKE and maybe others in the future) + * @param string $field optional field name that is being matched against + * (might be required when emulating ILIKE) + * + * @return string SQL pattern + */ + function matchPattern($pattern, $operator = null, $field = null) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $match = ''; + if (!is_null($operator)) { + $field = is_null($field) ? '' : $field.' '; + $operator = strtoupper($operator); + switch ($operator) { + // case insensitive + case 'ILIKE': + $match = $field.'LIKE '; + break; + // case sensitive + case 'LIKE': + $match = $field.'LIKE '; + break; + default: + return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'not a supported operator type:'. $operator, __FUNCTION__); + } + } + $match.= "'"; + foreach ($pattern as $key => $value) { + if ($key % 2) { + $match.= $value; + } else { + $match.= $db->escapePattern($db->escape($value)); + } + } + $match.= "'"; + $match.= $this->patternEscapeString(); + return $match; + } + + // }}} + // {{{ _mapNativeDatatype() + + /** + * Maps a native array description of a field to a MDB2 datatype and length + * + * @param array $field native field description + * @return array containing the various possible types, length, sign, fixed + * @access public + */ + function _mapNativeDatatype($field) + { + $db_type = strtolower($field['type']); + $length = !empty($field['length']) ? $field['length'] : null; + $unsigned = !empty($field['unsigned']) ? $field['unsigned'] : null; + $fixed = null; + $type = array(); + switch ($db_type) { + case 'boolean': + $type[] = 'boolean'; + break; + case 'tinyint': + $type[] = 'integer'; + $type[] = 'boolean'; + if (preg_match('/^(is|has)/', $field['name'])) { + $type = array_reverse($type); + } + $unsigned = preg_match('/ unsigned/i', $field['type']); + $length = 1; + break; + case 'smallint': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $field['type']); + $length = 2; + break; + case 'mediumint': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $field['type']); + $length = 3; + break; + case 'int': + case 'integer': + case 'serial': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $field['type']); + $length = 4; + break; + case 'bigint': + case 'bigserial': + $type[] = 'integer'; + $unsigned = preg_match('/ unsigned/i', $field['type']); + $length = 8; + break; + case 'clob': + $type[] = 'clob'; + $fixed = false; + break; + case 'tinytext': + case 'mediumtext': + case 'longtext': + case 'text': + case 'varchar': + case 'varchar2': + $fixed = false; + case 'char': + $type[] = 'text'; + if ($length == '1') { + $type[] = 'boolean'; + if (preg_match('/^(is|has)/', $field['name'])) { + $type = array_reverse($type); + } + } elseif (strstr($db_type, 'text')) { + $type[] = 'clob'; + $type = array_reverse($type); + } + if ($fixed !== false) { + $fixed = true; + } + break; + case 'date': + $type[] = 'date'; + $length = null; + break; + case 'datetime': + case 'timestamp': + $type[] = 'timestamp'; + $length = null; + break; + case 'time': + $type[] = 'time'; + $length = null; + break; + case 'float': + case 'double': + case 'real': + $type[] = 'float'; + break; + case 'decimal': + case 'numeric': + $type[] = 'decimal'; + $length = $length.','.$field['decimal']; + break; + case 'tinyblob': + case 'mediumblob': + case 'longblob': + case 'blob': + $type[] = 'blob'; + $length = null; + break; + case 'year': + $type[] = 'integer'; + $type[] = 'date'; + $length = null; + break; + default: + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'unknown database attribute type: '.$db_type, __FUNCTION__); + } + + if ((int)$length <= 0) { + $length = null; + } + + return array($type, $length, $unsigned, $fixed); + } + + // }}} +} + +?> \ No newline at end of file diff --git a/lib/MDB2/Driver/Function/sqlite3.php b/lib/MDB2/Driver/Function/sqlite3.php new file mode 100644 index 0000000000..0d6b329f0a --- /dev/null +++ b/lib/MDB2/Driver/Function/sqlite3.php @@ -0,0 +1,161 @@ + | +// +----------------------------------------------------------------------+ +// +// + +require_once('MDB2/Driver/Function/Common.php'); + +/** + * MDB2 SQLite driver for the function modules + * + * @package MDB2 + * @category Database + * @author Lukas Smith + */ +class MDB2_Driver_Function_sqlite3 extends MDB2_Driver_Function_Common +{ + // {{{ constructor + + /** + * Constructor + */ + function __construct($db_index) + { + parent::__construct($db_index); + // create all sorts of UDFs + } + + // {{{ now() + + /** + * Return string to call a variable with the current timestamp inside an SQL statement + * There are three special variables for current date and time. + * + * @return string to call a variable with the current timestamp + * @access public + */ + function now($type = 'timestamp') + { + switch ($type) { + case 'time': + return 'time(\'now\')'; + case 'date': + return 'date(\'now\')'; + case 'timestamp': + default: + return 'datetime(\'now\')'; + } + } + + // }}} + // {{{ unixtimestamp() + + /** + * return string to call a function to get the unix timestamp from a iso timestamp + * + * @param string $expression + * + * @return string to call a variable with the timestamp + * @access public + */ + function unixtimestamp($expression) + { + return 'strftime("%s",'. $expression.', "utc")'; + } + + // }}} + // {{{ substring() + + /** + * return string to call a function to get a substring inside an SQL statement + * + * @return string to call a function to get a substring + * @access public + */ + function substring($value, $position = 1, $length = null) + { + if (!is_null($length)) { + return "substr($value,$position,$length)"; + } + return "substr($value,$position,length($value))"; + } + + // }}} + // {{{ random() + + /** + * return string to call a function to get random value inside an SQL statement + * + * @return return string to generate float between 0 and 1 + * @access public + */ + function random() + { + return '((RANDOM()+2147483648)/4294967296)'; + } + + // }}} + // {{{ replace() + + /** + * return string to call a function to get a replacement inside an SQL statement. + * + * @return string to call a function to get a replace + * @access public + */ + function replace($str, $from_str, $to_str) + { + $db =& $this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $error =& $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'method not implemented', __FUNCTION__); + return $error; + } + + // }}} +} +?> diff --git a/lib/MDB2/Driver/Manager/sqlite3.php b/lib/MDB2/Driver/Manager/sqlite3.php new file mode 100644 index 0000000000..7096126a52 --- /dev/null +++ b/lib/MDB2/Driver/Manager/sqlite3.php @@ -0,0 +1,1364 @@ + | +// +----------------------------------------------------------------------+ +// +// + +require_once('MDB2/Driver/Manager/Common.php'); + +/** + * MDB2 SQLite driver for the management modules + * + * @package MDB2 + * @category Database + * @author Lukas Smith + * @author Lorenzo Alberton + */ +class MDB2_Driver_Manager_sqlite3 extends MDB2_Driver_Manager_Common +{ + // {{{ createDatabase() + + /** + * create a new database + * + * @param string $name name of the database that should be created + * @param array $options array with charset info + * + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + function createDatabase($name, $options = array()) + { + global $SERVERROOT; + $datadir=OC_CONFIG::getValue( "datadirectory", "$SERVERROOT/data" ); + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $database_file = $db->_getDatabaseFile($name); + if (file_exists($database_file)) { + return $db->raiseError(MDB2_ERROR_ALREADY_EXISTS, null, null, + 'database already exists', __FUNCTION__); + } + $php_errormsg = ''; + $database_file="$datadir/$database_file.db"; + $handle=new SQLite3($database_file); + if (!$handle) { + return $db->raiseError(MDB2_ERROR_CANNOT_CREATE, null, null, + (isset($php_errormsg) ? $php_errormsg : 'could not create the database file'), __FUNCTION__); + } + //sqlite doesn't support the latin1 we use +// if (!empty($options['charset'])) { +// $query = 'PRAGMA encoding = ' . $db->quote($options['charset'], 'text'); +// $handle->exec($query); +// } + $handle->close(); + return MDB2_OK; + } + + // }}} + // {{{ dropDatabase() + + /** + * drop an existing database + * + * @param string $name name of the database that should be dropped + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + function dropDatabase($name) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $database_file = $db->_getDatabaseFile($name); + if (!@file_exists($database_file)) { + return $db->raiseError(MDB2_ERROR_CANNOT_DROP, null, null, + 'database does not exist', __FUNCTION__); + } + $result = @unlink($database_file); + if (!$result) { + return $db->raiseError(MDB2_ERROR_CANNOT_DROP, null, null, + (isset($php_errormsg) ? $php_errormsg : 'could not remove the database file'), __FUNCTION__); + } + return MDB2_OK; + } + + // }}} + // {{{ _getAdvancedFKOptions() + + /** + * Return the FOREIGN KEY query section dealing with non-standard options + * as MATCH, INITIALLY DEFERRED, ON UPDATE, ... + * + * @param array $definition + * @return string + * @access protected + */ + function _getAdvancedFKOptions($definition) + { + $query = ''; + if (!empty($definition['match'])) { + $query .= ' MATCH '.$definition['match']; + } + if (!empty($definition['onupdate']) && (strtoupper($definition['onupdate']) != 'NO ACTION')) { + $query .= ' ON UPDATE '.$definition['onupdate']; + } + if (!empty($definition['ondelete']) && (strtoupper($definition['ondelete']) != 'NO ACTION')) { + $query .= ' ON DELETE '.$definition['ondelete']; + } + if (!empty($definition['deferrable'])) { + $query .= ' DEFERRABLE'; + } else { + $query .= ' NOT DEFERRABLE'; + } + if (!empty($definition['initiallydeferred'])) { + $query .= ' INITIALLY DEFERRED'; + } else { + $query .= ' INITIALLY IMMEDIATE'; + } + return $query; + } + + // }}} + // {{{ _getCreateTableQuery() + + /** + * Create a basic SQL query for a new table creation + * @param string $name Name of the database that should be created + * @param array $fields Associative array that contains the definition of each field of the new table + * @param array $options An associative array of table options + * @return mixed string (the SQL query) on success, a MDB2 error on failure + * @see createTable() + */ + function _getCreateTableQuery($name, $fields, $options = array()) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + if (!$name) { + return $db->raiseError(MDB2_ERROR_CANNOT_CREATE, null, null, + 'no valid table name specified', __FUNCTION__); + } + if (empty($fields)) { + return $db->raiseError(MDB2_ERROR_CANNOT_CREATE, null, null, + 'no fields specified for table "'.$name.'"', __FUNCTION__); + } + $query_fields = $this->getFieldDeclarationList($fields); + if (PEAR::isError($query_fields)) { + return $query_fields; + } + if (!empty($options['primary'])) { + $query_fields.= ', PRIMARY KEY ('.implode(', ', array_keys($options['primary'])).')'; + } + if (!empty($options['foreign_keys'])) { + foreach ($options['foreign_keys'] as $fkname => $fkdef) { + if (empty($fkdef)) { + continue; + } + $query_fields.= ', CONSTRAINT '.$fkname.' FOREIGN KEY ('.implode(', ', array_keys($fkdef['fields'])).')'; + $query_fields.= ' REFERENCES '.$fkdef['references']['table'].' ('.implode(', ', array_keys($fkdef['references']['fields'])).')'; + $query_fields.= $this->_getAdvancedFKOptions($fkdef); + } + } + + $name = $db->quoteIdentifier($name, true); + $result = 'CREATE '; + if (!empty($options['temporary'])) { + $result .= $this->_getTemporaryTableQuery(); + } + $result .= " TABLE $name ($query_fields)"; + return $result; + } + + // }}} + // {{{ createTable() + + /** + * create a new table + * + * @param string $name Name of the database that should be created + * @param array $fields Associative array that contains the definition + * of each field of the new table + * @param array $options An associative array of table options + * + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + function createTable($name, $fields, $options = array()) + { + $result = parent::createTable($name, $fields, $options); + if (PEAR::isError($result)) { + return $result; + } + // create triggers to enforce FOREIGN KEY constraints + if (!empty($options['foreign_keys'])) { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + foreach ($options['foreign_keys'] as $fkname => $fkdef) { + if (empty($fkdef)) { + continue; + } + //set actions to default if not set + $fkdef['onupdate'] = empty($fkdef['onupdate']) ? $db->options['default_fk_action_onupdate'] : strtoupper($fkdef['onupdate']); + $fkdef['ondelete'] = empty($fkdef['ondelete']) ? $db->options['default_fk_action_ondelete'] : strtoupper($fkdef['ondelete']); + + $trigger_names = array( + 'insert' => $fkname.'_insert_trg', + 'update' => $fkname.'_update_trg', + 'pk_update' => $fkname.'_pk_update_trg', + 'pk_delete' => $fkname.'_pk_delete_trg', + ); + + //create the [insert|update] triggers on the FK table + $table_fields = array_keys($fkdef['fields']); + $referenced_fields = array_keys($fkdef['references']['fields']); + $query = 'CREATE TRIGGER %s BEFORE %s ON '.$name + .' FOR EACH ROW BEGIN' + .' SELECT RAISE(ROLLBACK, \'%s on table "'.$name.'" violates FOREIGN KEY constraint "'.$fkname.'"\')' + .' WHERE (SELECT '; + $aliased_fields = array(); + foreach ($referenced_fields as $field) { + $aliased_fields[] = $fkdef['references']['table'] .'.'.$field .' AS '.$field; + } + $query .= implode(',', $aliased_fields) + .' FROM '.$fkdef['references']['table'] + .' WHERE '; + $conditions = array(); + for ($i=0; $iexec(sprintf($query, $trigger_names['insert'], 'INSERT', 'insert')); + if (PEAR::isError($result)) { + return $result; + } + + $result = $db->exec(sprintf($query, $trigger_names['update'], 'UPDATE', 'update')); + if (PEAR::isError($result)) { + return $result; + } + + //create the ON [UPDATE|DELETE] triggers on the primary table + $restrict_action = 'SELECT RAISE(ROLLBACK, \'%s on table "'.$name.'" violates FOREIGN KEY constraint "'.$fkname.'"\')' + .' WHERE (SELECT '; + $aliased_fields = array(); + foreach ($table_fields as $field) { + $aliased_fields[] = $name .'.'.$field .' AS '.$field; + } + $restrict_action .= implode(',', $aliased_fields) + .' FROM '.$name + .' WHERE '; + $conditions = array(); + $new_values = array(); + $null_values = array(); + for ($i=0; $i OLD.'.$referenced_fields[$i]; + } + $restrict_action .= implode(' AND ', $conditions).') IS NOT NULL' + .' AND (' .implode(' OR ', $conditions2) .')'; + + $cascade_action_update = 'UPDATE '.$name.' SET '.implode(', ', $new_values) .' WHERE '.implode(' AND ', $conditions); + $cascade_action_delete = 'DELETE FROM '.$name.' WHERE '.implode(' AND ', $conditions); + $setnull_action = 'UPDATE '.$name.' SET '.implode(', ', $null_values).' WHERE '.implode(' AND ', $conditions); + + if ('SET DEFAULT' == $fkdef['onupdate'] || 'SET DEFAULT' == $fkdef['ondelete']) { + $db->loadModule('Reverse', null, true); + $default_values = array(); + foreach ($table_fields as $table_field) { + $field_definition = $db->reverse->getTableFieldDefinition($name, $field); + if (PEAR::isError($field_definition)) { + return $field_definition; + } + $default_values[] = $table_field .' = '. $field_definition[0]['default']; + } + $setdefault_action = 'UPDATE '.$name.' SET '.implode(', ', $default_values).' WHERE '.implode(' AND ', $conditions); + } + + $query = 'CREATE TRIGGER %s' + .' %s ON '.$fkdef['references']['table'] + .' FOR EACH ROW BEGIN '; + + if ('CASCADE' == $fkdef['onupdate']) { + $sql_update = sprintf($query, $trigger_names['pk_update'], 'AFTER UPDATE', 'update') . $cascade_action_update. '; END;'; + } elseif ('SET NULL' == $fkdef['onupdate']) { + $sql_update = sprintf($query, $trigger_names['pk_update'], 'BEFORE UPDATE', 'update') . $setnull_action. '; END;'; + } elseif ('SET DEFAULT' == $fkdef['onupdate']) { + $sql_update = sprintf($query, $trigger_names['pk_update'], 'BEFORE UPDATE', 'update') . $setdefault_action. '; END;'; + } elseif ('NO ACTION' == $fkdef['onupdate']) { + $sql_update = sprintf($query.$restrict_action, $trigger_names['pk_update'], 'AFTER UPDATE', 'update') . '; END;'; + } elseif ('RESTRICT' == $fkdef['onupdate']) { + $sql_update = sprintf($query.$restrict_action, $trigger_names['pk_update'], 'BEFORE UPDATE', 'update') . '; END;'; + } + if ('CASCADE' == $fkdef['ondelete']) { + $sql_delete = sprintf($query, $trigger_names['pk_delete'], 'AFTER DELETE', 'delete') . $cascade_action_delete. '; END;'; + } elseif ('SET NULL' == $fkdef['ondelete']) { + $sql_delete = sprintf($query, $trigger_names['pk_delete'], 'BEFORE DELETE', 'delete') . $setnull_action. '; END;'; + } elseif ('SET DEFAULT' == $fkdef['ondelete']) { + $sql_delete = sprintf($query, $trigger_names['pk_delete'], 'BEFORE DELETE', 'delete') . $setdefault_action. '; END;'; + } elseif ('NO ACTION' == $fkdef['ondelete']) { + $sql_delete = sprintf($query.$restrict_action, $trigger_names['pk_delete'], 'AFTER DELETE', 'delete') . '; END;'; + } elseif ('RESTRICT' == $fkdef['ondelete']) { + $sql_delete = sprintf($query.$restrict_action, $trigger_names['pk_delete'], 'BEFORE DELETE', 'delete') . '; END;'; + } + + if (PEAR::isError($result)) { + return $result; + } + $result = $db->exec($sql_delete); + if (PEAR::isError($result)) { + return $result; + } + $result = $db->exec($sql_update); + if (PEAR::isError($result)) { + return $result; + } + } + } + if (PEAR::isError($result)) { + return $result; + } + return MDB2_OK; + } + + // }}} + // {{{ dropTable() + + /** + * drop an existing table + * + * @param string $name name of the table that should be dropped + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + function dropTable($name) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + //delete the triggers associated to existing FK constraints + $constraints = $this->listTableConstraints($name); + if (!PEAR::isError($constraints) && !empty($constraints)) { + $db->loadModule('Reverse', null, true); + foreach ($constraints as $constraint) { + $definition = $db->reverse->getTableConstraintDefinition($name, $constraint); + if (!PEAR::isError($definition) && !empty($definition['foreign'])) { + $result = $this->_dropFKTriggers($name, $constraint, $definition['references']['table']); + if (PEAR::isError($result)) { + return $result; + } + } + } + } + + $name = $db->quoteIdentifier($name, true); + return $db->exec("DROP TABLE $name"); + } + + // }}} + // {{{ vacuum() + + /** + * Optimize (vacuum) all the tables in the db (or only the specified table) + * and optionally run ANALYZE. + * + * @param string $table table name (all the tables if empty) + * @param array $options an array with driver-specific options: + * - timeout [int] (in seconds) [mssql-only] + * - analyze [boolean] [pgsql and mysql] + * - full [boolean] [pgsql-only] + * - freeze [boolean] [pgsql-only] + * + * @return mixed MDB2_OK success, a MDB2 error on failure + * @access public + */ + function vacuum($table = null, $options = array()) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $query = 'VACUUM'; + if (!empty($table)) { + $query .= ' '.$db->quoteIdentifier($table, true); + } + return $db->exec($query); + } + + // }}} + // {{{ alterTable() + + /** + * alter an existing table + * + * @param string $name name of the table that is intended to be changed. + * @param array $changes associative array that contains the details of each type + * of change that is intended to be performed. The types of + * changes that are currently supported are defined as follows: + * + * name + * + * New name for the table. + * + * add + * + * Associative array with the names of fields to be added as + * indexes of the array. The value of each entry of the array + * should be set to another associative array with the properties + * of the fields to be added. The properties of the fields should + * be the same as defined by the MDB2 parser. + * + * + * remove + * + * Associative array with the names of fields to be removed as indexes + * of the array. Currently the values assigned to each entry are ignored. + * An empty array should be used for future compatibility. + * + * rename + * + * Associative array with the names of fields to be renamed as indexes + * of the array. The value of each entry of the array should be set to + * another associative array with the entry named name with the new + * field name and the entry named Declaration that is expected to contain + * the portion of the field declaration already in DBMS specific SQL code + * as it is used in the CREATE TABLE statement. + * + * change + * + * Associative array with the names of the fields to be changed as indexes + * of the array. Keep in mind that if it is intended to change either the + * name of a field and any other properties, the change array entries + * should have the new names of the fields as array indexes. + * + * The value of each entry of the array should be set to another associative + * array with the properties of the fields to that are meant to be changed as + * array entries. These entries should be assigned to the new values of the + * respective properties. The properties of the fields should be the same + * as defined by the MDB2 parser. + * + * Example + * array( + * 'name' => 'userlist', + * 'add' => array( + * 'quota' => array( + * 'type' => 'integer', + * 'unsigned' => 1 + * ) + * ), + * 'remove' => array( + * 'file_limit' => array(), + * 'time_limit' => array() + * ), + * 'change' => array( + * 'name' => array( + * 'length' => '20', + * 'definition' => array( + * 'type' => 'text', + * 'length' => 20, + * ), + * ) + * ), + * 'rename' => array( + * 'sex' => array( + * 'name' => 'gender', + * 'definition' => array( + * 'type' => 'text', + * 'length' => 1, + * 'default' => 'M', + * ), + * ) + * ) + * ) + * + * @param boolean $check indicates whether the function should just check if the DBMS driver + * can perform the requested table alterations if the value is true or + * actually perform them otherwise. + * @access public + * + * @return mixed MDB2_OK on success, a MDB2 error on failure + */ + function alterTable($name, $changes, $check, $options = array()) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + foreach ($changes as $change_name => $change) { + switch ($change_name) { + case 'add': + case 'remove': + case 'change': + case 'name': + case 'rename': + break; + default: + return $db->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null, + 'change type "'.$change_name.'" not yet supported', __FUNCTION__); + } + } + + if ($check) { + return MDB2_OK; + } + + $db->loadModule('Reverse', null, true); + + // actually sqlite 2.x supports no ALTER TABLE at all .. so we emulate it + $fields = $db->manager->listTableFields($name); + if (PEAR::isError($fields)) { + return $fields; + } + + $fields = array_flip($fields); + foreach ($fields as $field => $value) { + $definition = $db->reverse->getTableFieldDefinition($name, $field); + if (PEAR::isError($definition)) { + return $definition; + } + $fields[$field] = $definition[0]; + } + + $indexes = $db->manager->listTableIndexes($name); + if (PEAR::isError($indexes)) { + return $indexes; + } + + $indexes = array_flip($indexes); + foreach ($indexes as $index => $value) { + $definition = $db->reverse->getTableIndexDefinition($name, $index); + if (PEAR::isError($definition)) { + return $definition; + } + $indexes[$index] = $definition; + } + + $constraints = $db->manager->listTableConstraints($name); + if (PEAR::isError($constraints)) { + return $constraints; + } + + if (!array_key_exists('foreign_keys', $options)) { + $options['foreign_keys'] = array(); + } + $constraints = array_flip($constraints); + foreach ($constraints as $constraint => $value) { + if (!empty($definition['primary'])) { + if (!array_key_exists('primary', $options)) { + $options['primary'] = $definition['fields']; + //remove from the $constraint array, it's already handled by createTable() + unset($constraints[$constraint]); + } + } else { + $c_definition = $db->reverse->getTableConstraintDefinition($name, $constraint); + if (PEAR::isError($c_definition)) { + return $c_definition; + } + if (!empty($c_definition['foreign'])) { + if (!array_key_exists($constraint, $options['foreign_keys'])) { + $options['foreign_keys'][$constraint] = $c_definition; + } + //remove from the $constraint array, it's already handled by createTable() + unset($constraints[$constraint]); + } else { + $constraints[$constraint] = $c_definition; + } + } + } + + $name_new = $name; + $create_order = $select_fields = array_keys($fields); + foreach ($changes as $change_name => $change) { + switch ($change_name) { + case 'add': + foreach ($change as $field_name => $field) { + $fields[$field_name] = $field; + $create_order[] = $field_name; + } + break; + case 'remove': + foreach ($change as $field_name => $field) { + unset($fields[$field_name]); + $select_fields = array_diff($select_fields, array($field_name)); + $create_order = array_diff($create_order, array($field_name)); + } + break; + case 'change': + foreach ($change as $field_name => $field) { + $fields[$field_name] = $field['definition']; + } + break; + case 'name': + $name_new = $change; + break; + case 'rename': + foreach ($change as $field_name => $field) { + unset($fields[$field_name]); + $fields[$field['name']] = $field['definition']; + $create_order[array_search($field_name, $create_order)] = $field['name']; + } + break; + default: + return $db->raiseError(MDB2_ERROR_CANNOT_ALTER, null, null, + 'change type "'.$change_name.'" not yet supported', __FUNCTION__); + } + } + + $data = null; + if (!empty($select_fields)) { + $query = 'SELECT '.implode(', ', $select_fields).' FROM '.$db->quoteIdentifier($name, true); + $data = $db->queryAll($query, null, MDB2_FETCHMODE_ORDERED); + } + + $result = $this->dropTable($name); + if (PEAR::isError($result)) { + return $result; + } + + $result = $this->createTable($name_new, $fields, $options); + if (PEAR::isError($result)) { + return $result; + } + + foreach ($indexes as $index => $definition) { + $this->createIndex($name_new, $index, $definition); + } + + foreach ($constraints as $constraint => $definition) { + $this->createConstraint($name_new, $constraint, $definition); + } + + if (!empty($select_fields) && !empty($data)) { + $query = 'INSERT INTO '.$db->quoteIdentifier($name_new, true); + $query.= '('.implode(', ', array_slice(array_keys($fields), 0, count($select_fields))).')'; + $query.=' VALUES (?'.str_repeat(', ?', (count($select_fields) - 1)).')'; + $stmt =$db->prepare($query, null, MDB2_PREPARE_MANIP); + if (PEAR::isError($stmt)) { + return $stmt; + } + foreach ($data as $row) { + $result = $stmt->execute($row); + if (PEAR::isError($result)) { + return $result; + } + } + } + return MDB2_OK; + } + + // }}} + // {{{ listDatabases() + + /** + * list all databases + * + * @return mixed array of database names on success, a MDB2 error on failure + * @access public + */ + function listDatabases() + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'list databases is not supported', __FUNCTION__); + } + + // }}} + // {{{ listUsers() + + /** + * list all users + * + * @return mixed array of user names on success, a MDB2 error on failure + * @access public + */ + function listUsers() + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'list databases is not supported', __FUNCTION__); + } + + // }}} + // {{{ listViews() + + /** + * list all views in the current database + * + * @return mixed array of view names on success, a MDB2 error on failure + * @access public + */ + function listViews($dummy=null) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $query = "SELECT name FROM sqlite_master WHERE type='view' AND sql NOT NULL"; + $result = $db->queryCol($query); + if (PEAR::isError($result)) { + return $result; + } + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result); + } + return $result; + } + + // }}} + // {{{ listTableViews() + + /** + * list the views in the database that reference a given table + * + * @param string table for which all referenced views should be found + * @return mixed array of view names on success, a MDB2 error on failure + * @access public + */ + function listTableViews($table) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $query = "SELECT name, sql FROM sqlite_master WHERE type='view' AND sql NOT NULL"; + $views = $db->queryAll($query, array('text', 'text'), MDB2_FETCHMODE_ASSOC); + if (PEAR::isError($views)) { + return $views; + } + $result = array(); + foreach ($views as $row) { + if (preg_match("/^create view .* \bfrom\b\s+\b{$table}\b /i", $row['sql'])) { + if (!empty($row['name'])) { + $result[$row['name']] = true; + } + } + } + + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $result = array_change_key_case($result, $db->options['field_case']); + } + return array_keys($result); + } + + // }}} + // {{{ listTables() + + /** + * list all tables in the current database + * + * @return mixed array of table names on success, a MDB2 error on failure + * @access public + */ + function listTables($dummy=null) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $query = "SELECT name FROM sqlite_master WHERE type='table' AND sql NOT NULL ORDER BY name"; + $table_names = $db->queryCol($query); + if (PEAR::isError($table_names)) { + return $table_names; + } + $result = array(); + foreach ($table_names as $table_name) { + if (!$this->_fixSequenceName($table_name, true)) { + $result[] = $table_name; + } + } + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result); + } + return $result; + } + + // }}} + // {{{ listTableFields() + + /** + * list all fields in a table in the current database + * + * @param string $table name of table that should be used in method + * @return mixed array of field names on success, a MDB2 error on failure + * @access public + */ + function listTableFields($table) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $result = $db->loadModule('Reverse', null, true); + if (PEAR::isError($result)) { + return $result; + } + $query = "SELECT sql FROM sqlite_master WHERE type='table' AND "; + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $query.= 'LOWER(name)='.$db->quote(strtolower($table), 'text'); + } else { + $query.= 'name='.$db->quote($table, 'text'); + } + $sql = $db->queryOne($query); + if (PEAR::isError($sql)) { + return $sql; + } + $columns = $db->reverse->_getTableColumns($sql); + $fields = array(); + foreach ($columns as $column) { + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + if ($db->options['field_case'] == CASE_LOWER) { + $column['name'] = strtolower($column['name']); + } else { + $column['name'] = strtoupper($column['name']); + } + } else { + $column = array_change_key_case($column, $db->options['field_case']); + } + $fields[] = $column['name']; + } + return $fields; + } + + // }}} + // {{{ listTableTriggers() + + /** + * list all triggers in the database that reference a given table + * + * @param string table for which all referenced triggers should be found + * @return mixed array of trigger names on success, a MDB2 error on failure + * @access public + */ + function listTableTriggers($table = null) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $query = "SELECT name FROM sqlite_master WHERE type='trigger' AND sql NOT NULL"; + if (!is_null($table)) { + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $query.= ' AND LOWER(tbl_name)='.$db->quote(strtolower($table), 'text'); + } else { + $query.= ' AND tbl_name='.$db->quote($table, 'text'); + } + } + $result = $db->queryCol($query); + if (PEAR::isError($result)) { + return $result; + } + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result); + } + return $result; + } + + // }}} + // {{{ createIndex() + + /** + * Get the stucture of a field into an array + * + * @param string $table name of the table on which the index is to be created + * @param string $name name of the index to be created + * @param array $definition associative array that defines properties of the index to be created. + * Currently, only one property named FIELDS is supported. This property + * is also an associative with the names of the index fields as array + * indexes. Each entry of this array is set to another type of associative + * array that specifies properties of the index that are specific to + * each field. + * + * Currently, only the sorting property is supported. It should be used + * to define the sorting direction of the index. It may be set to either + * ascending or descending. + * + * Not all DBMS support index sorting direction configuration. The DBMS + * drivers of those that do not support it ignore this property. Use the + * function support() to determine whether the DBMS driver can manage indexes. + + * Example + * array( + * 'fields' => array( + * 'user_name' => array( + * 'sorting' => 'ascending' + * ), + * 'last_login' => array() + * ) + * ) + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + function createIndex($table, $name, $definition) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $table = $db->quoteIdentifier($table, true); + $name = $db->getIndexName($name); + $query = "CREATE INDEX $name ON $table"; + $fields = array(); + foreach ($definition['fields'] as $field_name => $field) { + $field_string = $field_name; + if (!empty($field['sorting'])) { + switch ($field['sorting']) { + case 'ascending': + $field_string.= ' ASC'; + break; + case 'descending': + $field_string.= ' DESC'; + break; + } + } + $fields[] = $field_string; + } + $query .= ' ('.implode(', ', $fields) . ')'; + return $db->exec($query); + } + + // }}} + // {{{ dropIndex() + + /** + * drop existing index + * + * @param string $table name of table that should be used in method + * @param string $name name of the index to be dropped + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + function dropIndex($table, $name) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $name = $db->getIndexName($name); + return $db->exec("DROP INDEX $name"); + } + + // }}} + // {{{ listTableIndexes() + + /** + * list all indexes in a table + * + * @param string $table name of table that should be used in method + * @return mixed array of index names on success, a MDB2 error on failure + * @access public + */ + function listTableIndexes($table) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $table = $db->quote($table, 'text'); + $query = "SELECT sql FROM sqlite_master WHERE type='index' AND "; + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $query.= 'LOWER(tbl_name)='.strtolower($table); + } else { + $query.= "tbl_name=$table"; + } + $query.= " AND sql NOT NULL ORDER BY name"; + $indexes = $db->queryCol($query, 'text'); + if (PEAR::isError($indexes)) { + return $indexes; + } + + $result = array(); + foreach ($indexes as $sql) { + if (preg_match("/^create index ([^ ]+) on /i", $sql, $tmp)) { + $index = $this->_fixIndexName($tmp[1]); + if (!empty($index)) { + $result[$index] = true; + } + } + } + + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $result = array_change_key_case($result, $db->options['field_case']); + } + return array_keys($result); + } + + // }}} + // {{{ createConstraint() + + /** + * create a constraint on a table + * + * @param string $table name of the table on which the constraint is to be created + * @param string $name name of the constraint to be created + * @param array $definition associative array that defines properties of the constraint to be created. + * Currently, only one property named FIELDS is supported. This property + * is also an associative with the names of the constraint fields as array + * constraints. Each entry of this array is set to another type of associative + * array that specifies properties of the constraint that are specific to + * each field. + * + * Example + * array( + * 'fields' => array( + * 'user_name' => array(), + * 'last_login' => array() + * ) + * ) + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + function createConstraint($table, $name, $definition) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + if (!empty($definition['primary'])) { + return $db->manager->alterTable($table, array(), false, array('primary' => $definition['fields'])); + } + + if (!empty($definition['foreign'])) { + return $db->manager->alterTable($table, array(), false, array('foreign_keys' => array($name => $definition))); + } + + $table = $db->quoteIdentifier($table, true); + $name = $db->getIndexName($name); + $query = "CREATE UNIQUE INDEX $name ON $table"; + $fields = array(); + foreach ($definition['fields'] as $field_name => $field) { + $field_string = $field_name; + if (!empty($field['sorting'])) { + switch ($field['sorting']) { + case 'ascending': + $field_string.= ' ASC'; + break; + case 'descending': + $field_string.= ' DESC'; + break; + } + } + $fields[] = $field_string; + } + $query .= ' ('.implode(', ', $fields) . ')'; + return $db->exec($query); + } + + // }}} + // {{{ dropConstraint() + + /** + * drop existing constraint + * + * @param string $table name of table that should be used in method + * @param string $name name of the constraint to be dropped + * @param string $primary hint if the constraint is primary + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + function dropConstraint($table, $name, $primary = false) + { + if ($primary || $name == 'PRIMARY') { + return $this->alterTable($table, array(), false, array('primary' => null)); + } + + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + //is it a FK constraint? If so, also delete the associated triggers + $db->loadModule('Reverse', null, true); + $definition = $db->reverse->getTableConstraintDefinition($table, $name); + if (!PEAR::isError($definition) && !empty($definition['foreign'])) { + //first drop the FK enforcing triggers + $result = $this->_dropFKTriggers($table, $name, $definition['references']['table']); + if (PEAR::isError($result)) { + return $result; + } + //then drop the constraint itself + return $this->alterTable($table, array(), false, array('foreign_keys' => array($name => null))); + } + + $name = $db->getIndexName($name); + return $db->exec("DROP INDEX $name"); + } + + // }}} + // {{{ _dropFKTriggers() + + /** + * Drop the triggers created to enforce the FOREIGN KEY constraint on the table + * + * @param string $table table name + * @param string $fkname FOREIGN KEY constraint name + * @param string $referenced_table referenced table name + * + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access private + */ + function _dropFKTriggers($table, $fkname, $referenced_table) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $triggers = $this->listTableTriggers($table); + $triggers2 = $this->listTableTriggers($referenced_table); + if (!PEAR::isError($triggers2) && !PEAR::isError($triggers)) { + $triggers = array_merge($triggers, $triggers2); + $pattern = '/^'.$fkname.'(_pk)?_(insert|update|delete)_trg$/i'; + foreach ($triggers as $trigger) { + if (preg_match($pattern, $trigger)) { + $result = $db->exec('DROP TRIGGER '.$trigger); + if (PEAR::isError($result)) { + return $result; + } + } + } + } + return MDB2_OK; + } + + // }}} + // {{{ listTableConstraints() + + /** + * list all constraints in a table + * + * @param string $table name of table that should be used in method + * @return mixed array of constraint names on success, a MDB2 error on failure + * @access public + */ + function listTableConstraints($table) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $table = $db->quote($table, 'text'); + $query = "SELECT sql FROM sqlite_master WHERE type='index' AND "; + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $query.= 'LOWER(tbl_name)='.strtolower($table); + } else { + $query.= "tbl_name=$table"; + } + $query.= " AND sql NOT NULL ORDER BY name"; + $indexes = $db->queryCol($query, 'text'); + if (PEAR::isError($indexes)) { + return $indexes; + } + + $result = array(); + foreach ($indexes as $sql) { + if (preg_match("/^create unique index ([^ ]+) on /i", $sql, $tmp)) { + $index = $this->_fixIndexName($tmp[1]); + if (!empty($index)) { + $result[$index] = true; + } + } + } + + // also search in table definition for PRIMARY KEYs... + $query = "SELECT sql FROM sqlite_master WHERE type='table' AND "; + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $query.= 'LOWER(name)='.strtolower($table); + } else { + $query.= "name=$table"; + } + $query.= " AND sql NOT NULL ORDER BY name"; + $table_def = $db->queryOne($query, 'text'); + if (PEAR::isError($table_def)) { + return $table_def; + } + if (preg_match("/\bPRIMARY\s+KEY\b/i", $table_def, $tmp)) { + $result['primary'] = true; + } + + // ...and for FOREIGN KEYs + if (preg_match_all("/\bCONSTRAINT\b\s+([^\s]+)\s+\bFOREIGN\s+KEY/imsx", $table_def, $tmp)) { + foreach ($tmp[1] as $fk) { + $result[$fk] = true; + } + } + + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $result = array_change_key_case($result, $db->options['field_case']); + } + return array_keys($result); + } + + // }}} + // {{{ createSequence() + + /** + * create sequence + * + * @param string $seq_name name of the sequence to be created + * @param string $start start value of the sequence; default is 1 + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + function createSequence($seq_name, $start = 1) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true); + $seqcol_name = $db->quoteIdentifier($db->options['seqcol_name'], true); + $query = "CREATE TABLE $sequence_name ($seqcol_name INTEGER PRIMARY KEY DEFAULT 0 NOT NULL)"; + $res = $db->exec($query); + if (PEAR::isError($res)) { + return $res; + } + if ($start == 1) { + return MDB2_OK; + } + $res = $db->exec("INSERT INTO $sequence_name ($seqcol_name) VALUES (".($start-1).')'); + if (!PEAR::isError($res)) { + return MDB2_OK; + } + // Handle error + $result = $db->exec("DROP TABLE $sequence_name"); + if (PEAR::isError($result)) { + return $db->raiseError($result, null, null, + 'could not drop inconsistent sequence table', __FUNCTION__); + } + return $db->raiseError($res, null, null, + 'could not create sequence table', __FUNCTION__); + } + + // }}} + // {{{ dropSequence() + + /** + * drop existing sequence + * + * @param string $seq_name name of the sequence to be dropped + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + function dropSequence($seq_name) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $sequence_name = $db->quoteIdentifier($db->getSequenceName($seq_name), true); + return $db->exec("DROP TABLE $sequence_name"); + } + + // }}} + // {{{ listSequences() + + /** + * list all sequences in the current database + * + * @return mixed array of sequence names on success, a MDB2 error on failure + * @access public + */ + function listSequences($dummy=null) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $query = "SELECT name FROM sqlite_master WHERE type='table' AND sql NOT NULL ORDER BY name"; + $table_names = $db->queryCol($query); + if (PEAR::isError($table_names)) { + return $table_names; + } + $result = array(); + foreach ($table_names as $table_name) { + if ($sqn = $this->_fixSequenceName($table_name, true)) { + $result[] = $sqn; + } + } + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $result = array_map(($db->options['field_case'] == CASE_LOWER ? 'strtolower' : 'strtoupper'), $result); + } + return $result; + } + + // }}} +} +?> \ No newline at end of file diff --git a/lib/MDB2/Driver/Native/sqlite3.php b/lib/MDB2/Driver/Native/sqlite3.php new file mode 100644 index 0000000000..81dc67dea6 --- /dev/null +++ b/lib/MDB2/Driver/Native/sqlite3.php @@ -0,0 +1,58 @@ + | +// +----------------------------------------------------------------------+ +// +// +require_once 'MDB2/Driver/Native/Common.php'; + +/** + * MDB2 SQLite driver for the native module + * + * @package MDB2 + * @category Database + * @author Lukas Smith + */ +class MDB2_Driver_Native_sqlite extends MDB2_Driver_Native_Common +{ +} +?> \ No newline at end of file diff --git a/lib/MDB2/Driver/Reverse/sqlite3.php b/lib/MDB2/Driver/Reverse/sqlite3.php new file mode 100644 index 0000000000..d488977b15 --- /dev/null +++ b/lib/MDB2/Driver/Reverse/sqlite3.php @@ -0,0 +1,607 @@ + | +// +----------------------------------------------------------------------+ +// +// + +require_once('MDB2/Driver/Reverse/Common.php'); + +/** + * MDB2 SQlite driver for the schema reverse engineering module + * + * @package MDB2 + * @category Database + * @author Lukas Smith + */ +class MDB2_Driver_Reverse_sqlite3 extends MDB2_Driver_Reverse_Common +{ + /** + * Remove SQL comments from the field definition + * + * @access private + */ + function _removeComments($sql) { + $lines = explode("\n", $sql); + foreach ($lines as $k => $line) { + $pieces = explode('--', $line); + if (count($pieces) > 1 && (substr_count($pieces[0], '\'') % 2) == 0) { + $lines[$k] = substr($line, 0, strpos($line, '--')); + } + } + return implode("\n", $lines); + } + + /** + * + */ + function _getTableColumns($sql) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + $start_pos = strpos($sql, '('); + $end_pos = strrpos($sql, ')'); + $column_def = substr($sql, $start_pos+1, $end_pos-$start_pos-1); + // replace the decimal length-places-separator with a colon + $column_def = preg_replace('/(\d),(\d)/', '\1:\2', $column_def); + $column_def = $this->_removeComments($column_def); + $column_sql = explode(',', $column_def); + $columns = array(); + $count = count($column_sql); + if ($count == 0) { + return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'unexpected empty table column definition list', __FUNCTION__); + } + $regexp = '/^\s*([^\s]+) +(CHAR|VARCHAR|VARCHAR2|TEXT|BOOLEAN|SMALLINT|INT|INTEGER|DECIMAL|BIGINT|DOUBLE|FLOAT|DATETIME|DATE|TIME|LONGTEXT|LONGBLOB)( ?\(([1-9][0-9]*)(:([1-9][0-9]*))?\))?( NULL| NOT NULL)?( UNSIGNED)?( NULL| NOT NULL)?( PRIMARY KEY)?( DEFAULT (\'[^\']*\'|[^ ]+))?( NULL| NOT NULL)?( PRIMARY KEY)?(\s*\-\-.*)?$/i'; + $regexp2 = '/^\s*([^ ]+) +(PRIMARY|UNIQUE|CHECK)$/i'; + for ($i=0, $j=0; $i<$count; ++$i) { + if (!preg_match($regexp, trim($column_sql[$i]), $matches)) { + if (!preg_match($regexp2, trim($column_sql[$i]))) { + continue; + } + return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'unexpected table column SQL definition: "'.$column_sql[$i].'"', __FUNCTION__); + } + $columns[$j]['name'] = trim($matches[1], implode('', $db->identifier_quoting)); + $columns[$j]['type'] = strtolower($matches[2]); + if (isset($matches[4]) && strlen($matches[4])) { + $columns[$j]['length'] = $matches[4]; + } + if (isset($matches[6]) && strlen($matches[6])) { + $columns[$j]['decimal'] = $matches[6]; + } + if (isset($matches[8]) && strlen($matches[8])) { + $columns[$j]['unsigned'] = true; + } + if (isset($matches[9]) && strlen($matches[9])) { + $columns[$j]['autoincrement'] = true; + } + if (isset($matches[12]) && strlen($matches[12])) { + $default = $matches[12]; + if (strlen($default) && $default[0]=="'") { + $default = str_replace("''", "'", substr($default, 1, strlen($default)-2)); + } + if ($default === 'NULL') { + $default = null; + } + $columns[$j]['default'] = $default; + } + if (isset($matches[7]) && strlen($matches[7])) { + $columns[$j]['notnull'] = ($matches[7] === ' NOT NULL'); + } else if (isset($matches[9]) && strlen($matches[9])) { + $columns[$j]['notnull'] = ($matches[9] === ' NOT NULL'); + } else if (isset($matches[13]) && strlen($matches[13])) { + $columns[$j]['notnull'] = ($matches[13] === ' NOT NULL'); + } + ++$j; + } + return $columns; + } + + // {{{ getTableFieldDefinition() + + /** + * Get the stucture of a field into an array + * + * @param string $table_name name of table that should be used in method + * @param string $field_name name of field that should be used in method + * @return mixed data array on success, a MDB2 error on failure. + * The returned array contains an array for each field definition, + * with (some of) these indices: + * [notnull] [nativetype] [length] [fixed] [default] [type] [mdb2type] + * @access public + */ + function getTableFieldDefinition($table_name, $field_name) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + list($schema, $table) = $this->splitTableSchema($table_name); + + $result = $db->loadModule('Datatype', null, true); + if (PEAR::isError($result)) { + return $result; + } + $query = "SELECT sql FROM sqlite_master WHERE type='table' AND "; + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $query.= 'LOWER(name)='.$db->quote(strtolower($table), 'text'); + } else { + $query.= 'name='.$db->quote($table, 'text'); + } + $sql = $db->queryOne($query); + if (PEAR::isError($sql)) { + return $sql; + } + $columns = $this->_getTableColumns($sql); + foreach ($columns as $column) { + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + if ($db->options['field_case'] == CASE_LOWER) { + $column['name'] = strtolower($column['name']); + } else { + $column['name'] = strtoupper($column['name']); + } + } else { + $column = array_change_key_case($column, $db->options['field_case']); + } + if ($field_name == $column['name']) { + $mapped_datatype = $db->datatype->mapNativeDatatype($column); + if (PEAR::isError($mapped_datatype)) { + return $mapped_datatype; + } + list($types, $length, $unsigned, $fixed) = $mapped_datatype; + $notnull = false; + if (!empty($column['notnull'])) { + $notnull = $column['notnull']; + } + $default = false; + if (array_key_exists('default', $column)) { + $default = $column['default']; + if (is_null($default) && $notnull) { + $default = ''; + } + } + $autoincrement = false; + if (!empty($column['autoincrement'])) { + $autoincrement = true; + } + + $definition[0] = array( + 'notnull' => $notnull, + 'nativetype' => preg_replace('/^([a-z]+)[^a-z].*/i', '\\1', $column['type']) + ); + if (!is_null($length)) { + $definition[0]['length'] = $length; + } + if (!is_null($unsigned)) { + $definition[0]['unsigned'] = $unsigned; + } + if (!is_null($fixed)) { + $definition[0]['fixed'] = $fixed; + } + if ($default !== false) { + $definition[0]['default'] = $default; + } + if ($autoincrement !== false) { + $definition[0]['autoincrement'] = $autoincrement; + } + foreach ($types as $key => $type) { + $definition[$key] = $definition[0]; + if ($type == 'clob' || $type == 'blob') { + unset($definition[$key]['default']); + } + $definition[$key]['type'] = $type; + $definition[$key]['mdb2type'] = $type; + } + return $definition; + } + } + + return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, + 'it was not specified an existing table column', __FUNCTION__); + } + + // }}} + // {{{ getTableIndexDefinition() + + /** + * Get the stucture of an index into an array + * + * @param string $table_name name of table that should be used in method + * @param string $index_name name of index that should be used in method + * @return mixed data array on success, a MDB2 error on failure + * @access public + */ + function getTableIndexDefinition($table_name, $index_name) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + list($schema, $table) = $this->splitTableSchema($table_name); + + $query = "SELECT sql FROM sqlite_master WHERE type='index' AND "; + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $query.= 'LOWER(name)=%s AND LOWER(tbl_name)=' . $db->quote(strtolower($table), 'text'); + } else { + $query.= 'name=%s AND tbl_name=' . $db->quote($table, 'text'); + } + $query.= ' AND sql NOT NULL ORDER BY name'; + $index_name_mdb2 = $db->getIndexName($index_name); + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $qry = sprintf($query, $db->quote(strtolower($index_name_mdb2), 'text')); + } else { + $qry = sprintf($query, $db->quote($index_name_mdb2, 'text')); + } + $sql = $db->queryOne($qry, 'text'); + if (PEAR::isError($sql) || empty($sql)) { + // fallback to the given $index_name, without transformation + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $qry = sprintf($query, $db->quote(strtolower($index_name), 'text')); + } else { + $qry = sprintf($query, $db->quote($index_name, 'text')); + } + $sql = $db->queryOne($qry, 'text'); + } + if (PEAR::isError($sql)) { + return $sql; + } + if (!$sql) { + return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, + 'it was not specified an existing table index', __FUNCTION__); + } + + $sql = strtolower($sql); + $start_pos = strpos($sql, '('); + $end_pos = strrpos($sql, ')'); + $column_names = substr($sql, $start_pos+1, $end_pos-$start_pos-1); + $column_names = explode(',', $column_names); + + if (preg_match("/^create unique/", $sql)) { + return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, + 'it was not specified an existing table index', __FUNCTION__); + } + + $definition = array(); + $count = count($column_names); + for ($i=0; $i<$count; ++$i) { + $column_name = strtok($column_names[$i], ' '); + $collation = strtok(' '); + $definition['fields'][$column_name] = array( + 'position' => $i+1 + ); + if (!empty($collation)) { + $definition['fields'][$column_name]['sorting'] = + ($collation=='ASC' ? 'ascending' : 'descending'); + } + } + + if (empty($definition['fields'])) { + return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, + 'it was not specified an existing table index', __FUNCTION__); + } + return $definition; + } + + // }}} + // {{{ getTableConstraintDefinition() + + /** + * Get the stucture of a constraint into an array + * + * @param string $table_name name of table that should be used in method + * @param string $constraint_name name of constraint that should be used in method + * @return mixed data array on success, a MDB2 error on failure + * @access public + */ + function getTableConstraintDefinition($table_name, $constraint_name) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + list($schema, $table) = $this->splitTableSchema($table_name); + + $query = "SELECT sql FROM sqlite_master WHERE type='index' AND "; + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $query.= 'LOWER(name)=%s AND LOWER(tbl_name)=' . $db->quote(strtolower($table), 'text'); + } else { + $query.= 'name=%s AND tbl_name=' . $db->quote($table, 'text'); + } + $query.= ' AND sql NOT NULL ORDER BY name'; + $constraint_name_mdb2 = $db->getIndexName($constraint_name); + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $qry = sprintf($query, $db->quote(strtolower($constraint_name_mdb2), 'text')); + } else { + $qry = sprintf($query, $db->quote($constraint_name_mdb2, 'text')); + } + $sql = $db->queryOne($qry, 'text'); + if (PEAR::isError($sql) || empty($sql)) { + // fallback to the given $index_name, without transformation + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $qry = sprintf($query, $db->quote(strtolower($constraint_name), 'text')); + } else { + $qry = sprintf($query, $db->quote($constraint_name, 'text')); + } + $sql = $db->queryOne($qry, 'text'); + } + if (PEAR::isError($sql)) { + return $sql; + } + //default values, eventually overridden + $definition = array( + 'primary' => false, + 'unique' => false, + 'foreign' => false, + 'check' => false, + 'fields' => array(), + 'references' => array( + 'table' => '', + 'fields' => array(), + ), + 'onupdate' => '', + 'ondelete' => '', + 'match' => '', + 'deferrable' => false, + 'initiallydeferred' => false, + ); + if (!$sql) { + $query = "SELECT sql FROM sqlite_master WHERE type='table' AND "; + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $query.= 'LOWER(name)='.$db->quote(strtolower($table), 'text'); + } else { + $query.= 'name='.$db->quote($table, 'text'); + } + $query.= " AND sql NOT NULL ORDER BY name"; + $sql = $db->queryOne($query, 'text'); + if (PEAR::isError($sql)) { + return $sql; + } + if ($constraint_name == 'primary') { + // search in table definition for PRIMARY KEYs + if (preg_match("/\bPRIMARY\s+KEY\b\s*\(([^)]+)/i", $sql, $tmp)) { + $definition['primary'] = true; + $definition['fields'] = array(); + $column_names = explode(',', $tmp[1]); + $colpos = 1; + foreach ($column_names as $column_name) { + $definition['fields'][trim($column_name)] = array( + 'position' => $colpos++ + ); + } + return $definition; + } + if (preg_match("/\"([^\"]+)\"[^\,\"]+\bPRIMARY\s+KEY\b[^\,\)]*/i", $sql, $tmp)) { + $definition['primary'] = true; + $definition['fields'] = array(); + $column_names = explode(',', $tmp[1]); + $colpos = 1; + foreach ($column_names as $column_name) { + $definition['fields'][trim($column_name)] = array( + 'position' => $colpos++ + ); + } + return $definition; + } + } else { + // search in table definition for FOREIGN KEYs + $pattern = "/\bCONSTRAINT\b\s+%s\s+ + \bFOREIGN\s+KEY\b\s*\(([^\)]+)\)\s* + \bREFERENCES\b\s+([^\s]+)\s*\(([^\)]+)\)\s* + (?:\bMATCH\s*([^\s]+))?\s* + (?:\bON\s+UPDATE\s+([^\s,\)]+))?\s* + (?:\bON\s+DELETE\s+([^\s,\)]+))?\s* + /imsx"; + $found_fk = false; + if (preg_match(sprintf($pattern, $constraint_name_mdb2), $sql, $tmp)) { + $found_fk = true; + } elseif (preg_match(sprintf($pattern, $constraint_name), $sql, $tmp)) { + $found_fk = true; + } + if ($found_fk) { + $definition['foreign'] = true; + $definition['match'] = 'SIMPLE'; + $definition['onupdate'] = 'NO ACTION'; + $definition['ondelete'] = 'NO ACTION'; + $definition['references']['table'] = $tmp[2]; + $column_names = explode(',', $tmp[1]); + $colpos = 1; + foreach ($column_names as $column_name) { + $definition['fields'][trim($column_name)] = array( + 'position' => $colpos++ + ); + } + $referenced_cols = explode(',', $tmp[3]); + $colpos = 1; + foreach ($referenced_cols as $column_name) { + $definition['references']['fields'][trim($column_name)] = array( + 'position' => $colpos++ + ); + } + if (isset($tmp[4])) { + $definition['match'] = $tmp[4]; + } + if (isset($tmp[5])) { + $definition['onupdate'] = $tmp[5]; + } + if (isset($tmp[6])) { + $definition['ondelete'] = $tmp[6]; + } + return $definition; + } + } + $sql = false; + } + if (!$sql) { + return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, + $constraint_name . ' is not an existing table constraint', __FUNCTION__); + } + + $sql = strtolower($sql); + $start_pos = strpos($sql, '('); + $end_pos = strrpos($sql, ')'); + $column_names = substr($sql, $start_pos+1, $end_pos-$start_pos-1); + $column_names = explode(',', $column_names); + + if (!preg_match("/^create unique/", $sql)) { + return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, + $constraint_name . ' is not an existing table constraint', __FUNCTION__); + } + + $definition['unique'] = true; + $count = count($column_names); + for ($i=0; $i<$count; ++$i) { + $column_name = strtok($column_names[$i]," "); + $collation = strtok(" "); + $definition['fields'][$column_name] = array( + 'position' => $i+1 + ); + if (!empty($collation)) { + $definition['fields'][$column_name]['sorting'] = + ($collation=='ASC' ? 'ascending' : 'descending'); + } + } + + if (empty($definition['fields'])) { + return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, + $constraint_name . ' is not an existing table constraint', __FUNCTION__); + } + return $definition; + } + + // }}} + // {{{ getTriggerDefinition() + + /** + * Get the structure of a trigger into an array + * + * EXPERIMENTAL + * + * WARNING: this function is experimental and may change the returned value + * at any time until labelled as non-experimental + * + * @param string $trigger name of trigger that should be used in method + * @return mixed data array on success, a MDB2 error on failure + * @access public + */ + function getTriggerDefinition($trigger) + { + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $query = "SELECT name as trigger_name, + tbl_name AS table_name, + sql AS trigger_body, + NULL AS trigger_type, + NULL AS trigger_event, + NULL AS trigger_comment, + 1 AS trigger_enabled + FROM sqlite_master + WHERE type='trigger'"; + if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $query.= ' AND LOWER(name)='.$db->quote(strtolower($trigger), 'text'); + } else { + $query.= ' AND name='.$db->quote($trigger, 'text'); + } + $types = array( + 'trigger_name' => 'text', + 'table_name' => 'text', + 'trigger_body' => 'text', + 'trigger_type' => 'text', + 'trigger_event' => 'text', + 'trigger_comment' => 'text', + 'trigger_enabled' => 'boolean', + ); + $def = $db->queryRow($query, $types, MDB2_FETCHMODE_ASSOC); + if (PEAR::isError($def)) { + return $def; + } + if (empty($def)) { + return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, + 'it was not specified an existing trigger', __FUNCTION__); + } + if (preg_match("/^create\s+(?:temp|temporary)?trigger\s+(?:if\s+not\s+exists\s+)?.*(before|after)?\s+(insert|update|delete)/Uims", $def['trigger_body'], $tmp)) { + $def['trigger_type'] = strtoupper($tmp[1]); + $def['trigger_event'] = strtoupper($tmp[2]); + } + return $def; + } + + // }}} + // {{{ tableInfo() + + /** + * Returns information about a table + * + * @param string $result a string containing the name of a table + * @param int $mode a valid tableInfo mode + * + * @return array an associative array with the information requested. + * A MDB2_Error object on failure. + * + * @see MDB2_Driver_Common::tableInfo() + * @since Method available since Release 1.7.0 + */ + function tableInfo($result, $mode = null) + { + if (is_string($result)) { + return parent::tableInfo($result, $mode); + } + + $db =$this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + return $db->raiseError(MDB2_ERROR_NOT_CAPABLE, null, null, + 'This DBMS can not obtain tableInfo from result sets', __FUNCTION__); + } +} + +?> \ No newline at end of file diff --git a/lib/MDB2/Driver/sqlite3.php b/lib/MDB2/Driver/sqlite3.php new file mode 100644 index 0000000000..aadc5748b0 --- /dev/null +++ b/lib/MDB2/Driver/sqlite3.php @@ -0,0 +1,1024 @@ + | +// +----------------------------------------------------------------------+ +// +// + +/** + * MDB2 SQLite3 driver + * + * @package MDB2 + * @category Database + * @author Lukas Smith + */ +class MDB2_Driver_sqlite3 extends MDB2_Driver_Common +{ + // {{{ properties + public $string_quoting = array('start' => "'", 'end' => "'", 'escape' => "'", 'escape_pattern' => false); + + public $identifier_quoting = array('start' => '"', 'end' => '"', 'escape' => '"'); + + public $_lasterror = ''; + + public $fix_assoc_fields_names = false; + + // }}} + // {{{ constructor + + /** + * Constructor + */ + function __construct() + { + parent::__construct(); + + $this->phptype = 'sqlite3'; + $this->dbsyntax = 'sqlite'; + + $this->supported['sequences'] = 'emulated'; + $this->supported['indexes'] = true; + $this->supported['affected_rows'] = true; + $this->supported['summary_functions'] = true; + $this->supported['order_by_text'] = true; + $this->supported['current_id'] = 'emulated'; + $this->supported['limit_queries'] = true; + $this->supported['LOBs'] = true; + $this->supported['replace'] = true; + $this->supported['transactions'] = false; + $this->supported['savepoints'] = false; + $this->supported['sub_selects'] = true; + $this->supported['triggers'] = true; + $this->supported['auto_increment'] = true; + $this->supported['primary_key'] = false; // requires alter table implementation + $this->supported['result_introspection'] = false; // not implemented + $this->supported['prepared_statements'] = 'emulated'; + $this->supported['identifier_quoting'] = true; + $this->supported['pattern_escaping'] = false; + $this->supported['new_link'] = false; + + $this->options['DBA_username'] = false; + $this->options['DBA_password'] = false; + $this->options['base_transaction_name'] = '___php_MDB2_sqlite_auto_commit_off'; + $this->options['fixed_float'] = 0; + $this->options['database_path'] = ''; + $this->options['database_extension'] = ''; + $this->options['server_version'] = ''; + $this->options['max_identifiers_length'] = 128; //no real limit + } + + // }}} + // {{{ errorInfo() + + /** + * This method is used to collect information about an error + * + * @param integer $error + * @return array + * @access public + */ + function errorInfo($error = null) + { + $native_code = null; + if ($this->connection) { + $native_code = $this->connection->lastErrorCode(); + } + $native_msg = $this->_lasterror + ? html_entity_decode($this->_lasterror) : $this->connection->lastErrorMsg(); + + // PHP 5.2+ prepends the function name to $php_errormsg, so we need + // this hack to work around it, per bug #9599. + $native_msg = preg_replace('/^sqlite[a-z_]+\(\)[^:]*: /', '', $native_msg); + + if (is_null($error)) { + static $error_regexps; + if (empty($error_regexps)) { + $error_regexps = array( + '/^no such table:/' => MDB2_ERROR_NOSUCHTABLE, + '/^no such index:/' => MDB2_ERROR_NOT_FOUND, + '/^(table|index) .* already exists$/' => MDB2_ERROR_ALREADY_EXISTS, + '/PRIMARY KEY must be unique/i' => MDB2_ERROR_CONSTRAINT, + '/is not unique/' => MDB2_ERROR_CONSTRAINT, + '/columns .* are not unique/i' => MDB2_ERROR_CONSTRAINT, + '/uniqueness constraint failed/' => MDB2_ERROR_CONSTRAINT, + '/may not be NULL/' => MDB2_ERROR_CONSTRAINT_NOT_NULL, + '/^no such column:/' => MDB2_ERROR_NOSUCHFIELD, + '/no column named/' => MDB2_ERROR_NOSUCHFIELD, + '/column not present in both tables/i' => MDB2_ERROR_NOSUCHFIELD, + '/^near ".*": syntax error$/' => MDB2_ERROR_SYNTAX, + '/[0-9]+ values for [0-9]+ columns/i' => MDB2_ERROR_VALUE_COUNT_ON_ROW, + ); + } + foreach ($error_regexps as $regexp => $code) { + if (preg_match($regexp, $native_msg)) { + $error = $code; + break; + } + } + } + return array($error, $native_code, $native_msg); + } + + // }}} + // {{{ escape() + + /** + * Quotes a string so it can be safely used in a query. It will quote + * the text so it can safely be used within a query. + * + * @param string the input string to quote + * @param bool escape wildcards + * + * @return string quoted string + * + * @access public + */ + public function escape($text, $escape_wildcards = false) + { + if($this->connection){ + return $this->connection->escapeString($text); + }else{ + return str_replace("'","''",$text);//TODO; more + } + } + + // }}} + // {{{ beginTransaction() + + /** + * Start a transaction or set a savepoint. + * + * @param string name of a savepoint to set + * @return mixed MDB2_OK on success, a MDB2 error on failure + * + * @access public + */ + function beginTransaction($savepoint = null) + { + $this->debug('Starting transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint)); + if (!is_null($savepoint)) { + return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'savepoints are not supported', __FUNCTION__); + } elseif ($this->in_transaction) { + return MDB2_OK; //nothing to do + } + if (!$this->destructor_registered && $this->opened_persistent) { + $this->destructor_registered = true; + register_shutdown_function('MDB2_closeOpenTransactions'); + } + $query = 'BEGIN TRANSACTION '.$this->options['base_transaction_name']; + $result =$this->_doQuery($query, true); + if (PEAR::isError($result)) { + return $result; + } + $this->in_transaction = true; + return MDB2_OK; + } + + // }}} + // {{{ commit() + + /** + * Commit the database changes done during a transaction that is in + * progress or release a savepoint. This function may only be called when + * auto-committing is disabled, otherwise it will fail. Therefore, a new + * transaction is implicitly started after committing the pending changes. + * + * @param string name of a savepoint to release + * @return mixed MDB2_OK on success, a MDB2 error on failure + * + * @access public + */ + function commit($savepoint = null) + { + $this->debug('Committing transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint)); + if (!$this->in_transaction) { + return $this->raiseError(MDB2_ERROR_INVALID, null, null, + 'commit/release savepoint cannot be done changes are auto committed', __FUNCTION__); + } + if (!is_null($savepoint)) { + return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'savepoints are not supported', __FUNCTION__); + } + + $query = 'COMMIT TRANSACTION '.$this->options['base_transaction_name']; + $result =$this->_doQuery($query, true); + if (PEAR::isError($result)) { + return $result; + } + $this->in_transaction = false; + return MDB2_OK; + } + + // }}} + // {{{ + + /** + * Cancel any database changes done during a transaction or since a specific + * savepoint that is in progress. This function may only be called when + * auto-committing is disabled, otherwise it will fail. Therefore, a new + * transaction is implicitly started after canceling the pending changes. + * + * @param string name of a savepoint to rollback to + * @return mixed MDB2_OK on success, a MDB2 error on failure + * + * @access public + */ + function rollback($savepoint = null) + { + $this->debug('Rolling back transaction/savepoint', __FUNCTION__, array('is_manip' => true, 'savepoint' => $savepoint)); + if (!$this->in_transaction) { + return $this->raiseError(MDB2_ERROR_INVALID, null, null, + 'rollback cannot be done changes are auto committed', __FUNCTION__); + } + if (!is_null($savepoint)) { + return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'savepoints are not supported', __FUNCTION__); + } + + $query = 'ROLLBACK TRANSACTION '.$this->options['base_transaction_name']; + $result =$this->_doQuery($query, true); + if (PEAR::isError($result)) { + return $result; + } + $this->in_transaction = false; + return MDB2_OK; + } + + // }}} + // {{{ function setTransactionIsolation() + + /** + * Set the transacton isolation level. + * + * @param string standard isolation level + * READ UNCOMMITTED (allows dirty reads) + * READ COMMITTED (prevents dirty reads) + * REPEATABLE READ (prevents nonrepeatable reads) + * SERIALIZABLE (prevents phantom reads) + * @return mixed MDB2_OK on success, a MDB2 error on failure + * + * @access public + * @since 2.1.1 + */ + static function setTransactionIsolation($isolation,$options=array()) + { + $this->debug('Setting transaction isolation level', __FUNCTION__, array('is_manip' => true)); + switch ($isolation) { + case 'READ UNCOMMITTED': + $isolation = 0; + break; + case 'READ COMMITTED': + case 'REPEATABLE READ': + case 'SERIALIZABLE': + $isolation = 1; + break; + default: + return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'isolation level is not supported: '.$isolation, __FUNCTION__); + } + + $query = "PRAGMA read_uncommitted=$isolation"; + return $this->_doQuery($query, true); + } + + // }}} + // {{{ getDatabaseFile() + + /** + * Builds the string with path+dbname+extension + * + * @return string full database path+file + * @access protected + */ + function _getDatabaseFile($database_name) + { + if ($database_name === '' || $database_name === ':memory:') { + return $database_name; + } + return $this->options['database_path'].$database_name.$this->options['database_extension']; + } + + // }}} + // {{{ connect() + + /** + * Connect to the database + * + * @return true on success, MDB2 Error Object on failure + **/ + function connect() + { + global $SERVERROOT; + $datadir=OC_CONFIG::getValue( "datadirectory", "$SERVERROOT/data" ); + $database_file = $this->_getDatabaseFile($this->database_name); + if (is_resource($this->connection)) { + //if (count(array_diff($this->connected_dsn, $this->dsn)) == 0 + if (MDB2::areEquals($this->connected_dsn, $this->dsn) + && $this->connected_database_name == $database_file + && $this->opened_persistent == $this->options['persistent'] + ) { + return MDB2_OK; + } + $this->disconnect(false); + } + + if (!PEAR::loadExtension($this->phptype)) { + return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, + 'extension '.$this->phptype.' is not compiled into PHP', __FUNCTION__); + } + + if (empty($this->database_name)) { + return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, + 'unable to establish a connection', __FUNCTION__); + } + + if ($database_file !== ':memory:') { + if(!strpos($database_file,'.db')){ + $database_file="$datadir/$database_file.db"; + } + if (!file_exists($database_file)) { + if (!touch($database_file)) { + return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, + 'Could not create database file', __FUNCTION__); + } + if (!isset($this->dsn['mode']) + || !is_numeric($this->dsn['mode']) + ) { + $mode = 0644; + } else { + $mode = octdec($this->dsn['mode']); + } + if (!chmod($database_file, $mode)) { + return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, + 'Could not be chmodded database file', __FUNCTION__); + } + if (!file_exists($database_file)) { + return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null, + 'Could not be found database file', __FUNCTION__); + } + } + if (!is_file($database_file)) { + return $this->raiseError(MDB2_ERROR_INVALID, null, null, + 'Database is a directory name', __FUNCTION__); + } + if (!is_readable($database_file)) { + return $this->raiseError(MDB2_ERROR_ACCESS_VIOLATION, null, null, + 'Could not read database file', __FUNCTION__); + } + } + + $php_errormsg = ''; + $this->connection = new SQLite3($database_file); + $this->_lasterror = $this->connection->lastErrorMsg(); + if (!$this->connection) { + return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, + 'unable to establish a connection', __FUNCTION__); + } + + if ($this->fix_assoc_fields_names || + $this->options['portability'] & MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES) + { + $this->connection->exec("PRAGMA short_column_names = 1"); + $this->fix_assoc_fields_names = true; + } + + $this->connected_dsn = $this->dsn; + $this->connected_database_name = $database_file; + $this->opened_persistent = $this->getoption('persistent'); + $this->dbsyntax = $this->dsn['dbsyntax'] ? $this->dsn['dbsyntax'] : $this->phptype; + + return MDB2_OK; + } + + // }}} + // {{{ databaseExists() + + /** + * check if given database name is exists? + * + * @param string $name name of the database that should be checked + * + * @return mixed true/false on success, a MDB2 error on failure + * @access public + */ + function databaseExists($name) + { + $database_file = $this->_getDatabaseFile($name); + $result = file_exists($database_file); + return $result; + } + + // }}} + // {{{ disconnect() + + /** + * Log out and disconnect from the database. + * + * @param boolean $force if the disconnect should be forced even if the + * connection is opened persistently + * @return mixed true on success, false if not connected and error + * object on error + * @access public + */ + function disconnect($force = true) + { + if ($this->connection instanceof SQLite3) { + if ($this->in_transaction) { + $dsn = $this->dsn; + $database_name = $this->database_name; + $persistent = $this->options['persistent']; + $this->dsn = $this->connected_dsn; + $this->database_name = $this->connected_database_name; + $this->options['persistent'] = $this->opened_persistent; + $this->rollback(); + $this->dsn = $dsn; + $this->database_name = $database_name; + $this->options['persistent'] = $persistent; + } + + if (!$this->opened_persistent || $force) { + $this->connection->close(); + } + } else { + return false; + } + return parent::disconnect($force); + } + + // }}} + // {{{ _doQuery() + + /** + * Execute a query + * @param string $query query + * @param boolean $is_manip if the query is a manipulation query + * @param resource $connection + * @param string $database_name + * @return result or error object + * @access protected + */ + function &_doQuery($query, $is_manip = false, $connection = null, $database_name = null) + { + $this->last_query = $query; + $result = $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'pre')); + if ($result) { + if (PEAR::isError($result)) { + return $result; + } + $query = $result; + } + if ($this->options['disable_query']) { + $result = $is_manip ? 0 : null; + return $result; + } +// print_r(debug_backtrace()); + $result=$this->connection->query($query.';'); + $this->_lasterror = $this->connection->lastErrorMsg(); + + if (!$result) { + $err =$this->raiseError(null, null, null, + 'Could not execute statement', __FUNCTION__); + return $err; + } + + $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'post', 'result' => $result)); + return $result; + } + + // }}} + // {{{ _affectedRows() + + /** + * Returns the number of rows affected + * + * @param resource $result + * @param resource $connection + * @return mixed MDB2 Error Object or the number of rows affected + * @access private + */ + function _affectedRows($connection, $result = null) + { + return $this->connection->changes(); + } + + // }}} + // {{{ _modifyQuery() + + /** + * Changes a query string for various DBMS specific reasons + * + * @param string $query query to modify + * @param boolean $is_manip if it is a DML query + * @param integer $limit limit the number of rows + * @param integer $offset start reading from given offset + * @return string modified query + * @access protected + */ + function _modifyQuery($query, $is_manip, $limit, $offset) + { + if ($this->options['portability'] & MDB2_PORTABILITY_DELETE_COUNT) { + if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $query)) { + $query = preg_replace('/^\s*DELETE\s+FROM\s+(\S+)\s*$/', + 'DELETE FROM \1 WHERE 1=1', $query); + } + } + if ($limit > 0 + && !preg_match('/LIMIT\s*\d(?:\s*(?:,|OFFSET)\s*\d+)?(?:[^\)]*)?$/i', $query) + ) { + $query = rtrim($query); + if (substr($query, -1) == ';') { + $query = substr($query, 0, -1); + } + if ($is_manip) { + $query.= " LIMIT $limit"; + } else { + $query.= " LIMIT $offset,$limit"; + } + } + return $query; + } + + // }}} + // {{{ getServerVersion() + + /** + * return version information about the server + * + * @param bool $native determines if the raw version string should be returned + * @return mixed array/string with version information or MDB2 error object + * @access public + */ + function getServerVersion($native = false) + { + $server_info = false; + if ($this->connected_server_info) { + $server_info = $this->connected_server_info; + } elseif ($this->options['server_version']) { + $server_info = $this->options['server_version']; + } elseif (function_exists('sqlite_libversion')) { + $server_info = @sqlite_libversion(); + } + if (!$server_info) { + return $this->raiseError(MDB2_ERROR_UNSUPPORTED, null, null, + 'Requires either the "server_version" option or the sqlite_libversion() function', __FUNCTION__); + } + // cache server_info + $this->connected_server_info = $server_info; + if (!$native) { + $tmp = explode('.', $server_info, 3); + $server_info = array( + 'major' => isset($tmp[0]) ? $tmp[0] : null, + 'minor' => isset($tmp[1]) ? $tmp[1] : null, + 'patch' => isset($tmp[2]) ? $tmp[2] : null, + 'extra' => null, + 'native' => $server_info, + ); + } + return $server_info; + } + + // }}} + // {{{ replace() + + /** + * Execute a SQL REPLACE query. A REPLACE query is identical to a INSERT + * query, except that if there is already a row in the table with the same + * key field values, the old row is deleted before the new row is inserted. + * + * The REPLACE type of query does not make part of the SQL standards. Since + * practically only SQLite implements it natively, this type of query is + * emulated through this method for other DBMS using standard types of + * queries inside a transaction to assure the atomicity of the operation. + * + * @access public + * + * @param string $table name of the table on which the REPLACE query will + * be executed. + * @param array $fields associative array that describes the fields and the + * values that will be inserted or updated in the specified table. The + * indexes of the array are the names of all the fields of the table. The + * values of the array are also associative arrays that describe the + * values and other properties of the table fields. + * + * Here follows a list of field properties that need to be specified: + * + * value: + * Value to be assigned to the specified field. This value may be + * of specified in database independent type format as this + * function can perform the necessary datatype conversions. + * + * Default: + * this property is required unless the Null property + * is set to 1. + * + * type + * Name of the type of the field. Currently, all types Metabase + * are supported except for clob and blob. + * + * Default: no type conversion + * + * null + * Boolean property that indicates that the value for this field + * should be set to null. + * + * The default value for fields missing in INSERT queries may be + * specified the definition of a table. Often, the default value + * is already null, but since the REPLACE may be emulated using + * an UPDATE query, make sure that all fields of the table are + * listed in this function argument array. + * + * Default: 0 + * + * key + * Boolean property that indicates that this field should be + * handled as a primary key or at least as part of the compound + * unique index of the table that will determine the row that will + * updated if it exists or inserted a new row otherwise. + * + * This function will fail if no key field is specified or if the + * value of a key field is set to null because fields that are + * part of unique index they may not be null. + * + * Default: 0 + * + * @return mixed MDB2_OK on success, a MDB2 error on failure + */ + function replace($table, $fields) + { + $count = count($fields); + $query = $values = ''; + $keys = $colnum = 0; + for (reset($fields); $colnum < $count; next($fields), $colnum++) { + $name = key($fields); + if ($colnum > 0) { + $query .= ','; + $values.= ','; + } + $query.= $this->quoteIdentifier($name, true); + if (isset($fields[$name]['null']) && $fields[$name]['null']) { + $value = 'NULL'; + } else { + $type = isset($fields[$name]['type']) ? $fields[$name]['type'] : null; + $value = $this->quote($fields[$name]['value'], $type); + if (PEAR::isError($value)) { + return $value; + } + } + $values.= $value; + if (isset($fields[$name]['key']) && $fields[$name]['key']) { + if ($value === 'NULL') { + return $this->raiseError(MDB2_ERROR_CANNOT_REPLACE, null, null, + 'key value '.$name.' may not be NULL', __FUNCTION__); + } + $keys++; + } + } + if ($keys == 0) { + return $this->raiseError(MDB2_ERROR_CANNOT_REPLACE, null, null, + 'not specified which fields are keys', __FUNCTION__); + } + + $connection = $this->getConnection(); + if (PEAR::isError($connection)) { + return $connection; + } + + $table = $this->quoteIdentifier($table, true); + $query = "REPLACE INTO $table ($query) VALUES ($values)"; + $result =$this->_doQuery($query, true, $connection); + if (PEAR::isError($result)) { + return $result; + } + return $this->_affectedRows($connection, $result); + } + + // }}} + // {{{ nextID() + + /** + * Returns the next free id of a sequence + * + * @param string $seq_name name of the sequence + * @param boolean $ondemand when true the sequence is + * automatic created, if it + * not exists + * + * @return mixed MDB2 Error Object or id + * @access public + */ + function nextID($seq_name, $ondemand = true) + { + $sequence_name = $this->quoteIdentifier($this->getSequenceName($seq_name), true); + $seqcol_name = $this->options['seqcol_name']; + $query = "INSERT INTO $sequence_name ($seqcol_name) VALUES (NULL)"; + $this->pushErrorHandling(PEAR_ERROR_RETURN); + $this->expectError(MDB2_ERROR_NOSUCHTABLE); + $result =$this->_doQuery($query, true); + $this->popExpect(); + $this->popErrorHandling(); + if (PEAR::isError($result)) { + if ($ondemand && $result->getCode() == MDB2_ERROR_NOSUCHTABLE) { + $this->loadModule('Manager', null, true); + $result = $this->manager->createSequence($seq_name); + if (PEAR::isError($result)) { + return $this->raiseError($result, null, null, + 'on demand sequence '.$seq_name.' could not be created', __FUNCTION__); + } else { + return $this->nextID($seq_name, false); + } + } + return $result; + } + $value = $this->lastInsertID(); + if (is_numeric($value)) { + $query = "DELETE FROM $sequence_name WHERE $seqcol_name < $value"; + $result =$this->_doQuery($query, true); + if (PEAR::isError($result)) { + $this->warnings[] = 'nextID: could not delete previous sequence table values from '.$seq_name; + } + } + return $value; + } + + // }}} + // {{{ lastInsertID() + + /** + * Returns the autoincrement ID if supported or $id or fetches the current + * ID in a sequence called: $table.(empty($field) ? '' : '_'.$field) + * + * @param string $table name of the table into which a new row was inserted + * @param string $field name of the field into which a new row was inserted + * @return mixed MDB2 Error Object or id + * @access public + */ + function lastInsertID($table = null, $field = null) + { + return $this->connection->lastInsertRowID(); + } + + // }}} + // {{{ currID() + + /** + * Returns the current id of a sequence + * + * @param string $seq_name name of the sequence + * @return mixed MDB2 Error Object or id + * @access public + */ + function currID($seq_name) + { + $sequence_name = $this->quoteIdentifier($this->getSequenceName($seq_name), true); + $seqcol_name = $this->quoteIdentifier($this->options['seqcol_name'], true); + $query = "SELECT MAX($seqcol_name) FROM $sequence_name"; + return $this->queryOne($query, 'integer'); + } +} + +/** + * MDB2 SQLite result driver + * + * @package MDB2 + * @category Database + * @author Lukas Smith + */ +class MDB2_Result_sqlite3 extends MDB2_Result_Common +{ + // }}} + // {{{ fetchRow() + + /** + * Fetch a row and insert the data into an existing array. + * + * @param int $fetchmode how the array data should be indexed + * @param int $rownum number of the row where the data can be found + * @return int data array on success, a MDB2 error on failure + * @access public + */ + function &fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT, $rownum = null) + { + if (!is_null($rownum)) { + $seek = $this->seek($rownum); + if (PEAR::isError($seek)) { + return $seek; + } + } + if ($fetchmode == MDB2_FETCHMODE_DEFAULT) { + $fetchmode = $this->db->fetchmode; + } + if ($fetchmode & MDB2_FETCHMODE_ASSOC) { + //$row = @sqlite_fetch_array($this->result, SQLITE_ASSOC); + $row=$this->result->fetchArray(SQLITE3_ASSOC); + if (is_array($row) + && $this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE + ) { + $row = array_change_key_case($row, $this->db->options['field_case']); + } + } else { + $row=$this->result->fetchArray(SQLITE3_NUM); + } + if (!$row) { + if ($this->result === false) { + $err =$this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, + 'resultset has already been freed', __FUNCTION__); + return $err; + } + $null = null; + return $null; + } + $mode = $this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL; + $rtrim = false; + if ($this->db->options['portability'] & MDB2_PORTABILITY_RTRIM) { + if (empty($this->types)) { + $mode += MDB2_PORTABILITY_RTRIM; + } else { + $rtrim = true; + } + } + if ($mode) { + $this->db->_fixResultArrayValues($row, $mode); + } + if (!empty($this->types)) { + $row = $this->db->datatype->convertResultRow($this->types, $row, $rtrim); + } + if (!empty($this->values)) { + $this->_assignBindColumns($row); + } + if ($fetchmode === MDB2_FETCHMODE_OBJECT) { + $object_class = $this->db->options['fetch_class']; + if ($object_class == 'stdClass') { + $row = (object) $row; + } else { + $row = new $object_class($row); + } + } + ++$this->rownum; + return $row; + } + + // }}} + // {{{ _getColumnNames() + + /** + * Retrieve the names of columns returned by the DBMS in a query result. + * + * @return mixed Array variable that holds the names of columns as keys + * or an MDB2 error on failure. + * Some DBMS may not return any columns when the result set + * does not contain any rows. + * @access private + */ + function _getColumnNames() + { + $columns = array(); + $numcols = $this->numCols(); + if (PEAR::isError($numcols)) { + return $numcols; + } + for ($column = 0; $column < $numcols; $column++) { + $column_name = $this->result->getColumnName($column); + $columns[$column_name] = $column; + } + if ($this->db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) { + $columns = array_change_key_case($columns, $this->db->options['field_case']); + } + return $columns; + } + + // }}} + // {{{ numCols() + + /** + * Count the number of columns returned by the DBMS in a query result. + * + * @access public + * @return mixed integer value with the number of columns, a MDB2 error + * on failure + */ + function numCols() + { + $this->result->numColumns(); + } +} + +/** + * MDB2 SQLite buffered result driver + * + * @package MDB2 + * @category Database + * @author Lukas Smith + */ +class MDB2_BufferedResult_sqlite3 extends MDB2_Result_sqlite3 +{ + // {{{ seek() + + /** + * Seek to a specific row in a result set + * + * @param int $rownum number of the row where the data can be found + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + function seek($rownum = 0) + { + $this->result->reset(); + for($i=0;$i<$rownum;$i++){ + $this->result->fetchArray(); + } + $this->rownum = $rownum - 1; + return MDB2_OK; + } + + // }}} + // {{{ valid() + + /** + * Check if the end of the result set has been reached + * + * @return mixed true or false on sucess, a MDB2 error on failure + * @access public + */ + function valid() + { + $numrows = $this->numRows(); + if (PEAR::isError($numrows)) { + return $numrows; + } + return $this->rownum < ($numrows - 1); + } + + // }}} + // {{{ numRows() + + /** + * Returns the number of rows in a result object + * + * @return mixed MDB2 Error Object or the number of rows + * @access public + */ + function numRows() + { + $rows = 0; + $this->result->reset(); + while($this->result->fetchArray()){ + $rows++; + } + $this->result->reset(); + return $rows; + } +} + +/** + * MDB2 SQLite statement driver + * + * @package MDB2 + * @category Database + * @author Lukas Smith + */ +class MDB2_Statement_sqlite3 extends MDB2_Statement_Common +{ + +} + +?> \ No newline at end of file From 1ea43dd7f9928ac6e74f36822ccb4deeeb804db3 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 13 Jun 2011 04:06:43 +0200 Subject: [PATCH 009/111] make OC_DB work with the sqlite3 driver --- lib/database.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/database.php b/lib/database.php index 0f0950d05a..8d7c76756c 100644 --- a/lib/database.php +++ b/lib/database.php @@ -60,10 +60,10 @@ class OC_DB { 'quote_identifier' => true ); // Add the dsn according to the database type - if( $CONFIG_DBTYPE == 'sqlite' ){ + if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){ // sqlite $dsn = array( - 'phptype' => 'sqlite', + 'phptype' => $CONFIG_DBTYPE, 'database' => "$datadir/$CONFIG_DBNAME.db", 'mode' => '0644' ); } @@ -100,6 +100,9 @@ class OC_DB { // We always, really always want associative arrays self::$DBConnection->setFetchMode(MDB2_FETCHMODE_ASSOC); + + //we need to function module for query pre-procesing + self::$DBConnection->loadModule('Function'); } // we are done. great! @@ -297,15 +300,14 @@ class OC_DB { * and replaces the ` woth ' or " according to the database driver. */ private static function processQuery( $query ){ + self::connect(); // We need Database type and table prefix $CONFIG_DBTYPE = OC_CONFIG::getValue( "dbtype", "sqlite" ); $CONFIG_DBTABLEPREFIX = OC_CONFIG::getValue( "dbtableprefix", "oc_" ); // differences is getting the current timestamp - if( $CONFIG_DBTYPE == 'sqlite' ){ - $query = str_replace( 'NOW()', "strftime('%s', 'now')", $query ); - $query = str_replace( 'now()', "strftime('%s', 'now')", $query ); - } + $query = str_replace( 'NOW()', self::$DBConnection->now(), $query ); + $query = str_replace( 'now()', self::$DBConnection->now(), $query ); // differences in escaping of table names (` for mysql) // Problem: what if there is a ` in the value we want to insert? From 80194daec7b612a356daac7c13ccc904a70ffbbf Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 8 Jun 2011 23:12:06 +0200 Subject: [PATCH 010/111] Fix php4 legacy calls Reviewed-by: Robin Appelman Reviewboard: http://git.reviewboard.kde.org/r/101549/ --- 3dparty/MDB2.php | 10 +++++----- 3dparty/MDB2/Schema/Parser.php | 9 +-------- 3dparty/MDB2/Schema/Validate.php | 5 ----- 3dparty/PEAR.php | 12 ++++++------ 4 files changed, 12 insertions(+), 24 deletions(-) diff --git a/3dparty/MDB2.php b/3dparty/MDB2.php index 30e564f145..fbc7107914 100644 --- a/3dparty/MDB2.php +++ b/3dparty/MDB2.php @@ -639,7 +639,7 @@ class MDB2 */ static function isError($data, $code = null) { - if (is_a($data, 'MDB2_Error')) { + if ($data instanceof MDB2_Error) { if (is_null($code)) { return true; } elseif (is_string($code)) { @@ -666,7 +666,7 @@ class MDB2 */ static function isConnection($value) { - return is_a($value, 'MDB2_Driver_Common'); + return ($value instanceof MDB2_Driver_Common); } // }}} @@ -683,7 +683,7 @@ class MDB2 */ static function isResult($value) { - return is_a($value, 'MDB2_Result'); + return $value instanceof MDB2_Result; } // }}} @@ -700,7 +700,7 @@ class MDB2 */ static function isResultCommon($value) { - return is_a($value, 'MDB2_Result_Common'); + return ($value instanceof MDB2_Result_Common); } // }}} @@ -717,7 +717,7 @@ class MDB2 */ static function isStatement($value) { - return is_a($value, 'MDB2_Statement_Common'); + return $value instanceof MDB2_Statement_Common; } // }}} diff --git a/3dparty/MDB2/Schema/Parser.php b/3dparty/MDB2/Schema/Parser.php index bd7a965793..b740ef55fa 100644 --- a/3dparty/MDB2/Schema/Parser.php +++ b/3dparty/MDB2/Schema/Parser.php @@ -127,13 +127,6 @@ class MDB2_Schema_Parser extends XML_Parser $this->val =new MDB2_Schema_Validate($fail_on_invalid_names, $valid_types, $force_defaults); } - function MDB2_Schema_Parser($variables, $fail_on_invalid_names = true, - $structure = false, $valid_types = array(), - $force_defaults = true) - { - $this->__construct($variables, $fail_on_invalid_names, $structure, $valid_types, $force_defaults); - } - function startHandler($xp, $element, $attribs) { if (strtolower($element) == 'variable') { @@ -503,7 +496,7 @@ class MDB2_Schema_Parser extends XML_Parser $this->element = implode('-', $this->elements); } - function &raiseError($msg = null, $xmlecode = 0, $xp = null, $ecode = MDB2_SCHEMA_ERROR_PARSE,$a=null,$b=null,$c=null) + function raiseError($msg = null, $xmlecode = 0, $xp = null, $ecode = MDB2_SCHEMA_ERROR_PARSE,$a=null,$b=null,$c=null) { if (is_null($this->error)) { $error = ''; diff --git a/3dparty/MDB2/Schema/Validate.php b/3dparty/MDB2/Schema/Validate.php index 21be024ce9..217cf51b95 100644 --- a/3dparty/MDB2/Schema/Validate.php +++ b/3dparty/MDB2/Schema/Validate.php @@ -91,11 +91,6 @@ class MDB2_Schema_Validate $this->force_defaults = $force_defaults; } - function MDB2_Schema_Validate($fail_on_invalid_names = true, $valid_types = array(), $force_defaults = true) - { - $this->__construct($fail_on_invalid_names, $valid_types, $force_defaults); - } - // }}} // {{{ raiseError() diff --git a/3dparty/PEAR.php b/3dparty/PEAR.php index 9760b9d265..f832c0d491 100644 --- a/3dparty/PEAR.php +++ b/3dparty/PEAR.php @@ -249,7 +249,7 @@ class PEAR */ static function isError($data, $code = null) { - if (is_a($data, 'PEAR_Error')) { + if ($data instanceof PEAR_Error) { if (is_null($code)) { return true; } elseif (is_string($code)) { @@ -305,7 +305,7 @@ class PEAR function setErrorHandling($mode = null, $options = null) { - if (isset($this) && is_a($this, 'PEAR')) { + if (isset($this) && $this instanceof PEAR) { $setmode = &$this->_default_error_mode; $setoptions = &$this->_default_error_options; } else { @@ -557,7 +557,7 @@ class PEAR $code = null, $userinfo = null) { - if (isset($this) && is_a($this, 'PEAR')) { + if (isset($this) && $this instanceof PEAR) { return $this->raiseError($message, $code, null, null, $userinfo); } else { return PEAR::raiseError($message, $code, null, null, $userinfo); @@ -653,7 +653,7 @@ class PEAR function pushErrorHandling($mode, $options = null) { $stack = &$GLOBALS['_PEAR_error_handler_stack']; - if (isset($this) && is_a($this, 'PEAR')) { + if (isset($this) && $this instanceof PEAR) { $def_mode = &$this->_default_error_mode; $def_options = &$this->_default_error_options; } else { @@ -662,7 +662,7 @@ class PEAR } $stack[] = array($def_mode, $def_options); - if (isset($this) && is_a($this, 'PEAR')) { + if (isset($this) && $this instanceof PEAR) { $this->setErrorHandling($mode, $options); } else { PEAR::setErrorHandling($mode, $options); @@ -687,7 +687,7 @@ class PEAR array_pop($stack); list($mode, $options) = $stack[sizeof($stack) - 1]; array_pop($stack); - if (isset($this) && is_a($this, 'PEAR')) { + if (isset($this) && $this instanceof PEAR) { $this->setErrorHandling($mode, $options); } else { PEAR::setErrorHandling($mode, $options); From 1e0fe05bef4a935c23d290ebda67059679da629f Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 13 Jun 2011 23:15:15 +0200 Subject: [PATCH 011/111] fix error with empty config file --- lib/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/config.php b/lib/config.php index 6af9fcbe5a..60c6739a3f 100644 --- a/lib/config.php +++ b/lib/config.php @@ -139,7 +139,7 @@ class OC_CONFIG{ // Include the file, save the data from $CONFIG include( "$SERVERROOT/config/config.php" ); - if( isset( $CONFIG ) || is_array( $CONFIG )){ + if( isset( $CONFIG ) && is_array( $CONFIG )){ self::$cache = $CONFIG; } From f863002e95e864939923e286ba18e7adfbb786e7 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 13 Jun 2011 23:18:39 +0200 Subject: [PATCH 012/111] use sqlite3 if sqlite2 isn't available --- lib/setup.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/setup.php b/lib/setup.php index 72507f221b..ab4a786c43 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -1,6 +1,6 @@ \ No newline at end of file +?> From 00858efbe27be3e4e594a9eba40214f451188af5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 14 Jun 2011 01:11:49 +0200 Subject: [PATCH 013/111] store numbers as strings to prevent errors with numeric passwords --- lib/config.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/config.php b/lib/config.php index 60c6739a3f..cd18ddd499 100644 --- a/lib/config.php +++ b/lib/config.php @@ -169,9 +169,6 @@ class OC_CONFIG{ $value = $value ? 'true' : 'false'; $content .= "\"$key\" => $value,\n"; } - elseif( is_numeric( $value )){ - $content .= "\"$key\" => $value,\n"; - } else{ $value = str_replace( "'", "\\'", $value ); $content .= "\"$key\" => '$value',\n"; From f6eb7c120538bea8e488a868f9f3d99906a1ea0f Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 14 Jun 2011 01:20:26 +0200 Subject: [PATCH 014/111] make use of native sqlite3 prepared statements --- lib/MDB2/Driver/sqlite3.php | 331 +++++++++++++++++++++++++++++++++++- 1 file changed, 329 insertions(+), 2 deletions(-) diff --git a/lib/MDB2/Driver/sqlite3.php b/lib/MDB2/Driver/sqlite3.php index aadc5748b0..abd2b16ad4 100644 --- a/lib/MDB2/Driver/sqlite3.php +++ b/lib/MDB2/Driver/sqlite3.php @@ -91,7 +91,7 @@ class MDB2_Driver_sqlite3 extends MDB2_Driver_Common $this->supported['auto_increment'] = true; $this->supported['primary_key'] = false; // requires alter table implementation $this->supported['result_introspection'] = false; // not implemented - $this->supported['prepared_statements'] = 'emulated'; + $this->supported['prepared_statements'] = true; $this->supported['identifier_quoting'] = true; $this->supported['pattern_escaping'] = false; $this->supported['new_link'] = false; @@ -511,7 +511,6 @@ class MDB2_Driver_sqlite3 extends MDB2_Driver_Common $result = $is_manip ? 0 : null; return $result; } -// print_r(debug_backtrace()); $result=$this->connection->query($query.';'); $this->_lasterror = $this->connection->lastErrorMsg(); @@ -814,6 +813,118 @@ class MDB2_Driver_sqlite3 extends MDB2_Driver_Common $query = "SELECT MAX($seqcol_name) FROM $sequence_name"; return $this->queryOne($query, 'integer'); } + + /** + * Prepares a query for multiple execution with execute(). + * With some database backends, this is emulated. + * prepare() requires a generic query as string like + * 'INSERT INTO numbers VALUES(?,?)' or + * 'INSERT INTO numbers VALUES(:foo,:bar)'. + * The ? and :name and are placeholders which can be set using + * bindParam() and the query can be sent off using the execute() method. + * The allowed format for :name can be set with the 'bindname_format' option. + * + * @param string $query the query to prepare + * @param mixed $types array that contains the types of the placeholders + * @param mixed $result_types array that contains the types of the columns in + * the result set or MDB2_PREPARE_RESULT, if set to + * MDB2_PREPARE_MANIP the query is handled as a manipulation query + * @param mixed $lobs key (field) value (parameter) pair for all lob placeholders + * @return mixed resource handle for the prepared query on success, a MDB2 + * error on failure + * @access public + * @see bindParam, execute + */ + function &prepare($query, $types = null, $result_types = null, $lobs = array()) + { + if ($this->options['emulate_prepared'] + || $this->supported['prepared_statements'] !== true + ) { + $obj =& parent::prepare($query, $types, $result_types, $lobs); + return $obj; + } + $this->last_query = $query; + $is_manip = ($result_types === MDB2_PREPARE_MANIP); + $offset = $this->offset; + $limit = $this->limit; + $this->offset = $this->limit = 0; + $query = $this->_modifyQuery($query, $is_manip, $limit, $offset); + $result = $this->debug($query, __FUNCTION__, array('is_manip' => $is_manip, 'when' => 'pre')); + if ($result) { + if (PEAR::isError($result)) { + return $result; + } + $query = $result; + } + $placeholder_type_guess = $placeholder_type = null; + $question = '?'; + $colon = ':'; + $positions = array(); + $position = 0; + while ($position < strlen($query)) { + $q_position = strpos($query, $question, $position); + $c_position = strpos($query, $colon, $position); + if ($q_position && $c_position) { + $p_position = min($q_position, $c_position); + } elseif ($q_position) { + $p_position = $q_position; + } elseif ($c_position) { + $p_position = $c_position; + } else { + break; + } + if (is_null($placeholder_type)) { + $placeholder_type_guess = $query[$p_position]; + } + + $new_pos = $this->_skipDelimitedStrings($query, $position, $p_position); + if (PEAR::isError($new_pos)) { + return $new_pos; + } + if ($new_pos != $position) { + $position = $new_pos; + continue; //evaluate again starting from the new position + } + + + if ($query[$position] == $placeholder_type_guess) { + if (is_null($placeholder_type)) { + $placeholder_type = $query[$p_position]; + $question = $colon = $placeholder_type; + } + if ($placeholder_type == ':') { + $regexp = '/^.{'.($position+1).'}('.$this->options['bindname_format'].').*$/s'; + $parameter = preg_replace($regexp, '\\1', $query); + if ($parameter === '') { + $err =& $this->raiseError(MDB2_ERROR_SYNTAX, null, null, + 'named parameter name must match "bindname_format" option', __FUNCTION__); + return $err; + } + $positions[$p_position] = $parameter; + $query = substr_replace($query, '?', $position, strlen($parameter)+1); + } else { + $positions[$p_position] = count($positions); + } + $position = $p_position + 1; + } else { + $position = $p_position; + } + } + $connection = $this->getConnection(); + if (PEAR::isError($connection)) { + return $connection; + } + $statement =$this->connection->prepare($query); + if (!$statement) { + return $this->db->raiseError(MDB2_ERROR_NOT_FOUND, null, null, + 'unable to prepare statement: '.$query); + } + + $class_name = 'MDB2_Statement_'.$this->phptype; + $obj = new $class_name($this, $statement, $positions, $query, $types, $result_types, $is_manip, $limit, $offset); + $this->debug($query, __FUNCTION__, array('is_manip' => $is_manip, 'when' => 'post', 'result' => $obj)); + return $obj; + } } /** @@ -1018,7 +1129,223 @@ class MDB2_BufferedResult_sqlite3 extends MDB2_Result_sqlite3 */ class MDB2_Statement_sqlite3 extends MDB2_Statement_Common { + // }}} + // {{{ function bindValue($parameter, &$value, $type = null) + private function getParamType($type){ + switch(strtolower($type)){ + case 'text': + return SQLITE3_TEXT; + case 'boolean': + case 'integer': + return SQLITE3_INTEGER; + case 'float': + return SQLITE3_FLOAT; + case 'blob': + return SQLITE3_BLOB; + } + } + /** + * Set the value of a parameter of a prepared query. + * + * @param int the order number of the parameter in the query + * statement. The order number of the first parameter is 1. + * @param mixed value that is meant to be assigned to specified + * parameter. The type of the value depends on the $type argument. + * @param string specifies the type of the field + * + * @return mixed MDB2_OK on success, a MDB2 error on failure + * + * @access public + */ + function bindValue($parameter, $value, $type = null){ + if($type){ + $type=$this->getParamType($type); + $this->statement->bindValue($parameter,$value,$type); + }else{ + $this->statement->bindValue($parameter,$value); + } + return MDB2_OK; + } + + /** + * Bind a variable to a parameter of a prepared query. + * + * @param int the order number of the parameter in the query + * statement. The order number of the first parameter is 1. + * @param mixed variable that is meant to be bound to specified + * parameter. The type of the value depends on the $type argument. + * @param string specifies the type of the field + * + * @return mixed MDB2_OK on success, a MDB2 error on failure + * + * @access public + */ + function bindParam($parameter, &$value, $type = null){ + if($type){ + $type=$this->getParamType($type); + $this->statement->bindParam($parameter,$value,$type); + }else{ + $this->statement->bindParam($parameter,$value); + } + return MDB2_OK; + } + + /** + * Release resources allocated for the specified prepared query. + * + * @return mixed MDB2_OK on success, a MDB2 error on failure + * @access public + */ + function free() + { + $this->statement->close(); + } + + /** + * Execute a prepared query statement helper method. + * + * @param mixed $result_class string which specifies which result class to use + * @param mixed $result_wrap_class string which specifies which class to wrap results in + * + * @return mixed MDB2_Result or integer (affected rows) on success, + * a MDB2 error on failure + * @access private + */ + function &_execute($result_class = true, $result_wrap_class = false){ + if (is_null($this->statement)) { + $result =& parent::_execute($result_class, $result_wrap_class); + return $result; + } + $this->db->last_query = $this->query; + $this->db->debug($this->query, 'execute', array('is_manip' => $this->is_manip, 'when' => 'pre', 'parameters' => $this->values)); + if ($this->db->getOption('disable_query')) { + $result = $this->is_manip ? 0 : null; + return $result; + } + + $connection = $this->db->getConnection(); + if (PEAR::isError($connection)) { + return $connection; + } + + $result = $this->statement->execute(); + if ($result==false) { + $err =$this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, + 'cant execute statement', __FUNCTION__); + } + + if ($this->is_manip) { + $affected_rows = $this->db->_affectedRows($connection, $result); + return $affected_rows; + } + + $result =& $this->db->_wrapResult($result, $this->result_types, + $result_class, $result_wrap_class, $this->limit, $this->offset); + $this->db->debug($this->query, 'execute', array('is_manip' => $this->is_manip, 'when' => 'post', 'result' => $result)); + return $result; + } + + /** + * Set the values of multiple a parameter of a prepared query in bulk. + * + * @param array specifies all necessary information + * for bindValue() the array elements must use keys corresponding to + * the number of the position of the parameter. + * @param array specifies the types of the fields + * + * @return mixed MDB2_OK on success, a MDB2 error on failure + * + * @access public + * @see bindParam() + */ + function bindValueArray($values, $types = null) + { + $types = is_array($types) ? array_values($types) : array_fill(0, count($values), null); + $parameters = array_keys($values); + foreach ($parameters as $key => $parameter) { + $this->db->pushErrorHandling(PEAR_ERROR_RETURN); + $this->db->expectError(MDB2_ERROR_NOT_FOUND); + $err = $this->bindValue($parameter+1, $values[$parameter], $types[$key]); + $this->db->popExpect(); + $this->db->popErrorHandling(); + if (PEAR::isError($err)) { + if ($err->getCode() == MDB2_ERROR_NOT_FOUND) { + //ignore (extra value for missing placeholder) + continue; + } + return $err; + } + } + return MDB2_OK; + } + // }}} + // {{{ function bindParamArray(&$values, $types = null) + + /** + * Bind the variables of multiple a parameter of a prepared query in bulk. + * + * @param array specifies all necessary information + * for bindParam() the array elements must use keys corresponding to + * the number of the position of the parameter. + * @param array specifies the types of the fields + * + * @return mixed MDB2_OK on success, a MDB2 error on failure + * + * @access public + * @see bindParam() + */ + function bindParamArray(&$values, $types = null) + { + $types = is_array($types) ? array_values($types) : array_fill(0, count($values), null); + $parameters = array_keys($values); + foreach ($parameters as $key => $parameter) { + $err = $this->bindParam($parameter+1, $values[$parameter], $types[$key]); + if (PEAR::isError($err)) { + return $err; + } + } + return MDB2_OK; + } + + // }}} + // {{{ function &execute($values = null, $result_class = true, $result_wrap_class = false) + + /** + * Execute a prepared query statement. + * + * @param array specifies all necessary information + * for bindParam() the array elements must use keys corresponding + * to the number of the position of the parameter. + * @param mixed specifies which result class to use + * @param mixed specifies which class to wrap results in + * + * @return mixed MDB2_Result or integer (affected rows) on success, + * a MDB2 error on failure + * @access public + */ + function &execute($values = null, $result_class = true, $result_wrap_class = false) + { + if (is_null($this->positions)) { + return $this->db->raiseError(MDB2_ERROR, null, null, + 'Prepared statement has already been freed', __FUNCTION__); + } + $values = (array)$values; + if (!empty($values)) { + if(count($this->types)){ + $types=$this->types; + }else{ + $types=null; + } + $err = $this->bindValueArray($values,$types); + if (PEAR::isError($err)) { + return $this->db->raiseError(MDB2_ERROR, null, null, + 'Binding Values failed with message: ' . $err->getMessage(), __FUNCTION__); + } + } + $result =$this->_execute($result_class, $result_wrap_class); + return $result; + } } ?> \ No newline at end of file From 141ffbb1f53f465e64125a020dee6304075a51aa Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 14 Jun 2011 01:22:58 +0200 Subject: [PATCH 015/111] small fix in filesystem test --- tests/index.php | 6 +++--- tests/lib/filesystem.php | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/index.php b/tests/index.php index 5e0dbc2c83..30ebde1123 100644 --- a/tests/index.php +++ b/tests/index.php @@ -30,7 +30,7 @@ require_once('testcase.php'); require_once('template.php'); $testCases=loadFiles(__DIR__,array('index.php','templates')); - +ob_end_clean(); $testResults=array(); foreach($testCases as $testCaseClass){ $testCase=new $testCaseClass(); @@ -65,10 +65,10 @@ function loadFiles($path,$exclude=false){ $dh=opendir($path); while($file=readdir($dh)){ if($file!='.' && $file!='..' && array_search($file,$exclude)===false){ - if(is_file($path.'/'.$file)){ + if(is_file($path.'/'.$file) and substr($file,-3)=='php'){ $result=require_once($path.'/'.$file); $results[]=$result; - }else{ + }elseif(is_dir($path.'/'.$file)){ $subResults=loadFiles($path.'/'.$file); $results=array_merge($results,$subResults); } diff --git a/tests/lib/filesystem.php b/tests/lib/filesystem.php index 73b0069519..1b1703a06d 100644 --- a/tests/lib/filesystem.php +++ b/tests/lib/filesystem.php @@ -84,7 +84,6 @@ class OC_FILEYSYSTEM_Test extends OC_TestCase public function readfile(){ OC_FILESYSTEM::file_put_contents('/dummy','foo'); - ob_clean(); ob_start(); OC_FILESYSTEM::readfile('/dummy'); $this->assertEquals('foo', ob_get_contents(),'Unexpected output of readfile'); From 7d3ae7ae9baa7a2212fb80f31434d746e811d455 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 14 Jun 2011 16:03:57 +0200 Subject: [PATCH 016/111] fix settings page for non-admin users --- lib/template.php | 4 ++-- templates/layout.admin.php | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/template.php b/lib/template.php index 0d6776aa26..93adc35eca 100644 --- a/lib/template.php +++ b/lib/template.php @@ -206,9 +206,9 @@ class OC_TEMPLATE{ $page->assign('searchbox', $search->fetchPage()); // Add menu data if( OC_GROUP::inGroup( $_SESSION["user_id"], "admin" )){ - $page->assign( "settingsnavigation", OC_APP::getSettingsNavigation()); + $page->assign( "adminnavigation", OC_APP::getAdminNavigation()); } - $page->assign( "adminnavigation", OC_APP::getAdminNavigation()); + $page->assign( "settingsnavigation", OC_APP::getSettingsNavigation()); } else { diff --git a/templates/layout.admin.php b/templates/layout.admin.php index 541427f5d5..36b824639d 100644 --- a/templates/layout.admin.php +++ b/templates/layout.admin.php @@ -33,14 +33,16 @@ - -
  • class="active">
  • - - -
  • - - - + + +
  • class="active">
  • + + +
  • + + + + From 1b6307471e0fe3c79b09682c4afd5c8d9d44896c Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 14 Jun 2011 16:13:51 +0200 Subject: [PATCH 017/111] remove outdated plugins entry in settings page --- admin/appinfo/app.php | 1 - 1 file changed, 1 deletion(-) diff --git a/admin/appinfo/app.php b/admin/appinfo/app.php index e87013bd99..775575e22a 100644 --- a/admin/appinfo/app.php +++ b/admin/appinfo/app.php @@ -5,7 +5,6 @@ OC_APP::register( array( "order" => 1, "id" => "admin", "name" => "Administratio OC_APP::addAdminPage( array( "id" => "core_system", "order" => 1, "href" => OC_HELPER::linkTo( "admin", "system.php" ), "name" =>"System", "icon" => OC_HELPER::imagePath( "admin", "administration.png" ))); OC_APP::addAdminPage( array( "id" => "core_users", "order" => 2, "href" => OC_HELPER::linkTo( "admin", "users.php" ), "name" => "Users", "icon" => OC_HELPER::imagePath( "admin", "users.png" ))); OC_APP::addAdminPage( array( "id" => "core_apps", "order" => 3, "href" => OC_HELPER::linkTo( "admin", "apps.php" ), "name" => "Apps", "icon" => OC_HELPER::imagePath( "admin", "apps.png" ))); -OC_APP::addAdminPage( array( "id" => "core_plugins", "order" => 4, "href" => OC_HELPER::linkTo( "admin", "plugins.php" ), "name" => "Plugins", "icon" => OC_HELPER::imagePath( "admin", "plugins.png" ))); // Add subentries for App installer OC_APP::addNavigationSubEntry( "core_apps", array( "id" => "core_apps_installed", "order" => 4, "href" => OC_HELPER::linkTo( "admin", "apps.php?add=some¶meters=here" ), "name" => "Installed apps", "icon" => OC_HELPER::imagePath( "admin", "navicon.png" ))); From fd2c1839a1e2d306cc55c810c4d3741c67b9dab5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 14 Jun 2011 16:16:50 +0200 Subject: [PATCH 018/111] remove plugins settings page --- admin/plugins.php | 52 ------------------------------------- admin/templates/plugins.php | 28 -------------------- 2 files changed, 80 deletions(-) delete mode 100644 admin/plugins.php delete mode 100644 admin/templates/plugins.php diff --git a/admin/plugins.php b/admin/plugins.php deleted file mode 100644 index fd1933a7fa..0000000000 --- a/admin/plugins.php +++ /dev/null @@ -1,52 +0,0 @@ -. -* -*/ - -require_once('../lib/base.php'); -require( 'template.php' ); -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ - header( "Location: ".OC_HELPER::linkTo( "index.php" )); - exit(); -} - -OC_APP::setActiveNavigationEntry( "core_plugins" ); -$plugins=array(); -$blacklist=OC_PLUGIN::loadBlackList(); - -foreach( OC_PLUGIN::listPlugins() as $i ){ - // Gather data about plugin - $data = OC_PLUGIN::getPluginData($plugin); - - // Is it enabled? - $data["enabled"] = ( array_search( $plugin, $blacklist ) === false ); - - // Add the data - $plugins[] = $data; -} - - -$tmpl = new OC_TEMPLATE( "admin", "plugins", "admin" ); -$tmpl->assign( "plugins", $plugins ); -$tmpl->printPage(); - -?> - diff --git a/admin/templates/plugins.php b/admin/templates/plugins.php deleted file mode 100644 index 8f5e87d3e8..0000000000 --- a/admin/templates/plugins.php +++ /dev/null @@ -1,28 +0,0 @@ - -

    Administration

    -

    Plugins

    - - - - - - - - - - - - - - - - - - - - -
    NameDescriptionVersionAuthor
    enable
    From 3062723c343c25fe8e5d9482b699eaa4e4f6a6b7 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 16 Jun 2011 14:56:49 +0200 Subject: [PATCH 019/111] default to sqlite3 over sqlite2 for new installations --- lib/setup.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/setup.php b/lib/setup.php index ab4a786c43..c2757021f2 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -66,8 +66,8 @@ class OC_SETUP { $password = htmlspecialchars_decode($options['adminpass']); $datadir = htmlspecialchars_decode($options['directory']); - //if only sqlite3 is available use that. - if($dbtype=='sqlite' and !is_callable('sqlite_open')){ + //use sqlite3 when available, otherise sqlite2 will be used. + if($dbtype=='sqlite' and class_exists('SQLite3')){ $dbtype='sqlite3'; } From 300b8c06cfacbae7df4f7886851cea8c895111c5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 16 Jun 2011 22:44:16 +0200 Subject: [PATCH 020/111] allow plugins to cancel filesystem operations using the provided hooks --- lib/filesystem.php | 154 ++++++++++++++++++++++++++++++--------------- 1 file changed, 104 insertions(+), 50 deletions(-) diff --git a/lib/filesystem.php b/lib/filesystem.php index 27a937f5e4..0faa740470 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -29,10 +29,13 @@ * * Hooks provided: * read(path) - * write(path) - * create(path) (when a file is created both, write and create will be emited) - * delete(path) - * rename(oldpath,newpath) + * write(path, &run) + * create(path, &run) (when a file is created, both create and write will be emited in that order) + * delete(path, &run) + * rename(oldpath,newpath, &run) + * copy(oldpath,newpath, &run) (if the newpath doesn't exists yes, copy, create and write will be emited in that order) + * + * the &run parameter can be set to false to prevent the operation from occuring */ class OC_FILESYSTEM{ static private $storages=array(); @@ -222,14 +225,23 @@ class OC_FILESYSTEM{ static public function mkdir($path){ $parent=substr($path,0,strrpos($path,'/')); if(self::canWrite($parent) and $storage=self::getStorage($path)){ - OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path)); - return $storage->mkdir(self::getInternalPath($path)); + $run=true; + OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path, 'run' => &$run)); + if($run){ + OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path, 'run' => &$run)); + } + if($run){ + return $storage->mkdir(self::getInternalPath($path)); + } } } static public function rmdir($path){ if(self::canWrite($path) and $storage=self::getStorage($path)){ - OC_HOOK::emit( 'OC_FILESYSTEM', 'delete', array( 'path' => $path)); - return $storage->rmdir(self::getInternalPath($path)); + $run=true; + OC_HOOK::emit( 'OC_FILESYSTEM', 'delete', array( 'path' => $path, 'run' => &$run)); + if($run){ + return $storage->rmdir(self::getInternalPath($path)); + } } } static public function opendir($path){ @@ -319,55 +331,76 @@ class OC_FILESYSTEM{ } static public function file_put_contents($path,$data){ if(self::canWrite($path) and $storage=self::getStorage($path)){ - OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path)); + $run=true; if(!self::file_exists($path)){ - OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path)); + OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path, 'run' => &$run)); + } + if($run){ + OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path, 'run' => &$run)); + } + if($run){ + return $storage->file_put_contents(self::getInternalPath($path),$data); } - return $storage->file_put_contents(self::getInternalPath($path),$data); } } static public function unlink($path){ if(self::canWrite($path) and $storage=self::getStorage($path)){ - OC_HOOK::emit( 'OC_FILESYSTEM', 'delete', array( 'path' => $path)); - return $storage->unlink(self::getInternalPath($path)); + $run=true; + OC_HOOK::emit( 'OC_FILESYSTEM', 'delete', array( 'path' => $path, 'run' => &$run)); + if($run){ + return $storage->unlink(self::getInternalPath($path)); + } } } static public function rename($path1,$path2){ if(self::canWrite($path1) and self::canWrite($path2)){ - $mp1=self::getMountPoint($path1); - $mp2=self::getMountPoint($path2); - if($mp1==$mp2){ - if($storage=self::getStorage($path1)){ - return $storage->rename(self::getInternalPath($path1),self::getInternalPath($path2)); + $run=true; + OC_HOOK::emit( 'OC_FILESYSTEM', 'rename', array( 'oldpath' => $path1 ,'newpath'=>$path2, 'run' => &$run)); + if($run){ + $mp1=self::getMountPoint($path1); + $mp2=self::getMountPoint($path2); + if($mp1==$mp2){ + if($storage=self::getStorage($path1)){ + return $storage->rename(self::getInternalPath($path1),self::getInternalPath($path2)); + } + }elseif($storage1=self::getStorage($path1) and $storage2=self::getStorage($path2)){ + $tmpFile=$storage1->toTmpFile(self::getInternalPath($path1)); + $result=$storage2->fromTmpFile(self::getInternalPath($path2)); + $storage1->unlink(self::getInternalPath($path1)); + return $result; } - }elseif($storage1=self::getStorage($path1) and $storage2=self::getStorage($path2)){ - $tmpFile=$storage1->toTmpFile(self::getInternalPath($path1)); - $result=$storage2->fromTmpFile(self::getInternalPath($path2)); - $storage1->unlink(self::getInternalPath($path1)); - return $result; } - OC_HOOK::emit( 'OC_FILESYSTEM', 'rename', array( 'oldpath' => $path1 ,'newpath'=>$path2)); } } static public function copy($path1,$path2){ if(self::canRead($path1) and self::canWrite($path2)){ - $mp1=self::getMountPoint($path1); - $mp2=self::getMountPoint($path2); - if($mp1==$mp2){ - if($storage=self::getStorage($path1)){ - return $storage->copy(self::getInternalPath($path1),self::getInternalPath($path2)); - } - }elseif($storage1=self::getStorage($path1) and $storage2=self::getStorage($path2)){ - $tmpFile=$storage1->toTmpFile(self::getInternalPath($path1)); - return $storage2->fromTmpFile(self::getInternalPath($path2)); + $run=true; + OC_HOOK::emit( 'OC_FILESYSTEM', 'copy', array( 'oldpath' => $path1 ,'newpath'=>$path2, 'run' => &$run)); + if($run and !self::file_exists($path2)){ + OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path2, 'run' => &$run)); + } + if($run){ + OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path2, 'run' => &$run)); + } + if($run){ + $mp1=self::getMountPoint($path1); + $mp2=self::getMountPoint($path2); + if($mp1==$mp2){ + if($storage=self::getStorage($path1)){ + return $storage->copy(self::getInternalPath($path1),self::getInternalPath($path2)); + } + }elseif($storage1=self::getStorage($path1) and $storage2=self::getStorage($path2)){ + $tmpFile=$storage1->toTmpFile(self::getInternalPath($path1)); + return $storage2->fromTmpFile(self::getInternalPath($path2)); + } } - OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path2)); } } static public function fopen($path,$mode){ $allowed=((strpos($path,'r')===false and strpos($path,'r+')!==false and self::canRead) or self::canWrite($path)); if($allowed){ if($storage=self::getStorage($path)){ + $run=true; switch($mode){ case 'r': OC_HOOK::emit( 'OC_FILESYSTEM', 'read', array( 'path' => $path)); @@ -377,21 +410,27 @@ class OC_FILESYSTEM{ case 'x+': case 'a+': OC_HOOK::emit( 'OC_FILESYSTEM', 'read', array( 'path' => $path)); - OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path)); if(!self::file_exists($path)){ OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path)); } + if($run){ + OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path, 'run' => &$run)); + } break; case 'w': case 'x': case 'a': - OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path)); if(!self::file_exists($path)){ OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path)); } + if($run){ + OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path, 'run' => &$run)); + } break; } - return $storage->fopen(self::getInternalPath($path),$mode); + if($run){ + return $storage->fopen(self::getInternalPath($path),$mode); + } } } } @@ -403,20 +442,30 @@ class OC_FILESYSTEM{ } static public function fromTmpFile($tmpFile,$path){ if(self::canWrite($path) and $storage=self::getStorage($path)){ - OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path)); + $run=true; if(!self::file_exists($path)){ - OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path)); + OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path, 'run' => &$run)); + } + if($run){ + OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path, 'run' => &$run)); + } + if($run){ + return $storage->fromTmpFile($tmpFile,self::getInternalPath($path)); } - return $storage->fromTmpFile($tmpFile,self::getInternalPath($path)); } } static public function fromUploadedFile($tmpFile,$path){ if(self::canWrite($path) and $storage=self::getStorage($path)){ - OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path)); - if(!self::file_exists($path)){ - OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path)); + $run=true; + if($run and !self::file_exists($path)){ + OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path, 'run' => &$run)); + } + if($run){ + OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path, 'run' => &$run)); + } + if($run){ + return $storage->fromUploadedFile($tmpFile,self::getInternalPath($path)); } - return $storage->fromUploadedFile($tmpFile,self::getInternalPath($path)); } } static public function getMimeType($path){ @@ -426,8 +475,11 @@ class OC_FILESYSTEM{ } static public function delTree($path){ if(self::canWrite($path) and $storage=self::getStorage($path)){ - OC_HOOK::emit( 'OC_FILESYSTEM', 'delete', array( 'path' => $path)); - return $storage->delTree(self::getInternalPath($path)); + $run=true; + OC_HOOK::emit( 'OC_FILESYSTEM', 'delete', array( 'path' => $path, 'run' => &$run)); + if($run){ + return $storage->delTree(self::getInternalPath($path)); + } } } static public function find($path){ @@ -475,10 +527,12 @@ class OC_FILESYSTEM{ $fakeRootLength=strlen(self::$fakeRoot); foreach(self::$storages as $mountpoint=>$storage){ $results=$storage->search($query); - foreach($results as $result){ - $file=str_replace('//','/',$mountpoint.$result); - $file=substr($file,$fakeRootLength); - $files[]=$file; + if(is_array($results)){ + foreach($results as $result){ + $file=str_replace('//','/',$mountpoint.$result); + $file=substr($file,$fakeRootLength); + $files[]=$file; + } } } return $files; From 07b72ca53459bcd150a21e2133a7d5936d92cbec Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 16 Jun 2011 23:15:58 +0200 Subject: [PATCH 021/111] make the system for default fileactions more flexible --- files/js/fileactions.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/files/js/fileactions.js b/files/js/fileactions.js index dec1d1cfb0..1bdbc4ac0b 100644 --- a/files/js/fileactions.js +++ b/files/js/fileactions.js @@ -8,7 +8,7 @@ FileActions={ FileActions.actions[mime][name]=action; }, setDefault:function(mime,name){ - FileActions.defaults[mime]=FileActions.actions[mime][name]; + FileActions.defaults[mime]=name; }, get:function(mime,type){ var actions={}; @@ -35,15 +35,18 @@ FileActions={ if(mime){ var mimePart=mime.substr(0,mime.indexOf('/')); } + var name=false; if(mime && FileActions.defaults[mime]){ - return FileActions.defaults[mime]; + name=FileActions.defaults[mime]; }else if(mime && FileActions.defaults[mimePart]){ - return FileActions.defaults[mimePart]; + name=FileActions.defaults[mimePart]; }else if(type && FileActions.defaults[type]){ - return FileActions.defaults[type]; + name=FileActions.defaults[type]; }else{ - return FileActions.defaults.all; + name=FileActions.defaults.all; } + var actions=this.get(mime,type); + return actions[name]; }, display:function(parent){ $('#file_menu ul').empty(); From 561c3a15f0d3821ffbaef84052c77182914b2d12 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 17 Jun 2011 14:17:08 +0200 Subject: [PATCH 022/111] prevent some possible warnings if there are files in /apps --- lib/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/app.php b/lib/app.php index a56e0c2f9e..e373331850 100644 --- a/lib/app.php +++ b/lib/app.php @@ -59,7 +59,7 @@ class OC_APP{ // The rest comes here $dir = opendir( "$SERVERROOT/apps" ); while( false !== ( $filename = readdir( $dir ))){ - if( substr( $filename, 0, 1 ) != '.' ){ + if( substr( $filename, 0, 1 ) != '.' and is_dir("$SERVERROOT/apps/$filename") ){ if( file_exists( "$SERVERROOT/apps/$filename/appinfo/app.php" )){ if(OC_APPCONFIG::getValue($filename,'installed_version',0)==0){ //check if the plugin is fully installed //install the database From c4e7761ee814f18ff6dca4e88f13b3bf05959290 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 17 Jun 2011 14:17:53 +0200 Subject: [PATCH 023/111] make new folder dialog behave more like a regular form, so you can press enter to create the folder --- files/js/files.js | 3 ++- files/templates/index.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/files/js/files.js b/files/js/files.js index 0172ab1b1a..45931b9bae 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -51,7 +51,8 @@ $(document).ready(function() { } }); - $('#file_newfolder_submit').click(function() { + $('#file_newfolder_form').submit(function(event) { + event.preventDefault(); $.ajax({ url: 'ajax/newfolder.php', data: "dir="+$('#dir').val()+"&foldername="+$('#file_newfolder_name').val(), diff --git a/files/templates/index.php b/files/templates/index.php index 11cf0360e1..d2d0a237d7 100644 --- a/files/templates/index.php +++ b/files/templates/index.php @@ -13,7 +13,7 @@
      - +
    Download From 51420a75228d10c803f102eefa3264484675616e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 17 Jun 2011 16:09:43 +0200 Subject: [PATCH 024/111] only create one connection to a sqlite3 database, fixes 'Database locked' errors with webdav --- lib/MDB2/Driver/sqlite3.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/MDB2/Driver/sqlite3.php b/lib/MDB2/Driver/sqlite3.php index abd2b16ad4..a569da187a 100644 --- a/lib/MDB2/Driver/sqlite3.php +++ b/lib/MDB2/Driver/sqlite3.php @@ -348,6 +348,9 @@ class MDB2_Driver_sqlite3 extends MDB2_Driver_Common **/ function connect() { + if($this->connection instanceof SQLite3){ + return MDB2_OK; + } global $SERVERROOT; $datadir=OC_CONFIG::getValue( "datadirectory", "$SERVERROOT/data" ); $database_file = $this->_getDatabaseFile($this->database_name); @@ -409,6 +412,7 @@ class MDB2_Driver_sqlite3 extends MDB2_Driver_Common $php_errormsg = ''; $this->connection = new SQLite3($database_file); + $this->connection->busyTimeout(100); $this->_lasterror = $this->connection->lastErrorMsg(); if (!$this->connection) { return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, @@ -1346,6 +1350,10 @@ class MDB2_Statement_sqlite3 extends MDB2_Statement_Common $result =$this->_execute($result_class, $result_wrap_class); return $result; } + + function __destruct() { + $this->free(); + } } ?> \ No newline at end of file From be3ee0318942f092839b3de04f193a04e397116c Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Sat, 18 Jun 2011 22:02:45 +0200 Subject: [PATCH 025/111] handle app repo connection failure --- admin/apps.php | 7 ++ admin/templates/app_noconn.php | 7 ++ lib/ocsclient.php | 116 ++++++++++++++++++--------------- 3 files changed, 78 insertions(+), 52 deletions(-) create mode 100644 admin/templates/app_noconn.php diff --git a/admin/apps.php b/admin/apps.php index 7ce3f4c419..5b4e65e340 100644 --- a/admin/apps.php +++ b/admin/apps.php @@ -36,7 +36,14 @@ if(isset($_GET['id'])) $id=$_GET['id']; else $id=0; if(isset($_GET['cat'])) $cat=$_GET['cat']; else $cat=0; $categories=OC_OCSCLIENT::getCategories(); +if($categories==NULL){ + OC_APP::setActiveNavigationEntry( "core_apps" ); + $tmpl = new OC_TEMPLATE( "admin", "app_noconn", "admin" ); + $tmpl->printPage(); + unset($tmpl); + exit(); +} /* All diff --git a/admin/templates/app_noconn.php b/admin/templates/app_noconn.php new file mode 100644 index 0000000000..2ca3d15d44 --- /dev/null +++ b/admin/templates/app_noconn.php @@ -0,0 +1,7 @@ + +

    Apps Repository

    +

    Cannot connect to apps repository

    \ No newline at end of file diff --git a/lib/ocsclient.php b/lib/ocsclient.php index a3c4659c6e..cfd529b2ec 100644 --- a/lib/ocsclient.php +++ b/lib/ocsclient.php @@ -37,7 +37,10 @@ class OC_OCSCLIENT{ public static function getCategories(){ $url='http://api.apps.owncloud.com/v1/content/categories'; - $xml=file_get_contents($url); + $xml=@file_get_contents($url); + if($xml==FALSE){ + return NULL; + } $data=simplexml_load_string($xml); $tmp=$data->data; @@ -61,16 +64,19 @@ class OC_OCSCLIENT{ * This function returns a list of all the applications on the OCS server */ public static function getApplications($categories){ - if(is_array($categories)) { + if(is_array($categories)) { $categoriesstring=implode('x',$categories); }else{ $categoriesstring=$categories; } $url='http://api.apps.owncloud.com/v1/content/data?categories='.urlencode($categoriesstring).'&sortmode=new&page=0&pagesize=10'; $apps=array(); - $xml=file_get_contents($url); + $xml=@file_get_contents($url); + if($xml==FALSE){ + return NULL; + } $data=simplexml_load_string($xml); - + $tmp=$data->data->content; for($i = 0; $i < count($tmp); $i++) { $app=array(); @@ -90,60 +96,66 @@ class OC_OCSCLIENT{ } - /** - * @brief Get an the applications from the OCS server - * @returns array with application data - * - * This function returns an applications from the OCS server - */ - public static function getApplication($id){ - $url='http://api.apps.owncloud.com/v1/content/data/'.urlencode($id); + /** + * @brief Get an the applications from the OCS server + * @returns array with application data + * + * This function returns an applications from the OCS server + */ + public static function getApplication($id){ + $url='http://api.apps.owncloud.com/v1/content/data/'.urlencode($id); - $xml=file_get_contents($url); - $data=simplexml_load_string($xml); + $xml=@file_get_contents($url); + if($xml==FALSE){ + return NULL; + } + $data=simplexml_load_string($xml); - $tmp=$data->data->content; - $app=array(); - $app['id']=$tmp->id; - $app['name']=$tmp->name; - $app['type']=$tmp->typeid; - $app['typename']=$tmp->typename; - $app['personid']=$tmp->personid; - $app['detailpage']=$tmp->detailpage; - $app['preview1']=$tmp->smallpreviewpic1; - $app['preview2']=$tmp->smallpreviewpic2; - $app['preview3']=$tmp->smallpreviewpic3; - $app['changed']=strtotime($tmp->changed); - $app['description']=$tmp->description; + $tmp=$data->data->content; + $app=array(); + $app['id']=$tmp->id; + $app['name']=$tmp->name; + $app['type']=$tmp->typeid; + $app['typename']=$tmp->typename; + $app['personid']=$tmp->personid; + $app['detailpage']=$tmp->detailpage; + $app['preview1']=$tmp->smallpreviewpic1; + $app['preview2']=$tmp->smallpreviewpic2; + $app['preview3']=$tmp->smallpreviewpic3; + $app['changed']=strtotime($tmp->changed); + $app['description']=$tmp->description; - return $app; - } + return $app; + } - /** - * @brief Get all the knowledgebase entries from the OCS server - * @returns array with q and a data - * - * This function returns a list of all the knowledgebase entries from the OCS server - */ - public static function getKnownledgebaseEntries(){ - $url='http://api.apps.owncloud.com/v1/knowledgebase/data?type=150&page=0&pagesize=10'; + /** + * @brief Get all the knowledgebase entries from the OCS server + * @returns array with q and a data + * + * This function returns a list of all the knowledgebase entries from the OCS server + */ + public static function getKnownledgebaseEntries(){ + $url='http://api.apps.owncloud.com/v1/knowledgebase/data?type=150&page=0&pagesize=10'; - $kbe=array(); - $xml=file_get_contents($url); - $data=simplexml_load_string($xml); + $kbe=array(); + $xml=@file_get_contents($url); + if($xml==FALSE){ + return NULL; + } + $data=simplexml_load_string($xml); - $tmp=$data->data->content; - for($i = 0; $i < count($tmp); $i++) { - $kb=array(); - $kb['id']=$tmp[$i]->id; - $kb['name']=$tmp[$i]->name; - $kb['description']=$tmp[$i]->description; - $kb['answer']=$tmp[$i]->answer; - $kb['preview1']=$tmp[$i]->smallpreviewpic1; - $kbe[]=$kb; - } - return $kbe; - } + $tmp=$data->data->content; + for($i = 0; $i < count($tmp); $i++) { + $kb=array(); + $kb['id']=$tmp[$i]->id; + $kb['name']=$tmp[$i]->name; + $kb['description']=$tmp[$i]->description; + $kb['answer']=$tmp[$i]->answer; + $kb['preview1']=$tmp[$i]->smallpreviewpic1; + $kbe[]=$kb; + } + return $kbe; + } From 97ab331b2a41777b64881118819902183e5f0b98 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Sat, 18 Jun 2011 23:57:03 +0200 Subject: [PATCH 026/111] change db index names to avoid collisions --- apps/files_publiclink/appinfo/database.xml | 2 +- db_structure.xml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/files_publiclink/appinfo/database.xml b/apps/files_publiclink/appinfo/database.xml index de63b03f44..4fe6be47d8 100644 --- a/apps/files_publiclink/appinfo/database.xml +++ b/apps/files_publiclink/appinfo/database.xml @@ -35,7 +35,7 @@ true - token + a_files_publiclink_token true token diff --git a/db_structure.xml b/db_structure.xml index 599352c2a8..19cdccef8a 100644 --- a/db_structure.xml +++ b/db_structure.xml @@ -208,7 +208,7 @@ - path + locks_path path ascending @@ -216,7 +216,7 @@ - path_2 + locks_path_2 path ascending @@ -224,7 +224,7 @@ - path_3 + locks_path_3 path ascending @@ -236,7 +236,7 @@ - expires + locks_expires expires ascending @@ -253,7 +253,7 @@ - token + locks_token true token From 1cab3ca92cf07f7e4d7402fae7cf49e1e489b14f Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Sun, 19 Jun 2011 00:55:19 +0200 Subject: [PATCH 027/111] move installation of shipped apps to setup --- lib/app.php | 24 +++--------------------- lib/setup.php | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/lib/app.php b/lib/app.php index e373331850..4e67da3c41 100644 --- a/lib/app.php +++ b/lib/app.php @@ -57,28 +57,10 @@ class OC_APP{ } // The rest comes here - $dir = opendir( "$SERVERROOT/apps" ); - while( false !== ( $filename = readdir( $dir ))){ - if( substr( $filename, 0, 1 ) != '.' and is_dir("$SERVERROOT/apps/$filename") ){ - if( file_exists( "$SERVERROOT/apps/$filename/appinfo/app.php" )){ - if(OC_APPCONFIG::getValue($filename,'installed_version',0)==0){ //check if the plugin is fully installed - //install the database - if(is_file("$SERVERROOT/apps/$filename/appinfo/database.xml")){ - OC_DB::createDbFromStructure("$SERVERROOT/apps/$filename/appinfo/database.xml"); - } - - //run appinfo/install.php - if(is_file("$SERVERROOT/apps/$filename/appinfo/install.php")){ - include("$SERVERROOT/apps/$filename/appinfo/install.php"); - } - $info=self::getAppInfo("$SERVERROOT/apps/$filename/appinfo/info.xml"); - OC_APPCONFIG::setValue($filename,'installed_version',$info['version']); - } - require( "apps/$filename/appinfo/app.php" ); - } - } + $apps = OC_APPCONFIG::getApps(); + foreach( $apps as $app ){ + require( "apps/$app/appinfo/app.php" ); } - closedir( $dir ); self::$init = true; diff --git a/lib/setup.php b/lib/setup.php index c2757021f2..e9cb3da686 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -31,6 +31,7 @@ else { class OC_SETUP { public static function install($options) { + global $SERVERROOT; $error = array(); $dbtype = $options['dbtype']; @@ -133,6 +134,21 @@ class OC_SETUP { OC_GROUP::createGroup('admin'); OC_GROUP::addToGroup($username, 'admin'); + foreach( array( "files_imageviewer", "files_publiclink" ) as $app ){ + + if(is_file("$SERVERROOT/apps/$app/appinfo/database.xml")){ + OC_DB::createDbFromStructure("$SERVERROOT/apps/$app/appinfo/database.xml"); + } + + //run appinfo/install.php + if(is_file("$SERVERROOT/apps/$app/appinfo/install.php")){ + include("$SERVERROOT/apps/$app/appinfo/install.php"); + } + + $info=OC_APP::getAppInfo("$SERVERROOT/apps/$app/appinfo/info.xml"); + OC_APPCONFIG::setValue($app,'installed_version',$info['version']); + } + //create htaccess files for apache hosts self::createHtaccess(); //TODO detect if apache is used From 14dddc0c9e116874b76bdf5965cd2c1b0e4d2e5e Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Sun, 19 Jun 2011 14:23:24 +0200 Subject: [PATCH 028/111] forgot "event" as a parameter. --- apps/files_publiclink/js/admin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/files_publiclink/js/admin.js b/apps/files_publiclink/js/admin.js index 9a0bad604a..2185771814 100644 --- a/apps/files_publiclink/js/admin.js +++ b/apps/files_publiclink/js/admin.js @@ -8,7 +8,7 @@ $(document).ready(function() { source: "../../files/ajax/autocomplete.php", minLength: 1 }); - $("button.delete").live('click', function() { + $("button.delete").live('click', function( event ) { event.preventDefault(); var token=$(this).attr('data-token'); var data="token="+token; @@ -22,7 +22,7 @@ $(document).ready(function() { } }); }); - $('#newlink').submit(function(){ + $('#newlink').submit(function( event ){ event.preventDefault(); var path=$('#path').val(); var expire=$('#expire_time').val()||0; From 6a19a7d22639f056ccb39d94f2358882ed875faf Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Sun, 19 Jun 2011 14:24:26 +0200 Subject: [PATCH 029/111] added preferences to base.php, will be needed for i18n stuff --- lib/base.php | 2 ++ log/index.php | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/base.php b/lib/base.php index 50c41dc085..1baf5dc167 100644 --- a/lib/base.php +++ b/lib/base.php @@ -80,6 +80,8 @@ require_once('appconfig.php'); require_once('files.php'); require_once('filesystem.php'); require_once('filestorage.php'); +require_once('l10n.php'); +require_once('preferences.php'); require_once('log.php'); require_once('user.php'); require_once('group.php'); diff --git a/log/index.php b/log/index.php index 56bbbadb99..985ab60b52 100644 --- a/log/index.php +++ b/log/index.php @@ -24,8 +24,7 @@ //require_once('../../config/config.php'); require_once('../lib/base.php'); -require( 'template.php' ); -require( 'preferences.php' ); +require_once( 'template.php' ); if( !OC_USER::isLoggedIn()){ header( 'Location: '.OC_HELPER::linkTo( 'index.php' )); From baa00a589f7d4cdf920e5fb8185082e19bc179d1 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Sun, 19 Jun 2011 14:27:52 +0200 Subject: [PATCH 030/111] l10n added --- lib/l10n.php | 247 +++++++++++++++++++++++++++++++++++++++++++++++ lib/template.php | 7 +- 2 files changed, 252 insertions(+), 2 deletions(-) create mode 100644 lib/l10n.php diff --git a/lib/l10n.php b/lib/l10n.php new file mode 100644 index 0000000000..47d331b3fc --- /dev/null +++ b/lib/l10n.php @@ -0,0 +1,247 @@ +. + * + */ + +/** + * This class is for i18n and l10n + */ +class OC_L10N{ + /** + * cache + */ + protected static $cache = array(); + + /** + * The best language + */ + protected static $language = ''; + + /** + * Translations + */ + private $translations = array(); + + /** + * Localization + */ + private $localizations = array( + 'date' => 'd.m.Y', + 'datetime' => 'd.m.Y H:i:s', + 'time' => 'H:i:s' ); + + /** + * @brief The constructor + * @param $app the app requesting l10n + * @param $lang default: null Language + * @returns OC_L10N-Object + * + * If language is not set, the constructor tries to find the right + * language. + */ + public function __construct( $app, $lang = null ){ + // Find the right language + if( is_null( $lang )){ + self::findLanguage( $app ); + } + + // Use cache if possible + if(array_key_exists($app.'::'.$lang, self::$cache )){ + $this->translations = self::$cache[$app.'::'.$lang]['t']; + $this->localizations = self::$cache[$app.'::'.$lang]['l']; + } + else{ + $i18ndir = self::findI18nDir( $app ); + + // Localization is in /l10n, Texts are in $i18ndir + // (Just no need to define date/time format etc. twice) + if( file_exists( $i18ndir.$lang.'php' )){ + // Include the file, save the data from $CONFIG + include( $i18ndir.$lang.'php' ); + if( isset( $TRANSLATIONS ) && is_array( $TRANSLATIONS )){ + $this->translations = $TRANSLATIONS; + } + } + + if( file_exists( '/l10n/l10n-'.$lang.'php' )){ + // Include the file, save the data from $CONFIG + include( $SERVERROOT.'/l10n/l10n-'.$lang.'php' ); + if( isset( $LOCALIZATIONS ) && is_array( $LOCALIZATIONS )){ + $this->localizations = array_merge( $this->localizations, $LOCALIZATIONS ); + } + } + + self::$cache[$app.'::'.$lang]['t'] = $this->translations; + self::$cache[$app.'::'.$lang]['l'] = $this->localizations; + } + } + + /** + * @brief Translating + * @param $text The text we need a translation for + * @returns Translation or the same text + * + * Returns the translation. If no translation is found, $text will be + * returned. + */ + public function t($text){ + if(array_key_exists($text, $this->translations)){ + return $this->translations[$text]; + } + return $text; + } + + /** + * @brief Localization + * @param $type Type of localization + * @param $params parameters for this localization + * @returns String or false + * + * Returns the localized data. + * + * Implemented types: + * - date + * - Creates a date + * - l10n-field: date + * - params: timestamp (int) + * - datetime + * - Creates date and time + * - l10n-field: datetime + * - params: timestamp (int) + * - time + * - Creates a time + * - l10n-field: time + * - params: timestamp (int) + */ + public function l($type, $data){ + switch($type){ + case 'date': + return date( $this->localizations['date'], $data ); + break; + case 'datetime': + return date( $this->localizations['datetime'], $data ); + break; + case 'time': + return date( $this->localizations['time'], $data ); + break; + default: + return false; + } + } + + /** + * @brief Choose a language + * @param $texts Associative Array with possible strings + * @returns String + * + * $text is an array 'de' => 'hallo welt', 'en' => 'hello world', ... + * + * This function is useful to avoid loading thousands of files if only one + * simple string is needed, for example in appinfo.php + */ + public static function selectLanguage( $text ){ + $lang = self::findLanguage( array_keys( $text )); + return $text[$lang]; + } + + /** + * @brief find the best language + * @param $app Array or string, details below + * @returns language + * + * If $app is an array, ownCloud assumes that these are the available + * languages. Otherwise ownCloud tries to find the files in the l10n + * folder. + * + * If nothing works it returns 'en' + */ + public static function findLanguage( $app = null ){ + if( !is_array( $app) && self::$language != '' ){ + return self::$language; + } + + $available = array(); + if( is_array( $app )){ + $available = $app; + } + else{ + $dir = self::findI18nDir( $app ); + if( file_exists($dir)){ + $dh = opendir($dir); + while(( $file = readdir( $dh )) !== false ){ + if( substr( $file, -4, 4 ) == '.php' ){ + $i = substr( $file, 0, -4 ); + if( $i != '' ){ + $available[] = $i; + } + } + } + closedir($dh); + } + } + + if( isset($_SESSION['user_id']) && OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang' )){ + $lang = OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang' ); + self::$language = $lang; + if( array_search( $lang, $available )){ + return $lang; + } + } + + if( isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] )){ + $accepted_languages = preg_split( '/,\s*/', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ); + foreach( $accepted_languages as $i ){ + $temp = explode( ';', $i ); + $temp = explode( '-', $temp[0] ); + if( array_key_exists( $temp[0], $available )){ + return $temp[0]; + } + } + } + + // Last try: English + return 'en'; + } + + /** + * @brief find the best language + * @param $app App that needs to be translated + * @returns language + * + * Finds the best language. Depends on user settings and browser + * information + */ + protected static function findI18nDir( $app ){ + global $SERVERROOT; + + // find the i18n dir + $i18ndir = $SERVERROOT.'/l10n/'; + if( $app != 'core' && $app != '' ){ + // Check if the app is in the app folder + if( file_exists( $SERVERROOT.'/apps/'.$app.'/l10n/' )){ + $i18ndir = $SERVERROOT.'/apps/'.$app.'/l10n/'; + } + else{ + $i18ndir = $SERVERROOT.'/'.$app.'/l10n/'; + } + } + return $i18ndir; + } +} \ No newline at end of file diff --git a/lib/template.php b/lib/template.php index 93adc35eca..6b9a1c38e1 100644 --- a/lib/template.php +++ b/lib/template.php @@ -73,8 +73,9 @@ function human_file_size( $bytes ){ class OC_TEMPLATE{ private $renderas; // Create a full page? private $application; // template Application - private $vars; // The smarty object - private $template; // The smarty object + private $vars; // Vars + private $template; // The path to the template + private $l10n; // The l10n-Object /** * @brief Constructor @@ -113,6 +114,7 @@ class OC_TEMPLATE{ $this->application = $app; $this->template = $template; $this->vars = array(); + $this->l10n = new OC_L10N($app); } /** @@ -251,6 +253,7 @@ class OC_TEMPLATE{ private function _fetch(){ // Register the variables $_ = $this->vars; + $l = $this->l10n; // Execute the template ob_start(); From d5b550395af51d1299da4600870a403b7f7921d8 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Sun, 19 Jun 2011 15:08:28 +0200 Subject: [PATCH 031/111] Removed debug messages --- lib/files.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/lib/files.php b/lib/files.php index 9e66f9dab8..fca311833b 100644 --- a/lib/files.php +++ b/lib/files.php @@ -30,15 +30,6 @@ require_once("log.php"); */ class OC_FILES { static $tmpFiles=array(); - /** - * show a web GUI filebrowser - * - * @param basedir $basedir - * @param dir $dir - */ - public static function showBrowser($basedir,$dir){ - echo '
    '; - } /** * get the content of a directory @@ -101,7 +92,7 @@ class OC_FILES { if(strpos($files,';')){ $files=explode(';',$files); } - echo 't'; + if(is_array($files)){ $zip = new ZipArchive(); $filename = sys_get_temp_dir()."/ownCloud.zip"; @@ -300,7 +291,6 @@ class OC_FILES { global $SERVERROOT; global $WEBROOT; $size=OC_HELPER::humanFileSize($size); - echo $size; $size=substr($size,0,-1);//strip the B $size=str_replace(' ','',$size); //remove the space between the size and the postfix $content = "ErrorDocument 404 /$WEBROOT/templates/404.php\n";//custom 404 error page From 6b2ec221045c2e437d5658be1bc1dc001911e1e4 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Sun, 19 Jun 2011 15:18:52 +0200 Subject: [PATCH 032/111] allow disabling apps, install apps as disabled --- lib/app.php | 41 ++++++++++++++++++++++++++++++++++++++++- lib/installer.php | 45 ++++++++++++++++++++++++++++++++++++--------- lib/setup.php | 1 + 3 files changed, 77 insertions(+), 10 deletions(-) diff --git a/lib/app.php b/lib/app.php index 4e67da3c41..c2a850b6f6 100644 --- a/lib/app.php +++ b/lib/app.php @@ -59,7 +59,9 @@ class OC_APP{ // The rest comes here $apps = OC_APPCONFIG::getApps(); foreach( $apps as $app ){ - require( "apps/$app/appinfo/app.php" ); + if( self::isEnabled( $app )){ + require( "apps/$app/appinfo/app.php" ); + } } self::$init = true; @@ -68,6 +70,43 @@ class OC_APP{ return true; } + /** + * @brief checks whether or not an app is enabled + * @param $app app + * @returns true/false + * + * This function checks whether or not an app is enabled. + */ + public static function isEnabled( $app ){ + if( 'yes' == OC_APPCONFIG::getValue( $app, 'enabled' )){ + return true; + } + + return false; + } + + /** + * @brief enables an app + * @param $app app + * @returns true/false + * + * This function set an app as enabled in appconfig. + */ + public static function enable( $app ){ + OC_APPCONFIG::setValue( $app, 'enabled', 'yes' ); + } + + /** + * @brief enables an app + * @param $app app + * @returns true/false + * + * This function set an app as enabled in appconfig. + */ + public static function disable( $app ){ + OC_APPCONFIG::setValue( $app, 'enabled', 'no' ); + } + /** * @brief makes owncloud aware of this app * @param $data array with all information diff --git a/lib/installer.php b/lib/installer.php index 7ab07bf507..02b71027cd 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -59,7 +59,7 @@ class OC_INSTALLER{ if(!isset($data['source'])){ error_log("No source specified when installing app"); - return; + return false; } //download the file if necesary @@ -67,13 +67,13 @@ class OC_INSTALLER{ $path=tempnam(sys_get_temp_dir(),'oc_installer_'); if(!isset($data['href'])){ error_log("No href specified when installing app from http"); - return; + return false; } copy($data['href'],$path); }else{ if(!isset($data['path'])){ error_log("No path specified when installing app from local file"); - return; + return false; } $path=$data['path']; } @@ -92,7 +92,7 @@ class OC_INSTALLER{ if($data['source']=='http'){ unlink($path); } - return; + return false; } //load the info.xml file of the app @@ -102,23 +102,33 @@ class OC_INSTALLER{ if($data['source']=='http'){ unlink($path); } - return; + return false; } $info=OC_APP::getAppInfo($extractDir.'/appinfo/info.xml'); $basedir=$SERVERROOT.'/apps/'.$info['id']; //check if an app with the same id is already installed - if(is_dir($basedir)){ + if(self::isInstalled( $info['id'] ))){ error_log("App already installed"); OC_HELPER::rmdirr($extractDir); if($data['source']=='http'){ unlink($path); } - return; + return false; } + + //check if the destination directory already exists ++ if(is_dir($basedir)){ ++ error_log("App's directory already exists"); ++ OC_HELPER::rmdirr($extractDir); ++ if($data['source']=='http'){ ++ unlink($path); ++ } ++ return false; ++ } if(isset($data['pretent']) and $data['pretent']==true){ - return; + return false; } //copy the app to the correct place @@ -128,7 +138,7 @@ class OC_INSTALLER{ if($data['source']=='http'){ unlink($path); } - return; + return false; } OC_HELPER::copyr($extractDir,$basedir); @@ -150,6 +160,23 @@ class OC_INSTALLER{ //set the installed version OC_APPCONFIG::setValue($info['id'],'installed_version',$info['version']); + OC_APPCONFIG::setValue($info['id'],'enabled','no'); + return true; + } + + /** + * @brief checks whether or not an app is installed + * @param $app app + * @returns true/false + * + * Checks whether or not an app is installed, i.e. registered in apps table. + */ + public static function isInstalled( $app ){ + + if( null == OC_APPCONFIG::getValue( $app, "installed_version" )){ + return false; + } + return true; } diff --git a/lib/setup.php b/lib/setup.php index e9cb3da686..43ead7b96a 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -147,6 +147,7 @@ class OC_SETUP { $info=OC_APP::getAppInfo("$SERVERROOT/apps/$app/appinfo/info.xml"); OC_APPCONFIG::setValue($app,'installed_version',$info['version']); + OC_APPCONFIG::setValue($app,'enabled','yes'); } //create htaccess files for apache hosts From a688e5a5b1d34abba1b2b59ae790022a40ff3d29 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Sun, 19 Jun 2011 16:05:23 +0200 Subject: [PATCH 033/111] Load preferences only if user is registered --- lib/l10n.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/l10n.php b/lib/l10n.php index 47d331b3fc..e800941e3d 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -197,7 +197,7 @@ class OC_L10N{ } } - if( isset($_SESSION['user_id']) && OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang' )){ + if( isset($_SESSION['user_id']) && $_SESSION['user_id'] && OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang' )){ $lang = OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang' ); self::$language = $lang; if( array_search( $lang, $available )){ From abac11d8c42fdc3e93bbfc65d8e30474d3bb876a Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Sun, 19 Jun 2011 18:50:25 +0200 Subject: [PATCH 034/111] tabs, not spaces --- log/index.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/log/index.php b/log/index.php index 985ab60b52..950e1f82d1 100644 --- a/log/index.php +++ b/log/index.php @@ -21,14 +21,13 @@ * */ - //require_once('../../config/config.php'); require_once('../lib/base.php'); require_once( 'template.php' ); if( !OC_USER::isLoggedIn()){ - header( 'Location: '.OC_HELPER::linkTo( 'index.php' )); - exit(); + header( 'Location: '.OC_HELPER::linkTo( 'index.php' )); + exit(); } //load the script @@ -48,15 +47,15 @@ if(isset($_POST['save'])){ OC_PREFERENCES::setValue($_SESSION['user_id'],'log','pagesize',$_POST['size']); } //clear log entries -else if(isset($_POST['clear'])){ - $removeBeforeDate=(isset($_POST['removeBeforeDate']))?$_POST['removeBeforeDate']:0; - if($removeBeforeDate!==0){ - $removeBeforeDate=strtotime($removeBeforeDate); - OC_LOG::deleteBefore($removeBeforeDate); - } +elseif(isset($_POST['clear'])){ + $removeBeforeDate=(isset($_POST['removeBeforeDate']))?$_POST['removeBeforeDate']:0; + if($removeBeforeDate!==0){ + $removeBeforeDate=strtotime($removeBeforeDate); + OC_LOG::deleteBefore($removeBeforeDate); + } } -else if(isset($_POST['clearall'])){ - OC_LOG::deleteAll(); +elseif(isset($_POST['clearall'])){ + OC_LOG::deleteAll(); } OC_APP::setActiveNavigationEntry( 'log' ); @@ -83,7 +82,8 @@ $url=OC_HELPER::linkTo( 'log', 'index.php' ).'?page='; $pager=OC_UTIL::getPageNavi($pageCount,$page,$url); if($pager){ $pagerHTML=$pager->fetchPage(); -}else{ +} +else{ $pagerHTML=''; } @@ -91,7 +91,8 @@ $showActions=array(); foreach($allActions as $action){ if(array_search($action,$selectedActions)!==false){ $showActions[$action]='checked="checked"'; - }else{ + } + else{ $showActions[$action]=''; } } From e8e483d07943e7c4874ee6147e3910ee868ed14d Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Sun, 19 Jun 2011 18:53:02 +0200 Subject: [PATCH 035/111] L10N is here ;-) --- .gitignore | 6 ++++ docs/createtranslation.pl | 28 ++++++++++++++++ l10n/l10n-de.php | 5 +++ lib/l10n.php | 17 ++++++---- log/l10n/de.php | 14 ++++++++ log/l10n/de.po | 68 +++++++++++++++++++++++++++++++++++++++ log/l10n/log | 3 ++ log/l10n/messages.pot | 66 +++++++++++++++++++++++++++++++++++++ log/l10n/xgettextfiles | 1 + log/templates/index.php | 26 +++++++-------- 10 files changed, 214 insertions(+), 20 deletions(-) create mode 100644 docs/createtranslation.pl create mode 100644 l10n/l10n-de.php create mode 100644 log/l10n/de.php create mode 100644 log/l10n/de.po create mode 100644 log/l10n/log create mode 100644 log/l10n/messages.pot create mode 100644 log/l10n/xgettextfiles diff --git a/.gitignore b/.gitignore index 9cfb7a5861..6a1ffc21ca 100644 --- a/.gitignore +++ b/.gitignore @@ -16,5 +16,11 @@ _darcs/* CVS/* .svn/* RCS/* + +# kdevelop .kdev *.kdev4 + +# Lokalize +*lokalize* + diff --git a/docs/createtranslation.pl b/docs/createtranslation.pl new file mode 100644 index 0000000000..4c1c7c38d7 --- /dev/null +++ b/docs/createtranslation.pl @@ -0,0 +1,28 @@ +#!/usr/bin/perl +use strict; +use Locale::PO; +use Data::Dumper; + +opendir( DIR, '.' ); +my @files = readdir( DIR ); +closedir( DIR ); + +foreach my $i ( @files ){ + next unless $i =~ m/^(.*)\.po$/; + my $lang = $1; + my $hash = Locale::PO->load_file_ashash( $i ); + + # Create array + my @strings = (); + foreach my $key ( keys( %{$hash} )){ + next if $key eq '""'; + push( @strings, $hash->{$key}->msgid()." => ".$hash->{$key}->msgstr()); + } + + # Write PHP file + open( OUT, ">$lang.php" ); + print OUT " 'd.m.Y', + 'datetime' => 'd.m.Y H:i:s', + 'time' => 'H:i:s' ); diff --git a/lib/l10n.php b/lib/l10n.php index e800941e3d..4eae109cb5 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -57,32 +57,33 @@ class OC_L10N{ * language. */ public function __construct( $app, $lang = null ){ + global $SERVERROOT; // Find the right language if( is_null( $lang )){ - self::findLanguage( $app ); + $lang = self::findLanguage( $app ); } // Use cache if possible if(array_key_exists($app.'::'.$lang, self::$cache )){ + $this->translations = self::$cache[$app.'::'.$lang]['t']; $this->localizations = self::$cache[$app.'::'.$lang]['l']; } else{ $i18ndir = self::findI18nDir( $app ); - // Localization is in /l10n, Texts are in $i18ndir // (Just no need to define date/time format etc. twice) - if( file_exists( $i18ndir.$lang.'php' )){ + if( file_exists( $i18ndir.$lang.'.php' )){ // Include the file, save the data from $CONFIG - include( $i18ndir.$lang.'php' ); + include( $i18ndir.$lang.'.php' ); if( isset( $TRANSLATIONS ) && is_array( $TRANSLATIONS )){ $this->translations = $TRANSLATIONS; } } - if( file_exists( '/l10n/l10n-'.$lang.'php' )){ + if( file_exists( $SERVERROOT.'/l10n/l10n-'.$lang.'.php' )){ // Include the file, save the data from $CONFIG - include( $SERVERROOT.'/l10n/l10n-'.$lang.'php' ); + include( $SERVERROOT.'/l10n/l10n-'.$lang.'.php' ); if( isset( $LOCALIZATIONS ) && is_array( $LOCALIZATIONS )){ $this->localizations = array_merge( $this->localizations, $LOCALIZATIONS ); } @@ -133,12 +134,15 @@ class OC_L10N{ public function l($type, $data){ switch($type){ case 'date': + if( is_string( $data )) $data = strtotime( $data ); return date( $this->localizations['date'], $data ); break; case 'datetime': + if( is_string( $data )) $data = strtotime( $data ); return date( $this->localizations['datetime'], $data ); break; case 'time': + if( is_string( $data )) $data = strtotime( $data ); return date( $this->localizations['time'], $data ); break; default: @@ -209,7 +213,6 @@ class OC_L10N{ $accepted_languages = preg_split( '/,\s*/', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ); foreach( $accepted_languages as $i ){ $temp = explode( ';', $i ); - $temp = explode( '-', $temp[0] ); if( array_key_exists( $temp[0], $available )){ return $temp[0]; } diff --git a/log/l10n/de.php b/log/l10n/de.php new file mode 100644 index 0000000000..5cfc3486af --- /dev/null +++ b/log/l10n/de.php @@ -0,0 +1,14 @@ + "Zeige", +"Uploads" => "Uploads", +"Filter:" => "Filter:", +"Logouts" => "Abmeldungen", +"Logins" => "Anmeldungen", +"When" => "Wann", +"Downloads" => "Downloads", +"Clear log entries before" => "Lösche Einträge vor dem", +"What" => "Was", +"entries per page." => "Einträge pro Seite", +"Creations" => "Erstellungen", +"Deletions" => "Löschungen" +); diff --git a/log/l10n/de.po b/log/l10n/de.po new file mode 100644 index 0000000000..a901754f1a --- /dev/null +++ b/log/l10n/de.po @@ -0,0 +1,68 @@ +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Jakob Sack , 2011. +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-19 16:44+0200\n" +"PO-Revision-Date: 2011-06-19 16:54+0200\n" +"Last-Translator: Jakob Sack \n" +"Language-Team: German \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.2\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" + +#: ../templates/index.php:4 +msgid "Filter:" +msgstr "Filter:" + +#: ../templates/index.php:7 +msgid "Logins" +msgstr "Anmeldungen" + +#: ../templates/index.php:8 +msgid "Logouts" +msgstr "Abmeldungen" + +#: ../templates/index.php:9 +msgid "Downloads" +msgstr "Downloads" + +#: ../templates/index.php:10 +msgid "Uploads" +msgstr "Uploads" + +#: ../templates/index.php:11 +msgid "Creations" +msgstr "Erstellungen" + +#: ../templates/index.php:12 +msgid "Deletions" +msgstr "Löschungen" + +#: ../templates/index.php:15 +msgid "Show:" +msgstr "Zeige" + +#: ../templates/index.php:16 +msgid "entries per page." +msgstr "Einträge pro Seite" + +#: ../templates/index.php:26 +msgid "What" +msgstr "Was" + +#: ../templates/index.php:27 +msgid "When" +msgstr "Wann" + +#: ../templates/index.php:45 +msgid "Clear log entries before" +msgstr "Lösche Einträge vor dem" + + diff --git a/log/l10n/log b/log/l10n/log new file mode 100644 index 0000000000..e5e074bf9a --- /dev/null +++ b/log/l10n/log @@ -0,0 +1,3 @@ +[General] +LangCode=de +TargetLangCode=de diff --git a/log/l10n/messages.pot b/log/l10n/messages.pot new file mode 100644 index 0000000000..2da2355a3a --- /dev/null +++ b/log/l10n/messages.pot @@ -0,0 +1,66 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-19 16:53+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../templates/index.php:4 +msgid "Filter:" +msgstr "" + +#: ../templates/index.php:7 +msgid "Logins" +msgstr "" + +#: ../templates/index.php:8 +msgid "Logouts" +msgstr "" + +#: ../templates/index.php:9 +msgid "Downloads" +msgstr "" + +#: ../templates/index.php:10 +msgid "Uploads" +msgstr "" + +#: ../templates/index.php:11 +msgid "Creations" +msgstr "" + +#: ../templates/index.php:12 +msgid "Deletions" +msgstr "" + +#: ../templates/index.php:15 +msgid "Show:" +msgstr "" + +#: ../templates/index.php:16 +msgid "entries per page." +msgstr "" + +#: ../templates/index.php:26 +msgid "What" +msgstr "" + +#: ../templates/index.php:27 +msgid "When" +msgstr "" + +#: ../templates/index.php:45 +msgid "Clear log entries before" +msgstr "" diff --git a/log/l10n/xgettextfiles b/log/l10n/xgettextfiles new file mode 100644 index 0000000000..a24bcc89a8 --- /dev/null +++ b/log/l10n/xgettextfiles @@ -0,0 +1 @@ +../templates/index.php diff --git a/log/templates/index.php b/log/templates/index.php index 5f398b1dbc..2756332f51 100644 --- a/log/templates/index.php +++ b/log/templates/index.php @@ -1,19 +1,19 @@

    - Filter : + t( 'Filter:' ); ?> - name="login" id="logins" /> - name="logout" id="logouts" /> - name="read" id="downloads" /> - name="write" id="uploads" /> - name="create" id="creations" /> - name="delete" id="deletions" /> + name="login" id="logins" /> + name="logout" id="logouts" /> + name="read" id="downloads" /> + name="write" id="uploads" /> + name="create" id="creations" /> + name="delete" id="deletions" />

    - Show : -  entries per page. + t( 'Show:' ); ?> +  t( 'entries per page.' ); ?>

    @@ -23,15 +23,15 @@ - - + + - + @@ -42,7 +42,7 @@

    - Clear log entries before + t( 'Clear log entries before' ); ?> From c26719a10de214a6ea1c352b13bdd52b34e5a070 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Sun, 19 Jun 2011 19:38:51 +0200 Subject: [PATCH 036/111] Fixed documentation of OC_L10N --- lib/l10n.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/l10n.php b/lib/l10n.php index 4eae109cb5..2f72b97117 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -121,18 +121,20 @@ class OC_L10N{ * - date * - Creates a date * - l10n-field: date - * - params: timestamp (int) + * - params: timestamp (int/string) * - datetime * - Creates date and time * - l10n-field: datetime - * - params: timestamp (int) + * - params: timestamp (int/string) * - time * - Creates a time * - l10n-field: time - * - params: timestamp (int) + * - params: timestamp (int/string) */ public function l($type, $data){ switch($type){ + // If you add something don't forget to add it to $localizations + // at the top of the page case 'date': if( is_string( $data )) $data = strtotime( $data ); return date( $this->localizations['date'], $data ); From 80257558af202cbfb242cd3ab8ef31511f52aa51 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Sun, 19 Jun 2011 22:15:38 +0200 Subject: [PATCH 037/111] admin templates are now translateable --- admin/templates/app.php | 6 +++--- admin/templates/app_noconn.php | 4 ++-- admin/templates/apps.php | 8 ++++---- admin/templates/system.php | 4 ++-- admin/templates/users.php | 28 ++++++++++++++-------------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/admin/templates/app.php b/admin/templates/app.php index 1ea31bdecd..c8989e323c 100644 --- a/admin/templates/app.php +++ b/admin/templates/app.php @@ -6,7 +6,7 @@ $app=$_['app']; ?>

    '.$app['typename'].''); ?>
    -
    +l('datetime', $app["changed"]); ?>
    WhatWhent( 'What' ); ?>t( 'When' ); ?>
    "> l('datetime', $entry["date"] ); ?>
    @@ -19,9 +19,9 @@ $app=$_['app']; - +

    - read more
    '); ?> + '.$l->t( 'read more' ).'
    '); ?>
    INSTALLt( 'INSTALL' ); ?>
    diff --git a/admin/templates/app_noconn.php b/admin/templates/app_noconn.php index 2ca3d15d44..70b7d9b311 100644 --- a/admin/templates/app_noconn.php +++ b/admin/templates/app_noconn.php @@ -3,5 +3,5 @@ * Template for Apps when can't connect to app store */ ?> -

    Apps Repository

    -

    Cannot connect to apps repository

    \ No newline at end of file +

    t( 'Apps Repository' ); ?>

    +

    t( 'Cannot connect to apps repository' ); ?>

    diff --git a/admin/templates/apps.php b/admin/templates/apps.php index 36a7cd5302..593aad6318 100644 --- a/admin/templates/apps.php +++ b/admin/templates/apps.php @@ -3,15 +3,15 @@ * Template for Apps */ ?> -

    Apps Repository

    +

    t( 'Apps Repository' ); ?>

    - - + + @@ -19,7 +19,7 @@ - + diff --git a/admin/templates/system.php b/admin/templates/system.php index 4087b40a48..92ff9c836a 100644 --- a/admin/templates/system.php +++ b/admin/templates/system.php @@ -3,6 +3,6 @@ * Template for admin pages */ ?> -

    Administration

    -

    System Settings

    +

    t( 'Administration' ); ?>

    +

    t( 'System Settings' ); ?>

    #TBD \ No newline at end of file diff --git a/admin/templates/users.php b/admin/templates/users.php index 235df5bf82..c6ee57a61d 100644 --- a/admin/templates/users.php +++ b/admin/templates/users.php @@ -3,22 +3,22 @@
    NameModifiedt( 'Name' ); ?>t( 'Modified' ); ?>
    "") { echo(''); } ?> " title="">
    '.$app['typename'].''); ?>
    l('datetime', $app["changed"]); ?>
    - + - + @@ -37,17 +37,17 @@ "> - +
    Namet( 'Name' ); ?> Groups
       
    removet( 'remove' ); ?>
    -

    Groups

    +

    t( 'Groups' ); ?>

    - + @@ -55,7 +55,7 @@ - + @@ -65,7 +65,7 @@ diff --git a/templates/part.searchbox.php b/templates/part.searchbox.php index 910af81ebb..7465a7326e 100644 --- a/templates/part.searchbox.php +++ b/templates/part.searchbox.php @@ -1,4 +1,4 @@ ' method='post'> '/> - + ' class='prettybutton'/> \ No newline at end of file From 99ae7cd47777f7d7176194d4caced9036fcb1f46 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Sun, 19 Jun 2011 23:46:59 +0200 Subject: [PATCH 045/111] Autodetection of language is working now --- lib/l10n.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/l10n.php b/lib/l10n.php index 8a7ff9d853..f760d78c72 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -224,7 +224,7 @@ class OC_L10N{ $accepted_languages = preg_split( '/,\s*/', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ); foreach( $accepted_languages as $i ){ $temp = explode( ';', $i ); - if( array_key_exists( $temp[0], $available )){ + if( array_search( $temp[0], $available ) !== false ){ return $temp[0]; } } From a7b7f5a76ce7fe3fb371f008d5de9c749ac5c1c1 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Mon, 20 Jun 2011 00:17:49 +0200 Subject: [PATCH 046/111] app files_publiclink is now translateable --- apps/files_publiclink/templates/admin.php | 10 +++++----- apps/files_publiclink/templates/index.php | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/files_publiclink/templates/admin.php b/apps/files_publiclink/templates/admin.php index 2483eef321..95b99109f2 100644 --- a/apps/files_publiclink/templates/admin.php +++ b/apps/files_publiclink/templates/admin.php @@ -2,18 +2,18 @@
    Namet( 'Name' ); ?>
    - remove + t( 'remove' ); ?>   @@ -91,22 +91,22 @@
    - Do you really want to delete user $user? + t( 'Do you really want to delete user' ); ?> $user?
    - Do you really want to delete group $group? + t( 'Do you really want to delete group' ); ?> $group?
    From 07f2fcf7ec249d45dfe1a4e38439d1e756a0bc86 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 19 Jun 2011 22:23:05 +0200 Subject: [PATCH 038/111] add post_* hooks to filesystem for write, create, delete, rename and copy --- lib/filesystem.php | 103 +++++++++++++++++++++++++++++++++------------ 1 file changed, 76 insertions(+), 27 deletions(-) diff --git a/lib/filesystem.php b/lib/filesystem.php index 0faa740470..e6b1638d8d 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -30,10 +30,15 @@ * Hooks provided: * read(path) * write(path, &run) + * post_write(path) * create(path, &run) (when a file is created, both create and write will be emited in that order) + * post_create(path) * delete(path, &run) + * post_delete(path) * rename(oldpath,newpath, &run) + * post_rename(oldpath,newpath) * copy(oldpath,newpath, &run) (if the newpath doesn't exists yes, copy, create and write will be emited in that order) + * post_rename(oldpath,newpath) * * the &run parameter can be set to false to prevent the operation from occuring */ @@ -231,7 +236,10 @@ class OC_FILESYSTEM{ OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path, 'run' => &$run)); } if($run){ - return $storage->mkdir(self::getInternalPath($path)); + $result=$storage->mkdir(self::getInternalPath($path)); + OC_HOOK::emit( 'OC_FILESYSTEM', 'post_create', array( 'path' => $path)); + OC_HOOK::emit( 'OC_FILESYSTEM', 'post_write', array( 'path' => $path)); + return $result; } } } @@ -240,7 +248,9 @@ class OC_FILESYSTEM{ $run=true; OC_HOOK::emit( 'OC_FILESYSTEM', 'delete', array( 'path' => $path, 'run' => &$run)); if($run){ - return $storage->rmdir(self::getInternalPath($path)); + $result=$storage->rmdir(self::getInternalPath($path)); + OC_HOOK::emit( 'OC_FILESYSTEM', 'post_delete', array( 'path' => $path)); + return $result; } } } @@ -332,14 +342,20 @@ class OC_FILESYSTEM{ static public function file_put_contents($path,$data){ if(self::canWrite($path) and $storage=self::getStorage($path)){ $run=true; - if(!self::file_exists($path)){ + $exists=self::file_exists($path); + if(!$exists){ OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path, 'run' => &$run)); } if($run){ OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path, 'run' => &$run)); } if($run){ - return $storage->file_put_contents(self::getInternalPath($path),$data); + $result=$storage->file_put_contents(self::getInternalPath($path),$data); + if(!$exists){ + OC_HOOK::emit( 'OC_FILESYSTEM', 'post_create', array( 'path' => $path)); + } + OC_HOOK::emit( 'OC_FILESYSTEM', 'post_write', array( 'path' => $path)); + return $result; } } } @@ -348,7 +364,9 @@ class OC_FILESYSTEM{ $run=true; OC_HOOK::emit( 'OC_FILESYSTEM', 'delete', array( 'path' => $path, 'run' => &$run)); if($run){ - return $storage->unlink(self::getInternalPath($path)); + $result=$storage->unlink(self::getInternalPath($path)); + OC_HOOK::emit( 'OC_FILESYSTEM', 'post_delete', array( 'path' => $path)); + return $result; } } } @@ -361,14 +379,15 @@ class OC_FILESYSTEM{ $mp2=self::getMountPoint($path2); if($mp1==$mp2){ if($storage=self::getStorage($path1)){ - return $storage->rename(self::getInternalPath($path1),self::getInternalPath($path2)); + $result=$storage->rename(self::getInternalPath($path1),self::getInternalPath($path2)); } }elseif($storage1=self::getStorage($path1) and $storage2=self::getStorage($path2)){ $tmpFile=$storage1->toTmpFile(self::getInternalPath($path1)); $result=$storage2->fromTmpFile(self::getInternalPath($path2)); $storage1->unlink(self::getInternalPath($path1)); - return $result; } + OC_HOOK::emit( 'OC_FILESYSTEM', 'post_rename', array( 'oldpath' => $path1, 'newpath'=>$path2)); + return $result; } } } @@ -376,7 +395,8 @@ class OC_FILESYSTEM{ if(self::canRead($path1) and self::canWrite($path2)){ $run=true; OC_HOOK::emit( 'OC_FILESYSTEM', 'copy', array( 'oldpath' => $path1 ,'newpath'=>$path2, 'run' => &$run)); - if($run and !self::file_exists($path2)){ + $exists=self::file_exists($path2); + if($run and !$exists){ OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path2, 'run' => &$run)); } if($run){ @@ -387,12 +407,18 @@ class OC_FILESYSTEM{ $mp2=self::getMountPoint($path2); if($mp1==$mp2){ if($storage=self::getStorage($path1)){ - return $storage->copy(self::getInternalPath($path1),self::getInternalPath($path2)); + $result=$storage->copy(self::getInternalPath($path1),self::getInternalPath($path2)); } }elseif($storage1=self::getStorage($path1) and $storage2=self::getStorage($path2)){ $tmpFile=$storage1->toTmpFile(self::getInternalPath($path1)); - return $storage2->fromTmpFile(self::getInternalPath($path2)); + $result=$storage2->fromTmpFile(self::getInternalPath($path2)); } + OC_HOOK::emit( 'OC_FILESYSTEM', 'post_copy', array( 'oldpath' => $path1 ,'newpath'=>$path2)); + if(!$exists){ + OC_HOOK::emit( 'OC_FILESYSTEM', 'post_create', array( 'path' => $path)); + } + OC_HOOK::emit( 'OC_FILESYSTEM', 'post_write', array( 'path' => $path)); + return $result; } } } @@ -401,6 +427,8 @@ class OC_FILESYSTEM{ if($allowed){ if($storage=self::getStorage($path)){ $run=true; + $exists=self::file_exists($path); + $write=false; switch($mode){ case 'r': OC_HOOK::emit( 'OC_FILESYSTEM', 'read', array( 'path' => $path)); @@ -410,26 +438,33 @@ class OC_FILESYSTEM{ case 'x+': case 'a+': OC_HOOK::emit( 'OC_FILESYSTEM', 'read', array( 'path' => $path)); - if(!self::file_exists($path)){ - OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path)); - } - if($run){ - OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path, 'run' => &$run)); - } + $write=true; break; case 'w': case 'x': case 'a': - if(!self::file_exists($path)){ - OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path)); - } - if($run){ - OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path, 'run' => &$run)); - } + $write=true; break; } + if($write){ + if(!$exists){ + OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path)); + } + if($run){ + OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path, 'run' => &$run)); + } + } if($run){ - return $storage->fopen(self::getInternalPath($path),$mode); + $result=$storage->fopen(self::getInternalPath($path),$mode); + if($write){ + if(!$exists){ + OC_HOOK::emit( 'OC_FILESYSTEM', 'post_create', array( 'path' => $path)); + } + if($run){ + OC_HOOK::emit( 'OC_FILESYSTEM', 'post_write', array( 'path' => $path)); + } + } + return $result; } } } @@ -443,28 +478,42 @@ class OC_FILESYSTEM{ static public function fromTmpFile($tmpFile,$path){ if(self::canWrite($path) and $storage=self::getStorage($path)){ $run=true; - if(!self::file_exists($path)){ + $exists=self::file_exists($path); + if(!$exists){ OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path, 'run' => &$run)); } if($run){ OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path, 'run' => &$run)); } if($run){ - return $storage->fromTmpFile($tmpFile,self::getInternalPath($path)); + $result=$storage->fromTmpFile($tmpFile,self::getInternalPath($path)); + if(!$exists){ + OC_HOOK::emit( 'OC_FILESYSTEM', 'post_create', array( 'path' => $path)); + } + OC_HOOK::emit( 'OC_FILESYSTEM', 'post_write', array( 'path' => $path)); + return $result; } } } static public function fromUploadedFile($tmpFile,$path){ + error_log('upload'); if(self::canWrite($path) and $storage=self::getStorage($path)){ $run=true; - if($run and !self::file_exists($path)){ + $exists=self::file_exists($path); + if(!$exists){ OC_HOOK::emit( 'OC_FILESYSTEM', 'create', array( 'path' => $path, 'run' => &$run)); } if($run){ OC_HOOK::emit( 'OC_FILESYSTEM', 'write', array( 'path' => $path, 'run' => &$run)); } + error_log('upload2'); if($run){ - return $storage->fromUploadedFile($tmpFile,self::getInternalPath($path)); + $result=$storage->fromUploadedFile($tmpFile,self::getInternalPath($path)); + if(!$exists){ + OC_HOOK::emit( 'OC_FILESYSTEM', 'post_create', array( 'path' => $path)); + } + OC_HOOK::emit( 'OC_FILESYSTEM', 'post_write', array( 'path' => $path)); + return $result; } } } From 11dc3bb0e15753e54ceca74300963202b397092b Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 19 Jun 2011 22:30:47 +0200 Subject: [PATCH 039/111] only load apps if they exist --- lib/app.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/app.php b/lib/app.php index c2a850b6f6..544c57c1d6 100644 --- a/lib/app.php +++ b/lib/app.php @@ -60,7 +60,9 @@ class OC_APP{ $apps = OC_APPCONFIG::getApps(); foreach( $apps as $app ){ if( self::isEnabled( $app )){ - require( "apps/$app/appinfo/app.php" ); + if(is_file($SERVERROOT."/apps/$app/appinfo/app.php")){ + require( "apps/$app/appinfo/app.php" ); + } } } From 37f9e037725de58bd9b611fff759f7d12cc6ee5a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 19 Jun 2011 22:34:04 +0200 Subject: [PATCH 040/111] improved check in oc_preferences if a key already exists --- lib/preferences.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/preferences.php b/lib/preferences.php index 5a9ed39508..0f4636f683 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -139,10 +139,12 @@ class OC_PREFERENCES{ */ public static function setValue( $user, $app, $key, $value ){ // Check if the key does exist - $exists = self::getValue( $user, $app, $key, null ); + $query = OC_DB::prepare( 'SELECT configvalue FROM *PREFIX*preferences WHERE userid = ? AND appid = ? AND configkey = ?' ); + $values=$query->execute(array($user,$app,$key))->fetchAll(); + error_log(print_r($values,true)); + $exists=(count($values)>0); - // null: does not exist. Insert. - if( is_null( $exists )){ + if( !$exists ){ $query = OC_DB::prepare( 'INSERT INTO *PREFIX*preferences ( userid, appid, configkey, configvalue ) VALUES( ?, ?, ?, ? )' ); $query->execute( array( $user, $app, $key, $value )); } From ee247a21a49c801a4bf96b42a2d6ea28c9446ee6 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Sun, 19 Jun 2011 22:42:33 +0200 Subject: [PATCH 041/111] shipped apps are no longer hardcoded --- lib/installer.php | 18 +++++++++--------- lib/setup.php | 46 ++++++++++++++++++++++++++++++---------------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/lib/installer.php b/lib/installer.php index 02b71027cd..91b7ea7da6 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -108,7 +108,7 @@ class OC_INSTALLER{ $basedir=$SERVERROOT.'/apps/'.$info['id']; //check if an app with the same id is already installed - if(self::isInstalled( $info['id'] ))){ + if(self::isInstalled( $info['id'] )){ error_log("App already installed"); OC_HELPER::rmdirr($extractDir); if($data['source']=='http'){ @@ -118,14 +118,14 @@ class OC_INSTALLER{ } //check if the destination directory already exists -+ if(is_dir($basedir)){ -+ error_log("App's directory already exists"); -+ OC_HELPER::rmdirr($extractDir); -+ if($data['source']=='http'){ -+ unlink($path); -+ } -+ return false; -+ } + if(is_dir($basedir)){ + error_log("App's directory already exists"); + OC_HELPER::rmdirr($extractDir); + if($data['source']=='http'){ + unlink($path); + } + return false; + } if(isset($data['pretent']) and $data['pretent']==true){ return false; diff --git a/lib/setup.php b/lib/setup.php index 43ead7b96a..0e324b741a 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -1,5 +1,7 @@ From 51c0a8e3ced84eeb4465d5f81571b448f231a4a5 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Sun, 19 Jun 2011 23:10:59 +0200 Subject: [PATCH 042/111] index now properly reloaded after setup --- lib/setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/setup.php b/lib/setup.php index 0e324b741a..f64842a904 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -23,7 +23,7 @@ if(isset($_POST['install']) AND $_POST['install']=='true') { OC_TEMPLATE::printGuestPage("", "installation", $options); } else { - header("Location: $WEBROOT"); + header("Location: $SUBURI"); exit(); } } From 38545d5ee467016b8b1ea28faead546179889f09 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Sun, 19 Jun 2011 23:29:09 +0200 Subject: [PATCH 043/111] and even more properly now ;P --- lib/setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/setup.php b/lib/setup.php index f64842a904..5905261f18 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -23,7 +23,7 @@ if(isset($_POST['install']) AND $_POST['install']=='true') { OC_TEMPLATE::printGuestPage("", "installation", $options); } else { - header("Location: $SUBURI"); + header("Location: $WEBROOT$SUBURI"); exit(); } } From b31a8ac985c829fde5e7baa90efd21eeb27fb08c Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Sun, 19 Jun 2011 23:33:34 +0200 Subject: [PATCH 044/111] More l10n-stuff --- admin/l10n/messages.pot | 91 ++++++++++++++++++++++++++ admin/l10n/xgettextfiles | 5 ++ docs/createtranslation.pl | 1 + docs/getstrings.pl | 18 ++++++ index.php | 2 + js/js.js | 45 ++++++------- js/setup.js | 26 ++++++++ l10n/de.php | 11 ++++ l10n/de.po | 120 +++++++++++++++++++++++++++++++++++ l10n/javascript.php | 34 ++++++++++ l10n/messages.pot | 120 +++++++++++++++++++++++++++++++++++ l10n/xgettextfiles | 7 ++ lib/l10n.php | 20 ++++-- log/l10n/da.php | 14 ++++ log/l10n/da.po | 67 +++++++++++++++++++ log/l10n/log | 1 + templates/404.php | 2 +- templates/installation.php | 36 +++++------ templates/layout.admin.php | 3 + templates/layout.guest.php | 5 +- templates/layout.user.php | 3 + templates/login.php | 2 +- templates/logout.php | 2 +- templates/part.pagenavi.php | 4 +- templates/part.searchbox.php | 2 +- 25 files changed, 585 insertions(+), 56 deletions(-) create mode 100644 admin/l10n/messages.pot create mode 100644 admin/l10n/xgettextfiles create mode 100644 docs/getstrings.pl create mode 100644 js/setup.js create mode 100644 l10n/de.php create mode 100644 l10n/de.po create mode 100644 l10n/javascript.php create mode 100644 l10n/messages.pot create mode 100644 l10n/xgettextfiles create mode 100644 log/l10n/da.php create mode 100644 log/l10n/da.po diff --git a/admin/l10n/messages.pot b/admin/l10n/messages.pot new file mode 100644 index 0000000000..c30a445431 --- /dev/null +++ b/admin/l10n/messages.pot @@ -0,0 +1,91 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-19 23:32+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../templates/app.php:22 +msgid "read more" +msgstr "" + +#: ../templates/app.php:24 +msgid "INSTALL" +msgstr "" + +#: ../templates/app_noconn.php:6 ../templates/apps.php:6 +msgid "Apps Repository" +msgstr "" + +#: ../templates/app_noconn.php:7 +msgid "Cannot connect to apps repository" +msgstr "" + +#: ../templates/apps.php:13 ../templates/users.php:6 ../templates/users.php:20 +#: ../templates/users.php:50 +msgid "Name" +msgstr "" + +#: ../templates/apps.php:14 +msgid "Modified" +msgstr "" + +#: ../templates/system.php:6 +msgid "Administration" +msgstr "" + +#: ../templates/system.php:7 +msgid "System Settings" +msgstr "" + +#: ../templates/users.php:13 +msgid "Add user" +msgstr "" + +#: ../templates/users.php:21 +msgid "Password" +msgstr "" + +#: ../templates/users.php:30 +msgid "Create user" +msgstr "" + +#: ../templates/users.php:40 ../templates/users.php:68 +msgid "remove" +msgstr "" + +#: ../templates/users.php:46 +msgid "Groups" +msgstr "" + +#: ../templates/users.php:58 +msgid "Create group" +msgstr "" + +#: ../templates/users.php:94 +msgid "Force new password:" +msgstr "" + +#: ../templates/users.php:96 +msgid "Set" +msgstr "" + +#: ../templates/users.php:102 +msgid "Do you really want to delete user" +msgstr "" + +#: ../templates/users.php:109 +msgid "Do you really want to delete group" +msgstr "" diff --git a/admin/l10n/xgettextfiles b/admin/l10n/xgettextfiles new file mode 100644 index 0000000000..37acbc25de --- /dev/null +++ b/admin/l10n/xgettextfiles @@ -0,0 +1,5 @@ +../templates/app.php +../templates/app_noconn.php +../templates/apps.php +../templates/system.php +../templates/users.php diff --git a/docs/createtranslation.pl b/docs/createtranslation.pl index 4c1c7c38d7..12ba22a5ea 100644 --- a/docs/createtranslation.pl +++ b/docs/createtranslation.pl @@ -16,6 +16,7 @@ foreach my $i ( @files ){ my @strings = (); foreach my $key ( keys( %{$hash} )){ next if $key eq '""'; + next if $hash->{$key}->msgstr() eq '""'; push( @strings, $hash->{$key}->msgid()." => ".$hash->{$key}->msgstr()); } diff --git a/docs/getstrings.pl b/docs/getstrings.pl new file mode 100644 index 0000000000..0325438b55 --- /dev/null +++ b/docs/getstrings.pl @@ -0,0 +1,18 @@ +#!/usr/bin/perl +use strict; + +if( -e 'messages.pot' ){ + `xgettext --files-from=xgettextfiles --join-existing --output=messages.pot --keyword=t` +} +else{ + `xgettext --files-from=xgettextfiles --output=messages.pot --keyword=t` +} + +opendir( DIR, '.' ); +my @files = readdir( DIR ); +closedir( DIR ); + +foreach my $i ( @files ){ + next unless $i =~ m/^(.*)\.po$/; + `xgettext --files-from=xgettextfiles --join-existing --output=$i --keyword=t` +} diff --git a/index.php b/index.php index f4d6f27a3c..5aaa8fb89c 100644 --- a/index.php +++ b/index.php @@ -27,6 +27,8 @@ require_once(dirname(__FILE__).'/lib/base.php'); require_once('appconfig.php'); require_once('template.php'); +OC_UTIL::addScript('setup'); + $not_installed = !OC_CONFIG::getValue('installed', false); $install_called = (isset($_POST['install']) AND $_POST['install']=='true'); diff --git a/js/js.js b/js/js.js index a6765ec62d..7e44b7ce6d 100644 --- a/js/js.js +++ b/js/js.js @@ -1,26 +1,23 @@ -$(document).ready(function() { - // Hide the MySQL config div if needed : - if(!$('#mysql').is(':checked') && $('#hasSQLite').val()=='true') { - $('#use_mysql').hide(); - } - - $('#datadirField').hide(250); - if($('#hasSQLite').val()=='true'){ - $('#databaseField').hide(250); - } - - $('#sqlite').click(function() { - $('#use_mysql').slideUp(250); - }); - - $('#mysql').click(function() { - $('#use_mysql').slideDown(250); - }); - - $('#showAdvanced').click(function() { - $('#datadirField').slideToggle(250); - if($('#hasSQLite').val()=='true'){ - $('#databaseField').slideToggle(250); +var _l10ncache = {}; +function t(app,text){ + if( !( app in _l10ncache )){ + $.post( oc_webroot+'/l10n/javascript.php', {'app': app}, function(jsondata){ + _l10ncache[app] = jsondata.data; + }); + + // Bad answer ... + if( !( app in _l10ncache )){ + _l10ncache[app] = []; } - }); + } + if( typeof( _l10ncache[app][text] ) !== 'undefined' ){ + return _l10ncache[app][text]; + } + else{ + return text; + } +} + +$(document).ready(function(){ + // Put fancy stuff in here }); diff --git a/js/setup.js b/js/setup.js new file mode 100644 index 0000000000..b4616b8b14 --- /dev/null +++ b/js/setup.js @@ -0,0 +1,26 @@ +$(document).ready(function() { + // Hide the MySQL config div if needed : + if(!$('#mysql').is(':checked') && $('#hasSQLite').val()=='true') { + $('#use_mysql').hide(); + } + + $('#datadirField').hide(250); + if($('#hasSQLite').val()=='true'){ + $('#databaseField').hide(250); + } + + $('#sqlite').click(function() { + $('#use_mysql').slideUp(250); + }); + + $('#mysql').click(function() { + $('#use_mysql').slideDown(250); + }); + + $('#showAdvanced').click(function() { + $('#datadirField').slideToggle(250); + if($('#hasSQLite').val()=='true'){ + $('#databaseField').slideToggle(250); + } + }); +}); diff --git a/l10n/de.php b/l10n/de.php new file mode 100644 index 0000000000..fb00345e69 --- /dev/null +++ b/l10n/de.php @@ -0,0 +1,11 @@ + "Sie wurden abgemeldet.", +"Set where to store the data." => "Speicherort der Daten", +"Advanced" => "Erweitert", +"prev" => "zurück", +"Login:" => "Benutzername:", +"Login failed!" => "Anmeldung Fehlgeschlagen!", +"next" => "weiter", +"Password:" => "Passwort:", +"Search" => "Suchen" +); diff --git a/l10n/de.po b/l10n/de.po new file mode 100644 index 0000000000..19b12ca4aa --- /dev/null +++ b/l10n/de.po @@ -0,0 +1,120 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-19 23:27+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../templates/404.php:15 +msgid "Error 404, Cloud not found" +msgstr "" + +#: ../templates/installation.php:6 +msgid "Welcome to ownCloud, your personnal cloud." +msgstr "" + +#: ../templates/installation.php:7 +msgid "To finish the installation, please follow the steps below." +msgstr "" + +#: ../templates/installation.php:26 +msgid "Create an admin account." +msgstr "" + +#: ../templates/installation.php:27 +msgid "Login:" +msgstr "Benutzername:" + +#: ../templates/installation.php:28 +msgid "Password:" +msgstr "Passwort:" + +#: ../templates/installation.php:31 +msgid "Advanced" +msgstr "Erweitert" + +#: ../templates/installation.php:34 +msgid "Set where to store the data." +msgstr "Speicherort der Daten" + +#: ../templates/installation.php:35 +msgid "Data directory:" +msgstr "" + +#: ../templates/installation.php:39 +msgid "Configure your database." +msgstr "" + +#: ../templates/installation.php:43 +msgid "I will use a SQLite database. You have nothing to do!" +msgstr "" + +#: ../templates/installation.php:46 +msgid "SQLite" +msgstr "" + +#: ../templates/installation.php:53 +msgid "I will use a MySQL database." +msgstr "" + +#: ../templates/installation.php:59 +msgid "Host:" +msgstr "" + +#: ../templates/installation.php:60 +msgid "Database name:" +msgstr "" + +#: ../templates/installation.php:61 +msgid "Table prefix:" +msgstr "" + +#: ../templates/installation.php:62 +msgid "MySQL user login:" +msgstr "" + +#: ../templates/installation.php:63 +msgid "MySQL user password:" +msgstr "" + +#: ../templates/layout.guest.php:17 ../templates/layout.guest.php:20 +msgid "" +"ownCloud is a personal cloud which runs " +"on your own server.

    " +msgstr "" + +#: ../templates/login.php:6 +msgid "Login failed!" +msgstr "Anmeldung Fehlgeschlagen!" + +#: ../templates/logout.php:1 +msgid "You are logged out." +msgstr "Sie wurden abgemeldet." + +#: ../templates/part.pagenavi.php:6 +msgid "prev" +msgstr "zurück" + +#: ../templates/part.pagenavi.php:26 +msgid "next" +msgstr "weiter" + +#: ../templates/part.searchbox.php:3 +msgid "Search" +msgstr "Suchen" + +#: ../templates/installation.php:68 +msgid "Finish setup" +msgstr "" diff --git a/l10n/javascript.php b/l10n/javascript.php new file mode 100644 index 0000000000..a1e84487f6 --- /dev/null +++ b/l10n/javascript.php @@ -0,0 +1,34 @@ +. +* +*/ + +// Init owncloud +require_once('../lib/base.php'); + +$app = $_POST["app"]; + +// We send json data +header( "Content-Type: application/jsonrequest" ); +$l = new OC_L10N( $app ); + +echo json_encode( array( 'status' => 'success', 'data' => $l->getTranslations())); +?> diff --git a/l10n/messages.pot b/l10n/messages.pot new file mode 100644 index 0000000000..591a1c724e --- /dev/null +++ b/l10n/messages.pot @@ -0,0 +1,120 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-19 23:27+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../templates/404.php:15 +msgid "Error 404, Cloud not found" +msgstr "" + +#: ../templates/installation.php:6 +msgid "Welcome to ownCloud, your personnal cloud." +msgstr "" + +#: ../templates/installation.php:7 +msgid "To finish the installation, please follow the steps below." +msgstr "" + +#: ../templates/installation.php:26 +msgid "Create an admin account." +msgstr "" + +#: ../templates/installation.php:27 +msgid "Login:" +msgstr "" + +#: ../templates/installation.php:28 +msgid "Password:" +msgstr "" + +#: ../templates/installation.php:31 +msgid "Advanced" +msgstr "" + +#: ../templates/installation.php:34 +msgid "Set where to store the data." +msgstr "" + +#: ../templates/installation.php:35 +msgid "Data directory:" +msgstr "" + +#: ../templates/installation.php:39 +msgid "Configure your database." +msgstr "" + +#: ../templates/installation.php:43 +msgid "I will use a SQLite database. You have nothing to do!" +msgstr "" + +#: ../templates/installation.php:46 +msgid "SQLite" +msgstr "" + +#: ../templates/installation.php:53 +msgid "I will use a MySQL database." +msgstr "" + +#: ../templates/installation.php:59 +msgid "Host:" +msgstr "" + +#: ../templates/installation.php:60 +msgid "Database name:" +msgstr "" + +#: ../templates/installation.php:61 +msgid "Table prefix:" +msgstr "" + +#: ../templates/installation.php:62 +msgid "MySQL user login:" +msgstr "" + +#: ../templates/installation.php:63 +msgid "MySQL user password:" +msgstr "" + +#: ../templates/installation.php:68 +msgid "Finish setup" +msgstr "" + +#: ../templates/layout.guest.php:20 +msgid "" +"ownCloud is a personal cloud which runs " +"on your own server.

    " +msgstr "" + +#: ../templates/login.php:6 +msgid "Login failed!" +msgstr "" + +#: ../templates/logout.php:1 +msgid "You are logged out." +msgstr "" + +#: ../templates/part.pagenavi.php:6 +msgid "prev" +msgstr "" + +#: ../templates/part.pagenavi.php:26 +msgid "next" +msgstr "" + +#: ../templates/part.searchbox.php:3 +msgid "Search" +msgstr "" diff --git a/l10n/xgettextfiles b/l10n/xgettextfiles new file mode 100644 index 0000000000..b5d83a880d --- /dev/null +++ b/l10n/xgettextfiles @@ -0,0 +1,7 @@ +../templates/404.php +../templates/installation.php +../templates/layout.guest.php +../templates/login.php +../templates/logout.php +../templates/part.pagenavi.php +../templates/part.searchbox.php diff --git a/lib/l10n.php b/lib/l10n.php index 2f72b97117..8a7ff9d853 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -109,6 +109,16 @@ class OC_L10N{ return $text; } + /** + * @brief getTranslations + * @returns Fetch all translations + * + * Returns an associative array with all translations + */ + public function getTranslations(){ + return $this->translations; + } + /** * @brief Localization * @param $type Type of localization @@ -202,11 +212,10 @@ class OC_L10N{ closedir($dh); } } - if( isset($_SESSION['user_id']) && $_SESSION['user_id'] && OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang' )){ $lang = OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang' ); self::$language = $lang; - if( array_search( $lang, $available )){ + if( array_search( $lang, $available ) !== false ){ return $lang; } } @@ -226,12 +235,9 @@ class OC_L10N{ } /** - * @brief find the best language + * @brief find the l10n directory * @param $app App that needs to be translated - * @returns language - * - * Finds the best language. Depends on user settings and browser - * information + * @returns directory */ protected static function findI18nDir( $app ){ global $SERVERROOT; diff --git a/log/l10n/da.php b/log/l10n/da.php new file mode 100644 index 0000000000..8ab99277bf --- /dev/null +++ b/log/l10n/da.php @@ -0,0 +1,14 @@ + "Vis:", +"Uploads" => "Uploads", +"Filter:" => "Filter:", +"Logouts" => "Logouts", +"Logins" => "Logins", +"When" => "Hvornår", +"Downloads" => "Downloads", +"Clear log entries before" => "Slet log poster før", +"What" => "Hvilket", +"entries per page." => "poster pr side.", +"Creations" => "Oprettelser", +"Deletions" => "Sletninger" +); diff --git a/log/l10n/da.po b/log/l10n/da.po new file mode 100644 index 0000000000..5a88aedee9 --- /dev/null +++ b/log/l10n/da.po @@ -0,0 +1,67 @@ +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Mikkel Bjerg Larsen , 2011. +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-19 16:53+0200\n" +"PO-Revision-Date: 2011-06-19 21:09+0200\n" +"Last-Translator: Mikkel Bjerg Larsen \n" +"Language-Team: American English \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.2\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: ../templates/index.php:4 +msgid "Filter:" +msgstr "Filter:" + +#: ../templates/index.php:7 +msgid "Logins" +msgstr "Logins" + +#: ../templates/index.php:8 +msgid "Logouts" +msgstr "Logouts" + +#: ../templates/index.php:9 +msgid "Downloads" +msgstr "Downloads" + +#: ../templates/index.php:10 +msgid "Uploads" +msgstr "Uploads" + +#: ../templates/index.php:11 +msgid "Creations" +msgstr "Oprettelser" + +#: ../templates/index.php:12 +msgid "Deletions" +msgstr "Sletninger" + +#: ../templates/index.php:15 +msgid "Show:" +msgstr "Vis:" + +#: ../templates/index.php:16 +msgid "entries per page." +msgstr "poster pr side." + +#: ../templates/index.php:26 +msgid "What" +msgstr "Hvilket" + +#: ../templates/index.php:27 +msgid "When" +msgstr "Hvornår" + +#: ../templates/index.php:45 +msgid "Clear log entries before" +msgstr "Slet log poster før" + diff --git a/log/l10n/log b/log/l10n/log index e5e074bf9a..f70eb6af3f 100644 --- a/log/l10n/log +++ b/log/l10n/log @@ -1,3 +1,4 @@ [General] LangCode=de +ProjectID=oc_log TargetLangCode=de diff --git a/templates/404.php b/templates/404.php index 8909db29a4..b287571d16 100644 --- a/templates/404.php +++ b/templates/404.php @@ -12,7 +12,7 @@ if(!isset($_)){//also provide standalone error page " alt="ownCloud" />
    • - Error 404, Cloud not found
      + t( 'Error 404, Cloud not found' ); ?>

    diff --git a/templates/installation.php b/templates/installation.php index 880beb9a89..93c00547ab 100644 --- a/templates/installation.php +++ b/templates/installation.php @@ -3,8 +3,8 @@

    - Welcome to ownCloud, your personnal cloud.
    - To finish the installation, please follow the steps below. + t( 'Welcome to ownCloud, your personnal cloud.' ); ?>
    + t( 'To finish the installation, please follow the steps below.' ); ?>

    0): ?> @@ -23,48 +23,48 @@
    - Create an admin account. -

    -

    + t( 'Create an admin account.' ); ?> +

    +

    - Advanced '> + t( 'Advanced' ); ?> '>
    - Set where to store the data. -

    + t( 'Set where to store the data.' ); ?> +

    - Configure your database. + t( 'Configure your database.' ); ?> -

    I will use a SQLite database. You have nothing to do !

    +

    t( 'I will use a SQLite database. You have nothing to do!' ); ?>

    -

    />

    +

    />

    -

    I will use a MySQL database.

    +

    t( 'I will use a MySQL database.' ); ?>

    />

    -

    -

    -

    -

    -

    +

    +

    +

    +

    +

    -

    +

    diff --git a/templates/layout.admin.php b/templates/layout.admin.php index 36b824639d..66fb3ccc60 100644 --- a/templates/layout.admin.php +++ b/templates/layout.admin.php @@ -7,6 +7,9 @@ + diff --git a/templates/layout.guest.php b/templates/layout.guest.php index c957553082..ce99b00b9f 100644 --- a/templates/layout.guest.php +++ b/templates/layout.guest.php @@ -7,6 +7,9 @@ + @@ -14,6 +17,6 @@ -

    ownCloud is a personal cloud which runs on your own server.

    +

    t( 'ownCloud is a personal cloud which runs on your own server.

    ' ); ?> diff --git a/templates/layout.user.php b/templates/layout.user.php index da30df294f..f21db202a8 100644 --- a/templates/layout.user.php +++ b/templates/layout.user.php @@ -7,6 +7,9 @@ + diff --git a/templates/login.php b/templates/login.php index 845ae831a4..e0f6ce23e2 100644 --- a/templates/login.php +++ b/templates/login.php @@ -3,7 +3,7 @@
    - Login failed! + t( 'Login failed!' ); ?> diff --git a/templates/logout.php b/templates/logout.php index 4a15998a5c..8cbbdd9cc8 100644 --- a/templates/logout.php +++ b/templates/logout.php @@ -1 +1 @@ -You are logged out. +t( 'You are logged out.' ); ?> \ No newline at end of file diff --git a/templates/part.pagenavi.php b/templates/part.pagenavi.php index d48d0cada3..0602b79388 100644 --- a/templates/part.pagenavi.php +++ b/templates/part.pagenavi.php @@ -3,7 +3,7 @@
    0):?> - prev   + t( 'prev' ); ?>   @@ -23,7 +23,7 @@ - next + t( 'next' ); ?>
    - - - + + + '> - + - + diff --git a/apps/files_publiclink/templates/index.php b/apps/files_publiclink/templates/index.php index 9e23845260..759f3ad877 100644 --- a/apps/files_publiclink/templates/index.php +++ b/apps/files_publiclink/templates/index.php @@ -5,9 +5,9 @@ - - - + + + From 76b12c4ae0ea9941b030f0a13786d0ac3fc32f76 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 20 Jun 2011 14:33:02 +0200 Subject: [PATCH 047/111] add settings option for language --- lib/l10n.php | 37 +++++++++++++++++---------- settings/ajax/setlanguage.php | 24 ++++++++++++++++++ settings/index.php | 7 +++++ settings/js/main.js | 14 ++++++++++ settings/templates/index.php | 48 ++++++++++++++++++++++------------- 5 files changed, 99 insertions(+), 31 deletions(-) create mode 100644 settings/ajax/setlanguage.php diff --git a/lib/l10n.php b/lib/l10n.php index f760d78c72..729310825d 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -198,19 +198,7 @@ class OC_L10N{ $available = $app; } else{ - $dir = self::findI18nDir( $app ); - if( file_exists($dir)){ - $dh = opendir($dir); - while(( $file = readdir( $dh )) !== false ){ - if( substr( $file, -4, 4 ) == '.php' ){ - $i = substr( $file, 0, -4 ); - if( $i != '' ){ - $available[] = $i; - } - } - } - closedir($dh); - } + $available=self::findAvailableLanguages( $app ); } if( isset($_SESSION['user_id']) && $_SESSION['user_id'] && OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang' )){ $lang = OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang' ); @@ -255,4 +243,27 @@ class OC_L10N{ } return $i18ndir; } + + /** + * @brief find all available languages for an app + * @param $app App that needs to be translated + * @returns array an array of available languages + */ + 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 ){ + $i = substr( $file, 0, -4 ); + if( $i != '' ){ + $available[] = $i; + } + } + } + closedir($dh); + } + return $available; + } } \ No newline at end of file diff --git a/settings/ajax/setlanguage.php b/settings/ajax/setlanguage.php new file mode 100644 index 0000000000..672836afe0 --- /dev/null +++ b/settings/ajax/setlanguage.php @@ -0,0 +1,24 @@ + "error", "data" => array( "message" => "Authentication error" ))); + exit(); +} + +// Get data +if( isset( $_POST['lang'] ) ){ + $lang=$_POST['lang']; + OC_PREFERENCES::setValue( $_SESSION['user_id'], 'core', 'lang', $lang ); + echo json_encode( array( "status" => "success", "data" => array( "message" => "Language changed" ))); +}else{ + echo json_encode( array( "status" => "error", "data" => array( "message" => "Invalid request" ))); +} + +?> diff --git a/settings/index.php b/settings/index.php index 1a442eca81..e2a73a5d9f 100644 --- a/settings/index.php +++ b/settings/index.php @@ -18,11 +18,18 @@ $free=OC_FILESYSTEM::free_space(); $total=$free+$used; $relative=round(($used/$total)*100); +$lang=OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang', 'en' ); +$languages=OC_L10N::findAvailableLanguages(); +//put the current language in the front +unset($languages[array_search($lang,$languages)]); +array_unshift($languages,$lang); + // Return template $tmpl = new OC_TEMPLATE( "settings", "index", "admin"); $tmpl->assign('usage',OC_HELPER::humanFileSize($used)); $tmpl->assign('total_space',OC_HELPER::humanFileSize($total)); $tmpl->assign('usage_relative',$relative); +$tmpl->assign('languages',$languages); $tmpl->printPage(); ?> diff --git a/settings/js/main.js b/settings/js/main.js index e05fc68743..010225bcb2 100644 --- a/settings/js/main.js +++ b/settings/js/main.js @@ -18,4 +18,18 @@ $(document).ready(function(){ }); return false; }); + + $("#languageinput").change( function(){ + // Serialize the data + var post = $( "#languageinput" ).serialize(); + // Ajax foo + $.post( 'ajax/setlanguage.php', post, function(data){ + if( data.status == "success" ){ + } + else{ + $('#passworderror').html( data.data.message ); + } + }); + return false; + }); } ); diff --git a/settings/templates/index.php b/settings/templates/index.php index 2d5e9d9140..f8ef9faf1d 100644 --- a/settings/templates/index.php +++ b/settings/templates/index.php @@ -8,23 +8,35 @@
    - Change Password -
    You're password got changed
    -
    -

    - - -

    -

    - - -

    -

    - - -

    - + Change Password +
    You're password got changed
    +
    +

    + + +

    +

    + + +

    +

    + + +

    + +
    + + +
    +
    + Language + +
    From 4c1d3155a3ee4ddb48a0bb4281fe74391db1f016 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 20 Jun 2011 14:51:33 +0200 Subject: [PATCH 048/111] make personal settings translatable --- settings/ajax/changepassword.php | 12 +++-- settings/ajax/setlanguage.php | 8 +-- settings/l10n/messages.pot | 86 ++++++++++++++++++++++++++++++++ settings/l10n/xgettextfiles | 3 ++ settings/templates/index.php | 16 +++--- 5 files changed, 109 insertions(+), 16 deletions(-) create mode 100644 settings/l10n/messages.pot create mode 100644 settings/l10n/xgettextfiles diff --git a/settings/ajax/changepassword.php b/settings/ajax/changepassword.php index 1a9ad73610..f568d3ef87 100644 --- a/settings/ajax/changepassword.php +++ b/settings/ajax/changepassword.php @@ -3,33 +3,35 @@ // Init owncloud require_once('../../lib/base.php'); +$l=new OC_L10N('settings'); + // We send json data header( "Content-Type: application/jsonrequest" ); // Check if we are a user if( !OC_USER::isLoggedIn()){ - echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); + echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t( "Authentication error" ) ))); exit(); } // Get data if( !isset( $_POST["password"] ) && !isset( $_POST["oldpassword"] )){ - echo json_encode( array( "status" => "error", "data" => array( "message" => "You have to enter the old and the new password!" ))); + echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t( "You have to enter the old and the new password!" ) ))); exit(); } // Check if the old password is correct if( !OC_USER::checkPassword( $_SESSION["user_id"], $_POST["oldpassword"] )){ - echo json_encode( array( "status" => "error", "data" => array( "message" => "Your old password is wrong!" ))); + echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t("Your old password is wrong!") ))); exit(); } // Change password if( OC_USER::setPassword( $_SESSION["user_id"], $_POST["password"] )){ - echo json_encode( array( "status" => "success", "data" => array( "message" => "Password changed" ))); + echo json_encode( array( "status" => "success", "data" => array( "message" => $l->t("Password changed") ))); } else{ - echo json_encode( array( "status" => "error", "data" => array( "message" => "Unable to change password" ))); + echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t("Unable to change password") ))); } ?> diff --git a/settings/ajax/setlanguage.php b/settings/ajax/setlanguage.php index 672836afe0..f971806f4c 100644 --- a/settings/ajax/setlanguage.php +++ b/settings/ajax/setlanguage.php @@ -3,12 +3,14 @@ // Init owncloud require_once('../../lib/base.php'); +$l=new OC_L10N('settings'); + // We send json data header( "Content-Type: application/jsonrequest" ); // Check if we are a user if( !OC_USER::isLoggedIn()){ - echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); + echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t("Authentication error") ))); exit(); } @@ -16,9 +18,9 @@ if( !OC_USER::isLoggedIn()){ if( isset( $_POST['lang'] ) ){ $lang=$_POST['lang']; OC_PREFERENCES::setValue( $_SESSION['user_id'], 'core', 'lang', $lang ); - echo json_encode( array( "status" => "success", "data" => array( "message" => "Language changed" ))); + echo json_encode( array( "status" => "success", "data" => array( "message" => $l->t("Language changed") ))); }else{ - echo json_encode( array( "status" => "error", "data" => array( "message" => "Invalid request" ))); + echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t("Invalid request") ))); } ?> diff --git a/settings/l10n/messages.pot b/settings/l10n/messages.pot new file mode 100644 index 0000000000..705d583ee7 --- /dev/null +++ b/settings/l10n/messages.pot @@ -0,0 +1,86 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-20 14:47+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../templates/index.php:3 +msgid "Account information" +msgstr "" + +#: ../templates/index.php:5 +msgid "You're currently using" +msgstr "" + +#: ../templates/index.php:5 +msgid "of your" +msgstr "" + +#: ../templates/index.php:5 +msgid "space" +msgstr "" + +#: ../templates/index.php:11 +msgid "Change Password" +msgstr "" + +#: ../templates/index.php:12 +msgid "Your password got changed" +msgstr "" + +#: ../templates/index.php:15 +msgid "Old password:" +msgstr "" + +#: ../templates/index.php:19 +msgid "New password" +msgstr "" + +#: ../templates/index.php:24 +msgid "Show new password" +msgstr "" + +#: ../templates/index.php:34 +msgid "Language" +msgstr "" + +#: ../ajax/changepassword.php:13 ../ajax/setlanguage.php:13 +msgid "Authentication error" +msgstr "" + +#: ../ajax/changepassword.php:19 +msgid "You have to enter the old and the new password!" +msgstr "" + +#: ../ajax/changepassword.php:25 +msgid "Your old password is wrong!" +msgstr "" + +#: ../ajax/changepassword.php:31 +msgid "Password changed" +msgstr "" + +#: ../ajax/changepassword.php:34 +msgid "Unable to change password" +msgstr "" + +#: ../ajax/setlanguage.php:21 +msgid "Language changed" +msgstr "" + +#: ../ajax/setlanguage.php:23 +msgid "Invalid request" +msgstr "" diff --git a/settings/l10n/xgettextfiles b/settings/l10n/xgettextfiles new file mode 100644 index 0000000000..8a2f185f23 --- /dev/null +++ b/settings/l10n/xgettextfiles @@ -0,0 +1,3 @@ +../templates/index.php +../ajax/changepassword.php +../ajax/setlanguage.php \ No newline at end of file diff --git a/settings/templates/index.php b/settings/templates/index.php index f8ef9faf1d..761289acef 100644 --- a/settings/templates/index.php +++ b/settings/templates/index.php @@ -1,27 +1,27 @@
    - Account information + t( 'Account information' );?>
     
    -

    You're currently using % () of your space.

    +

    t( 'You\'re currently using' );?> % () t( 'of your' );?> t( 'space' );?>.

    - Change Password -
    You're password got changed
    + t( 'Change Password' );?> +
    t( 'Your password got changed');?>

    - +

    - +

    - +

    - Language + t( 'Language' );?> '/>
    + t( 'Maximum upload size' ); ?> '/>
    - Allow public folders
    + t( 'Allow public folders' ); ?>
    - (if public is enabled)
    - separated from webdav storage
    - let the user decide
    - folder "/public" in webdav storage
    - (endif)
    + t( '(if public is enabled)' ); ?>
    + t( 'separated from webdav storage' ); ?>
    + t( 'let the user decide' ); ?>
    + t( 'folder "/public" in webdav storage' ); ?>
    + t( '(endif)' ); ?>
    - Allow downloading shared files
    - Allow uploading in shared directory
    + t( 'Allow downloading shared files' ); ?>
    + t( 'Allow uploading in shared directory' ); ?>
    diff --git a/files/templates/index.php b/files/templates/index.php index d2d0a237d7..0f24a00f07 100644 --- a/files/templates/index.php +++ b/files/templates/index.php @@ -15,9 +15,9 @@   - Download - - Delete + t( 'Download' ); ?> + + t( 'Delete' ); ?>
    @@ -31,9 +31,9 @@
    - - - + + + From 317b18bef8fbaa412b20e29b1fde8ddc6425cda2 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Mon, 20 Jun 2011 17:13:18 +0200 Subject: [PATCH 051/111] make help translateable --- help/templates/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/help/templates/index.php b/help/templates/index.php index a117c3d5fb..ac7e12b757 100644 --- a/help/templates/index.php +++ b/help/templates/index.php @@ -1,5 +1,5 @@ -

    Questions and Answers

    +

    t( 'Questions and Answers' ); ?>

    @@ -18,6 +18,6 @@ $pageNavi=OC_UTIL::getPageNavi($_['pagecount'],$_['page'],$url); $pageNavi->printPage(); ?> -ASK A QUESTION +t( 'ASK A QUESTION' ); ?> From 7ac7a6801ce867a20c4b36950d5929e577915871 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Mon, 20 Jun 2011 18:16:24 +0200 Subject: [PATCH 052/111] added basic "installed apps" page --- admin/appinfo/app.php | 2 +- admin/apps.php | 99 ++++++++++++++++++++---------------- admin/css/apps.css | 18 +++++++ admin/templates/appsinst.php | 27 ++++++++++ 4 files changed, 100 insertions(+), 46 deletions(-) create mode 100644 admin/templates/appsinst.php diff --git a/admin/appinfo/app.php b/admin/appinfo/app.php index 775575e22a..d01b7d5d62 100644 --- a/admin/appinfo/app.php +++ b/admin/appinfo/app.php @@ -7,6 +7,6 @@ OC_APP::addAdminPage( array( "id" => "core_users", "order" => 2, "href" => OC_HE OC_APP::addAdminPage( array( "id" => "core_apps", "order" => 3, "href" => OC_HELPER::linkTo( "admin", "apps.php" ), "name" => "Apps", "icon" => OC_HELPER::imagePath( "admin", "apps.png" ))); // Add subentries for App installer -OC_APP::addNavigationSubEntry( "core_apps", array( "id" => "core_apps_installed", "order" => 4, "href" => OC_HELPER::linkTo( "admin", "apps.php?add=some¶meters=here" ), "name" => "Installed apps", "icon" => OC_HELPER::imagePath( "admin", "navicon.png" ))); +OC_APP::addNavigationSubEntry( "core_apps", array( "id" => "core_apps_installed", "order" => 4, "href" => OC_HELPER::linkTo( "admin", "apps.php?installed" ), "name" => "Installed apps", "icon" => OC_HELPER::imagePath( "admin", "navicon.png" ))); ?> diff --git a/admin/apps.php b/admin/apps.php index 5b4e65e340..725128a752 100644 --- a/admin/apps.php +++ b/admin/apps.php @@ -34,65 +34,74 @@ OC_UTIL::addStyle( "admin", "apps" ); if(isset($_GET['id'])) $id=$_GET['id']; else $id=0; if(isset($_GET['cat'])) $cat=$_GET['cat']; else $cat=0; +if(isset($_GET['installed'])) $installed=true; else $installed=false; -$categories=OC_OCSCLIENT::getCategories(); -if($categories==NULL){ - OC_APP::setActiveNavigationEntry( "core_apps" ); +if($installed){ + global $SERVERROOT; + $apps = OC_APPCONFIG::getApps(); + $records = array(); - $tmpl = new OC_TEMPLATE( "admin", "app_noconn", "admin" ); + OC_APP::setActiveNavigationEntry( "core_apps_installed" ); + echo count($apps); + foreach($apps as $app){ + $info=OC_APP::getAppInfo("$SERVERROOT/apps/$app/appinfo/info.xml"); + $record = array( 'id' => $app, + 'name' => $info['name'], + 'version' => $info['version'], + 'author' => $info['author'], + 'enabled' => OC_APP::isEnabled( $app )); + $records[]=$record; + } + + $tmpl = new OC_TEMPLATE( "admin", "appsinst", "admin" ); + $tmpl->assign( "apps", $records ); $tmpl->printPage(); unset($tmpl); exit(); -} -/* +}else{ -All -Installed Apps + $categories=OC_OCSCLIENT::getCategories(); + if($categories==NULL){ + OC_APP::setActiveNavigationEntry( "core_apps" ); - - -foreach($categories as $key=>$value) { -print_r($value); -} - - -*/ - -// OC_APP::setActiveNavigationEntry( "core_apps_installed" ); - - -if($id==0) { - OC_APP::setActiveNavigationEntry( "core_apps" ); - - if($cat==0){ - $numcats=array(); - foreach($categories as $key=>$value) $numcats[]=$key; - $apps=OC_OCSCLIENT::getApplications($numcats); - }else{ - $apps=OC_OCSCLIENT::getApplications($cat); + $tmpl = new OC_TEMPLATE( "admin", "app_noconn", "admin" ); + $tmpl->printPage(); + unset($tmpl); + exit(); } - // return template - $tmpl = new OC_TEMPLATE( "admin", "apps", "admin" ); - $tmpl->assign( "categories", $categories ); - $tmpl->assign( "apps", $apps ); - $tmpl->printPage(); - unset($tmpl); + if($id==0) { + OC_APP::setActiveNavigationEntry( "core_apps" ); -}else{ - OC_APP::setActiveNavigationEntry( "core_apps" ); + if($cat==0){ + $numcats=array(); + foreach($categories as $key=>$value) $numcats[]=$key; + $apps=OC_OCSCLIENT::getApplications($numcats); + }else{ + $apps=OC_OCSCLIENT::getApplications($cat); + } - $app=OC_OCSCLIENT::getApplication($id); + // return template + $tmpl = new OC_TEMPLATE( "admin", "apps", "admin" ); - $tmpl = new OC_TEMPLATE( "admin", "app", "admin" ); - $tmpl->assign( "categories", $categories ); - $tmpl->assign( "app", $app ); - $tmpl->printPage(); - unset($tmpl); + $tmpl->assign( "categories", $categories ); + $tmpl->assign( "apps", $apps ); + $tmpl->printPage(); + unset($tmpl); + }else{ + OC_APP::setActiveNavigationEntry( "core_apps" ); + + $app=OC_OCSCLIENT::getApplication($id); + + $tmpl = new OC_TEMPLATE( "admin", "app", "admin" ); + $tmpl->assign( "categories", $categories ); + $tmpl->assign( "app", $app ); + $tmpl->printPage(); + unset($tmpl); + + } } - ?> - diff --git a/admin/css/apps.css b/admin/css/apps.css index 7063762204..fbbd4fce4b 100644 --- a/admin/css/apps.css +++ b/admin/css/apps.css @@ -7,6 +7,24 @@ table td.date text-align: right; } +table td.version, table td.enabled, table td.disabled +{ + padding: 0.5em 1em; + text-align: center; +} + +table td.enabled +{ + color: #006600; + font-weight: bold; +} + +table td.disabled +{ + color: #660000; + font-weight: bold; +} + .preview { padding: 3px; diff --git a/admin/templates/appsinst.php b/admin/templates/appsinst.php new file mode 100644 index 0000000000..c1acc09d5d --- /dev/null +++ b/admin/templates/appsinst.php @@ -0,0 +1,27 @@ + +

    t( 'Installed Applications' ); ?>

    + +
    + + + + + + + + + + + + + + + + + + +
    t( 'Name' ); ?>t( 'Version' ); ?>t( 'Author' ); ?>t( 'Status' ); ?>
    t( $app['enabled'] ? 'enabled' : 'disabled' ); ?>
    \ No newline at end of file From 05637416529606d1aa9c19a3f988c386c17b1352 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 20 Jun 2011 19:04:31 +0200 Subject: [PATCH 053/111] fix sqlite3 driver for php<5.3 --- lib/MDB2/Driver/sqlite3.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/MDB2/Driver/sqlite3.php b/lib/MDB2/Driver/sqlite3.php index a569da187a..3b74afed14 100644 --- a/lib/MDB2/Driver/sqlite3.php +++ b/lib/MDB2/Driver/sqlite3.php @@ -412,7 +412,9 @@ class MDB2_Driver_sqlite3 extends MDB2_Driver_Common $php_errormsg = ''; $this->connection = new SQLite3($database_file); - $this->connection->busyTimeout(100); + if(is_callable(array($this->connection,'busyTimeout'))){//busy timout is only available in php>=5.3 + $this->connection->busyTimeout(100); + } $this->_lasterror = $this->connection->lastErrorMsg(); if (!$this->connection) { return $this->raiseError(MDB2_ERROR_CONNECT_FAILED, null, null, From 272fc252fb71422db2101a76fc541f20924808cd Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Mon, 20 Jun 2011 19:50:25 +0200 Subject: [PATCH 054/111] Activate "active" for subentries --- lib/app.php | 81 +++++++++++++++++++++----------------- templates/layout.admin.php | 4 +- 2 files changed, 47 insertions(+), 38 deletions(-) diff --git a/lib/app.php b/lib/app.php index 544c57c1d6..64704f09bb 100644 --- a/lib/app.php +++ b/lib/app.php @@ -29,7 +29,7 @@ class OC_APP{ static private $init = false; static private $apps = array(); - static private $activeapp = ""; + static private $activeapp = ''; static private $adminpages = array(); static private $settingspages = array(); static private $navigation = array(); @@ -52,16 +52,16 @@ class OC_APP{ } // Our very own core apps are hardcoded - foreach( array( "admin", "files", "log", "help", "settings" ) as $app ){ - require( "$app/appinfo/app.php" ); + foreach( array( 'admin', 'files', 'log', 'help', 'settings' ) as $app ){ + require( $app.'/appinfo/app.php' ); } // The rest comes here $apps = OC_APPCONFIG::getApps(); foreach( $apps as $app ){ if( self::isEnabled( $app )){ - if(is_file($SERVERROOT."/apps/$app/appinfo/app.php")){ - require( "apps/$app/appinfo/app.php" ); + if(is_file($SERVERROOT.'/apps/'.$app.'/appinfo/app.php')){ + require( 'apps/'.$app.'/appinfo/app.php' ); } } } @@ -116,8 +116,8 @@ class OC_APP{ * * This function registers the application. $data is an associative array. * The following keys are required: - * - id: id of the application, has to be unique ("addressbook") - * - name: Human readable name ("Addressbook") + * - id: id of the application, has to be unique ('addressbook') + * - name: Human readable name ('Addressbook') * - version: array with Version (major, minor, bugfix) ( array(1, 0, 2)) * * The following keys are optional: @@ -148,9 +148,9 @@ class OC_APP{ * This function adds a new entry to the navigation visible to users. $data * is an associative array. * The following keys are required: - * - id: unique id for this entry ("addressbook_index") + * - id: unique id for this entry ('addressbook_index') * - href: link to the page - * - name: Human readable name ("Addressbook") + * - name: Human readable name ('Addressbook') * * The following keys are optional: * - icon: path to the icon of the app @@ -174,9 +174,9 @@ class OC_APP{ * as being active (see activateNavigationEntry()). $data is an associative * array. * The following keys are required: - * - id: unique id for this entry ("addressbook_index") + * - id: unique id for this entry ('addressbook_index') * - href: link to the page - * - name: Human readable name ("Addressbook") + * - name: Human readable name ('Addressbook') * * The following keys are optional: * - icon: path to the icon of the app @@ -196,7 +196,7 @@ class OC_APP{ * @param $id id of the entry * @returns true/false * - * This function sets a navigation entry as active and removes the "active" + * This function sets a navigation entry as active and removes the 'active' * property from all other entries. The templates can use this for * highlighting the current position of the user. */ @@ -224,9 +224,9 @@ class OC_APP{ * This function registers a admin page that will be shown in the admin * menu. $data is an associative array. * The following keys are required: - * - id: unique id for this entry ("files_admin") + * - id: unique id for this entry ('files_admin') * - href: link to the admin page - * - name: Human readable name ("Files Administration") + * - name: Human readable name ('Files Administration') * * The following keys are optional: * - order: integer, that influences the position of your application in @@ -245,16 +245,16 @@ class OC_APP{ * * This function registers a settings page. $data is an associative array. * The following keys are required: - * - app: app the settings belong to ("files") - * - id: unique id for this entry ("files_public") + * - app: app the settings belong to ('files') + * - id: unique id for this entry ('files_public') * - href: link to the admin page - * - name: Human readable name ("Public files") + * - name: Human readable name ('Public files') * * The following keys are optional: * - order: integer, that influences the position of your application in * the list. Lower values come first. * - * For the main settings page of an app, the keys "app" and "id" have to be + * For the main settings page of an app, the keys 'app' and 'id' have to be * the same. */ public static function addSettingsPage( $data = array()){ @@ -268,11 +268,11 @@ class OC_APP{ * @returns associative array * * This function returns an array containing all entries added. The - * entries are sorted by the key "order" ascending. Additional to the keys + * entries are sorted by the key 'order' ascending. Additional to the keys * given for each app the following keys exist: * - active: boolean, signals if the user is on this navigation entry - * - children: array that is empty if the key "active" is false or - * contains the subentries if the key "active" is true + * - children: array that is empty if the key 'active' is false or + * contains the subentries if the key 'active' is true */ public static function getNavigation(){ $navigation = self::proceedNavigation( self::$navigation ); @@ -285,7 +285,7 @@ class OC_APP{ * @returns associative array * * This function returns an array containing all settings pages added. The - * entries are sorted by the key "order" ascending. + * entries are sorted by the key 'order' ascending. */ public static function getSettingsNavigation(){ $navigation = self::proceedNavigation( self::$settingspages ); @@ -299,7 +299,7 @@ class OC_APP{ * @returns associative array * * This function returns an array containing all admin pages added. The - * entries are sorted by the key "order" ascending. + * entries are sorted by the key 'order' ascending. */ public static function getAdminNavigation(){ $navigation = self::proceedNavigation( self::$adminpages ); @@ -313,38 +313,47 @@ class OC_APP{ $found = false; foreach( self::$subnavigation as $parent => $selection ){ foreach( $selection as $subentry ){ - if( $subentry["id"] == self::$activeapp ){ + if( $subentry['id'] == self::$activeapp ){ foreach( $list as &$naventry ){ - if( $naventry["id"] == $parent ){ - $naventry["active"] = true; - $naventry["subnavigation"] = $selection; + if( $naventry['id'] == $parent ){ + $naventry['active'] = true; + $naventry['subnavigation'] = $selection; } else{ - $naventry["active"] = false; + $naventry['active'] = false; } - } + } unset( $naventry ); $found = true; } } } + // Mark subentry as active + foreach( $list as &$naventry ){ + if( $naventry['active'] ){ + foreach( $naventry['subnavigation'] as &$subnaventry ){ + $subnaventry['active'] = $subnaventry['id'] == self::$activeapp? true : false; + } unset( $subnaventry ); + } + } unset( $naventry ); + return $list; } /// This is private as well. It simply works, so don't ask for more details private static function proceedNavigation( $list ){ foreach( $list as &$naventry ){ - $naventry["subnavigation"] = array(); - if( $naventry["id"] == self::$activeapp ){ - $naventry["active"] = true; - if( array_key_exists( $naventry["id"], self::$subnavigation )){ - $naventry["subnavigation"] = self::$subnavigation[$naventry["id"]]; + $naventry['subnavigation'] = array(); + if( $naventry['id'] == self::$activeapp ){ + $naventry['active'] = true; + if( array_key_exists( $naventry['id'], self::$subnavigation )){ + $naventry['subnavigation'] = self::$subnavigation[$naventry['id']]; } } else{ - $naventry["active"] = false; + $naventry['active'] = false; } - } + } unset( $naventry ); usort( $list, create_function( '$a, $b', 'if( $a["order"] == $b["order"] ){return 0;}elseif( $a["order"] < $b["order"] ){return -1;}else{return 1;}' )); diff --git a/templates/layout.admin.php b/templates/layout.admin.php index 66fb3ccc60..1fcd4568f8 100644 --- a/templates/layout.admin.php +++ b/templates/layout.admin.php @@ -32,7 +32,7 @@
  • class="active">
  • -
  • +
  • class="active">
  • @@ -41,7 +41,7 @@
  • class="active">
  • -
  • +
  • active
  • From 91c37bbb7642b996e4c386b3033cca02831371ef Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Mon, 20 Jun 2011 20:29:30 +0200 Subject: [PATCH 055/111] moved core stuff to /core --- {css => core/css}/images/no.png | Bin .../ui-bg_diagonals-thick_90_eeeeee_40x40.png | Bin .../images/ui-bg_flat_15_cd0a0a_40x100.png | Bin .../images/ui-bg_glass_100_e4f1fb_1x400.png | Bin .../images/ui-bg_glass_50_3baae3_1x400.png | Bin .../images/ui-bg_glass_80_d7ebf9_1x400.png | Bin .../ui-bg_highlight-hard_100_f2f5f7_1x100.png | Bin .../ui-bg_highlight-hard_70_000000_1x100.png | Bin .../ui-bg_highlight-soft_100_deedf7_1x100.png | Bin .../ui-bg_highlight-soft_25_ffef8f_1x100.png | Bin .../css}/images/ui-icons_2694e8_256x240.png | Bin .../css}/images/ui-icons_2e83ff_256x240.png | Bin .../css}/images/ui-icons_3d80b3_256x240.png | Bin .../css}/images/ui-icons_72a7cf_256x240.png | Bin .../css}/images/ui-icons_ffffff_256x240.png | Bin {css => core/css}/jquery-ui-1.8.10.custom.css | 0 {css => core/css}/styles.css | 0 {img => core/img}/actions/arrow-down.png | Bin {img => core/img}/actions/arrow-left.png | Bin {img => core/img}/actions/arrow-right.png | Bin {img => core/img}/actions/arrow-up.png | Bin {img => core/img}/actions/go-home.png | Bin {img => core/img}/body_background.jpg | Bin {img => core/img}/drop-arrow.png | Bin {img => core/img}/favicon-touch.png | Bin {img => core/img}/favicon.png | Bin {img => core/img}/header-a.png | Bin {img => core/img}/header-login.png | Bin {img => core/img}/header-settings-a.png | Bin {img => core/img}/header-settings.png | Bin {img => core/img}/header.png | Bin {img => core/img}/layout/back.png | Bin {img => core/img}/layout/logout.png | Bin {img => core/img}/layout/settings.png | Bin {img => core/img}/mimetypes/file.png | Bin .../img}/owncloud-logo-medium-white.png | Bin .../img}/owncloud-logo-small-white.png | Bin {img => core/img}/places/folder.png | Bin {img => core/img}/weather-clear.png | Bin {js => core/js}/jquery-1.5.min.js | 0 .../js}/jquery-ui-1.8.10.custom.min.js | 0 {js => core/js}/js.js | 0 {js => core/js}/setup.js | 0 {l10n => core/l10n}/de.php | 0 {l10n => core/l10n}/de.po | 0 {l10n => core/l10n}/javascript.php | 0 {l10n => core/l10n}/l10n-de.php | 0 {l10n => core/l10n}/messages.pot | 0 {l10n => core/l10n}/nl.php | 0 {l10n => core/l10n}/nl.po | 0 {l10n => core/l10n}/xgettextfiles | 0 {templates => core/templates}/404.php | 0 {templates => core/templates}/error.php | 0 .../templates}/installation.php | 0 .../templates}/layout.admin.php | 0 .../templates}/layout.guest.php | 0 {templates => core/templates}/layout.user.php | 0 {templates => core/templates}/login.php | 0 {templates => core/templates}/logout.php | 0 .../templates}/part.pagenavi.php | 0 .../templates}/part.searchbox.php | 0 files/css/files.css | 2 +- files/img/drop-arrow.png | Bin 0 -> 2899 bytes lib/helper.php | 19 +++++++++++------- lib/template.php | 16 +++++++++++---- 65 files changed, 25 insertions(+), 12 deletions(-) rename {css => core/css}/images/no.png (100%) rename {css => core/css}/images/ui-bg_diagonals-thick_90_eeeeee_40x40.png (100%) rename {css => core/css}/images/ui-bg_flat_15_cd0a0a_40x100.png (100%) rename {css => core/css}/images/ui-bg_glass_100_e4f1fb_1x400.png (100%) rename {css => core/css}/images/ui-bg_glass_50_3baae3_1x400.png (100%) rename {css => core/css}/images/ui-bg_glass_80_d7ebf9_1x400.png (100%) rename {css => core/css}/images/ui-bg_highlight-hard_100_f2f5f7_1x100.png (100%) rename {css => core/css}/images/ui-bg_highlight-hard_70_000000_1x100.png (100%) rename {css => core/css}/images/ui-bg_highlight-soft_100_deedf7_1x100.png (100%) rename {css => core/css}/images/ui-bg_highlight-soft_25_ffef8f_1x100.png (100%) rename {css => core/css}/images/ui-icons_2694e8_256x240.png (100%) rename {css => core/css}/images/ui-icons_2e83ff_256x240.png (100%) rename {css => core/css}/images/ui-icons_3d80b3_256x240.png (100%) rename {css => core/css}/images/ui-icons_72a7cf_256x240.png (100%) rename {css => core/css}/images/ui-icons_ffffff_256x240.png (100%) rename {css => core/css}/jquery-ui-1.8.10.custom.css (100%) rename {css => core/css}/styles.css (100%) rename {img => core/img}/actions/arrow-down.png (100%) rename {img => core/img}/actions/arrow-left.png (100%) rename {img => core/img}/actions/arrow-right.png (100%) rename {img => core/img}/actions/arrow-up.png (100%) rename {img => core/img}/actions/go-home.png (100%) rename {img => core/img}/body_background.jpg (100%) rename {img => core/img}/drop-arrow.png (100%) rename {img => core/img}/favicon-touch.png (100%) rename {img => core/img}/favicon.png (100%) rename {img => core/img}/header-a.png (100%) rename {img => core/img}/header-login.png (100%) rename {img => core/img}/header-settings-a.png (100%) rename {img => core/img}/header-settings.png (100%) rename {img => core/img}/header.png (100%) rename {img => core/img}/layout/back.png (100%) rename {img => core/img}/layout/logout.png (100%) rename {img => core/img}/layout/settings.png (100%) rename {img => core/img}/mimetypes/file.png (100%) rename {img => core/img}/owncloud-logo-medium-white.png (100%) rename {img => core/img}/owncloud-logo-small-white.png (100%) rename {img => core/img}/places/folder.png (100%) rename {img => core/img}/weather-clear.png (100%) rename {js => core/js}/jquery-1.5.min.js (100%) rename {js => core/js}/jquery-ui-1.8.10.custom.min.js (100%) rename {js => core/js}/js.js (100%) rename {js => core/js}/setup.js (100%) rename {l10n => core/l10n}/de.php (100%) rename {l10n => core/l10n}/de.po (100%) rename {l10n => core/l10n}/javascript.php (100%) rename {l10n => core/l10n}/l10n-de.php (100%) rename {l10n => core/l10n}/messages.pot (100%) rename {l10n => core/l10n}/nl.php (100%) rename {l10n => core/l10n}/nl.po (100%) rename {l10n => core/l10n}/xgettextfiles (100%) rename {templates => core/templates}/404.php (100%) rename {templates => core/templates}/error.php (100%) rename {templates => core/templates}/installation.php (100%) rename {templates => core/templates}/layout.admin.php (100%) rename {templates => core/templates}/layout.guest.php (100%) rename {templates => core/templates}/layout.user.php (100%) rename {templates => core/templates}/login.php (100%) rename {templates => core/templates}/logout.php (100%) rename {templates => core/templates}/part.pagenavi.php (100%) rename {templates => core/templates}/part.searchbox.php (100%) create mode 100644 files/img/drop-arrow.png diff --git a/css/images/no.png b/core/css/images/no.png similarity index 100% rename from css/images/no.png rename to core/css/images/no.png diff --git a/css/images/ui-bg_diagonals-thick_90_eeeeee_40x40.png b/core/css/images/ui-bg_diagonals-thick_90_eeeeee_40x40.png similarity index 100% rename from css/images/ui-bg_diagonals-thick_90_eeeeee_40x40.png rename to core/css/images/ui-bg_diagonals-thick_90_eeeeee_40x40.png diff --git a/css/images/ui-bg_flat_15_cd0a0a_40x100.png b/core/css/images/ui-bg_flat_15_cd0a0a_40x100.png similarity index 100% rename from css/images/ui-bg_flat_15_cd0a0a_40x100.png rename to core/css/images/ui-bg_flat_15_cd0a0a_40x100.png diff --git a/css/images/ui-bg_glass_100_e4f1fb_1x400.png b/core/css/images/ui-bg_glass_100_e4f1fb_1x400.png similarity index 100% rename from css/images/ui-bg_glass_100_e4f1fb_1x400.png rename to core/css/images/ui-bg_glass_100_e4f1fb_1x400.png diff --git a/css/images/ui-bg_glass_50_3baae3_1x400.png b/core/css/images/ui-bg_glass_50_3baae3_1x400.png similarity index 100% rename from css/images/ui-bg_glass_50_3baae3_1x400.png rename to core/css/images/ui-bg_glass_50_3baae3_1x400.png diff --git a/css/images/ui-bg_glass_80_d7ebf9_1x400.png b/core/css/images/ui-bg_glass_80_d7ebf9_1x400.png similarity index 100% rename from css/images/ui-bg_glass_80_d7ebf9_1x400.png rename to core/css/images/ui-bg_glass_80_d7ebf9_1x400.png diff --git a/css/images/ui-bg_highlight-hard_100_f2f5f7_1x100.png b/core/css/images/ui-bg_highlight-hard_100_f2f5f7_1x100.png similarity index 100% rename from css/images/ui-bg_highlight-hard_100_f2f5f7_1x100.png rename to core/css/images/ui-bg_highlight-hard_100_f2f5f7_1x100.png diff --git a/css/images/ui-bg_highlight-hard_70_000000_1x100.png b/core/css/images/ui-bg_highlight-hard_70_000000_1x100.png similarity index 100% rename from css/images/ui-bg_highlight-hard_70_000000_1x100.png rename to core/css/images/ui-bg_highlight-hard_70_000000_1x100.png diff --git a/css/images/ui-bg_highlight-soft_100_deedf7_1x100.png b/core/css/images/ui-bg_highlight-soft_100_deedf7_1x100.png similarity index 100% rename from css/images/ui-bg_highlight-soft_100_deedf7_1x100.png rename to core/css/images/ui-bg_highlight-soft_100_deedf7_1x100.png diff --git a/css/images/ui-bg_highlight-soft_25_ffef8f_1x100.png b/core/css/images/ui-bg_highlight-soft_25_ffef8f_1x100.png similarity index 100% rename from css/images/ui-bg_highlight-soft_25_ffef8f_1x100.png rename to core/css/images/ui-bg_highlight-soft_25_ffef8f_1x100.png diff --git a/css/images/ui-icons_2694e8_256x240.png b/core/css/images/ui-icons_2694e8_256x240.png similarity index 100% rename from css/images/ui-icons_2694e8_256x240.png rename to core/css/images/ui-icons_2694e8_256x240.png diff --git a/css/images/ui-icons_2e83ff_256x240.png b/core/css/images/ui-icons_2e83ff_256x240.png similarity index 100% rename from css/images/ui-icons_2e83ff_256x240.png rename to core/css/images/ui-icons_2e83ff_256x240.png diff --git a/css/images/ui-icons_3d80b3_256x240.png b/core/css/images/ui-icons_3d80b3_256x240.png similarity index 100% rename from css/images/ui-icons_3d80b3_256x240.png rename to core/css/images/ui-icons_3d80b3_256x240.png diff --git a/css/images/ui-icons_72a7cf_256x240.png b/core/css/images/ui-icons_72a7cf_256x240.png similarity index 100% rename from css/images/ui-icons_72a7cf_256x240.png rename to core/css/images/ui-icons_72a7cf_256x240.png diff --git a/css/images/ui-icons_ffffff_256x240.png b/core/css/images/ui-icons_ffffff_256x240.png similarity index 100% rename from css/images/ui-icons_ffffff_256x240.png rename to core/css/images/ui-icons_ffffff_256x240.png diff --git a/css/jquery-ui-1.8.10.custom.css b/core/css/jquery-ui-1.8.10.custom.css similarity index 100% rename from css/jquery-ui-1.8.10.custom.css rename to core/css/jquery-ui-1.8.10.custom.css diff --git a/css/styles.css b/core/css/styles.css similarity index 100% rename from css/styles.css rename to core/css/styles.css diff --git a/img/actions/arrow-down.png b/core/img/actions/arrow-down.png similarity index 100% rename from img/actions/arrow-down.png rename to core/img/actions/arrow-down.png diff --git a/img/actions/arrow-left.png b/core/img/actions/arrow-left.png similarity index 100% rename from img/actions/arrow-left.png rename to core/img/actions/arrow-left.png diff --git a/img/actions/arrow-right.png b/core/img/actions/arrow-right.png similarity index 100% rename from img/actions/arrow-right.png rename to core/img/actions/arrow-right.png diff --git a/img/actions/arrow-up.png b/core/img/actions/arrow-up.png similarity index 100% rename from img/actions/arrow-up.png rename to core/img/actions/arrow-up.png diff --git a/img/actions/go-home.png b/core/img/actions/go-home.png similarity index 100% rename from img/actions/go-home.png rename to core/img/actions/go-home.png diff --git a/img/body_background.jpg b/core/img/body_background.jpg similarity index 100% rename from img/body_background.jpg rename to core/img/body_background.jpg diff --git a/img/drop-arrow.png b/core/img/drop-arrow.png similarity index 100% rename from img/drop-arrow.png rename to core/img/drop-arrow.png diff --git a/img/favicon-touch.png b/core/img/favicon-touch.png similarity index 100% rename from img/favicon-touch.png rename to core/img/favicon-touch.png diff --git a/img/favicon.png b/core/img/favicon.png similarity index 100% rename from img/favicon.png rename to core/img/favicon.png diff --git a/img/header-a.png b/core/img/header-a.png similarity index 100% rename from img/header-a.png rename to core/img/header-a.png diff --git a/img/header-login.png b/core/img/header-login.png similarity index 100% rename from img/header-login.png rename to core/img/header-login.png diff --git a/img/header-settings-a.png b/core/img/header-settings-a.png similarity index 100% rename from img/header-settings-a.png rename to core/img/header-settings-a.png diff --git a/img/header-settings.png b/core/img/header-settings.png similarity index 100% rename from img/header-settings.png rename to core/img/header-settings.png diff --git a/img/header.png b/core/img/header.png similarity index 100% rename from img/header.png rename to core/img/header.png diff --git a/img/layout/back.png b/core/img/layout/back.png similarity index 100% rename from img/layout/back.png rename to core/img/layout/back.png diff --git a/img/layout/logout.png b/core/img/layout/logout.png similarity index 100% rename from img/layout/logout.png rename to core/img/layout/logout.png diff --git a/img/layout/settings.png b/core/img/layout/settings.png similarity index 100% rename from img/layout/settings.png rename to core/img/layout/settings.png diff --git a/img/mimetypes/file.png b/core/img/mimetypes/file.png similarity index 100% rename from img/mimetypes/file.png rename to core/img/mimetypes/file.png diff --git a/img/owncloud-logo-medium-white.png b/core/img/owncloud-logo-medium-white.png similarity index 100% rename from img/owncloud-logo-medium-white.png rename to core/img/owncloud-logo-medium-white.png diff --git a/img/owncloud-logo-small-white.png b/core/img/owncloud-logo-small-white.png similarity index 100% rename from img/owncloud-logo-small-white.png rename to core/img/owncloud-logo-small-white.png diff --git a/img/places/folder.png b/core/img/places/folder.png similarity index 100% rename from img/places/folder.png rename to core/img/places/folder.png diff --git a/img/weather-clear.png b/core/img/weather-clear.png similarity index 100% rename from img/weather-clear.png rename to core/img/weather-clear.png diff --git a/js/jquery-1.5.min.js b/core/js/jquery-1.5.min.js similarity index 100% rename from js/jquery-1.5.min.js rename to core/js/jquery-1.5.min.js diff --git a/js/jquery-ui-1.8.10.custom.min.js b/core/js/jquery-ui-1.8.10.custom.min.js similarity index 100% rename from js/jquery-ui-1.8.10.custom.min.js rename to core/js/jquery-ui-1.8.10.custom.min.js diff --git a/js/js.js b/core/js/js.js similarity index 100% rename from js/js.js rename to core/js/js.js diff --git a/js/setup.js b/core/js/setup.js similarity index 100% rename from js/setup.js rename to core/js/setup.js diff --git a/l10n/de.php b/core/l10n/de.php similarity index 100% rename from l10n/de.php rename to core/l10n/de.php diff --git a/l10n/de.po b/core/l10n/de.po similarity index 100% rename from l10n/de.po rename to core/l10n/de.po diff --git a/l10n/javascript.php b/core/l10n/javascript.php similarity index 100% rename from l10n/javascript.php rename to core/l10n/javascript.php diff --git a/l10n/l10n-de.php b/core/l10n/l10n-de.php similarity index 100% rename from l10n/l10n-de.php rename to core/l10n/l10n-de.php diff --git a/l10n/messages.pot b/core/l10n/messages.pot similarity index 100% rename from l10n/messages.pot rename to core/l10n/messages.pot diff --git a/l10n/nl.php b/core/l10n/nl.php similarity index 100% rename from l10n/nl.php rename to core/l10n/nl.php diff --git a/l10n/nl.po b/core/l10n/nl.po similarity index 100% rename from l10n/nl.po rename to core/l10n/nl.po diff --git a/l10n/xgettextfiles b/core/l10n/xgettextfiles similarity index 100% rename from l10n/xgettextfiles rename to core/l10n/xgettextfiles diff --git a/templates/404.php b/core/templates/404.php similarity index 100% rename from templates/404.php rename to core/templates/404.php diff --git a/templates/error.php b/core/templates/error.php similarity index 100% rename from templates/error.php rename to core/templates/error.php diff --git a/templates/installation.php b/core/templates/installation.php similarity index 100% rename from templates/installation.php rename to core/templates/installation.php diff --git a/templates/layout.admin.php b/core/templates/layout.admin.php similarity index 100% rename from templates/layout.admin.php rename to core/templates/layout.admin.php diff --git a/templates/layout.guest.php b/core/templates/layout.guest.php similarity index 100% rename from templates/layout.guest.php rename to core/templates/layout.guest.php diff --git a/templates/layout.user.php b/core/templates/layout.user.php similarity index 100% rename from templates/layout.user.php rename to core/templates/layout.user.php diff --git a/templates/login.php b/core/templates/login.php similarity index 100% rename from templates/login.php rename to core/templates/login.php diff --git a/templates/logout.php b/core/templates/logout.php similarity index 100% rename from templates/logout.php rename to core/templates/logout.php diff --git a/templates/part.pagenavi.php b/core/templates/part.pagenavi.php similarity index 100% rename from templates/part.pagenavi.php rename to core/templates/part.pagenavi.php diff --git a/templates/part.searchbox.php b/core/templates/part.searchbox.php similarity index 100% rename from templates/part.searchbox.php rename to core/templates/part.searchbox.php diff --git a/files/css/files.css b/files/css/files.css index 7c7965ab84..702ddefc19 100644 --- a/files/css/files.css +++ b/files/css/files.css @@ -110,5 +110,5 @@ table td.filename a width:16px; display: -moz-inline-box; /* fallback for older firefox versions*/ display: inline-block; - background-image:url('../../img/drop-arrow.png'); + background-image:url('../img/drop-arrow.png'); } \ No newline at end of file diff --git a/files/img/drop-arrow.png b/files/img/drop-arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..315395d5d4240bb8c2372e92f0af90ce0c9450b4 GIT binary patch literal 2899 zcmV-Z3#{~sP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=00004XF*Lt006O$eEU(80000WV@Og>004R=004l4008;_004mL004C` z008P>0026e000+nl3&F}0001PNklT5q(}e&002ovPDHLkV1nDvShoNG literal 0 HcmV?d00001 diff --git a/lib/helper.php b/lib/helper.php index 072607f742..6f7d7ce251 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -44,6 +44,9 @@ class OC_HELPER { return $WEBROOT . '/apps/' . $app . $file; } } + else{ + $app = 'core'; + } return $WEBROOT . '/' . $app . $file; } @@ -58,14 +61,16 @@ class OC_HELPER { public static function imagePath( $app, $image ){ global $SERVERROOT; global $WEBROOT; + // Check if the app is in the app folder if( file_exists( "$SERVERROOT/apps/$app/img/$image" )){ return "$WEBROOT/apps/$app/img/$image"; } - if( !empty( $app )){ + elseif( !empty( $app )){ return "$WEBROOT/$app/img/$image"; - }else{ - return "$WEBROOT/img/$image"; + } + else{ + return "$WEBROOT/core/img/$image"; } } @@ -84,15 +89,15 @@ class OC_HELPER { // Is it a dir? if( $mimetype == "dir" ){ - return "$WEBROOT/img/places/folder.png"; + return "$WEBROOT/core/img/places/folder.png"; } // Icon exists? - if( file_exists( "$SERVERROOT/img/mimetypes/$mimetype.png" )){ - return "$WEBROOT/img/mimetypes/$mimetype.png"; + if( file_exists( "$SERVERROOT/core/img/mimetypes/$mimetype.png" )){ + return "$WEBROOT/core/img/mimetypes/$mimetype.png"; } else{ - return "$WEBROOT/img/mimetypes/file.png"; + return "$WEBROOT/core/img/mimetypes/file.png"; } } diff --git a/lib/template.php b/lib/template.php index 6b9a1c38e1..69065e1ea1 100644 --- a/lib/template.php +++ b/lib/template.php @@ -95,8 +95,8 @@ class OC_TEMPLATE{ global $SERVERROOT; // Get the right template folder - $template = "$SERVERROOT/templates/"; - if( $app != "core" && $app != "" ){ + $template = "$SERVERROOT/core/templates/"; + if( $app != "" ){ // Check if the app is in the app folder if( file_exists( "$SERVERROOT/apps/$app/templates/" )){ $template = "$SERVERROOT/apps/$app/templates/"; @@ -222,16 +222,24 @@ class OC_TEMPLATE{ foreach(OC_UTIL::$scripts as $script){ if(is_file("$SERVERROOT/apps/$script.js" )){ $page->append( "jsfiles", "$WEBROOT/apps/$script.js" ); - }else{ + } + elseif(is_file("$SERVERROOT/$script.js" )){ $page->append( "jsfiles", "$WEBROOT/$script.js" ); } + else{ + $page->append( "jsfiles", "$WEBROOT/core/$script.js" ); + } } foreach(OC_UTIL::$styles as $style){ if(is_file("$SERVERROOT/apps/$style.css" )){ $page->append( "cssfiles", "$WEBROOT/apps/$style.css" ); - }else{ + } + elseif(is_file("$SERVERROOT/$style.css" )){ $page->append( "cssfiles", "$WEBROOT/$style.css" ); } + else{ + $page->append( "cssfiles", "$WEBROOT/core/$style.css" ); + } } // Add css files and js files From 0f0d37b85cfd3aea57c1d54ff005d881b55af304 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Mon, 20 Jun 2011 18:51:06 +0200 Subject: [PATCH 056/111] fixed minor string omission --- admin/templates/users.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/templates/users.php b/admin/templates/users.php index c6ee57a61d..0c26fd3bdf 100644 --- a/admin/templates/users.php +++ b/admin/templates/users.php @@ -4,7 +4,7 @@ t( 'Name' ); ?> - Groups + t( 'Groups' ); ?> From d38e958ada1390c36112ab2b0b4b28d1cae3e1df Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Mon, 20 Jun 2011 19:21:42 +0200 Subject: [PATCH 057/111] enable/disable apps by clicking their status --- admin/ajax/disableapp.php | 9 +++++++++ admin/ajax/enableapp.php | 9 +++++++++ admin/apps.php | 2 +- admin/js/apps.js | 17 +++++++++++++++++ admin/templates/appsinst.php | 4 ++-- 5 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 admin/ajax/disableapp.php create mode 100644 admin/ajax/enableapp.php create mode 100644 admin/js/apps.js diff --git a/admin/ajax/disableapp.php b/admin/ajax/disableapp.php new file mode 100644 index 0000000000..d23f8de7ef --- /dev/null +++ b/admin/ajax/disableapp.php @@ -0,0 +1,9 @@ + diff --git a/admin/ajax/enableapp.php b/admin/ajax/enableapp.php new file mode 100644 index 0000000000..d988d7fd2d --- /dev/null +++ b/admin/ajax/enableapp.php @@ -0,0 +1,9 @@ + diff --git a/admin/apps.php b/admin/apps.php index 725128a752..5eec7e626d 100644 --- a/admin/apps.php +++ b/admin/apps.php @@ -30,6 +30,7 @@ if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' // Load the files we need OC_UTIL::addStyle( "admin", "apps" ); +OC_UTIL::addScript( "admin", "apps" ); if(isset($_GET['id'])) $id=$_GET['id']; else $id=0; @@ -42,7 +43,6 @@ if($installed){ $records = array(); OC_APP::setActiveNavigationEntry( "core_apps_installed" ); - echo count($apps); foreach($apps as $app){ $info=OC_APP::getAppInfo("$SERVERROOT/apps/$app/appinfo/info.xml"); $record = array( 'id' => $app, diff --git a/admin/js/apps.js b/admin/js/apps.js new file mode 100644 index 0000000000..4d8c68171b --- /dev/null +++ b/admin/js/apps.js @@ -0,0 +1,17 @@ +$("div[x-use='appenableddiv']").live( "click", function(){ + appid = $(this).parent().parent().attr("x-uid"); + + if($(this).text() == "enabled"){ + $(this).html( "disabled" ); + $(this).parent().removeClass( "enabled" ); + $(this).parent().addClass( "disabled" ); + //$.post( "ajax/disableapp.php", $(appid).serialize(), function(data){} ); + $.post( "ajax/disableapp.php", { appid: appid }, function(data){ alert(data.status);}); + } + else if($(this).text() == "disabled"){ + $(this).html( "enabled" ); + $(this).parent().removeClass( "disabled" ); + $(this).parent().addClass( "enabled" ); + $.post( "ajax/enableapp.php", { appid: appid }, function(data){ alert(data.status);} ); + } +}); \ No newline at end of file diff --git a/admin/templates/appsinst.php b/admin/templates/appsinst.php index c1acc09d5d..482273da1d 100644 --- a/admin/templates/appsinst.php +++ b/admin/templates/appsinst.php @@ -16,11 +16,11 @@ - + - t( $app['enabled'] ? 'enabled' : 'disabled' ); ?> +
    t( $app['enabled'] ? 'enabled' : 'disabled' ); ?>
    From eb1ce7819a16e9b780e1272e405950817d1de6dc Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Mon, 20 Jun 2011 21:01:34 +0200 Subject: [PATCH 058/111] Fix linkTo() --- lib/helper.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/helper.php b/lib/helper.php index 6f7d7ce251..8cd6ebf75a 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -37,17 +37,24 @@ class OC_HELPER { global $WEBROOT; global $SERVERROOT; - if(!empty($app)) { + if( $app != '' ){ $app .= '/'; // Check if the app is in the app folder - if( file_exists( $SERVERROOT . '/apps/'. $app )){ + if( file_exists( $SERVERROOT . '/apps/'. $app.$file )){ return $WEBROOT . '/apps/' . $app . $file; } + else{ + return $WEBROOT . '/' . $app . $file; + } } else{ - $app = 'core'; + if( file_exists( $SERVERROOT . '/core/'. $file )){ + return $WEBROOT . '/core/'.$file; + } + else{ + return $WEBROOT . '/'.$file; + } } - return $WEBROOT . '/' . $app . $file; } /** From 06033914050633d51c45d6b5e79884bcc66283f8 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Mon, 20 Jun 2011 21:09:34 +0200 Subject: [PATCH 059/111] fixed page reload after logout --- index.php | 2 +- lib/setup.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 5aaa8fb89c..d1726676c6 100644 --- a/index.php +++ b/index.php @@ -47,7 +47,7 @@ elseif($not_installed OR $install_called) { elseif(OC_USER::isLoggedIn()) { if(isset($_GET["logout"]) and ($_GET["logout"])) { OC_USER::logout(); - header("Location: $WEBROOT"); + header("Location: ".$WEBROOT.'/'); exit(); } else { diff --git a/lib/setup.php b/lib/setup.php index 5905261f18..bdb5dcc4e2 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -23,7 +23,7 @@ if(isset($_POST['install']) AND $_POST['install']=='true') { OC_TEMPLATE::printGuestPage("", "installation", $options); } else { - header("Location: $WEBROOT$SUBURI"); + header("Location: ".$WEBROOT.'/'); exit(); } } From 61993419ecc16a7aa7046186e29e1dc92cf71cb7 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Mon, 20 Jun 2011 21:54:21 +0200 Subject: [PATCH 060/111] New i18n-structure --- .../javascript.php => ajax/translations.php} | 0 log/l10n/da.po => l10n/da/log.po | 0 core/l10n/de.po => l10n/de/core.po | 0 log/l10n/de.po => l10n/de/log.po | 0 l10n/l10n.pl | 104 ++++++++++++++++++ core/l10n/nl.po => l10n/nl/core.po | 0 log/l10n/messages.pot => l10n/nl/log.po | 0 settings/l10n/nl.po => l10n/nl/settings.po | 0 .../messages.pot => l10n/templates/admin.pot | 0 .../messages.pot => l10n/templates/core.pot | 0 log/l10n/nl.po => l10n/templates/log.pot | 0 .../templates/settings.pot | 0 lib/l10n.php | 8 +- log/l10n/log | 4 - 14 files changed, 108 insertions(+), 8 deletions(-) rename core/{l10n/javascript.php => ajax/translations.php} (100%) rename log/l10n/da.po => l10n/da/log.po (100%) rename core/l10n/de.po => l10n/de/core.po (100%) rename log/l10n/de.po => l10n/de/log.po (100%) create mode 100644 l10n/l10n.pl rename core/l10n/nl.po => l10n/nl/core.po (100%) rename log/l10n/messages.pot => l10n/nl/log.po (100%) rename settings/l10n/nl.po => l10n/nl/settings.po (100%) rename admin/l10n/messages.pot => l10n/templates/admin.pot (100%) rename core/l10n/messages.pot => l10n/templates/core.pot (100%) rename log/l10n/nl.po => l10n/templates/log.pot (100%) rename settings/l10n/messages.pot => l10n/templates/settings.pot (100%) delete mode 100644 log/l10n/log diff --git a/core/l10n/javascript.php b/core/ajax/translations.php similarity index 100% rename from core/l10n/javascript.php rename to core/ajax/translations.php diff --git a/log/l10n/da.po b/l10n/da/log.po similarity index 100% rename from log/l10n/da.po rename to l10n/da/log.po diff --git a/core/l10n/de.po b/l10n/de/core.po similarity index 100% rename from core/l10n/de.po rename to l10n/de/core.po diff --git a/log/l10n/de.po b/l10n/de/log.po similarity index 100% rename from log/l10n/de.po rename to l10n/de/log.po diff --git a/l10n/l10n.pl b/l10n/l10n.pl new file mode 100644 index 0000000000..5463e34e4d --- /dev/null +++ b/l10n/l10n.pl @@ -0,0 +1,104 @@ +#!/usr/bin/perl +use strict; +use Locale::PO; +use Cwd; +use Data::Dumper; + +sub crawl{ + my( $dir ) = @_; + my @found = (); + + opendir( DIR, $dir ); + my @files = readdir( DIR ); + closedir( DIR ); + + foreach my $i ( @files ){ + next if substr( $i, 0, 1 ) eq '.'; + if( -d $dir.'/'.$i ){ + push( @found, crawl( $dir.'/'.$i )); + } + elsif( $i eq 'xgettextfiles' ){ + push( @found, $dir ); + } + } + + return @found; +} + +my $task = shift( @ARGV ); +my $place = '..'; + +die( "Usuage: l10n.pl task\ntask: read, write\n") unless $task && $place; + +# Where are i18n-files? +my @dirs = crawl( $place ); + +# Languages +mkdir( 'templates' ) unless -d 'templates'; + +my @languages = (); +opendir( DIR, '.' ); +my @files = readdir( DIR ); +closedir( DIR ); +foreach my $i ( @files ){ + push( @languages, $i ) if -d $i && substr( $i, 0, 1 ) ne '.'; +} + +# Our current position +my $whereami = cwd(); + +if( $task eq 'read' ){ + foreach my $dir ( @dirs ){ + my @temp = split( /\//, $dir ); + pop( @temp ); + my $app = pop( @temp ); + chdir( $dir ); + foreach my $language ( @languages ){ + my $output = "${whereami}/$language/$app.po"; + $output .= 't' if $language eq 'templates'; + + if( -e $output ){ + `xgettext --files-from=xgettextfiles --join-existing --output="$output" --keyword=t` + } + else{ + `xgettext --files-from=xgettextfiles --output="$output" --keyword=t` + } + } + chdir( $whereami ); + } +} +elsif( $task eq 'write' ){ + foreach my $dir ( @dirs ){ + my @temp = split( /\//, $dir ); + pop( @temp ); + my $app = pop( @temp ); + chdir( $dir ); + foreach my $language ( @languages ){ + next if $language eq 'templates'; + + my $input = "${whereami}/$language/$app.po"; + next unless -e $input; + + my $hash = Locale::PO->load_file_ashash( $input ); + + # Create array + my @strings = (); + foreach my $key ( keys( %{$hash} )){ + next if $key eq '""'; + next if $hash->{$key}->msgstr() eq '""'; + push( @strings, $hash->{$key}->msgid()." => ".$hash->{$key}->msgstr()); + } + + # Write PHP file + open( OUT, ">$lang.php" ); + print OUT "localizations = array_merge( $this->localizations, $LOCALIZATIONS ); } @@ -231,8 +231,8 @@ class OC_L10N{ global $SERVERROOT; // find the i18n dir - $i18ndir = $SERVERROOT.'/l10n/'; - if( $app != 'core' && $app != '' ){ + $i18ndir = $SERVERROOT.'/core/l10n/'; + if( $app != '' ){ // Check if the app is in the app folder if( file_exists( $SERVERROOT.'/apps/'.$app.'/l10n/' )){ $i18ndir = $SERVERROOT.'/apps/'.$app.'/l10n/'; diff --git a/log/l10n/log b/log/l10n/log deleted file mode 100644 index f70eb6af3f..0000000000 --- a/log/l10n/log +++ /dev/null @@ -1,4 +0,0 @@ -[General] -LangCode=de -ProjectID=oc_log -TargetLangCode=de From 0c3880cffc2ab44cd4d658d424a66f3018913008 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Mon, 20 Jun 2011 21:58:43 +0200 Subject: [PATCH 061/111] Added danish translation --- help/l10n/xgettextfiles | 1 + l10n/da/admin.po | 92 ++++++++++++++++++++++++++++++ l10n/da/core.po | 123 ++++++++++++++++++++++++++++++++++++++++ l10n/da/settings.po | 87 ++++++++++++++++++++++++++++ 4 files changed, 303 insertions(+) create mode 100644 help/l10n/xgettextfiles create mode 100644 l10n/da/admin.po create mode 100644 l10n/da/core.po create mode 100644 l10n/da/settings.po diff --git a/help/l10n/xgettextfiles b/help/l10n/xgettextfiles new file mode 100644 index 0000000000..a24bcc89a8 --- /dev/null +++ b/help/l10n/xgettextfiles @@ -0,0 +1 @@ +../templates/index.php diff --git a/l10n/da/admin.po b/l10n/da/admin.po new file mode 100644 index 0000000000..b083b8ecca --- /dev/null +++ b/l10n/da/admin.po @@ -0,0 +1,92 @@ +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Mikkel Bjerg Larsen , 2011. +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-19 23:32+0200\n" +"PO-Revision-Date: 2011-06-20 00:36+0200\n" +"Last-Translator: Mikkel Bjerg Larsen \n" +"Language-Team: American English \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.2\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: ../templates/app.php:22 +msgid "read more" +msgstr "læs mere" + +#: ../templates/app.php:24 +msgid "INSTALL" +msgstr "INSTALLER" + +#: ../templates/app_noconn.php:6 ../templates/apps.php:6 +msgid "Apps Repository" +msgstr "Applikation arkiv" + +#: ../templates/app_noconn.php:7 +msgid "Cannot connect to apps repository" +msgstr "Kan ikke tilslutte applikations arkivet" + +#: ../templates/apps.php:13 ../templates/users.php:6 ../templates/users.php:20 +#: ../templates/users.php:50 +msgid "Name" +msgstr "Navn" + +#: ../templates/apps.php:14 +msgid "Modified" +msgstr "Ændret" + +#: ../templates/system.php:6 +msgid "Administration" +msgstr "Administration" + +#: ../templates/system.php:7 +msgid "System Settings" +msgstr "System indstillinger" + +#: ../templates/users.php:13 +msgid "Add user" +msgstr "Tilføj bruger" + +#: ../templates/users.php:21 +msgid "Password" +msgstr "Kodeord" + +#: ../templates/users.php:30 +msgid "Create user" +msgstr "Lav bruger" + +#: ../templates/users.php:40 ../templates/users.php:68 +msgid "remove" +msgstr "slet" + +#: ../templates/users.php:46 +msgid "Groups" +msgstr "Grupper" + +#: ../templates/users.php:58 +msgid "Create group" +msgstr "Lav gruppe" + +#: ../templates/users.php:94 +msgid "Force new password:" +msgstr "Tving ny adgangskode" + +#: ../templates/users.php:96 +msgid "Set" +msgstr "Indstil" + +#: ../templates/users.php:102 +msgid "Do you really want to delete user" +msgstr "Vil du virkelig slette denne bruger" + +#: ../templates/users.php:109 +msgid "Do you really want to delete group" +msgstr "Vil du virkelig slette denne gruppe" + diff --git a/l10n/da/core.po b/l10n/da/core.po new file mode 100644 index 0000000000..7529cc2a57 --- /dev/null +++ b/l10n/da/core.po @@ -0,0 +1,123 @@ +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Mikkel Bjerg Larsen , 2011. +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-19 23:27+0200\n" +"PO-Revision-Date: 2011-06-20 00:21+0200\n" +"Last-Translator: Mikkel Bjerg Larsen \n" +"Language-Team: American English \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.2\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: ../templates/404.php:15 +msgid "Error 404, Cloud not found" +msgstr "Fejl 404, Skyen kan ikke findes" + +#: ../templates/installation.php:6 +msgid "Welcome to ownCloud, your personnal cloud." +msgstr "Velkommen til ownCloud, Din personlige Sky." + +#: ../templates/installation.php:7 +msgid "To finish the installation, please follow the steps below." +msgstr "For at fuldføre installationen, følg venligst nedenstående trin" + +#: ../templates/installation.php:26 +msgid "Create an admin account." +msgstr "Lav en administrator konto." + +#: ../templates/installation.php:27 +msgid "Login:" +msgstr "Login:" + +#: ../templates/installation.php:28 +msgid "Password:" +msgstr "Kodeord:" + +#: ../templates/installation.php:31 +msgid "Advanced" +msgstr "Avanceret" + +#: ../templates/installation.php:34 +msgid "Set where to store the data." +msgstr "Indstil data mappe." + +#: ../templates/installation.php:35 +msgid "Data directory:" +msgstr "Data mappe:" + +#: ../templates/installation.php:39 +msgid "Configure your database." +msgstr "Konfigurer din database." + +#: ../templates/installation.php:43 +msgid "I will use a SQLite database. You have nothing to do!" +msgstr "Jeg vil benytte en SQLite database. Du skal ikke gøre noget!" + +#: ../templates/installation.php:46 +msgid "SQLite" +msgstr "SQLite" + +#: ../templates/installation.php:53 +msgid "I will use a MySQL database." +msgstr "Jeg vil benytte en MySQL database." + +#: ../templates/installation.php:59 +msgid "Host:" +msgstr "Host:" + +#: ../templates/installation.php:60 +msgid "Database name:" +msgstr "Database navn:" + +#: ../templates/installation.php:61 +msgid "Table prefix:" +msgstr "Tabel prefix:" + +#: ../templates/installation.php:62 +msgid "MySQL user login:" +msgstr "MySQL bruger login:" + +#: ../templates/installation.php:63 +msgid "MySQL user password:" +msgstr "MySQL bruger password:" + +#: ../templates/installation.php:68 +msgid "Finish setup" +msgstr "Afslut installation" + +#: ../templates/layout.guest.php:20 +msgid "" +"ownCloud is a personal cloud which runs " +"on your own server.

    " +msgstr "" +"ownCloud er din personly sky der køre på " +"din egen server.

    " + +#: ../templates/login.php:6 +msgid "Login failed!" +msgstr "Login misslykkedes" + +#: ../templates/logout.php:1 +msgid "You are logged out." +msgstr "Du er nu logget ud" + +#: ../templates/part.pagenavi.php:6 +msgid "prev" +msgstr "forrige" + +#: ../templates/part.pagenavi.php:26 +msgid "next" +msgstr "næste" + +#: ../templates/part.searchbox.php:3 +msgid "Search" +msgstr "Søg" + diff --git a/l10n/da/settings.po b/l10n/da/settings.po new file mode 100644 index 0000000000..8158261a3a --- /dev/null +++ b/l10n/da/settings.po @@ -0,0 +1,87 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-20 14:47+0200\n" +"PO-Revision-Date: 2011-06-20 15:16+0100\n" +"Last-Translator: Mikkel Bjerg Larsen \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../templates/index.php:3 +msgid "Account information" +msgstr "Konto information" + +#: ../templates/index.php:5 +msgid "You're currently using" +msgstr "Du udnytter i øjeblikket" + +#: ../templates/index.php:5 +msgid "of your" +msgstr "af din" + +#: ../templates/index.php:5 +msgid "space" +msgstr "plads" + +#: ../templates/index.php:11 +msgid "Change Password" +msgstr "Ændre adgangskode" + +#: ../templates/index.php:12 +msgid "Your password got changed" +msgstr "Din adgangskode er ændret" + +#: ../templates/index.php:15 +msgid "Old password:" +msgstr "Gamle adgangskode" + +#: ../templates/index.php:19 +msgid "New password" +msgstr "Ny adgangskode" + +#: ../templates/index.php:24 +msgid "Show new password" +msgstr "Vis den nye adgangskode" + +#: ../templates/index.php:34 +msgid "Language" +msgstr "Sprog" + +#: ../ajax/changepassword.php:13 +#: ../ajax/setlanguage.php:13 +msgid "Authentication error" +msgstr "Godkendelsesfejl" + +#: ../ajax/changepassword.php:19 +msgid "You have to enter the old and the new password!" +msgstr "Du skal indtaste din gamle og nye adganskode" + +#: ../ajax/changepassword.php:25 +msgid "Your old password is wrong!" +msgstr "Dit gamle adgangskode er forkert!" + +#: ../ajax/changepassword.php:31 +msgid "Password changed" +msgstr "Adgangskoden er ændret" + +#: ../ajax/changepassword.php:34 +msgid "Unable to change password" +msgstr "Kan ikke ændre din adgangskode" + +#: ../ajax/setlanguage.php:21 +msgid "Language changed" +msgstr "Sprog ændret" + +#: ../ajax/setlanguage.php:23 +msgid "Invalid request" +msgstr "Invalid forespørgsel" + From daa194cede61efe0df017a24c58acabd413e0042 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Mon, 20 Jun 2011 22:02:13 +0200 Subject: [PATCH 062/111] more i18n improvements --- l10n/da/admin.po | 19 ++++---- l10n/da/core.po | 21 ++++----- l10n/da/help.po | 26 +++++++++++ l10n/da/log.po | 17 ++++--- l10n/da/settings.po | 11 ++--- l10n/de/admin.po | 91 +++++++++++++++++++++++++++++++++++++ l10n/de/core.po | 2 +- l10n/de/help.po | 26 +++++++++++ l10n/de/log.po | 18 ++++---- l10n/de/settings.po | 86 +++++++++++++++++++++++++++++++++++ l10n/l10n.pl | 2 +- l10n/nl/admin.po | 91 +++++++++++++++++++++++++++++++++++++ l10n/nl/core.po | 18 ++++---- l10n/nl/help.po | 26 +++++++++++ l10n/nl/log.po | 2 +- l10n/nl/settings.po | 17 ++++--- l10n/templates/admin.pot | 4 +- l10n/templates/core.pot | 2 +- l10n/templates/help.pot | 26 +++++++++++ l10n/templates/log.pot | 2 +- l10n/templates/settings.pot | 2 +- 21 files changed, 436 insertions(+), 73 deletions(-) create mode 100644 l10n/da/help.po create mode 100644 l10n/de/admin.po create mode 100644 l10n/de/help.po create mode 100644 l10n/de/settings.po create mode 100644 l10n/nl/admin.po create mode 100644 l10n/nl/help.po create mode 100644 l10n/templates/help.pot diff --git a/l10n/da/admin.po b/l10n/da/admin.po index b083b8ecca..26f34e599a 100644 --- a/l10n/da/admin.po +++ b/l10n/da/admin.po @@ -1,21 +1,21 @@ +# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. # -# Mikkel Bjerg Larsen , 2011. +#, fuzzy msgid "" msgstr "" -"Project-Id-Version: \n" +"Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-06-19 23:32+0200\n" -"PO-Revision-Date: 2011-06-20 00:36+0200\n" -"Last-Translator: Mikkel Bjerg Larsen \n" -"Language-Team: American English \n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Lokalize 1.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../templates/app.php:22 msgid "read more" @@ -66,7 +66,7 @@ msgstr "Lav bruger" msgid "remove" msgstr "slet" -#: ../templates/users.php:46 +#: ../templates/users.php:46 ../templates/users.php:7 msgid "Groups" msgstr "Grupper" @@ -89,4 +89,3 @@ msgstr "Vil du virkelig slette denne bruger" #: ../templates/users.php:109 msgid "Do you really want to delete group" msgstr "Vil du virkelig slette denne gruppe" - diff --git a/l10n/da/core.po b/l10n/da/core.po index 7529cc2a57..b31b7b93db 100644 --- a/l10n/da/core.po +++ b/l10n/da/core.po @@ -1,21 +1,21 @@ +# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. # -# Mikkel Bjerg Larsen , 2011. +#, fuzzy msgid "" msgstr "" -"Project-Id-Version: \n" +"Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-06-19 23:27+0200\n" -"PO-Revision-Date: 2011-06-20 00:21+0200\n" -"Last-Translator: Mikkel Bjerg Larsen \n" -"Language-Team: American English \n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Lokalize 1.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../templates/404.php:15 msgid "Error 404, Cloud not found" @@ -98,8 +98,8 @@ msgid "" "ownCloud is a personal cloud which runs " "on your own server.

    " msgstr "" -"ownCloud er din personly sky der køre på " -"din egen server.

    " +"ownCloud er din personly sky der køre " +"på din egen server.

    " #: ../templates/login.php:6 msgid "Login failed!" @@ -120,4 +120,3 @@ msgstr "næste" #: ../templates/part.searchbox.php:3 msgid "Search" msgstr "Søg" - diff --git a/l10n/da/help.po b/l10n/da/help.po new file mode 100644 index 0000000000..cd06f9b10a --- /dev/null +++ b/l10n/da/help.po @@ -0,0 +1,26 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../templates/index.php:2 +msgid "Questions and Answers" +msgstr "" + +#: ../templates/index.php:21 +msgid "ASK A QUESTION" +msgstr "" diff --git a/l10n/da/log.po b/l10n/da/log.po index 5a88aedee9..4c81d97ea4 100644 --- a/l10n/da/log.po +++ b/l10n/da/log.po @@ -1,21 +1,21 @@ +# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. # -# Mikkel Bjerg Larsen , 2011. +#, fuzzy msgid "" msgstr "" -"Project-Id-Version: \n" +"Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-06-19 16:53+0200\n" -"PO-Revision-Date: 2011-06-19 21:09+0200\n" -"Last-Translator: Mikkel Bjerg Larsen \n" -"Language-Team: American English \n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Lokalize 1.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../templates/index.php:4 msgid "Filter:" @@ -64,4 +64,3 @@ msgstr "Hvornår" #: ../templates/index.php:45 msgid "Clear log entries before" msgstr "Slet log poster før" - diff --git a/l10n/da/settings.po b/l10n/da/settings.po index 8158261a3a..b00f26b052 100644 --- a/l10n/da/settings.po +++ b/l10n/da/settings.po @@ -3,13 +3,14 @@ # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # +#, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-06-20 14:47+0200\n" -"PO-Revision-Date: 2011-06-20 15:16+0100\n" -"Last-Translator: Mikkel Bjerg Larsen \n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" @@ -56,8 +57,7 @@ msgstr "Vis den nye adgangskode" msgid "Language" msgstr "Sprog" -#: ../ajax/changepassword.php:13 -#: ../ajax/setlanguage.php:13 +#: ../ajax/changepassword.php:13 ../ajax/setlanguage.php:13 msgid "Authentication error" msgstr "Godkendelsesfejl" @@ -84,4 +84,3 @@ msgstr "Sprog ændret" #: ../ajax/setlanguage.php:23 msgid "Invalid request" msgstr "Invalid forespørgsel" - diff --git a/l10n/de/admin.po b/l10n/de/admin.po new file mode 100644 index 0000000000..94134e4439 --- /dev/null +++ b/l10n/de/admin.po @@ -0,0 +1,91 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../templates/app.php:22 +msgid "read more" +msgstr "" + +#: ../templates/app.php:24 +msgid "INSTALL" +msgstr "" + +#: ../templates/app_noconn.php:6 ../templates/apps.php:6 +msgid "Apps Repository" +msgstr "" + +#: ../templates/app_noconn.php:7 +msgid "Cannot connect to apps repository" +msgstr "" + +#: ../templates/apps.php:13 ../templates/users.php:6 ../templates/users.php:20 +#: ../templates/users.php:50 +msgid "Name" +msgstr "" + +#: ../templates/apps.php:14 +msgid "Modified" +msgstr "" + +#: ../templates/system.php:6 +msgid "Administration" +msgstr "" + +#: ../templates/system.php:7 +msgid "System Settings" +msgstr "" + +#: ../templates/users.php:7 ../templates/users.php:46 +msgid "Groups" +msgstr "" + +#: ../templates/users.php:13 +msgid "Add user" +msgstr "" + +#: ../templates/users.php:21 +msgid "Password" +msgstr "" + +#: ../templates/users.php:30 +msgid "Create user" +msgstr "" + +#: ../templates/users.php:40 ../templates/users.php:68 +msgid "remove" +msgstr "" + +#: ../templates/users.php:58 +msgid "Create group" +msgstr "" + +#: ../templates/users.php:94 +msgid "Force new password:" +msgstr "" + +#: ../templates/users.php:96 +msgid "Set" +msgstr "" + +#: ../templates/users.php:102 +msgid "Do you really want to delete user" +msgstr "" + +#: ../templates/users.php:109 +msgid "Do you really want to delete group" +msgstr "" diff --git a/l10n/de/core.po b/l10n/de/core.po index 19b12ca4aa..8b232607d9 100644 --- a/l10n/de/core.po +++ b/l10n/de/core.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-06-19 23:27+0200\n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/l10n/de/help.po b/l10n/de/help.po new file mode 100644 index 0000000000..cd06f9b10a --- /dev/null +++ b/l10n/de/help.po @@ -0,0 +1,26 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../templates/index.php:2 +msgid "Questions and Answers" +msgstr "" + +#: ../templates/index.php:21 +msgid "ASK A QUESTION" +msgstr "" diff --git a/l10n/de/log.po b/l10n/de/log.po index a901754f1a..2bb4104b30 100644 --- a/l10n/de/log.po +++ b/l10n/de/log.po @@ -1,21 +1,21 @@ +# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. # -# Jakob Sack , 2011. +#, fuzzy msgid "" msgstr "" -"Project-Id-Version: \n" +"Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-06-19 16:44+0200\n" -"PO-Revision-Date: 2011-06-19 16:54+0200\n" -"Last-Translator: Jakob Sack \n" -"Language-Team: German \n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Lokalize 1.2\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" #: ../templates/index.php:4 msgid "Filter:" @@ -64,5 +64,3 @@ msgstr "Wann" #: ../templates/index.php:45 msgid "Clear log entries before" msgstr "Lösche Einträge vor dem" - - diff --git a/l10n/de/settings.po b/l10n/de/settings.po new file mode 100644 index 0000000000..55f3298f6f --- /dev/null +++ b/l10n/de/settings.po @@ -0,0 +1,86 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../templates/index.php:3 +msgid "Account information" +msgstr "" + +#: ../templates/index.php:5 +msgid "You're currently using" +msgstr "" + +#: ../templates/index.php:5 +msgid "of your" +msgstr "" + +#: ../templates/index.php:5 +msgid "space" +msgstr "" + +#: ../templates/index.php:11 +msgid "Change Password" +msgstr "" + +#: ../templates/index.php:12 +msgid "Your password got changed" +msgstr "" + +#: ../templates/index.php:15 +msgid "Old password:" +msgstr "" + +#: ../templates/index.php:19 +msgid "New password" +msgstr "" + +#: ../templates/index.php:24 +msgid "Show new password" +msgstr "" + +#: ../templates/index.php:34 +msgid "Language" +msgstr "" + +#: ../ajax/changepassword.php:13 ../ajax/setlanguage.php:13 +msgid "Authentication error" +msgstr "" + +#: ../ajax/changepassword.php:19 +msgid "You have to enter the old and the new password!" +msgstr "" + +#: ../ajax/changepassword.php:25 +msgid "Your old password is wrong!" +msgstr "" + +#: ../ajax/changepassword.php:31 +msgid "Password changed" +msgstr "" + +#: ../ajax/changepassword.php:34 +msgid "Unable to change password" +msgstr "" + +#: ../ajax/setlanguage.php:21 +msgid "Language changed" +msgstr "" + +#: ../ajax/setlanguage.php:23 +msgid "Invalid request" +msgstr "" diff --git a/l10n/l10n.pl b/l10n/l10n.pl index 5463e34e4d..f798e4e60e 100644 --- a/l10n/l10n.pl +++ b/l10n/l10n.pl @@ -90,7 +90,7 @@ elsif( $task eq 'write' ){ } # Write PHP file - open( OUT, ">$lang.php" ); + open( OUT, ">$language.php" ); print OUT ", YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../templates/app.php:22 +msgid "read more" +msgstr "" + +#: ../templates/app.php:24 +msgid "INSTALL" +msgstr "" + +#: ../templates/app_noconn.php:6 ../templates/apps.php:6 +msgid "Apps Repository" +msgstr "" + +#: ../templates/app_noconn.php:7 +msgid "Cannot connect to apps repository" +msgstr "" + +#: ../templates/apps.php:13 ../templates/users.php:6 ../templates/users.php:20 +#: ../templates/users.php:50 +msgid "Name" +msgstr "" + +#: ../templates/apps.php:14 +msgid "Modified" +msgstr "" + +#: ../templates/system.php:6 +msgid "Administration" +msgstr "" + +#: ../templates/system.php:7 +msgid "System Settings" +msgstr "" + +#: ../templates/users.php:7 ../templates/users.php:46 +msgid "Groups" +msgstr "" + +#: ../templates/users.php:13 +msgid "Add user" +msgstr "" + +#: ../templates/users.php:21 +msgid "Password" +msgstr "" + +#: ../templates/users.php:30 +msgid "Create user" +msgstr "" + +#: ../templates/users.php:40 ../templates/users.php:68 +msgid "remove" +msgstr "" + +#: ../templates/users.php:58 +msgid "Create group" +msgstr "" + +#: ../templates/users.php:94 +msgid "Force new password:" +msgstr "" + +#: ../templates/users.php:96 +msgid "Set" +msgstr "" + +#: ../templates/users.php:102 +msgid "Do you really want to delete user" +msgstr "" + +#: ../templates/users.php:109 +msgid "Do you really want to delete group" +msgstr "" diff --git a/l10n/nl/core.po b/l10n/nl/core.po index 7a819e81dd..9aa3851d86 100644 --- a/l10n/nl/core.po +++ b/l10n/nl/core.po @@ -1,21 +1,21 @@ +# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. # -# Robin Appelman , 2011. +#, fuzzy msgid "" msgstr "" -"Project-Id-Version: \n" +"Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-06-19 23:27+0200\n" -"PO-Revision-Date: 2011-06-20 14:19+0200\n" -"Last-Translator: Robin Appelman \n" -"Language-Team: American English \n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Lokalize 1.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../templates/404.php:15 msgid "Error 404, Cloud not found" @@ -121,5 +121,3 @@ msgstr "volgende" #: ../templates/part.searchbox.php:3 msgid "Search" msgstr "Zoeken" - - diff --git a/l10n/nl/help.po b/l10n/nl/help.po new file mode 100644 index 0000000000..cd06f9b10a --- /dev/null +++ b/l10n/nl/help.po @@ -0,0 +1,26 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../templates/index.php:2 +msgid "Questions and Answers" +msgstr "" + +#: ../templates/index.php:21 +msgid "ASK A QUESTION" +msgstr "" diff --git a/l10n/nl/log.po b/l10n/nl/log.po index 2da2355a3a..c73912a626 100644 --- a/l10n/nl/log.po +++ b/l10n/nl/log.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-06-19 16:53+0200\n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/l10n/nl/settings.po b/l10n/nl/settings.po index 5b38f84b77..11c325d5fc 100644 --- a/l10n/nl/settings.po +++ b/l10n/nl/settings.po @@ -1,21 +1,21 @@ +# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. # -# Robin Appelman , 2011. +#, fuzzy msgid "" msgstr "" -"Project-Id-Version: \n" +"Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-06-20 14:47+0200\n" -"PO-Revision-Date: 2011-06-20 14:48+0200\n" -"Last-Translator: Robin Appelman \n" -"Language-Team: American English \n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Lokalize 1.2\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../templates/index.php:3 msgid "Account information" @@ -84,4 +84,3 @@ msgstr "Taal aangepast" #: ../ajax/setlanguage.php:23 msgid "Invalid request" msgstr "Ongeldige aanvraag" - diff --git a/l10n/templates/admin.pot b/l10n/templates/admin.pot index c30a445431..c683082b6f 100644 --- a/l10n/templates/admin.pot +++ b/l10n/templates/admin.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-06-19 23:32+0200\n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -66,7 +66,7 @@ msgstr "" msgid "remove" msgstr "" -#: ../templates/users.php:46 +#: ../templates/users.php:46 ../templates/users.php:7 msgid "Groups" msgstr "" diff --git a/l10n/templates/core.pot b/l10n/templates/core.pot index 591a1c724e..ef4f80b580 100644 --- a/l10n/templates/core.pot +++ b/l10n/templates/core.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-06-19 23:27+0200\n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/l10n/templates/help.pot b/l10n/templates/help.pot new file mode 100644 index 0000000000..cd06f9b10a --- /dev/null +++ b/l10n/templates/help.pot @@ -0,0 +1,26 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../templates/index.php:2 +msgid "Questions and Answers" +msgstr "" + +#: ../templates/index.php:21 +msgid "ASK A QUESTION" +msgstr "" diff --git a/l10n/templates/log.pot b/l10n/templates/log.pot index 2da2355a3a..c73912a626 100644 --- a/l10n/templates/log.pot +++ b/l10n/templates/log.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-06-19 16:53+0200\n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/l10n/templates/settings.pot b/l10n/templates/settings.pot index 705d583ee7..55f3298f6f 100644 --- a/l10n/templates/settings.pot +++ b/l10n/templates/settings.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-06-20 14:47+0200\n" +"POT-Creation-Date: 2011-06-20 22:00+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" From ef3386c5f8774a8959b93332f7fc388824a93385 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Mon, 20 Jun 2011 22:08:44 +0200 Subject: [PATCH 063/111] All translations should be in the new system --- admin/l10n/da.php | 20 ++++++++++++++++++++ core/l10n/da.php | 27 +++++++++++++++++++++++++++ l10n/l10n.pl | 1 + log/l10n/nl.php | 13 +------------ settings/l10n/da.php | 19 +++++++++++++++++++ 5 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 admin/l10n/da.php create mode 100644 core/l10n/da.php create mode 100644 settings/l10n/da.php diff --git a/admin/l10n/da.php b/admin/l10n/da.php new file mode 100644 index 0000000000..4601616efc --- /dev/null +++ b/admin/l10n/da.php @@ -0,0 +1,20 @@ + "slet", +"Password" => "Kodeord", +"Administration" => "Administration", +"Name" => "Navn", +"Do you really want to delete group" => "Vil du virkelig slette denne gruppe", +"System Settings" => "System indstillinger", +"Create group" => "Lav gruppe", +"Modified" => "Ændret", +"read more" => "læs mere", +"INSTALL" => "INSTALLER", +"Set" => "Indstil", +"Apps Repository" => "Applikation arkiv", +"Force new password:" => "Tving ny adgangskode", +"Add user" => "Tilføj bruger", +"Groups" => "Grupper", +"Cannot connect to apps repository" => "Kan ikke tilslutte applikations arkivet", +"Do you really want to delete user" => "Vil du virkelig slette denne bruger", +"Create user" => "Lav bruger" +); diff --git a/core/l10n/da.php b/core/l10n/da.php new file mode 100644 index 0000000000..d7aa3855d4 --- /dev/null +++ b/core/l10n/da.php @@ -0,0 +1,27 @@ +admin account." => "Lav en administrator konto.", +"Welcome to ownCloud, your personnal cloud." => "Velkommen til ownCloud, Din personlige Sky.", +"You are logged out." => "Du er nu logget ud", +"MySQL user password:" => "MySQL bruger password:", +"Error 404, Cloud not found" => "Fejl 404, Skyen kan ikke findes", +"Database name:" => "Database navn:", +"Set where to store the data." => "Indstil data mappe.", +"Advanced" => "Avanceret", +"To finish the installation, please follow the steps below." => "For at fuldføre installationen, følg venligst nedenstående trin", +"Host:" => "Host:", +"Table prefix:" => "Tabel prefix:", +"prev" => "forrige", +"Login:" => "Login:", +"Login failed!" => "Login misslykkedes", +"I will use a MySQL database." => "Jeg vil benytte en MySQL database.", +"next" => "næste", +"Password:" => "Kodeord:", +"SQLite" => "SQLite", +"MySQL user login:" => "MySQL bruger login:", +"ownCloud is a personal cloud which runs on your own server.

    " => "ownCloud er din personly sky der køre på din egen server.

    ", +"Search" => "Søg", +"Data directory:" => "Data mappe:", +"Finish setup" => "Afslut installation", +"Configure your database." => "Konfigurer din database.", +"I will use a SQLite database. You have nothing to do!" => "Jeg vil benytte en SQLite database. Du skal ikke gøre noget!" +); diff --git a/l10n/l10n.pl b/l10n/l10n.pl index f798e4e60e..a5fab01a2f 100644 --- a/l10n/l10n.pl +++ b/l10n/l10n.pl @@ -88,6 +88,7 @@ elsif( $task eq 'write' ){ next if $hash->{$key}->msgstr() eq '""'; push( @strings, $hash->{$key}->msgid()." => ".$hash->{$key}->msgstr()); } + next if $#strings == -1; # Skip empty files # Write PHP file open( OUT, ">$language.php" ); diff --git a/log/l10n/nl.php b/log/l10n/nl.php index 1eab84ef15..34178b6863 100644 --- a/log/l10n/nl.php +++ b/log/l10n/nl.php @@ -1,14 +1,3 @@ "Laat", -"Uploads" => "Uploads", -"Filter:" => "Filter: ", -"Logouts" => "Afmeldingen", -"Logins" => "Aanmeldingen", -"When" => "Wanneer", -"Downloads" => "Downloades", -"Clear log entries before" => "Verwijder logboek elementen ouder dan", -"What" => "Wat", -"entries per page." => "elementen per pagina zien.", -"Creations" => "Creaties", -"Deletions" => "Verwijderingen" + ); diff --git a/settings/l10n/da.php b/settings/l10n/da.php new file mode 100644 index 0000000000..4d403042e1 --- /dev/null +++ b/settings/l10n/da.php @@ -0,0 +1,19 @@ + "plads", +"You're currently using" => "Du udnytter i øjeblikket", +"Unable to change password" => "Kan ikke ændre din adgangskode", +"New password" => "Ny adgangskode", +"Authentication error" => "Godkendelsesfejl", +"Your password got changed" => "Din adgangskode er ændret", +"Language changed" => "Sprog ændret", +"Invalid request" => "Invalid forespørgsel", +"Account information" => "Konto information", +"of your" => "af din", +"Password changed" => "Adgangskoden er ændret", +"Old password:" => "Gamle adgangskode", +"Your old password is wrong!" => "Dit gamle adgangskode er forkert!", +"Show new password" => "Vis den nye adgangskode", +"You have to enter the old and the new password!" => "Du skal indtaste din gamle og nye adganskode", +"Language" => "Sprog", +"Change Password" => "Ændre adgangskode" +); From f72db005b565505b7754915de9b10f636669f9cf Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Mon, 20 Jun 2011 22:22:17 +0200 Subject: [PATCH 064/111] Keep order when creating php files --- l10n/l10n.pl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/l10n/l10n.pl b/l10n/l10n.pl index a5fab01a2f..88abc821e9 100644 --- a/l10n/l10n.pl +++ b/l10n/l10n.pl @@ -30,6 +30,10 @@ my $place = '..'; die( "Usuage: l10n.pl task\ntask: read, write\n") unless $task && $place; +# Our current position +my $whereami = cwd(); +die( "Program must be executed in a l10n-folder called 'l10n'" ) unless $whereami =~ m/\/l10n$/; + # Where are i18n-files? my @dirs = crawl( $place ); @@ -44,9 +48,6 @@ foreach my $i ( @files ){ push( @languages, $i ) if -d $i && substr( $i, 0, 1 ) ne '.'; } -# Our current position -my $whereami = cwd(); - if( $task eq 'read' ){ foreach my $dir ( @dirs ){ my @temp = split( /\//, $dir ); @@ -79,14 +80,13 @@ elsif( $task eq 'write' ){ my $input = "${whereami}/$language/$app.po"; next unless -e $input; - my $hash = Locale::PO->load_file_ashash( $input ); - + my $array = Locale::PO->load_file_asarray( $input ); # Create array my @strings = (); - foreach my $key ( keys( %{$hash} )){ - next if $key eq '""'; - next if $hash->{$key}->msgstr() eq '""'; - push( @strings, $hash->{$key}->msgid()." => ".$hash->{$key}->msgstr()); + foreach my $string ( @{$array} ){ + next if $string->msgid() eq '""'; + next if $string->msgstr() eq '""'; + push( @strings, $string->msgid()." => ".$string->msgstr()); } next if $#strings == -1; # Skip empty files From fb7f00edbca5b1892cdfc04358d6658e986a877c Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Mon, 20 Jun 2011 22:22:58 +0200 Subject: [PATCH 065/111] l10nlist.shuffle ;-) --- admin/l10n/da.php | 26 +++++++++++++------------- core/l10n/da.php | 38 +++++++++++++++++++------------------- core/l10n/de.php | 12 ++++++------ core/l10n/nl.php | 38 +++++++++++++++++++------------------- log/l10n/da.php | 16 ++++++++-------- log/l10n/de.php | 16 ++++++++-------- settings/l10n/da.php | 24 ++++++++++++------------ settings/l10n/nl.php | 24 ++++++++++++------------ 8 files changed, 97 insertions(+), 97 deletions(-) diff --git a/admin/l10n/da.php b/admin/l10n/da.php index 4601616efc..f405a358cb 100644 --- a/admin/l10n/da.php +++ b/admin/l10n/da.php @@ -1,20 +1,20 @@ "slet", -"Password" => "Kodeord", -"Administration" => "Administration", -"Name" => "Navn", -"Do you really want to delete group" => "Vil du virkelig slette denne gruppe", -"System Settings" => "System indstillinger", -"Create group" => "Lav gruppe", -"Modified" => "Ændret", "read more" => "læs mere", "INSTALL" => "INSTALLER", -"Set" => "Indstil", "Apps Repository" => "Applikation arkiv", -"Force new password:" => "Tving ny adgangskode", -"Add user" => "Tilføj bruger", -"Groups" => "Grupper", "Cannot connect to apps repository" => "Kan ikke tilslutte applikations arkivet", +"Name" => "Navn", +"Modified" => "Ændret", +"Administration" => "Administration", +"System Settings" => "System indstillinger", +"Add user" => "Tilføj bruger", +"Password" => "Kodeord", +"Create user" => "Lav bruger", +"remove" => "slet", +"Groups" => "Grupper", +"Create group" => "Lav gruppe", +"Force new password:" => "Tving ny adgangskode", +"Set" => "Indstil", "Do you really want to delete user" => "Vil du virkelig slette denne bruger", -"Create user" => "Lav bruger" +"Do you really want to delete group" => "Vil du virkelig slette denne gruppe" ); diff --git a/core/l10n/da.php b/core/l10n/da.php index d7aa3855d4..54a11ddba8 100644 --- a/core/l10n/da.php +++ b/core/l10n/da.php @@ -1,27 +1,27 @@ admin account." => "Lav en administrator konto.", -"Welcome to ownCloud, your personnal cloud." => "Velkommen til ownCloud, Din personlige Sky.", -"You are logged out." => "Du er nu logget ud", -"MySQL user password:" => "MySQL bruger password:", "Error 404, Cloud not found" => "Fejl 404, Skyen kan ikke findes", -"Database name:" => "Database navn:", -"Set where to store the data." => "Indstil data mappe.", -"Advanced" => "Avanceret", +"Welcome to ownCloud, your personnal cloud." => "Velkommen til ownCloud, Din personlige Sky.", "To finish the installation, please follow the steps below." => "For at fuldføre installationen, følg venligst nedenstående trin", -"Host:" => "Host:", -"Table prefix:" => "Tabel prefix:", -"prev" => "forrige", +"Create an admin account." => "Lav en administrator konto.", "Login:" => "Login:", -"Login failed!" => "Login misslykkedes", -"I will use a MySQL database." => "Jeg vil benytte en MySQL database.", -"next" => "næste", "Password:" => "Kodeord:", -"SQLite" => "SQLite", -"MySQL user login:" => "MySQL bruger login:", -"ownCloud is a personal cloud which runs on your own server.

    " => "ownCloud er din personly sky der køre på din egen server.

    ", -"Search" => "Søg", +"Advanced" => "Avanceret", +"Set where to store the data." => "Indstil data mappe.", "Data directory:" => "Data mappe:", -"Finish setup" => "Afslut installation", "Configure your database." => "Konfigurer din database.", -"I will use a SQLite database. You have nothing to do!" => "Jeg vil benytte en SQLite database. Du skal ikke gøre noget!" +"I will use a SQLite database. You have nothing to do!" => "Jeg vil benytte en SQLite database. Du skal ikke gøre noget!", +"SQLite" => "SQLite", +"I will use a MySQL database." => "Jeg vil benytte en MySQL database.", +"Host:" => "Host:", +"Database name:" => "Database navn:", +"Table prefix:" => "Tabel prefix:", +"MySQL user login:" => "MySQL bruger login:", +"MySQL user password:" => "MySQL bruger password:", +"Finish setup" => "Afslut installation", +"ownCloud is a personal cloud which runs on your own server.

    " => "ownCloud er din personly sky der køre på din egen server.

    ", +"Login failed!" => "Login misslykkedes", +"You are logged out." => "Du er nu logget ud", +"prev" => "forrige", +"next" => "næste", +"Search" => "Søg" ); diff --git a/core/l10n/de.php b/core/l10n/de.php index fb00345e69..cd89558a4d 100644 --- a/core/l10n/de.php +++ b/core/l10n/de.php @@ -1,11 +1,11 @@ "Sie wurden abgemeldet.", -"Set where to store the data." => "Speicherort der Daten", -"Advanced" => "Erweitert", -"prev" => "zurück", "Login:" => "Benutzername:", -"Login failed!" => "Anmeldung Fehlgeschlagen!", -"next" => "weiter", "Password:" => "Passwort:", +"Advanced" => "Erweitert", +"Set where to store the data." => "Speicherort der Daten", +"Login failed!" => "Anmeldung Fehlgeschlagen!", +"You are logged out." => "Sie wurden abgemeldet.", +"prev" => "zurück", +"next" => "weiter", "Search" => "Suchen" ); diff --git a/core/l10n/nl.php b/core/l10n/nl.php index 712444c800..bbffcd0831 100644 --- a/core/l10n/nl.php +++ b/core/l10n/nl.php @@ -1,27 +1,27 @@ admin account." => "Maak een administrator account. aan", -"Welcome to ownCloud, your personnal cloud." => "Welkom by ownCloud, jouw persoonlijke cloud", -"You are logged out." => "Je bent afgemend.", -"MySQL user password:" => "MySQL wachtwoord", "Error 404, Cloud not found" => "Fout 404, Cloud niet gevonden.", -"Database name:" => "Database naam:", -"Set where to store the data." => "Bepaal waar de gegevens opgeslagen moeten woorden.", -"Advanced" => "Geavanceerd", +"Welcome to ownCloud, your personnal cloud." => "Welkom by ownCloud, jouw persoonlijke cloud", "To finish the installation, please follow the steps below." => "Volg de volgende stappen om de instalatie af te ronden.", -"Host:" => "Host:", -"Table prefix:" => "Voorvoegsel voor tabelnaamen:", -"prev" => "vorige", +"Create an admin account." => "Maak een administrator account. aan", "Login:" => "Gebruikersnaam:", -"Login failed!" => "Aanmelden mislukt.", -"I will use a MySQL database." => "Er zal een MySQL database gebruikt woorden.", -"next" => "volgende", "Password:" => "Wachtwoord:", -"SQLite" => "SQLite", -"MySQL user login:" => "MySQL gebruikers naam.", -"ownCloud is a personal cloud which runs on your own server.

    " => "ownCloud is een persoonlijke cloud die op je eigen server draait.

    ", -"Search" => "Zoeken", +"Advanced" => "Geavanceerd", +"Set where to store the data." => "Bepaal waar de gegevens opgeslagen moeten woorden.", "Data directory:" => "Gegevens map:", -"Finish setup" => "Instalatie afronden", "Configure your database." => "Stel de database in.", -"I will use a SQLite database. You have nothing to do!" => "Er zan een SQLite database gebruikt woorden, je hoeft niks in te stellen." +"I will use a SQLite database. You have nothing to do!" => "Er zan een SQLite database gebruikt woorden, je hoeft niks in te stellen.", +"SQLite" => "SQLite", +"I will use a MySQL database." => "Er zal een MySQL database gebruikt woorden.", +"Host:" => "Host:", +"Database name:" => "Database naam:", +"Table prefix:" => "Voorvoegsel voor tabelnaamen:", +"MySQL user login:" => "MySQL gebruikers naam.", +"MySQL user password:" => "MySQL wachtwoord", +"Finish setup" => "Instalatie afronden", +"ownCloud is a personal cloud which runs on your own server.

    " => "ownCloud is een persoonlijke cloud die op je eigen server draait.

    ", +"Login failed!" => "Aanmelden mislukt.", +"You are logged out." => "Je bent afgemend.", +"prev" => "vorige", +"next" => "volgende", +"Search" => "Zoeken" ); diff --git a/log/l10n/da.php b/log/l10n/da.php index 8ab99277bf..8fbfae67a6 100644 --- a/log/l10n/da.php +++ b/log/l10n/da.php @@ -1,14 +1,14 @@ "Vis:", -"Uploads" => "Uploads", "Filter:" => "Filter:", -"Logouts" => "Logouts", "Logins" => "Logins", -"When" => "Hvornår", +"Logouts" => "Logouts", "Downloads" => "Downloads", -"Clear log entries before" => "Slet log poster før", -"What" => "Hvilket", -"entries per page." => "poster pr side.", +"Uploads" => "Uploads", "Creations" => "Oprettelser", -"Deletions" => "Sletninger" +"Deletions" => "Sletninger", +"Show:" => "Vis:", +"entries per page." => "poster pr side.", +"What" => "Hvilket", +"When" => "Hvornår", +"Clear log entries before" => "Slet log poster før" ); diff --git a/log/l10n/de.php b/log/l10n/de.php index 5cfc3486af..9cf804d6cf 100644 --- a/log/l10n/de.php +++ b/log/l10n/de.php @@ -1,14 +1,14 @@ "Zeige", -"Uploads" => "Uploads", "Filter:" => "Filter:", -"Logouts" => "Abmeldungen", "Logins" => "Anmeldungen", -"When" => "Wann", +"Logouts" => "Abmeldungen", "Downloads" => "Downloads", -"Clear log entries before" => "Lösche Einträge vor dem", -"What" => "Was", -"entries per page." => "Einträge pro Seite", +"Uploads" => "Uploads", "Creations" => "Erstellungen", -"Deletions" => "Löschungen" +"Deletions" => "Löschungen", +"Show:" => "Zeige", +"entries per page." => "Einträge pro Seite", +"What" => "Was", +"When" => "Wann", +"Clear log entries before" => "Lösche Einträge vor dem" ); diff --git a/settings/l10n/da.php b/settings/l10n/da.php index 4d403042e1..1c0b87f867 100644 --- a/settings/l10n/da.php +++ b/settings/l10n/da.php @@ -1,19 +1,19 @@ "plads", -"You're currently using" => "Du udnytter i øjeblikket", -"Unable to change password" => "Kan ikke ændre din adgangskode", -"New password" => "Ny adgangskode", -"Authentication error" => "Godkendelsesfejl", -"Your password got changed" => "Din adgangskode er ændret", -"Language changed" => "Sprog ændret", -"Invalid request" => "Invalid forespørgsel", "Account information" => "Konto information", +"You're currently using" => "Du udnytter i øjeblikket", "of your" => "af din", -"Password changed" => "Adgangskoden er ændret", +"space" => "plads", +"Change Password" => "Ændre adgangskode", +"Your password got changed" => "Din adgangskode er ændret", "Old password:" => "Gamle adgangskode", -"Your old password is wrong!" => "Dit gamle adgangskode er forkert!", +"New password" => "Ny adgangskode", "Show new password" => "Vis den nye adgangskode", -"You have to enter the old and the new password!" => "Du skal indtaste din gamle og nye adganskode", "Language" => "Sprog", -"Change Password" => "Ændre adgangskode" +"Authentication error" => "Godkendelsesfejl", +"You have to enter the old and the new password!" => "Du skal indtaste din gamle og nye adganskode", +"Your old password is wrong!" => "Dit gamle adgangskode er forkert!", +"Password changed" => "Adgangskoden er ændret", +"Unable to change password" => "Kan ikke ændre din adgangskode", +"Language changed" => "Sprog ændret", +"Invalid request" => "Invalid forespørgsel" ); diff --git a/settings/l10n/nl.php b/settings/l10n/nl.php index d673252155..f05e7cc7c2 100644 --- a/settings/l10n/nl.php +++ b/settings/l10n/nl.php @@ -1,19 +1,19 @@ "beschikbare ruimte.", -"You're currently using" => "Je gebruikt momenteel", -"Unable to change password" => "Wachtwoord aanpassen is niet mogenlijk", -"New password" => "Nieuw wachtwoord", -"Authentication error" => "Authenticatie fout.", -"Your password got changed" => "Je wachtwoord is aangepast", -"Language changed" => "Taal aangepast", -"Invalid request" => "Ongeldige aanvraag", "Account information" => "Gebruiks gegevens", +"You're currently using" => "Je gebruikt momenteel", "of your" => "van de", -"Password changed" => "Wachtwoord aangepast", +"space" => "beschikbare ruimte.", +"Change Password" => "Wachtwoord aanpassen", +"Your password got changed" => "Je wachtwoord is aangepast", "Old password:" => "Oud wachtwoord:", -"Your old password is wrong!" => "Het oude wachtwoord is verkeerd.", +"New password" => "Nieuw wachtwoord", "Show new password" => "Toon nieuw wachtwoord", -"You have to enter the old and the new password!" => "Je moet het oude en nieuwe wachtwoord invullen.", "Language" => "Taal", -"Change Password" => "Wachtwoord aanpassen" +"Authentication error" => "Authenticatie fout.", +"You have to enter the old and the new password!" => "Je moet het oude en nieuwe wachtwoord invullen.", +"Your old password is wrong!" => "Het oude wachtwoord is verkeerd.", +"Password changed" => "Wachtwoord aangepast", +"Unable to change password" => "Wachtwoord aanpassen is niet mogenlijk", +"Language changed" => "Taal aangepast", +"Invalid request" => "Ongeldige aanvraag" ); From bcfd1ff304a688823d60cf5a289d625e9501fff1 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Mon, 20 Jun 2011 22:57:28 +0200 Subject: [PATCH 066/111] Adapt javascript-i18n to latest changes --- core/ajax/translations.php | 2 +- core/js/js.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/ajax/translations.php b/core/ajax/translations.php index a1e84487f6..adaf7dcb75 100644 --- a/core/ajax/translations.php +++ b/core/ajax/translations.php @@ -22,7 +22,7 @@ */ // Init owncloud -require_once('../lib/base.php'); +require_once('../../lib/base.php'); $app = $_POST["app"]; diff --git a/core/js/js.js b/core/js/js.js index 7e44b7ce6d..9a14cb8ed4 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1,7 +1,7 @@ var _l10ncache = {}; function t(app,text){ if( !( app in _l10ncache )){ - $.post( oc_webroot+'/l10n/javascript.php', {'app': app}, function(jsondata){ + $.post( oc_webroot+'/core/ajax/translations.php', {'app': app}, function(jsondata){ _l10ncache[app] = jsondata.data; }); From 2d5b4dfa10fc852cd25d2c309fbd7764992ff0d8 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 21 Jun 2011 15:10:33 +0200 Subject: [PATCH 067/111] update dutch translations --- admin/l10n/nl.php | 20 ++++++++++++++++++ help/l10n/nl.php | 4 ++++ l10n/nl/admin.po | 53 ++++++++++++++++++++++++----------------------- l10n/nl/help.po | 21 ++++++++++--------- l10n/nl/log.po | 41 ++++++++++++++++++------------------ log/l10n/nl.php | 13 +++++++++++- 6 files changed, 95 insertions(+), 57 deletions(-) create mode 100644 admin/l10n/nl.php create mode 100644 help/l10n/nl.php diff --git a/admin/l10n/nl.php b/admin/l10n/nl.php new file mode 100644 index 0000000000..a762559e08 --- /dev/null +++ b/admin/l10n/nl.php @@ -0,0 +1,20 @@ + "Meer informatie", +"INSTALL" => "Instaleer", +"Apps Repository" => "Applicatie Database", +"Cannot connect to apps repository" => "Kan geen verbinding maken met de applicatie database", +"Name" => "Naam", +"Modified" => "Laatst aangepast", +"Administration" => "Administratie", +"System Settings" => "Systeem Instellingen", +"Groups" => "Groepen", +"Add user" => "Voeg gebruiker toe", +"Password" => "Wachtwoord", +"Create user" => "Maak gebruiker aan", +"remove" => "verwijder", +"Create group" => "Maak groep aan", +"Force new password:" => "Forceer nieuw wachtwoord:", +"Set" => "Ok", +"Do you really want to delete user" => "Weet je zeker dat je deze gebruiker wil verwijderen", +"Do you really want to delete group" => "Weet je zeker dat je deze groep wil verwijderen" +); diff --git a/help/l10n/nl.php b/help/l10n/nl.php new file mode 100644 index 0000000000..11a28894c7 --- /dev/null +++ b/help/l10n/nl.php @@ -0,0 +1,4 @@ + "Vraag en Antwoord", +"ASK A QUESTION" => "Stel een vraag" +); diff --git a/l10n/nl/admin.po b/l10n/nl/admin.po index 94134e4439..2feccb46b9 100644 --- a/l10n/nl/admin.po +++ b/l10n/nl/admin.po @@ -1,91 +1,92 @@ -# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. # -#, fuzzy +# Robin Appelman , 2011. msgid "" msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" +"Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2011-06-20 22:00+0200\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"PO-Revision-Date: 2011-06-21 15:00+0200\n" +"Last-Translator: Robin Appelman \n" +"Language-Team: American English \n" "Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.2\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../templates/app.php:22 msgid "read more" -msgstr "" +msgstr "Meer informatie" #: ../templates/app.php:24 msgid "INSTALL" -msgstr "" +msgstr "Instaleer" #: ../templates/app_noconn.php:6 ../templates/apps.php:6 msgid "Apps Repository" -msgstr "" +msgstr "Applicatie Database" #: ../templates/app_noconn.php:7 msgid "Cannot connect to apps repository" -msgstr "" +msgstr "Kan geen verbinding maken met de applicatie database" #: ../templates/apps.php:13 ../templates/users.php:6 ../templates/users.php:20 #: ../templates/users.php:50 msgid "Name" -msgstr "" +msgstr "Naam" #: ../templates/apps.php:14 msgid "Modified" -msgstr "" +msgstr "Laatst aangepast" #: ../templates/system.php:6 msgid "Administration" -msgstr "" +msgstr "Administratie" #: ../templates/system.php:7 msgid "System Settings" -msgstr "" +msgstr "Systeem Instellingen" #: ../templates/users.php:7 ../templates/users.php:46 msgid "Groups" -msgstr "" +msgstr "Groepen" #: ../templates/users.php:13 msgid "Add user" -msgstr "" +msgstr "Voeg gebruiker toe" #: ../templates/users.php:21 msgid "Password" -msgstr "" +msgstr "Wachtwoord" #: ../templates/users.php:30 msgid "Create user" -msgstr "" +msgstr "Maak gebruiker aan" #: ../templates/users.php:40 ../templates/users.php:68 msgid "remove" -msgstr "" +msgstr "verwijder" #: ../templates/users.php:58 msgid "Create group" -msgstr "" +msgstr "Maak groep aan" #: ../templates/users.php:94 msgid "Force new password:" -msgstr "" +msgstr "Forceer nieuw wachtwoord:" #: ../templates/users.php:96 msgid "Set" -msgstr "" +msgstr "Ok" #: ../templates/users.php:102 msgid "Do you really want to delete user" -msgstr "" +msgstr "Weet je zeker dat je deze gebruiker wil verwijderen" #: ../templates/users.php:109 msgid "Do you really want to delete group" -msgstr "" +msgstr "Weet je zeker dat je deze groep wil verwijderen" + diff --git a/l10n/nl/help.po b/l10n/nl/help.po index cd06f9b10a..b1f1f4bc44 100644 --- a/l10n/nl/help.po +++ b/l10n/nl/help.po @@ -1,26 +1,27 @@ -# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. # -#, fuzzy +# Robin Appelman , 2011. msgid "" msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" +"Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2011-06-20 22:00+0200\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"PO-Revision-Date: 2011-06-21 15:03+0200\n" +"Last-Translator: Robin Appelman \n" +"Language-Team: Dutch <>\n" "Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.2\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../templates/index.php:2 msgid "Questions and Answers" -msgstr "" +msgstr "Vraag en Antwoord" #: ../templates/index.php:21 msgid "ASK A QUESTION" -msgstr "" +msgstr "Stel een vraag" + diff --git a/l10n/nl/log.po b/l10n/nl/log.po index c73912a626..a071faeccf 100644 --- a/l10n/nl/log.po +++ b/l10n/nl/log.po @@ -1,66 +1,67 @@ -# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. # -#, fuzzy +# Robin Appelman , 2011. msgid "" msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" +"Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2011-06-20 22:00+0200\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"PO-Revision-Date: 2011-06-21 15:01+0200\n" +"Last-Translator: Robin Appelman \n" +"Language-Team: American English \n" "Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.2\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" #: ../templates/index.php:4 msgid "Filter:" -msgstr "" +msgstr "Filter:" #: ../templates/index.php:7 msgid "Logins" -msgstr "" +msgstr "Aanmeldingen" #: ../templates/index.php:8 msgid "Logouts" -msgstr "" +msgstr "Afmeldingen" #: ../templates/index.php:9 msgid "Downloads" -msgstr "" +msgstr "Downloads" #: ../templates/index.php:10 msgid "Uploads" -msgstr "" +msgstr "Uploads" #: ../templates/index.php:11 msgid "Creations" -msgstr "" +msgstr "Creaties" #: ../templates/index.php:12 msgid "Deletions" -msgstr "" +msgstr "Verwijderingen" #: ../templates/index.php:15 msgid "Show:" -msgstr "" +msgstr "Laat" #: ../templates/index.php:16 msgid "entries per page." -msgstr "" +msgstr "resulaten per pagina zien" #: ../templates/index.php:26 msgid "What" -msgstr "" +msgstr "Wat" #: ../templates/index.php:27 msgid "When" -msgstr "" +msgstr "Waneer" #: ../templates/index.php:45 msgid "Clear log entries before" -msgstr "" +msgstr "Verwijder logboek element ouder dan" + diff --git a/log/l10n/nl.php b/log/l10n/nl.php index 34178b6863..59e9fa04d2 100644 --- a/log/l10n/nl.php +++ b/log/l10n/nl.php @@ -1,3 +1,14 @@ "Filter:", +"Logins" => "Aanmeldingen", +"Logouts" => "Afmeldingen", +"Downloads" => "Downloads", +"Uploads" => "Uploads", +"Creations" => "Creaties", +"Deletions" => "Verwijderingen", +"Show:" => "Laat", +"entries per page." => "resulaten per pagina zien", +"What" => "Wat", +"When" => "Waneer", +"Clear log entries before" => "Verwijder logboek element ouder dan" ); From 34de2cacd137a42bb7705d869aecdc938993e8ff Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Tue, 21 Jun 2011 16:01:47 +0200 Subject: [PATCH 068/111] Updated danish translation --- admin/l10n/da.php | 6 +++--- core/l10n/da.php | 4 ++-- help/l10n/da.php | 4 ++++ l10n/da/admin.po | 25 +++++++++++++++---------- l10n/da/core.po | 18 +++++++----------- l10n/da/help.po | 12 ++++++------ l10n/da/settings.po | 13 +++++++------ settings/l10n/da.php | 4 ++-- 8 files changed, 46 insertions(+), 40 deletions(-) create mode 100644 help/l10n/da.php diff --git a/admin/l10n/da.php b/admin/l10n/da.php index f405a358cb..477dd9db9e 100644 --- a/admin/l10n/da.php +++ b/admin/l10n/da.php @@ -2,7 +2,7 @@ "read more" => "læs mere", "INSTALL" => "INSTALLER", "Apps Repository" => "Applikation arkiv", -"Cannot connect to apps repository" => "Kan ikke tilslutte applikations arkivet", +"Cannot connect to apps repository" => "Kan ikke oprette forbindelse til applikations arkivet", "Name" => "Navn", "Modified" => "Ændret", "Administration" => "Administration", @@ -15,6 +15,6 @@ "Create group" => "Lav gruppe", "Force new password:" => "Tving ny adgangskode", "Set" => "Indstil", -"Do you really want to delete user" => "Vil du virkelig slette denne bruger", -"Do you really want to delete group" => "Vil du virkelig slette denne gruppe" +"Do you really want to delete user" => "Vil du virkelig slette denne bruger?", +"Do you really want to delete group" => "Vil du virkelig slette denne gruppe?" ); diff --git a/core/l10n/da.php b/core/l10n/da.php index 54a11ddba8..631201bab6 100644 --- a/core/l10n/da.php +++ b/core/l10n/da.php @@ -1,6 +1,6 @@ "Fejl 404, Skyen kan ikke findes", -"Welcome to ownCloud, your personnal cloud." => "Velkommen til ownCloud, Din personlige Sky.", +"Welcome to ownCloud, your personnal cloud." => "Velkommen til ownCloud, din personlige Sky.", "To finish the installation, please follow the steps below." => "For at fuldføre installationen, følg venligst nedenstående trin", "Create an admin account." => "Lav en administrator konto.", "Login:" => "Login:", @@ -19,7 +19,7 @@ "MySQL user password:" => "MySQL bruger password:", "Finish setup" => "Afslut installation", "ownCloud is a personal cloud which runs on your own server.

    " => "ownCloud er din personly sky der køre på din egen server.

    ", -"Login failed!" => "Login misslykkedes", +"Login failed!" => "Login mislykkedes", "You are logged out." => "Du er nu logget ud", "prev" => "forrige", "next" => "næste", diff --git a/help/l10n/da.php b/help/l10n/da.php new file mode 100644 index 0000000000..2b8120c0c3 --- /dev/null +++ b/help/l10n/da.php @@ -0,0 +1,4 @@ + "Spørgsmål og Svar", +"ASK A QUESTION" => "STIL ET SPØRGSMÅL" +); diff --git a/l10n/da/admin.po b/l10n/da/admin.po index 26f34e599a..be62e2cd3d 100644 --- a/l10n/da/admin.po +++ b/l10n/da/admin.po @@ -3,14 +3,13 @@ # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2011-06-20 22:00+0200\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" +"PO-Revision-Date: 2011-06-21 15:08+0100\n" +"Last-Translator: Mikkel Bjerg Larsen \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" @@ -25,15 +24,18 @@ msgstr "læs mere" msgid "INSTALL" msgstr "INSTALLER" -#: ../templates/app_noconn.php:6 ../templates/apps.php:6 +#: ../templates/app_noconn.php:6 +#: ../templates/apps.php:6 msgid "Apps Repository" msgstr "Applikation arkiv" #: ../templates/app_noconn.php:7 msgid "Cannot connect to apps repository" -msgstr "Kan ikke tilslutte applikations arkivet" +msgstr "Kan ikke oprette forbindelse til applikations arkivet" -#: ../templates/apps.php:13 ../templates/users.php:6 ../templates/users.php:20 +#: ../templates/apps.php:13 +#: ../templates/users.php:6 +#: ../templates/users.php:20 #: ../templates/users.php:50 msgid "Name" msgstr "Navn" @@ -62,11 +64,13 @@ msgstr "Kodeord" msgid "Create user" msgstr "Lav bruger" -#: ../templates/users.php:40 ../templates/users.php:68 +#: ../templates/users.php:40 +#: ../templates/users.php:68 msgid "remove" msgstr "slet" -#: ../templates/users.php:46 ../templates/users.php:7 +#: ../templates/users.php:46 +#: ../templates/users.php:7 msgid "Groups" msgstr "Grupper" @@ -84,8 +88,9 @@ msgstr "Indstil" #: ../templates/users.php:102 msgid "Do you really want to delete user" -msgstr "Vil du virkelig slette denne bruger" +msgstr "Vil du virkelig slette denne bruger?" #: ../templates/users.php:109 msgid "Do you really want to delete group" -msgstr "Vil du virkelig slette denne gruppe" +msgstr "Vil du virkelig slette denne gruppe?" + diff --git a/l10n/da/core.po b/l10n/da/core.po index b31b7b93db..df83958287 100644 --- a/l10n/da/core.po +++ b/l10n/da/core.po @@ -3,14 +3,13 @@ # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2011-06-20 22:00+0200\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" +"PO-Revision-Date: 2011-06-21 15:10+0100\n" +"Last-Translator: Mikkel Bjerg Larsen \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" @@ -23,7 +22,7 @@ msgstr "Fejl 404, Skyen kan ikke findes" #: ../templates/installation.php:6 msgid "Welcome to ownCloud, your personnal cloud." -msgstr "Velkommen til ownCloud, Din personlige Sky." +msgstr "Velkommen til ownCloud, din personlige Sky." #: ../templates/installation.php:7 msgid "To finish the installation, please follow the steps below." @@ -94,16 +93,12 @@ msgid "Finish setup" msgstr "Afslut installation" #: ../templates/layout.guest.php:20 -msgid "" -"ownCloud is a personal cloud which runs " -"on your own server.

    " -msgstr "" -"ownCloud er din personly sky der køre " -"på din egen server.

    " +msgid "ownCloud is a personal cloud which runs on your own server.

    " +msgstr "ownCloud er din personly sky der køre på din egen server.

    " #: ../templates/login.php:6 msgid "Login failed!" -msgstr "Login misslykkedes" +msgstr "Login mislykkedes" #: ../templates/logout.php:1 msgid "You are logged out." @@ -120,3 +115,4 @@ msgstr "næste" #: ../templates/part.searchbox.php:3 msgid "Search" msgstr "Søg" + diff --git a/l10n/da/help.po b/l10n/da/help.po index cd06f9b10a..d09d34e0aa 100644 --- a/l10n/da/help.po +++ b/l10n/da/help.po @@ -3,24 +3,24 @@ # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2011-06-20 22:00+0200\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" +"PO-Revision-Date: 2011-06-21 15:02+0100\n" +"Last-Translator: Mikkel Bjerg Larsen \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../templates/index.php:2 msgid "Questions and Answers" -msgstr "" +msgstr "Spørgsmål og Svar" #: ../templates/index.php:21 msgid "ASK A QUESTION" -msgstr "" +msgstr "STIL ET SPØRGSMÅL" + diff --git a/l10n/da/settings.po b/l10n/da/settings.po index b00f26b052..c7981c921f 100644 --- a/l10n/da/settings.po +++ b/l10n/da/settings.po @@ -3,14 +3,13 @@ # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2011-06-20 22:00+0200\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" +"PO-Revision-Date: 2011-06-21 15:00+0100\n" +"Last-Translator: Mikkel Bjerg Larsen \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" @@ -47,7 +46,7 @@ msgstr "Gamle adgangskode" #: ../templates/index.php:19 msgid "New password" -msgstr "Ny adgangskode" +msgstr "Nye adgangskode" #: ../templates/index.php:24 msgid "Show new password" @@ -57,7 +56,8 @@ msgstr "Vis den nye adgangskode" msgid "Language" msgstr "Sprog" -#: ../ajax/changepassword.php:13 ../ajax/setlanguage.php:13 +#: ../ajax/changepassword.php:13 +#: ../ajax/setlanguage.php:13 msgid "Authentication error" msgstr "Godkendelsesfejl" @@ -67,7 +67,7 @@ msgstr "Du skal indtaste din gamle og nye adganskode" #: ../ajax/changepassword.php:25 msgid "Your old password is wrong!" -msgstr "Dit gamle adgangskode er forkert!" +msgstr "Din gamle adgangskode er forkert!" #: ../ajax/changepassword.php:31 msgid "Password changed" @@ -84,3 +84,4 @@ msgstr "Sprog ændret" #: ../ajax/setlanguage.php:23 msgid "Invalid request" msgstr "Invalid forespørgsel" + diff --git a/settings/l10n/da.php b/settings/l10n/da.php index 1c0b87f867..37a56f2f64 100644 --- a/settings/l10n/da.php +++ b/settings/l10n/da.php @@ -6,12 +6,12 @@ "Change Password" => "Ændre adgangskode", "Your password got changed" => "Din adgangskode er ændret", "Old password:" => "Gamle adgangskode", -"New password" => "Ny adgangskode", +"New password" => "Nye adgangskode", "Show new password" => "Vis den nye adgangskode", "Language" => "Sprog", "Authentication error" => "Godkendelsesfejl", "You have to enter the old and the new password!" => "Du skal indtaste din gamle og nye adganskode", -"Your old password is wrong!" => "Dit gamle adgangskode er forkert!", +"Your old password is wrong!" => "Din gamle adgangskode er forkert!", "Password changed" => "Adgangskoden er ændret", "Unable to change password" => "Kan ikke ændre din adgangskode", "Language changed" => "Sprog ændret", From c25474e2c587a394c33af4748733a604b7d2a711 Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Tue, 21 Jun 2011 16:19:30 +0200 Subject: [PATCH 069/111] Updated l10n script, fixed translation in admin/users template --- admin/templates/users.php | 2 +- l10n/l10n.pl | 15 ++++++--------- l10n/templates/admin.pot | 6 +++++- l10n/templates/core.pot | 2 +- l10n/templates/help.pot | 2 +- l10n/templates/log.pot | 2 +- l10n/templates/settings.pot | 2 +- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/admin/templates/users.php b/admin/templates/users.php index 0c26fd3bdf..70fc8b3ab2 100644 --- a/admin/templates/users.php +++ b/admin/templates/users.php @@ -1,4 +1,4 @@ -

    Users

    +

    t( 'Users' ); ?>

    diff --git a/l10n/l10n.pl b/l10n/l10n.pl index 88abc821e9..0ad33d2116 100644 --- a/l10n/l10n.pl +++ b/l10n/l10n.pl @@ -54,16 +54,13 @@ if( $task eq 'read' ){ pop( @temp ); my $app = pop( @temp ); chdir( $dir ); - foreach my $language ( @languages ){ - my $output = "${whereami}/$language/$app.po"; - $output .= 't' if $language eq 'templates'; + my $output = "${whereami}/templates/$app.pot"; - if( -e $output ){ - `xgettext --files-from=xgettextfiles --join-existing --output="$output" --keyword=t` - } - else{ - `xgettext --files-from=xgettextfiles --output="$output" --keyword=t` - } + if( -e $output ){ + `xgettext --files-from=xgettextfiles --join-existing --output="$output" --keyword=t` + } + else{ + `xgettext --files-from=xgettextfiles --output="$output" --keyword=t` } chdir( $whereami ); } diff --git a/l10n/templates/admin.pot b/l10n/templates/admin.pot index c683082b6f..cb01fee4d2 100644 --- a/l10n/templates/admin.pot +++ b/l10n/templates/admin.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"POT-Creation-Date: 2011-06-21 16:19+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -89,3 +89,7 @@ msgstr "" #: ../templates/users.php:109 msgid "Do you really want to delete group" msgstr "" + +#: ../templates/users.php:1 +msgid "Users" +msgstr "" diff --git a/l10n/templates/core.pot b/l10n/templates/core.pot index ef4f80b580..679ca60a98 100644 --- a/l10n/templates/core.pot +++ b/l10n/templates/core.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"POT-Creation-Date: 2011-06-21 16:19+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/l10n/templates/help.pot b/l10n/templates/help.pot index cd06f9b10a..43b9b26ff0 100644 --- a/l10n/templates/help.pot +++ b/l10n/templates/help.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"POT-Creation-Date: 2011-06-21 16:19+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/l10n/templates/log.pot b/l10n/templates/log.pot index c73912a626..91339d4513 100644 --- a/l10n/templates/log.pot +++ b/l10n/templates/log.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"POT-Creation-Date: 2011-06-21 16:19+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/l10n/templates/settings.pot b/l10n/templates/settings.pot index 55f3298f6f..ff8029ae46 100644 --- a/l10n/templates/settings.pot +++ b/l10n/templates/settings.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-06-20 22:00+0200\n" +"POT-Creation-Date: 2011-06-21 16:19+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" From c36b8621b4e91f01e979d62d3af2075e5e5630ee Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Tue, 21 Jun 2011 19:18:34 +0200 Subject: [PATCH 070/111] fixed wrong php tags --- admin/templates/users.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/admin/templates/users.php b/admin/templates/users.php index 70fc8b3ab2..133028c4e2 100644 --- a/admin/templates/users.php +++ b/admin/templates/users.php @@ -22,8 +22,8 @@ - + From 299d7bc3063a064cd0d86af75e4172fd46cdd81e Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Tue, 21 Jun 2011 23:05:54 +0200 Subject: [PATCH 074/111] install new shipped apps before fetching all apps --- admin/apps.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/admin/apps.php b/admin/apps.php index 56e76d139d..285cf9e90f 100644 --- a/admin/apps.php +++ b/admin/apps.php @@ -40,11 +40,10 @@ if(isset($_GET['installed'])) $installed=true; else $installed=false; if($installed){ global $SERVERROOT; + OC_INSTALLER::installShippedApps(false); $apps = OC_APPCONFIG::getApps(); $records = array(); - OC_INSTALLER::installShippedApps(false); - OC_APP::setActiveNavigationEntry( "core_apps_installed" ); foreach($apps as $app){ $info=OC_APP::getAppInfo("$SERVERROOT/apps/$app/appinfo/info.xml"); From 36dbb8edab6de784c45eee688000c5e330e70478 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 21 Jun 2011 23:58:02 +0200 Subject: [PATCH 075/111] prefix the mysql user name to avoid collissions --- lib/setup.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/setup.php b/lib/setup.php index 281f24db50..0a8c9650cb 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -97,13 +97,20 @@ class OC_SETUP { else { $query="SELECT user FROM mysql.user WHERE user='$dbuser'"; //this should be enough to check for admin rights in mysql if(mysql_query($query, $connection)) { - self::createDBUser($username, $password, $connection); //use the admin login data for the new database user - OC_CONFIG::setValue('dbuser', $username); - OC_CONFIG::setValue('dbpassword', $password); + + //add prefix to the mysql user name to prevent collissions + $dbusername='oc_mysql_'.$username; + //hash the password so we don't need to store the admin config in the config file + $dbpassowrd=md5(time().$password); + + self::createDBUser($dbusername, $dbpassowrd, $connection); + + OC_CONFIG::setValue('dbuser', $dbusername); + OC_CONFIG::setValue('dbpassword', $dbpassowrd); //create the database - self::createDatabase($dbname, $username, $connection); + self::createDatabase($dbname, $dbusername, $connection); } else { OC_CONFIG::setValue('dbuser', $dbuser); From 77f5fa0f078b03b96afe843ece35725a501ebe77 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Wed, 22 Jun 2011 01:45:50 +0200 Subject: [PATCH 076/111] fix "files" app admin link visible for non-admins --- files/appinfo/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/appinfo/app.php b/files/appinfo/app.php index bf67812cf3..06ca16e82d 100644 --- a/files/appinfo/app.php +++ b/files/appinfo/app.php @@ -3,7 +3,7 @@ OC_APP::register( array( "order" => 2, "id" => "files", "name" => "Files" )); OC_APP::addNavigationEntry( array( "id" => "files_index", "order" => 1, "href" => OC_HELPER::linkTo( "files", "index.php" ), "icon" => OC_HELPER::imagePath( "files", "home.png" ), "name" => "Files" )); -OC_APP::addSettingsPage( array( "id" => "files_administration", "order" => 1, "href" => OC_HELPER::linkTo( "files", "admin.php" ), "name" => "Files", "icon" => OC_HELPER::imagePath( "files", "folder.png" ))); +OC_APP::addAdminPage( array( "id" => "files_administration", "order" => 3, "href" => OC_HELPER::linkTo( "files", "admin.php" ), "name" => "Files", "icon" => OC_HELPER::imagePath( "files", "folder.png" ))); // To add navigation sub entries use From 4f6ea7e64824888a0a704f6c5f1cd32369d46afc Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Wed, 22 Jun 2011 03:55:13 +0200 Subject: [PATCH 077/111] added polish translation --- admin/l10n/pl.php | 21 ++++++++ core/l10n/pl.php | 27 ++++++++++ help/l10n/pl.php | 4 ++ l10n/pl/admin.po | 96 +++++++++++++++++++++++++++++++++ l10n/pl/core.po | 123 +++++++++++++++++++++++++++++++++++++++++++ l10n/pl/help.po | 28 ++++++++++ l10n/pl/log.po | 68 ++++++++++++++++++++++++ l10n/pl/settings.po | 88 +++++++++++++++++++++++++++++++ log/l10n/pl.php | 14 +++++ settings/l10n/pl.php | 19 +++++++ 10 files changed, 488 insertions(+) create mode 100644 admin/l10n/pl.php create mode 100644 core/l10n/pl.php create mode 100644 help/l10n/pl.php create mode 100644 l10n/pl/admin.po create mode 100644 l10n/pl/core.po create mode 100644 l10n/pl/help.po create mode 100644 l10n/pl/log.po create mode 100644 l10n/pl/settings.po create mode 100644 log/l10n/pl.php create mode 100644 settings/l10n/pl.php diff --git a/admin/l10n/pl.php b/admin/l10n/pl.php new file mode 100644 index 0000000000..9995c5da56 --- /dev/null +++ b/admin/l10n/pl.php @@ -0,0 +1,21 @@ + "czytaj więcej", +"INSTALL" => "INSTALUJ", +"Apps Repository" => "Repozytorium aplikacji", +"Cannot connect to apps repository" => "Nie można połączyć się z repozytorium aplikacji", +"Name" => "Nazwa", +"Modified" => "Zmodyfikowano", +"Administration" => "Administracja", +"System Settings" => "Ustawienia systemowe", +"Add user" => "Dodaj użytkownika", +"Password" => "Hasło", +"Create user" => "Utwórz użytkownika", +"remove" => "usuń", +"Groups" => "Grupy", +"Create group" => "Utwórz grupę", +"Force new password:" => "Wymuś nowe hasło", +"Set" => "Ustaw", +"Do you really want to delete user" => "Czy naprawdę chcesz usunąć użytkownika", +"Do you really want to delete group" => "Czy naprawdę chcesz usunąć grupę", +"Users" => "Użytkownicy" +); diff --git a/core/l10n/pl.php b/core/l10n/pl.php new file mode 100644 index 0000000000..6914e11557 --- /dev/null +++ b/core/l10n/pl.php @@ -0,0 +1,27 @@ + "Błąd 404, Chmura nie znaleziona", +"Welcome to ownCloud, your personnal cloud." => "Witaj w ownCloud, Twojej osobistej chmurze.", +"To finish the installation, please follow the steps below." => "By zakończyć instalację, podążaj poniższymi krokami.", +"Create an admin account." => "Utwórz konto administratora.", +"Login:" => "Login:", +"Password:" => "Hasło:", +"Advanced" => "Zaawansowane", +"Set where to store the data." => "Ustaw, gdzie przechowywać dane.", +"Data directory:" => "Katalog danych:", +"Configure your database." => "Skonfiguruj Twoją bazę danych.", +"I will use a SQLite database. You have nothing to do!" => "Użyję bazy SQLite. Nie masz tu nic do roboty!", +"SQLite" => "SQLite", +"I will use a MySQL database." => "Użyję bazy danych MySQL.", +"Host:" => "Host:", +"Database name:" => "Nazwa bazy:", +"Table prefix:" => "Przedrostek tabeli:", +"MySQL user login:" => "Login użytkownika MySQL:", +"MySQL user password:" => "Hasło użytkownika MySQL:", +"Finish setup" => "Zakończ instalację", +"ownCloud is a personal cloud which runs on your own server.

    " => "ownCloud jest osobistą chmurą działającą na Twoim własnym serwerze.

    ", +"Login failed!" => "Nie udało się zalogować!", +"You are logged out." => "Jesteś wylogowany.", +"prev" => "wstecz", +"next" => "dalej", +"Search" => "Szukaj" +); diff --git a/help/l10n/pl.php b/help/l10n/pl.php new file mode 100644 index 0000000000..7d37913d03 --- /dev/null +++ b/help/l10n/pl.php @@ -0,0 +1,4 @@ + "Pytania i odpowiedzi", +"ASK A QUESTION" => "ZADAJ PYTANIE" +); diff --git a/l10n/pl/admin.po b/l10n/pl/admin.po new file mode 100644 index 0000000000..858dccf668 --- /dev/null +++ b/l10n/pl/admin.po @@ -0,0 +1,96 @@ +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Kamil Domański , 2011. +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-21 16:19+0200\n" +"PO-Revision-Date: 2011-06-22 03:28+0200\n" +"Last-Translator: Kamil Domański \n" +"Language-Team: American English \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.2\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: ../templates/app.php:22 +msgid "read more" +msgstr "czytaj więcej" + +#: ../templates/app.php:24 +msgid "INSTALL" +msgstr "INSTALUJ" + +#: ../templates/app_noconn.php:6 ../templates/apps.php:6 +msgid "Apps Repository" +msgstr "Repozytorium aplikacji" + +#: ../templates/app_noconn.php:7 +msgid "Cannot connect to apps repository" +msgstr "Nie można połączyć się z repozytorium aplikacji" + +#: ../templates/apps.php:13 ../templates/users.php:6 ../templates/users.php:20 +#: ../templates/users.php:50 +msgid "Name" +msgstr "Nazwa" + +#: ../templates/apps.php:14 +msgid "Modified" +msgstr "Zmodyfikowano" + +#: ../templates/system.php:6 +msgid "Administration" +msgstr "Administracja" + +#: ../templates/system.php:7 +msgid "System Settings" +msgstr "Ustawienia systemowe" + +#: ../templates/users.php:13 +msgid "Add user" +msgstr "Dodaj użytkownika" + +#: ../templates/users.php:21 +msgid "Password" +msgstr "Hasło" + +#: ../templates/users.php:30 +msgid "Create user" +msgstr "Utwórz użytkownika" + +#: ../templates/users.php:40 ../templates/users.php:68 +msgid "remove" +msgstr "usuń" + +#: ../templates/users.php:46 ../templates/users.php:7 +msgid "Groups" +msgstr "Grupy" + +#: ../templates/users.php:58 +msgid "Create group" +msgstr "Utwórz grupę" + +#: ../templates/users.php:94 +msgid "Force new password:" +msgstr "Wymuś nowe hasło" + +#: ../templates/users.php:96 +msgid "Set" +msgstr "Ustaw" + +#: ../templates/users.php:102 +msgid "Do you really want to delete user" +msgstr "Czy naprawdę chcesz usunąć użytkownika" + +#: ../templates/users.php:109 +msgid "Do you really want to delete group" +msgstr "Czy naprawdę chcesz usunąć grupę" + +#: ../templates/users.php:1 +msgid "Users" +msgstr "Użytkownicy" + diff --git a/l10n/pl/core.po b/l10n/pl/core.po new file mode 100644 index 0000000000..717555818e --- /dev/null +++ b/l10n/pl/core.po @@ -0,0 +1,123 @@ +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Kamil Domański , 2011. +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-21 16:19+0200\n" +"PO-Revision-Date: 2011-06-22 03:36+0200\n" +"Last-Translator: Kamil Domański \n" +"Language-Team: American English \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.2\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: ../templates/404.php:15 +msgid "Error 404, Cloud not found" +msgstr "Błąd 404, Chmura nie znaleziona" + +#: ../templates/installation.php:6 +msgid "Welcome to ownCloud, your personnal cloud." +msgstr "Witaj w ownCloud, Twojej osobistej chmurze." + +#: ../templates/installation.php:7 +msgid "To finish the installation, please follow the steps below." +msgstr "By zakończyć instalację, podążaj poniższymi krokami." + +#: ../templates/installation.php:26 +msgid "Create an admin account." +msgstr "Utwórz konto administratora." + +#: ../templates/installation.php:27 +msgid "Login:" +msgstr "Login:" + +#: ../templates/installation.php:28 +msgid "Password:" +msgstr "Hasło:" + +#: ../templates/installation.php:31 +msgid "Advanced" +msgstr "Zaawansowane" + +#: ../templates/installation.php:34 +msgid "Set where to store the data." +msgstr "Ustaw, gdzie przechowywać dane." + +#: ../templates/installation.php:35 +msgid "Data directory:" +msgstr "Katalog danych:" + +#: ../templates/installation.php:39 +msgid "Configure your database." +msgstr "Skonfiguruj Twoją bazę danych." + +#: ../templates/installation.php:43 +msgid "I will use a SQLite database. You have nothing to do!" +msgstr "Użyję bazy SQLite. Nie masz tu nic do roboty!" + +#: ../templates/installation.php:46 +msgid "SQLite" +msgstr "SQLite" + +#: ../templates/installation.php:53 +msgid "I will use a MySQL database." +msgstr "Użyję bazy danych MySQL." + +#: ../templates/installation.php:59 +msgid "Host:" +msgstr "Host:" + +#: ../templates/installation.php:60 +msgid "Database name:" +msgstr "Nazwa bazy:" + +#: ../templates/installation.php:61 +msgid "Table prefix:" +msgstr "Przedrostek tabeli:" + +#: ../templates/installation.php:62 +msgid "MySQL user login:" +msgstr "Login użytkownika MySQL:" + +#: ../templates/installation.php:63 +msgid "MySQL user password:" +msgstr "Hasło użytkownika MySQL:" + +#: ../templates/installation.php:68 +msgid "Finish setup" +msgstr "Zakończ instalację" + +#: ../templates/layout.guest.php:20 +msgid "" +"ownCloud is a personal cloud which runs " +"on your own server.

    " +msgstr "" +"ownCloud jest osobistą chmurą działającą " +"na Twoim własnym serwerze.

    " + +#: ../templates/login.php:6 +msgid "Login failed!" +msgstr "Nie udało się zalogować!" + +#: ../templates/logout.php:1 +msgid "You are logged out." +msgstr "Jesteś wylogowany." + +#: ../templates/part.pagenavi.php:6 +msgid "prev" +msgstr "wstecz" + +#: ../templates/part.pagenavi.php:26 +msgid "next" +msgstr "dalej" + +#: ../templates/part.searchbox.php:3 +msgid "Search" +msgstr "Szukaj" + diff --git a/l10n/pl/help.po b/l10n/pl/help.po new file mode 100644 index 0000000000..a9d8481d5c --- /dev/null +++ b/l10n/pl/help.po @@ -0,0 +1,28 @@ +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Kamil Domański , 2011. +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-21 16:19+0200\n" +"PO-Revision-Date: 2011-06-22 03:45+0200\n" +"Last-Translator: Kamil Domański \n" +"Language-Team: Polish \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.2\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " +"|| n%100>=20) ? 1 : 2);\n" + +#: ../templates/index.php:2 +msgid "Questions and Answers" +msgstr "Pytania i odpowiedzi" + +#: ../templates/index.php:21 +msgid "ASK A QUESTION" +msgstr "ZADAJ PYTANIE" + diff --git a/l10n/pl/log.po b/l10n/pl/log.po new file mode 100644 index 0000000000..9c426ec231 --- /dev/null +++ b/l10n/pl/log.po @@ -0,0 +1,68 @@ +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Kamil Domański , 2011. +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-21 16:19+0200\n" +"PO-Revision-Date: 2011-06-22 03:50+0200\n" +"Last-Translator: Kamil Domański \n" +"Language-Team: Polish \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.2\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " +"|| n%100>=20) ? 1 : 2);\n" + +#: ../templates/index.php:4 +msgid "Filter:" +msgstr "Filtr:" + +#: ../templates/index.php:7 +msgid "Logins" +msgstr "Zalogowania" + +#: ../templates/index.php:8 +msgid "Logouts" +msgstr "Wylogowani" + +#: ../templates/index.php:9 +msgid "Downloads" +msgstr "Pobrania" + +#: ../templates/index.php:10 +msgid "Uploads" +msgstr "Wgrania" + +#: ../templates/index.php:11 +msgid "Creations" +msgstr "Utworzenia" + +#: ../templates/index.php:12 +msgid "Deletions" +msgstr "Usunięcia" + +#: ../templates/index.php:15 +msgid "Show:" +msgstr "Pokaż:" + +#: ../templates/index.php:16 +msgid "entries per page." +msgstr "wpisów na stronę." + +#: ../templates/index.php:26 +msgid "What" +msgstr "Co" + +#: ../templates/index.php:27 +msgid "When" +msgstr "Kiedy" + +#: ../templates/index.php:45 +msgid "Clear log entries before" +msgstr "Wyczyść spisy dziennika sprzed" + diff --git a/l10n/pl/settings.po b/l10n/pl/settings.po new file mode 100644 index 0000000000..6dec38f105 --- /dev/null +++ b/l10n/pl/settings.po @@ -0,0 +1,88 @@ +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Kamil Domański , 2011. +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-06-21 16:19+0200\n" +"PO-Revision-Date: 2011-06-22 03:52+0200\n" +"Last-Translator: Kamil Domański \n" +"Language-Team: Polish \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.2\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " +"|| n%100>=20) ? 1 : 2);\n" + +#: ../templates/index.php:3 +msgid "Account information" +msgstr "Dane konta" + +#: ../templates/index.php:5 +msgid "You're currently using" +msgstr "Obecnie używasz" + +#: ../templates/index.php:5 +msgid "of your" +msgstr "ze swoich" + +#: ../templates/index.php:5 +msgid "space" +msgstr "przestrzeni" + +#: ../templates/index.php:11 +msgid "Change Password" +msgstr "Zmień hasło" + +#: ../templates/index.php:12 +msgid "Your password got changed" +msgstr "Twoje hasło zostało zmienione" + +#: ../templates/index.php:15 +msgid "Old password:" +msgstr "Stare hasło" + +#: ../templates/index.php:19 +msgid "New password" +msgstr "Nowe hasło" + +#: ../templates/index.php:24 +msgid "Show new password" +msgstr "Pokaż nowe hasło" + +#: ../templates/index.php:34 +msgid "Language" +msgstr "Język" + +#: ../ajax/changepassword.php:13 ../ajax/setlanguage.php:13 +msgid "Authentication error" +msgstr "Błąd uwierzytelniania" + +#: ../ajax/changepassword.php:19 +msgid "You have to enter the old and the new password!" +msgstr "Musisz wprowadzić zarówno stare, jak i nowe hasło!" + +#: ../ajax/changepassword.php:25 +msgid "Your old password is wrong!" +msgstr "Twoje stare hasło jest błędne!" + +#: ../ajax/changepassword.php:31 +msgid "Password changed" +msgstr "Hasło zmienione" + +#: ../ajax/changepassword.php:34 +msgid "Unable to change password" +msgstr "NIe można zmienić hasła" + +#: ../ajax/setlanguage.php:21 +msgid "Language changed" +msgstr "Język zmieniony" + +#: ../ajax/setlanguage.php:23 +msgid "Invalid request" +msgstr "Nieprawidłowe żądanie" + diff --git a/log/l10n/pl.php b/log/l10n/pl.php new file mode 100644 index 0000000000..322e5df1ad --- /dev/null +++ b/log/l10n/pl.php @@ -0,0 +1,14 @@ + "Filtr:", +"Logins" => "Zalogowania", +"Logouts" => "Wylogowani", +"Downloads" => "Pobrania", +"Uploads" => "Wgrania", +"Creations" => "Utworzenia", +"Deletions" => "Usunięcia", +"Show:" => "Pokaż:", +"entries per page." => "wpisów na stronę.", +"What" => "Co", +"When" => "Kiedy", +"Clear log entries before" => "Wyczyść spisy dziennika sprzed" +); diff --git a/settings/l10n/pl.php b/settings/l10n/pl.php new file mode 100644 index 0000000000..b65fdd15b4 --- /dev/null +++ b/settings/l10n/pl.php @@ -0,0 +1,19 @@ + "Dane konta", +"You're currently using" => "Obecnie używasz", +"of your" => "ze swoich", +"space" => "przestrzeni", +"Change Password" => "Zmień hasło", +"Your password got changed" => "Twoje hasło zostało zmienione", +"Old password:" => "Stare hasło", +"New password" => "Nowe hasło", +"Show new password" => "Pokaż nowe hasło", +"Language" => "Język", +"Authentication error" => "Błąd uwierzytelniania", +"You have to enter the old and the new password!" => "Musisz wprowadzić zarówno stare, jak i nowe hasło!", +"Your old password is wrong!" => "Twoje stare hasło jest błędne!", +"Password changed" => "Hasło zmienione", +"Unable to change password" => "NIe można zmienić hasła", +"Language changed" => "Język zmieniony", +"Invalid request" => "Nieprawidłowe żądanie" +); From c0af177223f5ebd74614b775121ea7f3497d25a5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 22 Jun 2011 12:40:13 +0200 Subject: [PATCH 078/111] public link config is also for non admins --- apps/files_publiclink/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_publiclink/admin.php b/apps/files_publiclink/admin.php index a48076b4d4..afb726da31 100644 --- a/apps/files_publiclink/admin.php +++ b/apps/files_publiclink/admin.php @@ -29,7 +29,7 @@ require( 'template.php' ); // Check if we are a user -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn()){ header( "Location: ".OC_HELPER::linkTo( "index.php" )); exit(); } From 83958ebd4be58c64b23a3e9535f4246faeff8f4a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 22 Jun 2011 12:50:57 +0200 Subject: [PATCH 079/111] add oc_user::getUser to get the user id of the loggedin user --- admin/ajax/changepassword.php | 2 +- admin/ajax/creategroup.php | 2 +- admin/ajax/createuser.php | 2 +- admin/ajax/removegroup.php | 2 +- admin/ajax/removeuser.php | 2 +- admin/ajax/togglegroups.php | 2 +- admin/apps.php | 2 +- admin/system.php | 2 +- admin/users.php | 2 +- apps/files_publiclink/lib_public.php | 6 +++--- files/admin.php | 2 +- lib/base.php | 2 +- lib/l10n.php | 4 ++-- lib/user.php | 13 +++++++++++++ log/index.php | 8 ++++---- settings/ajax/setlanguage.php | 2 +- settings/index.php | 2 +- 17 files changed, 35 insertions(+), 22 deletions(-) diff --git a/admin/ajax/changepassword.php b/admin/ajax/changepassword.php index a8f3af1517..51634908a7 100644 --- a/admin/ajax/changepassword.php +++ b/admin/ajax/changepassword.php @@ -7,7 +7,7 @@ require_once('../../lib/base.php'); header( "Content-Type: application/jsonrequest" ); // Check if we are a user -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); exit(); } diff --git a/admin/ajax/creategroup.php b/admin/ajax/creategroup.php index eec2758793..df9a36aaa2 100644 --- a/admin/ajax/creategroup.php +++ b/admin/ajax/creategroup.php @@ -7,7 +7,7 @@ require_once('../../lib/base.php'); header( "Content-Type: application/jsonrequest" ); // Check if we are a user -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); exit(); } diff --git a/admin/ajax/createuser.php b/admin/ajax/createuser.php index a6e4ec0e93..507ded9079 100644 --- a/admin/ajax/createuser.php +++ b/admin/ajax/createuser.php @@ -7,7 +7,7 @@ require_once('../../lib/base.php'); header( "Content-Type: application/jsonrequest" ); // Check if we are a user -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); exit(); } diff --git a/admin/ajax/removegroup.php b/admin/ajax/removegroup.php index c7991ba581..e3d62e5fac 100644 --- a/admin/ajax/removegroup.php +++ b/admin/ajax/removegroup.php @@ -7,7 +7,7 @@ require_once('../../lib/base.php'); header( "Content-Type: application/jsonrequest" ); // Check if we are a user -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); exit(); } diff --git a/admin/ajax/removeuser.php b/admin/ajax/removeuser.php index 7e587f1605..6b48146ad4 100644 --- a/admin/ajax/removeuser.php +++ b/admin/ajax/removeuser.php @@ -7,7 +7,7 @@ require_once('../../lib/base.php'); header( "Content-Type: application/jsonrequest" ); // Check if we are a user -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); exit(); } diff --git a/admin/ajax/togglegroups.php b/admin/ajax/togglegroups.php index f821ae0bfa..5c7bd393e9 100644 --- a/admin/ajax/togglegroups.php +++ b/admin/ajax/togglegroups.php @@ -7,7 +7,7 @@ require_once('../../lib/base.php'); header( "Content-Type: application/jsonrequest" ); // Check if we are a user -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" ))); exit(); } diff --git a/admin/apps.php b/admin/apps.php index 285cf9e90f..b47611f536 100644 --- a/admin/apps.php +++ b/admin/apps.php @@ -24,7 +24,7 @@ require_once('../lib/base.php'); include_once('../lib/installer.php'); require( 'template.php' ); -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ header( "Location: ".OC_HELPER::linkTo( "", "index.php" )); exit(); } diff --git a/admin/system.php b/admin/system.php index 310979295f..284509144e 100644 --- a/admin/system.php +++ b/admin/system.php @@ -23,7 +23,7 @@ require_once('../lib/base.php'); require( 'template.php' ); -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ header( "Location: ".OC_HELPER::linkTo( "index.php" )); exit(); } diff --git a/admin/users.php b/admin/users.php index e44feb40fe..0848d57162 100644 --- a/admin/users.php +++ b/admin/users.php @@ -23,7 +23,7 @@ require_once('../lib/base.php'); require( 'template.php' ); -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ header( "Location: ".OC_HELPER::linkTo( "index.php" )); exit(); } diff --git a/apps/files_publiclink/lib_public.php b/apps/files_publiclink/lib_public.php index aeef921237..93ccc52d0e 100644 --- a/apps/files_publiclink/lib_public.php +++ b/apps/files_publiclink/lib_public.php @@ -7,7 +7,7 @@ class OC_PublicLink{ */ public function __construct($path,$expiretime=0){ if($path and OC_FILESYSTEM::file_exists($path) and OC_FILESYSTEM::is_readable($path)){ - $user=$_SESSION['user_id']; + $user=OC_USER::getUser(); $token=sha1("$user-$path-$expiretime"); $query=OC_DB::prepare("INSERT INTO *PREFIX*publiclink VALUES(?,?,?,?)"); $result=$query->execute(array($token,$path,$user,$expiretime)); @@ -60,7 +60,7 @@ class OC_PublicLink{ */ static public function getLinks(){ $query=OC_DB::prepare("SELECT * FROM *PREFIX*publiclink WHERE user=?"); - return $query->execute(array($_SESSION['user_id']))->fetchAll(); + return $query->execute(array(OC_USER::getUser()))->fetchAll(); } /** @@ -69,7 +69,7 @@ class OC_PublicLink{ static public function delete($token){ $query=OC_DB::prepare("SELECT user,path FROM *PREFIX*publiclink WHERE token=?"); $result=$query->execute(array($token))->fetchAll(); - if(count($result)>0 and $result[0]['user']==$_SESSION['user_id']){ + if(count($result)>0 and $result[0]['user']==OC_USER::getUser()){ $query=OC_DB::prepare("DELETE FROM *PREFIX*publiclink WHERE token=?"); $query->execute(array($token)); } diff --git a/files/admin.php b/files/admin.php index 59b822468e..5c9923aff8 100644 --- a/files/admin.php +++ b/files/admin.php @@ -28,7 +28,7 @@ require( 'template.php' ); // Check if we are a user -if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ header( "Location: ".OC_HELPER::linkTo( "index.php" )); exit(); } diff --git a/lib/base.php b/lib/base.php index e93c471272..0453e272a4 100644 --- a/lib/base.php +++ b/lib/base.php @@ -142,7 +142,7 @@ class OC_UTIL { // If we are not forced to load a specific user we load the one that is logged in if( $user == "" && OC_USER::isLoggedIn()){ - $user = $_SESSION['user_id']; + $user = OC_USER::getUser(); } if( $user != "" ){ //if we aren't logged in, there is no use to set up the filesystem diff --git a/lib/l10n.php b/lib/l10n.php index ff0238241a..053c6fbc10 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -200,8 +200,8 @@ class OC_L10N{ else{ $available=self::findAvailableLanguages( $app ); } - if( isset($_SESSION['user_id']) && $_SESSION['user_id'] && OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang' )){ - $lang = OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang' ); + if( OC_USER::getUser() && OC_PREFERENCES::getValue( OC_USER::getUser(), 'core', 'lang' )){ + $lang = OC_PREFERENCES::getValue( OC_USER::getUser(), 'core', 'lang' ); self::$language = $lang; if( array_search( $lang, $available ) !== false ){ return $lang; diff --git a/lib/user.php b/lib/user.php index 2e11a30e85..7eafef924a 100644 --- a/lib/user.php +++ b/lib/user.php @@ -231,6 +231,19 @@ class OC_USER { } } + /** + * @brief get the user idea of the user currently logged in. + * @return string uid or false + */ + public static function getUser(){ + if( isset($_SESSION['user_id']) AND $_SESSION['user_id'] ){ + return $_SESSION['user_id']; + } + else{ + return false; + } + } + /** * @brief Autogenerate a password * @returns string diff --git a/log/index.php b/log/index.php index 950e1f82d1..4986526e00 100644 --- a/log/index.php +++ b/log/index.php @@ -43,8 +43,8 @@ if(isset($_POST['save'])){ $selectedActions[]=$action; } } - OC_PREFERENCES::setValue($_SESSION['user_id'],'log','actions',implode(',',$selectedActions)); - OC_PREFERENCES::setValue($_SESSION['user_id'],'log','pagesize',$_POST['size']); + OC_PREFERENCES::setValue(OC_USER::getUser(),'log','actions',implode(',',$selectedActions)); + OC_PREFERENCES::setValue(OC_USER::getUser(),'log','pagesize',$_POST['size']); } //clear log entries elseif(isset($_POST['clear'])){ @@ -62,10 +62,10 @@ OC_APP::setActiveNavigationEntry( 'log' ); $logs=OC_LOG::get(); -$selectedActions=explode(',',OC_PREFERENCES::getValue($_SESSION['user_id'],'log','actions',implode(',',$allActions))); +$selectedActions=explode(',',OC_PREFERENCES::getValue(OC_USER::getUser(),'log','actions',implode(',',$allActions))); $logs=OC_LOG::filterAction($logs,$selectedActions); -$pageSize=OC_PREFERENCES::getValue($_SESSION['user_id'],'log','pagesize',20); +$pageSize=OC_PREFERENCES::getValue(OC_USER::getUser(),'log','pagesize',20); $pageCount=ceil(count($logs)/$pageSize); $page=isset($_GET['page'])?$_GET['page']:0; if($page>=$pageCount){ diff --git a/settings/ajax/setlanguage.php b/settings/ajax/setlanguage.php index f971806f4c..bc467fb900 100644 --- a/settings/ajax/setlanguage.php +++ b/settings/ajax/setlanguage.php @@ -17,7 +17,7 @@ if( !OC_USER::isLoggedIn()){ // Get data if( isset( $_POST['lang'] ) ){ $lang=$_POST['lang']; - OC_PREFERENCES::setValue( $_SESSION['user_id'], 'core', 'lang', $lang ); + OC_PREFERENCES::setValue( OC_USER::getUser(), 'core', 'lang', $lang ); echo json_encode( array( "status" => "success", "data" => array( "message" => $l->t("Language changed") ))); }else{ echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t("Invalid request") ))); diff --git a/settings/index.php b/settings/index.php index e2a73a5d9f..07adba142d 100644 --- a/settings/index.php +++ b/settings/index.php @@ -18,7 +18,7 @@ $free=OC_FILESYSTEM::free_space(); $total=$free+$used; $relative=round(($used/$total)*100); -$lang=OC_PREFERENCES::getValue( $_SESSION['user_id'], 'core', 'lang', 'en' ); +$lang=OC_PREFERENCES::getValue( OC_USER::getUser(), 'core', 'lang', 'en' ); $languages=OC_L10N::findAvailableLanguages(); //put the current language in the front unset($languages[array_search($lang,$languages)]); From 50dbc533e184cbce9bae3dd6710fbf87ab22694f Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Thu, 23 Jun 2011 01:53:48 +0200 Subject: [PATCH 080/111] updated/finished German translation --- l10n/de/admin.po | 36 ++++++++++++++++++------------------ l10n/de/core.po | 32 +++++++++++++++++--------------- l10n/de/help.po | 4 ++-- l10n/de/settings.po | 34 +++++++++++++++++----------------- 4 files changed, 54 insertions(+), 52 deletions(-) diff --git a/l10n/de/admin.po b/l10n/de/admin.po index 94134e4439..58db3b78e6 100644 --- a/l10n/de/admin.po +++ b/l10n/de/admin.po @@ -19,73 +19,73 @@ msgstr "" #: ../templates/app.php:22 msgid "read more" -msgstr "" +msgstr "mehr …" #: ../templates/app.php:24 msgid "INSTALL" -msgstr "" +msgstr "Installieren" #: ../templates/app_noconn.php:6 ../templates/apps.php:6 msgid "Apps Repository" -msgstr "" +msgstr "Anwendungen" #: ../templates/app_noconn.php:7 msgid "Cannot connect to apps repository" -msgstr "" +msgstr "Verbindung fehlgeschlagen" #: ../templates/apps.php:13 ../templates/users.php:6 ../templates/users.php:20 #: ../templates/users.php:50 msgid "Name" -msgstr "" +msgstr "Name" #: ../templates/apps.php:14 msgid "Modified" -msgstr "" +msgstr "Änderungsdatum" #: ../templates/system.php:6 msgid "Administration" -msgstr "" +msgstr "Verwaltung" #: ../templates/system.php:7 msgid "System Settings" -msgstr "" +msgstr "Systemeinstellungen" #: ../templates/users.php:7 ../templates/users.php:46 msgid "Groups" -msgstr "" +msgstr "Gruppen" #: ../templates/users.php:13 msgid "Add user" -msgstr "" +msgstr "Nutzer hinzufügen" #: ../templates/users.php:21 msgid "Password" -msgstr "" +msgstr "Passwort" #: ../templates/users.php:30 msgid "Create user" -msgstr "" +msgstr "Nutzer erstellen" #: ../templates/users.php:40 ../templates/users.php:68 msgid "remove" -msgstr "" +msgstr "entfernen" #: ../templates/users.php:58 msgid "Create group" -msgstr "" +msgstr "Gruppe erstellen" #: ../templates/users.php:94 msgid "Force new password:" -msgstr "" +msgstr "Neues Passwort:" #: ../templates/users.php:96 msgid "Set" -msgstr "" +msgstr "OK" #: ../templates/users.php:102 msgid "Do you really want to delete user" -msgstr "" +msgstr "Möchtest du den Nutzer wirklich entfernen?" #: ../templates/users.php:109 msgid "Do you really want to delete group" -msgstr "" +msgstr "Möchtest du die Gruppe wirklich entfernen?" diff --git a/l10n/de/core.po b/l10n/de/core.po index 8b232607d9..b78c799619 100644 --- a/l10n/de/core.po +++ b/l10n/de/core.po @@ -19,19 +19,19 @@ msgstr "" #: ../templates/404.php:15 msgid "Error 404, Cloud not found" -msgstr "" +msgstr "Cloud konnte nicht gefunden werden." #: ../templates/installation.php:6 msgid "Welcome to ownCloud, your personnal cloud." -msgstr "" +msgstr "Willkommen bei ownCloud, deinem persönlichen Online-Speicher." #: ../templates/installation.php:7 msgid "To finish the installation, please follow the steps below." -msgstr "" +msgstr "Die Installation ist fast abgeschlossen." #: ../templates/installation.php:26 msgid "Create an admin account." -msgstr "" +msgstr "Verwaltungskonto erstellen." #: ../templates/installation.php:27 msgid "Login:" @@ -51,49 +51,51 @@ msgstr "Speicherort der Daten" #: ../templates/installation.php:35 msgid "Data directory:" -msgstr "" +msgstr "Datenverzeichnis:" #: ../templates/installation.php:39 msgid "Configure your database." -msgstr "" +msgstr "Datenbank einstellen." #: ../templates/installation.php:43 msgid "I will use a SQLite database. You have nothing to do!" -msgstr "" +msgstr "Es wird eine SQLite-Datenbank genutzt." #: ../templates/installation.php:46 msgid "SQLite" -msgstr "" +msgstr "SQLite" #: ../templates/installation.php:53 msgid "I will use a MySQL database." -msgstr "" +msgstr "Es wird eine MySQL-Datenbank genutzt." #: ../templates/installation.php:59 msgid "Host:" -msgstr "" +msgstr "Host:" #: ../templates/installation.php:60 msgid "Database name:" -msgstr "" +msgstr "Datenbankname:" #: ../templates/installation.php:61 msgid "Table prefix:" -msgstr "" +msgstr "Tabellenpräfix:" #: ../templates/installation.php:62 msgid "MySQL user login:" -msgstr "" +msgstr "MySQL-Nutzername:" #: ../templates/installation.php:63 msgid "MySQL user password:" -msgstr "" +msgstr "MySQL-Passwort:" #: ../templates/layout.guest.php:17 ../templates/layout.guest.php:20 msgid "" "ownCloud is a personal cloud which runs " "on your own server.

    " msgstr "" +"ownCloud ist ein privater Online-Speicher " +"für deinen eigenen Server.

    " #: ../templates/login.php:6 msgid "Login failed!" @@ -117,4 +119,4 @@ msgstr "Suchen" #: ../templates/installation.php:68 msgid "Finish setup" -msgstr "" +msgstr "Installation abschließen" diff --git a/l10n/de/help.po b/l10n/de/help.po index cd06f9b10a..37029fffc7 100644 --- a/l10n/de/help.po +++ b/l10n/de/help.po @@ -19,8 +19,8 @@ msgstr "" #: ../templates/index.php:2 msgid "Questions and Answers" -msgstr "" +msgstr "Fragen & Antworten" #: ../templates/index.php:21 msgid "ASK A QUESTION" -msgstr "" +msgstr "Stell eine Frage" diff --git a/l10n/de/settings.po b/l10n/de/settings.po index 55f3298f6f..423514bc13 100644 --- a/l10n/de/settings.po +++ b/l10n/de/settings.po @@ -19,68 +19,68 @@ msgstr "" #: ../templates/index.php:3 msgid "Account information" -msgstr "" +msgstr "Konto-Information" #: ../templates/index.php:5 msgid "You're currently using" -msgstr "" +msgstr "Du benutzt gerade" #: ../templates/index.php:5 msgid "of your" -msgstr "" +msgstr "von deinem" #: ../templates/index.php:5 msgid "space" -msgstr "" +msgstr "Speicherplatz" #: ../templates/index.php:11 msgid "Change Password" -msgstr "" +msgstr "Passwort ändern" #: ../templates/index.php:12 msgid "Your password got changed" -msgstr "" +msgstr "Dein Passwort wurde geändert." #: ../templates/index.php:15 msgid "Old password:" -msgstr "" +msgstr "Aktuelles Passwort:" #: ../templates/index.php:19 msgid "New password" -msgstr "" +msgstr "Neues Passwort:" #: ../templates/index.php:24 msgid "Show new password" -msgstr "" +msgstr "Neues Passwort anzeigen" #: ../templates/index.php:34 msgid "Language" -msgstr "" +msgstr "Sprache" #: ../ajax/changepassword.php:13 ../ajax/setlanguage.php:13 msgid "Authentication error" -msgstr "" +msgstr "Berechtigungsfehler" #: ../ajax/changepassword.php:19 msgid "You have to enter the old and the new password!" -msgstr "" +msgstr "Du musst das aktuelle und ein neues Passwort angeben!" #: ../ajax/changepassword.php:25 msgid "Your old password is wrong!" -msgstr "" +msgstr "Du hast dein aktuelles Passwort falsch eingegeben!" #: ../ajax/changepassword.php:31 msgid "Password changed" -msgstr "" +msgstr "Passwort geändert" #: ../ajax/changepassword.php:34 msgid "Unable to change password" -msgstr "" +msgstr "Passwort konnte nicht geändert werden" #: ../ajax/setlanguage.php:21 msgid "Language changed" -msgstr "" +msgstr "Sprache geändert" #: ../ajax/setlanguage.php:23 msgid "Invalid request" -msgstr "" +msgstr "Ungültige Anfrage" From 481b7b25e2635f66b3aba6eeb4b2100b0f1a825b Mon Sep 17 00:00:00 2001 From: Jakob Sack Date: Thu, 23 Jun 2011 10:58:06 +0200 Subject: [PATCH 081/111] Make Jans German translation usuable --- admin/l10n/de.php | 20 ++++++++++++++++++++ core/l10n/de.php | 18 +++++++++++++++++- help/l10n/de.php | 4 ++++ l10n/de/log.po | 15 ++++++++------- settings/l10n/de.php | 19 +++++++++++++++++++ 5 files changed, 68 insertions(+), 8 deletions(-) create mode 100644 admin/l10n/de.php create mode 100644 help/l10n/de.php create mode 100644 settings/l10n/de.php diff --git a/admin/l10n/de.php b/admin/l10n/de.php new file mode 100644 index 0000000000..9d1b12b1a1 --- /dev/null +++ b/admin/l10n/de.php @@ -0,0 +1,20 @@ + "mehr …", +"INSTALL" => "Installieren", +"Apps Repository" => "Anwendungen", +"Cannot connect to apps repository" => "Verbindung fehlgeschlagen", +"Name" => "Name", +"Modified" => "Änderungsdatum", +"Administration" => "Verwaltung", +"System Settings" => "Systemeinstellungen", +"Groups" => "Gruppen", +"Add user" => "Nutzer hinzufügen", +"Password" => "Passwort", +"Create user" => "Nutzer erstellen", +"remove" => "entfernen", +"Create group" => "Gruppe erstellen", +"Force new password:" => "Neues Passwort:", +"Set" => "OK", +"Do you really want to delete user" => "Möchtest du den Nutzer wirklich entfernen?", +"Do you really want to delete group" => "Möchtest du die Gruppe wirklich entfernen?" +); diff --git a/core/l10n/de.php b/core/l10n/de.php index cd89558a4d..b1309beed0 100644 --- a/core/l10n/de.php +++ b/core/l10n/de.php @@ -1,11 +1,27 @@ "Cloud konnte nicht gefunden werden.", +"Welcome to ownCloud, your personnal cloud." => "Willkommen bei ownCloud, deinem persönlichen Online-Speicher.", +"To finish the installation, please follow the steps below." => "Die Installation ist fast abgeschlossen.", +"Create an admin account." => "Verwaltungskonto erstellen.", "Login:" => "Benutzername:", "Password:" => "Passwort:", "Advanced" => "Erweitert", "Set where to store the data." => "Speicherort der Daten", +"Data directory:" => "Datenverzeichnis:", +"Configure your database." => "Datenbank einstellen.", +"I will use a SQLite database. You have nothing to do!" => "Es wird eine SQLite-Datenbank genutzt.", +"SQLite" => "SQLite", +"I will use a MySQL database." => "Es wird eine MySQL-Datenbank genutzt.", +"Host:" => "Host:", +"Database name:" => "Datenbankname:", +"Table prefix:" => "Tabellenpräfix:", +"MySQL user login:" => "MySQL-Nutzername:", +"MySQL user password:" => "MySQL-Passwort:", +"ownCloud is a personal cloud which runs on your own server.

    " => "ownCloud ist ein privater Online-Speicher für deinen eigenen Server.

    ", "Login failed!" => "Anmeldung Fehlgeschlagen!", "You are logged out." => "Sie wurden abgemeldet.", "prev" => "zurück", "next" => "weiter", -"Search" => "Suchen" +"Search" => "Suchen", +"Finish setup" => "Installation abschließen" ); diff --git a/help/l10n/de.php b/help/l10n/de.php new file mode 100644 index 0000000000..07c5d1bb77 --- /dev/null +++ b/help/l10n/de.php @@ -0,0 +1,4 @@ + "Fragen & Antworten", +"ASK A QUESTION" => "Stell eine Frage" +); diff --git a/l10n/de/log.po b/l10n/de/log.po index 2bb4104b30..f552e1fd14 100644 --- a/l10n/de/log.po +++ b/l10n/de/log.po @@ -1,21 +1,21 @@ -# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. # -#, fuzzy +# Jakob Sack , 2011. msgid "" msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" +"Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2011-06-20 22:00+0200\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" +"PO-Revision-Date: 2011-06-21 16:44+0200\n" +"Last-Translator: Jakob Sack \n" +"Language-Team: German \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.2\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" #: ../templates/index.php:4 msgid "Filter:" @@ -64,3 +64,4 @@ msgstr "Wann" #: ../templates/index.php:45 msgid "Clear log entries before" msgstr "Lösche Einträge vor dem" + diff --git a/settings/l10n/de.php b/settings/l10n/de.php new file mode 100644 index 0000000000..e3be20de33 --- /dev/null +++ b/settings/l10n/de.php @@ -0,0 +1,19 @@ + "Konto-Information", +"You're currently using" => "Du benutzt gerade", +"of your" => "von deinem", +"space" => "Speicherplatz", +"Change Password" => "Passwort ändern", +"Your password got changed" => "Dein Passwort wurde geändert.", +"Old password:" => "Aktuelles Passwort:", +"New password" => "Neues Passwort:", +"Show new password" => "Neues Passwort anzeigen", +"Language" => "Sprache", +"Authentication error" => "Berechtigungsfehler", +"You have to enter the old and the new password!" => "Du musst das aktuelle und ein neues Passwort angeben!", +"Your old password is wrong!" => "Du hast dein aktuelles Passwort falsch eingegeben!", +"Password changed" => "Passwort geändert", +"Unable to change password" => "Passwort konnte nicht geändert werden", +"Language changed" => "Sprache geändert", +"Invalid request" => "Ungültige Anfrage" +); From 51b25574700de137f15da880f51bf3a3fb167b4d Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 23 Jun 2011 12:04:17 +0200 Subject: [PATCH 082/111] stop confusing people with a dummy share button --- files/templates/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/templates/index.php b/files/templates/index.php index 0f24a00f07..6eaa380506 100644 --- a/files/templates/index.php +++ b/files/templates/index.php @@ -16,7 +16,7 @@ t( 'Download' ); ?> - + t( 'Delete' ); ?>
    From 01471d3e2a29268e8f1dfa3c96da53a0bb9e731c Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 23 Jun 2011 12:06:46 +0200 Subject: [PATCH 083/111] return to default page on empty search --- search/index.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/search/index.php b/search/index.php index e6f41528ea..b348b22387 100644 --- a/search/index.php +++ b/search/index.php @@ -38,6 +38,9 @@ OC_UTIL::addStyle( 'search', 'search' ); $query=(isset($_POST['query']))?$_POST['query']:''; if($query){ $results=OC_SEARCH::search($query); +}else{ + header("Location: ".$WEBROOT.'/'.OC_APPCONFIG::getValue("core", "defaultpage", "files/index.php")); + exit(); } $resultTypes=array(); From 96657f8b620c374b2c4e3230f3451aa656a5b07b Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 23 Jun 2011 14:33:39 +0200 Subject: [PATCH 084/111] Detect backend features dynamically instead of trial-and-error usage Move documented functions for reference into OC_USER_EXAMPLE class. --- lib/User/backend.php | 112 +++++++++++++++++++------------------------ lib/User/example.php | 97 +++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+), 63 deletions(-) create mode 100644 lib/User/example.php diff --git a/lib/User/backend.php b/lib/User/backend.php index 8ea7f78190..1797d0c475 100644 --- a/lib/User/backend.php +++ b/lib/User/backend.php @@ -4,7 +4,9 @@ * ownCloud * * @author Frank Karlitschek + * @author Dominik Schmidt * @copyright 2010 Frank Karlitschek karlitschek@kde.org + * @copyright 2011 Dominik Schmidt dev@dominik-schmidt.de * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE @@ -22,79 +24,63 @@ */ /** - * error code for functions not provided by the storage provider + * error code for functions not provided by the user backend */ -define('OC_USER_BACKEND_NOT_IMPLEMENTED',-501); +define('OC_USER_BACKEND_NOT_IMPLEMENTED', -501); + +/** + * actions that user backends can define + */ +define('OC_USER_BACKEND_CREATE_USER', 0x000001); +define('OC_USER_BACKEND_DELETE_USER', 0x000010); +define('OC_USER_BACKEND_SET_PASSWORD', 0x000100); +define('OC_USER_BACKEND_CHECK_PASSWORD', 0x001000); +define('OC_USER_BACKEND_GET_USERS', 0x010000); +define('OC_USER_BACKEND_USER_EXISTS', 0x100000); + /** * abstract base class for user management + * subclass this for your own backends and see OC_USER_EXAMPLE for descriptions */ abstract class OC_USER_BACKEND { + protected $possibleActions = array( + OC_USER_BACKEND_CREATE_USER => 'createUser', + OC_USER_BACKEND_DELETE_USER => 'deleteUser', + OC_USER_BACKEND_SET_PASSWORD => 'setPassword', + OC_USER_BACKEND_CHECK_PASSWORD => 'checkPassword', + OC_USER_BACKEND_GET_USERS => 'getUsers', + OC_USER_BACKEND_USER_EXISTS => 'userExists' + ); + /** - * @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){ - return OC_USER_BACKEND_NOT_IMPLEMENTED; + * @brief Get all supported actions + * @returns bitwise-or'ed actions + * + * Returns the supported actions as int to be + * compared with OC_USER_BACKEND_CREATE_USER etc. + */ + public function getSupportedActions(){ + $actions = 0; + foreach($this->possibleActions AS $action => $methodName){ + if(method_exists($this, $methodName)) { + $actions |= $action; + } + } + + return $actions; } /** - * @brief delete a user - * @param $uid The username of the user to delete - * @returns true/false - * - * Deletes a user - */ - public function deleteUser( $uid ){ - return OC_USER_BACKEND_NOT_IMPLEMENTED; - } - - /** - * @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){ - return OC_USER_BACKEND_NOT_IMPLEMENTED; - } - - /** - * @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){ - return OC_USER_BACKEND_NOT_IMPLEMENTED; - } - - /** - * @brief Get a list of all users - * @returns array with all uids - * - * Get a list of all users. - */ - public function getUsers(){ - return OC_USER_BACKEND_NOT_IMPLEMENTED; - } - - /** - * @brief check if a user exists - * @param string $uid the username - * @return boolean - */ - public function userExists($uid){ - return OC_USER_BACKEND_NOT_IMPLEMENTED; + * @brief Check if backend implements actions + * @param $actions bitwise-or'ed actions + * @returns boolean + * + * Returns the supported actions as int to be + * compared with OC_USER_BACKEND_CREATE_USER etc. + */ + public function implementsActions($actions){ + return (bool)($this->getSupportedActions() & $actions); } } diff --git a/lib/User/example.php b/lib/User/example.php new file mode 100644 index 0000000000..4abc1b3d49 --- /dev/null +++ b/lib/User/example.php @@ -0,0 +1,97 @@ +. + * + */ + +require_once('User/backend.php'); + +/** + * abstract reference class for user management + * this class should only be used as a reference for method signatures and their descriptions + */ +abstract class OC_USER_EXAMPLE extends OC_USER_BACKEND { + /** + * @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){ + return OC_USER_BACKEND_NOT_IMPLEMENTED; + } + + /** + * @brief delete a user + * @param $uid The username of the user to delete + * @returns true/false + * + * Deletes a user + */ + public function deleteUser( $uid ){ + return OC_USER_BACKEND_NOT_IMPLEMENTED; + } + + /** + * @brief Set password + * @param $uid The username + * @param $password The new password + * @returns true/false + * + * Change the password of a user + */ + public function setPassword($uid, $password){ + return OC_USER_BACKEND_NOT_IMPLEMENTED; + } + + /** + * @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){ + return OC_USER_BACKEND_NOT_IMPLEMENTED; + } + + /** + * @brief Get a list of all users + * @returns array with all uids + * + * Get a list of all users. + */ + public function getUsers(){ + return OC_USER_BACKEND_NOT_IMPLEMENTED; + } + + /** + * @brief check if a user exists + * @param string $uid the username + * @return boolean + */ + public function userExists($uid){ + return OC_USER_BACKEND_NOT_IMPLEMENTED; + } +} From 3b2fcd356f0e1bc0472583d910932c7771ce991c Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 23 Jun 2011 15:24:09 +0200 Subject: [PATCH 085/111] Use new user backend API --- lib/user.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/user.php b/lib/user.php index 7eafef924a..33ee5b8762 100644 --- a/lib/user.php +++ b/lib/user.php @@ -66,7 +66,7 @@ class OC_USER { public static function getBackends(){ return self::$_backends; } - + /** * @brief gets used backends * @returns array of backends @@ -140,11 +140,13 @@ class OC_USER { if( $run ){ //create the user in the first backend that supports creating users foreach(self::$_usedBackends as $backend){ - $result=$backend->createUser($uid,$password); - if($result!==OC_USER_BACKEND_NOT_IMPLEMENTED){ - OC_HOOK::emit( "OC_USER", "post_createUser", array( "uid" => $uid, "password" => $password )); - return true; - } + if(!$backend->implementsActions(OC_USER_BACKEND_CREATE_USER)) + continue; + + $backend->createUser($uid,$password); + OC_HOOK::emit( "OC_USER", "post_createUser", array( "uid" => $uid, "password" => $password )); + + return true; } } return false; @@ -306,9 +308,8 @@ class OC_USER { public static function getUsers(){ $users=array(); foreach(self::$_usedBackends as $backend){ - $result=$backend->getUsers(); - if($result!=OC_USER_BACKEND_NOT_IMPLEMENTED){ - $users=array_merge($users,$result); + if($backend->implementsActions(OC_USER_BACKEND_GET_USERS)){ + $users=array_merge($users,$backend->getUsers()); } } return $users; From bd4aec2c4c979cf88fd2e430b52eb22b34b56dba Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 23 Jun 2011 17:04:32 +0200 Subject: [PATCH 086/111] Experimental OpenID user backend and server. Currently all users can set one OpenID identity that allows access to the account. The identity url's for the server is owncloud/apps/user_openid/user.php/$username --- apps/user_openid/appinfo/app.php | 38 + apps/user_openid/appinfo/info.xml | 10 + apps/user_openid/class.openid.v3.php | 328 +++++ apps/user_openid/phpmyid.php | 1723 +++++++++++++++++++++++ apps/user_openid/settings.php | 24 + apps/user_openid/templates/settings.php | 7 + apps/user_openid/user.php | 34 + apps/user_openid/user_openid.php | 73 + 8 files changed, 2237 insertions(+) create mode 100644 apps/user_openid/appinfo/app.php create mode 100644 apps/user_openid/appinfo/info.xml create mode 100644 apps/user_openid/class.openid.v3.php create mode 100644 apps/user_openid/phpmyid.php create mode 100644 apps/user_openid/settings.php create mode 100644 apps/user_openid/templates/settings.php create mode 100644 apps/user_openid/user.php create mode 100644 apps/user_openid/user_openid.php diff --git a/apps/user_openid/appinfo/app.php b/apps/user_openid/appinfo/app.php new file mode 100644 index 0000000000..fb3de10e2a --- /dev/null +++ b/apps/user_openid/appinfo/app.php @@ -0,0 +1,38 @@ + "user_openid_settings", 'order'=>1, "href" => OC_HELPER::linkTo( "user_openid", "settings.php" ), "name" => "OpenID")); + +//active the openid backend +OC_USER::useBackend('openid'); + +//check for results from openid requests +if(isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'id_res'){ + error_log('openid retured'); + $openid = new SimpleOpenID; + $openid->SetIdentity($_GET['openid_identity']); + $openid_validation_result = $openid->ValidateWithServer(); + if ($openid_validation_result == true){ // OK HERE KEY IS VALID + error_log('auth sucessfull'); + global $WEBROOT; + $identity=$openid->GetIdentity(); + error_log("auth as $identity"); + $user=OC_USER_OPENID::findUserForIdentity($identity); + if($user){ + $_SESSION['user_id']=$user; + header("Location: $WEBROOT"); + } + }else if($openid->IsError() == true){ // ON THE WAY, WE GOT SOME ERROR + $error = $openid->GetError(); + error_log("ERROR CODE: " . $error['code']); + error_log("ERROR DESCRIPTION: " . $error['description']); + }else{ // Signature Verification Failed + error_log("INVALID AUTHORIZATION"); + } +}else if (isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'cancel'){ // User Canceled your Request + error_log("USER CANCELED REQUEST"); + return false; +} + +?> diff --git a/apps/user_openid/appinfo/info.xml b/apps/user_openid/appinfo/info.xml new file mode 100644 index 0000000000..32525009d6 --- /dev/null +++ b/apps/user_openid/appinfo/info.xml @@ -0,0 +1,10 @@ + + + user_openid + OpenID user backend + Allow login through OpenID + 0.1 + AGPL + Robin Appelman + 2 + \ No newline at end of file diff --git a/apps/user_openid/class.openid.v3.php b/apps/user_openid/class.openid.v3.php new file mode 100644 index 0000000000..8afb9e5b81 --- /dev/null +++ b/apps/user_openid/class.openid.v3.php @@ -0,0 +1,328 @@ +SetIdentity($_POST['openid_url']); + :: SET RETURN URL :: + $openid->SetApprovedURL('http://www.yoursite.com/return.php'); // Script which handles a response from OpenID Server + :: SET TRUST ROOT :: + $openid->SetTrustRoot('http://www.yoursite.com/'); + :: FETCH SERVER URL FROM IDENTITY PAGE :: [Note: It is recomended to cache this (Session, Cookie, Database)] + $openid->GetOpenIDServer(); // Returns false if server is not found + :: REDIRECT USER TO OPEN ID SERVER FOR APPROVAL :: + + :: (OPTIONAL) SET OPENID SERVER :: + $openid->SetOpenIDServer($server_url); // If you have cached previously this, you don't have to call GetOpenIDServer and set value this directly + + STEP 2) + Once user gets returned we must validate signature + :: VALIDATE REQUEST :: + true|false = $openid->ValidateWithServer(); + + ERRORS: + array = $openid->GetError(); // Get latest Error code + + FIELDS: + OpenID allowes you to retreive a profile. To set what fields you'd like to get use (accepts either string or array): + $openid->SetRequiredFields(array('email','fullname','dob','gender','postcode','country','language','timezone')); + or + $openid->SetOptionalFields('postcode'); + +IMPORTANT TIPS: +OPENID as is now, is not trust system. It is a great single-sign on method. If you want to +store information about OpenID in your database for later use, make sure you handle url identities +properly. + For example: + https://steve.myopenid.com/ + https://steve.myopenid.com + http://steve.myopenid.com/ + http://steve.myopenid.com + ... are representing one single user. Some OpenIDs can be in format openidserver.com/users/user/ - keep this in mind when storing identities + + To help you store an OpenID in your DB, you can use function: + $openid_db_safe = $openid->OpenID_Standarize($upenid); + This may not be comatible with current specs, but it works in current enviroment. Use this function to get openid + in one format like steve.myopenid.com (without trailing slashes and http/https). + Use output to insert Identity to database. Don't use this for validation - it may fail. + +*/ + +class SimpleOpenID{ + var $openid_url_identity; + var $URLs = array(); + var $error = array(); + var $fields = array( + 'required' => array(), + 'optional' => array(), + ); + + function SimpleOpenID(){ + if (!function_exists('curl_exec')) { + die('Error: Class SimpleOpenID requires curl extension to work'); + } + } + function SetOpenIDServer($a){ + $this->URLs['openid_server'] = $a; + } + function SetTrustRoot($a){ + $this->URLs['trust_root'] = $a; + } + function SetCancelURL($a){ + $this->URLs['cancel'] = $a; + } + function SetApprovedURL($a){ + $this->URLs['approved'] = $a; + } + function SetRequiredFields($a){ + if (is_array($a)){ + $this->fields['required'] = $a; + }else{ + $this->fields['required'][] = $a; + } + } + function SetOptionalFields($a){ + if (is_array($a)){ + $this->fields['optional'] = $a; + }else{ + $this->fields['optional'][] = $a; + } + } + function SetIdentity($a){ // Set Identity URL + if ((stripos($a, 'http://') === false) + && (stripos($a, 'https://') === false)){ + $a = 'http://'.$a; + } +/* + $u = parse_url(trim($a)); + if (!isset($u['path'])){ + $u['path'] = '/'; + }else if(substr($u['path'],-1,1) == '/'){ + $u['path'] = substr($u['path'], 0, strlen($u['path'])-1); + } + if (isset($u['query'])){ // If there is a query string, then use identity as is + $identity = $a; + }else{ + $identity = $u['scheme'] . '://' . $u['host'] . $u['path']; + } +//*/ + $this->openid_url_identity = $a; + } + function GetIdentity(){ // Get Identity + return $this->openid_url_identity; + } + function GetError(){ + $e = $this->error; + return array('code'=>$e[0],'description'=>$e[1]); + } + + function ErrorStore($code, $desc = null){ + $errs['OPENID_NOSERVERSFOUND'] = 'Cannot find OpenID Server TAG on Identity page.'; + if ($desc == null){ + $desc = $errs[$code]; + } + $this->error = array($code,$desc); + } + + function IsError(){ + if (count($this->error) > 0){ + return true; + }else{ + return false; + } + } + + function splitResponse($response) { + $r = array(); + $response = explode("\n", $response); + foreach($response as $line) { + $line = trim($line); + if ($line != "") { + list($key, $value) = explode(":", $line, 2); + $r[trim($key)] = trim($value); + } + } + return $r; + } + + function OpenID_Standarize($openid_identity = null){ + if ($openid_identity === null) + $openid_identity = $this->openid_url_identity; + + $u = parse_url(strtolower(trim($openid_identity))); + + if (!isset($u['path']) || ($u['path'] == '/')) { + $u['path'] = ''; + } + if(substr($u['path'],-1,1) == '/'){ + $u['path'] = substr($u['path'], 0, strlen($u['path'])-1); + } + if (isset($u['query'])){ // If there is a query string, then use identity as is + return $u['host'] . $u['path'] . '?' . $u['query']; + }else{ + return $u['host'] . $u['path']; + } + } + + function array2url($arr){ // converts associated array to URL Query String + if (!is_array($arr)){ + return false; + } + $query = ''; + foreach($arr as $key => $value){ + $query .= $key . "=" . $value . "&"; + } + return $query; + } + function FSOCK_Request($url, $method="GET", $params = ""){ + $fp = fsockopen("ssl://www.myopenid.com", 443, $errno, $errstr, 3); // Connection timeout is 3 seconds + if (!$fp) { + $this->ErrorStore('OPENID_SOCKETERROR', $errstr); + return false; + } else { + $request = $method . " /server HTTP/1.0\r\n"; + $request .= "User-Agent: Simple OpenID PHP Class (http://www.phpclasses.org/simple_openid)\r\n"; + $request .= "Connection: close\r\n\r\n"; + fwrite($fp, $request); + stream_set_timeout($fp, 4); // Connection response timeout is 4 seconds + $res = fread($fp, 2000); + $info = stream_get_meta_data($fp); + fclose($fp); + + if ($info['timed_out']) { + $this->ErrorStore('OPENID_SOCKETTIMEOUT'); + } else { + return $res; + } + } + } + function CURL_Request($url, $method="GET", $params = "") { // Remember, SSL MUST BE SUPPORTED + if (is_array($params)) $params = $this->array2url($params); + $curl = curl_init($url . ($method == "GET" && $params != "" ? "?" . $params : "")); + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($curl, CURLOPT_HEADER, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_HTTPGET, ($method == "GET")); + curl_setopt($curl, CURLOPT_POST, ($method == "POST")); + if ($method == "POST") curl_setopt($curl, CURLOPT_POSTFIELDS, $params); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + $response = curl_exec($curl); + + if (curl_errno($curl) == 0){ + $response; + }else{ + $this->ErrorStore('OPENID_CURL', curl_error($curl)); + } + return $response; + } + + function HTML2OpenIDServer($content) { + $get = array(); + + // Get details of their OpenID server and (optional) delegate + preg_match_all('/]*rel=[\'"](openid2.provider )?openid.server[\'"][^>]*href=[\'"]([^\'"]+)[\'"][^>]*\/?>/i', $content, $matches1); + preg_match_all('/]*href=\'"([^\'"]+)[\'"][^>]*rel=[\'"](openid2.provider )?openid.server[\'"][^>]*\/?>/i', $content, $matches2); + $servers = array_merge($matches1[2], $matches2[1]); + + preg_match_all('/]*rel=[\'"]openid.delegate[\'"][^>]*href=[\'"]([^\'"]+)[\'"][^>]*\/?>/i', $content, $matches1); + + preg_match_all('/]*href=[\'"]([^\'"]+)[\'"][^>]*rel=[\'"]openid.delegate[\'"][^>]*\/?>/i', $content, $matches2); + + $delegates = array_merge($matches1[1], $matches2[1]); + + $ret = array($servers, $delegates); + return $ret; + } + + function GetOpenIDServer(){ + $response = $this->CURL_Request($this->openid_url_identity); + list($servers, $delegates) = $this->HTML2OpenIDServer($response); + if (count($servers) == 0){ + $this->ErrorStore('OPENID_NOSERVERSFOUND'); + return false; + } + if (isset($delegates[0]) + && ($delegates[0] != "")){ + $this->SetIdentity($delegates[0]); + } + $this->SetOpenIDServer($servers[0]); + return $servers[0]; + } + + function GetRedirectURL(){ + $params = array(); + $params['openid.return_to'] = urlencode($this->URLs['approved']); + $params['openid.mode'] = 'checkid_setup'; + $params['openid.identity'] = urlencode($this->openid_url_identity); + $params['openid.trust_root'] = urlencode($this->URLs['trust_root']); + + if (isset($this->fields['required']) + && (count($this->fields['required']) > 0)) { + $params['openid.sreg.required'] = implode(',',$this->fields['required']); + } + if (isset($this->fields['optional']) + && (count($this->fields['optional']) > 0)) { + $params['openid.sreg.optional'] = implode(',',$this->fields['optional']); + } + return $this->URLs['openid_server'] . "?". $this->array2url($params); + } + + function Redirect(){ + $redirect_to = $this->GetRedirectURL(); + if (headers_sent()){ // Use JavaScript to redirect if content has been previously sent (not recommended, but safe) + echo ''; + }else{ // Default Header Redirect + header('Location: ' . $redirect_to); + } + } + + function ValidateWithServer(){ + $params = array( + 'openid.assoc_handle' => urlencode($_GET['openid_assoc_handle']), + 'openid.signed' => urlencode($_GET['openid_signed']), + 'openid.sig' => urlencode($_GET['openid_sig']) + ); + // Send only required parameters to confirm validity + $arr_signed = explode(",",str_replace('sreg.','sreg_',$_GET['openid_signed'])); + for ($i=0; $iGetOpenIDServer(); + if ($openid_server == false){ + return false; + } + $response = $this->CURL_Request($openid_server,'POST',$params); + $data = $this->splitResponse($response); + + if ($data['is_valid'] == "true") { + return true; + }else{ + return false; + } + } +} + +?> \ No newline at end of file diff --git a/apps/user_openid/phpmyid.php b/apps/user_openid/phpmyid.php new file mode 100644 index 0000000000..719bbd954c --- /dev/null +++ b/apps/user_openid/phpmyid.php @@ -0,0 +1,1723 @@ + + * @copyright 2006-2008 + * @license http://www.gnu.org/licenses/gpl.html GNU Public License + * @url http://siege.org/projects/phpMyID + * @version 0.9 + */ + + +/** + * Set a constant to indicate that phpMyID is running + */ +define('PHPMYID_STARTED', true); + +/** + * List the known types and modes + * @name $known + * @global array $GLOBALS['known'] + */ +$GLOBALS['known'] = array( + 'assoc_types' => array('HMAC-SHA1'), + + 'openid_modes' => array('accept', + 'associate', + 'authorize', + 'cancel', + 'checkid_immediate', + 'checkid_setup', + 'check_authentication', + 'error', + 'id_res', + 'login', + 'logout', + 'test'), + + 'session_types' => array('', + 'DH-SHA1'), + + 'bigmath_types' => array('DH-SHA1'), +); + +/** + * Defined by OpenID spec + * @name $g + * @global integer $GLOBALS['g'] + */ +$GLOBALS['g'] = 2; + +/** + * Defined by OpenID spec + * @name $p + * @global integer $GLOBALS['p'] + */ +$GLOBALS['p'] = '155172898181473697471232257763715539915724801966915404479707' . +'7953140576293785419175806512274236981889937278161526466314385615958256881888' . +'8995127215884267541995034125870655654980358010487053768147672651325574704076' . +'5857479291291572334510643245094715007229621094194349783925984760375594985848' . +'253359305585439638443'; + + +// Runmode functions + +/** + * Allow the user to accept trust on a URL + * @global array $profile + */ +function accept_mode () { + global $profile; + + // this is a user session + user_session(); + + // the user needs refresh urls in their session to access this mode + if (! isset($_SESSION['post_accept_url']) || ! isset($_SESSION['cancel_accept_url']) || ! isset($_SESSION['unaccepted_url'])) + error_500('You may not access this mode directly.'); + + // has the user accepted the trust_root? + $accepted = @strlen($_REQUEST['accepted']) + ? $_REQUEST['accepted'] + : null; + + // if so, refresh back to post_accept_url + if ($accepted === 'yes') { + $_SESSION['accepted_url'] = $_SESSION['unaccepted_url']; + wrap_redirect($_SESSION['post_accept_url']); + + // if they rejected it, return to the client + } elseif ($accepted === 'no') { + wrap_redirect($_SESSION['cancel_accept_url']); + } + + // if neither, offer the trust request + $q = strpos($profile['req_url'], '?') ? '&' : '?'; + $yes = $profile['req_url'] . $q . 'accepted=yes'; + $no = $profile['req_url'] . $q . 'accepted=no'; + + wrap_html('The client site you are attempting to log into has requested that you trust the following URL:
    ' . $_SESSION['unaccepted_url'] . '

    Do you wish to continue?
    Yes | No'); +} + +/** * Perform an association with a consumer + * @global array $known + * @global array $profile + * @global integer $g + * @global integer $p + */ +function associate_mode () { + global $g, $known, $p, $profile; + + // Validate the request + if (! isset($_REQUEST['openid_mode']) || $_REQUEST['openid_mode'] != 'associate') + error_400(); + + // Get the request options, using defaults as necessary + $assoc_type = (@strlen($_REQUEST['openid_assoc_type']) + && in_array($_REQUEST['openid_assoc_type'], $known['assoc_types'])) + ? $_REQUEST['openid_assoc_type'] + : 'HMAC-SHA1'; + + $session_type = (@strlen($_REQUEST['openid_session_type']) + && in_array($_REQUEST['openid_session_type'], $known['session_types'])) + ? $_REQUEST['openid_session_type'] + : ''; + + $dh_modulus = (@strlen($_REQUEST['openid_dh_modulus'])) + ? long(base64_decode($_REQUEST['openid_dh_modulus'])) + : ($session_type == 'DH-SHA1' + ? $p + : null); + + $dh_gen = (@strlen($_REQUEST['openid_dh_gen'])) + ? long(base64_decode($_REQUEST['openid_dh_gen'])) + : ($session_type == 'DH-SHA1' + ? $g + : null); + + $dh_consumer_public = (@strlen($_REQUEST['openid_dh_consumer_public'])) + ? $_REQUEST['openid_dh_consumer_public'] + : ($session_type == 'DH-SHA1' + ? error_post('dh_consumer_public was not specified') + : null); + + $lifetime = time() + $profile['lifetime']; + + // Create standard keys + $keys = array( + 'assoc_type' => $assoc_type, + 'expires_in' => $profile['lifetime'] + ); + + // If I can't handle bigmath, default to plaintext sessions + if (in_array($session_type, $known['bigmath_types']) && $profile['use_bigmath'] === false) + $session_type = null; + + // Add response keys based on the session type + switch ($session_type) { + case 'DH-SHA1': + // Create the associate id and shared secret now + list ($assoc_handle, $shared_secret) = new_assoc($lifetime); + + // Compute the Diffie-Hellman stuff + $private_key = random($dh_modulus); + $public_key = bmpowmod($dh_gen, $private_key, $dh_modulus); + $remote_key = long(base64_decode($dh_consumer_public)); + $ss = bmpowmod($remote_key, $private_key, $dh_modulus); + + $keys['assoc_handle'] = $assoc_handle; + $keys['session_type'] = $session_type; + $keys['dh_server_public'] = base64_encode(bin($public_key)); + $keys['enc_mac_key'] = base64_encode(x_or(sha1_20(bin($ss)), $shared_secret)); + + break; + + default: + // Create the associate id and shared secret now + list ($assoc_handle, $shared_secret) = new_assoc($lifetime); + + $keys['assoc_handle'] = $assoc_handle; + $keys['mac_key'] = base64_encode($shared_secret); + } + + // Return the keys + wrap_kv($keys); +} + + +/** + * Perform a user authorization + * @global array $profile + */ +function authorize_mode () { + global $profile; + global $USERNAME; + + // this is a user session + + // the user needs refresh urls in their session to access this mode + if (! isset($_SESSION['post_auth_url']) || ! isset($_SESSION['cancel_auth_url'])) + error_500('You may not access this mode directly.'); + + if (isset($_SERVER['PHP_AUTH_USER']) && $profile['authorized'] === false && $_SERVER['PHP_AUTH_USER']==$USERNAME) { + if (OC_USER::checkPassword($USERNAME, $_SERVER['PHP_AUTH_PW'])) {// successful login! + + // return to the refresh url if they get in + $_SESSION['openid_auth']=true; + $_SESSION['openid_user']=$USERNAME; + wrap_redirect($_SESSION['post_auth_url']); + + // failed login + } else { + $_SESSION['failures']++; + debug('Login failed'); + debug('Fail count: ' . $_SESSION['failures']); + } + + } + + // if we get this far the user is not authorized, so send the headers + $uid = uniqid(mt_rand(1,9)); + $_SESSION['uniqid'] = $uid; + +// debug('Prompting user to log in. Stale? ' . $stale); + header('HTTP/1.0 401 Unauthorized'); +// header(sprintf('WWW-Authenticate: Digest qop="auth-int, auth", realm="%s", domain="%s", nonce="%s", opaque="%s", stale="%s", algorithm="MD5"', $profile['auth_realm'], $profile['auth_domain'], $uid, md5($profile['auth_realm']), $stale ? 'true' : 'false')); + header('WWW-Authenticate: Basic realm="ownCloud"'); + $q = strpos($_SESSION['cancel_auth_url'], '?') ? '&' : '?'; + wrap_refresh($_SESSION['cancel_auth_url'] . $q . 'openid.mode=cancel'); +// die('401 Unauthorized'); +} + + +/** + * Handle a consumer's request for cancellation. + */ +function cancel_mode () { + wrap_html('Request cancelled.'); +} + + +/** + * Handle a consumer's request to see if the user is authenticated + */ +function check_authentication_mode () { + // Validate the request + if (! isset($_REQUEST['openid_mode']) || $_REQUEST['openid_mode'] != 'check_authentication') + error_400(); + + $assoc_handle = @strlen($_REQUEST['openid_assoc_handle']) + ? $_REQUEST['openid_assoc_handle'] + : error_post('Missing assoc_handle'); + + $sig = @strlen($_REQUEST['openid_sig']) + ? $_REQUEST['openid_sig'] + : error_post('Missing sig'); + + $signed = @strlen($_REQUEST['openid_signed']) + ? $_REQUEST['openid_signed'] + : error_post('Missing signed'); + + // Prepare the return keys + $keys = array( + 'openid.mode' => 'id_res' + ); + + // Invalidate the assoc handle if we need to + if (@strlen($_REQUEST['openid_invalidate_handle'])) { + destroy_assoc_handle($_REQUEST['openid_invalidate_handle']); + + $keys['invalidate_handle'] = $_REQUEST['openid_invalidate_handle']; + } + + // Validate the sig by recreating the kv pair and signing + $_REQUEST['openid_mode'] = 'id_res'; + $tokens = ''; + foreach (explode(',', $signed) as $param) { + $post = preg_replace('/\./', '_', $param); + $tokens .= sprintf("%s:%s\n", $param, $_REQUEST['openid_' . $post]); + } + + // Add the sreg stuff, if we've got it + if (isset($sreg_required)) { + foreach (explode(',', $sreg_required) as $key) { + if (! isset($sreg[$key])) + continue; + $skey = 'sreg.' . $key; + + $tokens .= sprintf("%s:%s\n", $skey, $sreg[$key]); + $keys[$skey] = $sreg[$key]; + $fields[] = $skey; + } + } + + // Look up the consumer's shared_secret and timeout + list ($shared_secret, $expires) = secret($assoc_handle); + + // if I can't verify the assoc_handle, or if it's expired + if ($shared_secret == false || (is_numeric($expires) && $expires < time())) { + $keys['is_valid'] = 'false'; + + } else { + $ok = base64_encode(hmac($shared_secret, $tokens)); + $keys['is_valid'] = ($sig == $ok) ? 'true' : 'false'; + } + + // Return the keys + wrap_kv($keys); +} + + +/** + * Handle a consumer's request to see if the end user is logged in + * @global array $known + * @global array $profile + * @global array $sreg + */ +function checkid ( $wait ) { + global $known, $profile, $sreg; + global $USERNAME; + + // This is a user session + user_session(); + + // Get the options, use defaults as necessary + $return_to = @strlen($_REQUEST['openid_return_to']) + ? $_REQUEST['openid_return_to'] + : error_400('Missing return1_to'); + + $identity = @strlen($_REQUEST['openid_identity']) + ? $_REQUEST['openid_identity'] + : error_get($return_to, 'Missing identity'); + + $assoc_handle = @strlen($_REQUEST['openid_assoc_handle']) + ? $_REQUEST['openid_assoc.handle'] + : null; + + $trust_root = @strlen($_REQUEST['openid_trust_root']) + ? $_REQUEST['openid_trust_root'] + : $return_to; + + $sreg_required = @strlen($_REQUEST['openid_sreg_required']) + ? $_REQUEST['openid_sreg.required'] + : ''; + + $sreg_optional = @strlen($_REQUEST['openid_sreg_optional']) + ? $_REQUEST['openid_sreg.optional'] + : ''; + + // determine the cancel url + $q = strpos($return_to, '?') ? '&' : '?'; + $cancel_url = $return_to . $q . 'openid.mode=cancel'; + + // required and optional make no difference to us + $sreg_required .= ',' . $sreg_optional; + // do the trust_root analysis + if ($trust_root != $return_to) { + // the urls are not the same, be sure return decends from trust + if (! url_descends($return_to, $trust_root)) + error_500('Invalid trust_root: "' . $trust_root . '"'); + + } + + // transfer the user to the url accept mode if they're paranoid + if ($wait == 1 && isset($profile['paranoid']) && $profile['paranoid'] === true && (! session_is_registered('accepted_url') || $_SESSION['accepted_url'] != $trust_root)) { + $_SESSION['cancel_accept_url'] = $cancel_url; + $_SESSION['post_accept_url'] = $profile['req_url']; + $_SESSION['unaccepted_url'] = $trust_root; + + debug('Transferring to acceptance mode.'); + debug('Cancel URL: ' . $_SESSION['cancel_accept_url']); + debug('Post URL: ' . $_SESSION['post_accept_url']); + + $q = strpos($profile['idp_url'], '?') ? '&' : '?'; + wrap_redirect($profile['idp_url'] . $q . 'openid.mode=accept'); + } + + // make sure i am this identifier + if ($identity != $profile['idp_url']) { + debug("Invalid identity: $identity"); + debug("IdP URL: " . $profile['idp_url']); + error_get($return_to, "Invalid identity: '$identity'"); + } + + // begin setting up return keys + $keys = array( + 'mode' => 'id_res' + ); + + // if the user is not logged in, transfer to the authorization mode + if ($_SESSION['openid_auth'] === false || $USERNAME != $_SESSION['openid_user']) { + // users can only be logged in to one url at a time + $_SESSION['auth_username'] = null; + $_SESSION['auth_url'] = null; + + if ($wait) { + unset($_SESSION['uniqid']); + + $_SESSION['cancel_auth_url'] = $cancel_url; + $_SESSION['post_auth_url'] = $profile['req_url']; + + debug('Transferring to authorization mode.'); + debug('Cancel URL: ' . $_SESSION['cancel_auth_url']); + debug('Post URL: ' . $_SESSION['post_auth_url']); + + $q = strpos($profile['idp_url'], '?') ? '&' : '?'; + wrap_redirect($profile['idp_url'] . $q . 'openid.mode=authorize'); + } else { + $keys['user_setup_url'] = $profile['idp_url']; + } + + // the user is logged in + } else { + // remove the refresh URLs if set + unset($_SESSION['cancel_auth_url']); + unset($_SESSION['post_auth_url']); + + // check the assoc handle + list($shared_secret, $expires) = secret($assoc_handle); + + // if I can't verify the assoc_handle, or if it's expired + if ($shared_secret == false || (is_numeric($expires) && $expires < time())) { + debug("Session expired or missing key: $expires < " . time()); + if ($assoc_handle != null) { + $keys['invalidate_handle'] = $assoc_handle; + destroy_assoc_handle($assoc_handle); + } + + $lifetime = time() + $profile['lifetime']; + list ($assoc_handle, $shared_secret) = new_assoc($lifetime); + } + + $keys['identity'] = $profile['idp_url']; + $keys['assoc_handle'] = $assoc_handle; + $keys['return_to'] = $return_to; + + $fields = array_keys($keys); + $tokens = ''; + foreach ($fields as $key) + $tokens .= sprintf("%s:%s\n", $key, $keys[$key]); + + // add sreg keys + foreach (explode(',', $sreg_required) as $key) { + if (! isset($sreg[$key])) + continue; + $skey = 'sreg.' . $key; + + $tokens .= sprintf("%s:%s\n", $skey, $sreg[$key]); + $keys[$skey] = $sreg[$key]; + $fields[] = $skey; + } + + $keys['signed'] = implode(',', $fields); + $keys['sig'] = base64_encode(hmac($shared_secret, $tokens)); + } + + wrap_keyed_redirect($return_to, $keys); +} + + +/** + * Handle a consumer's request to see if the user is already logged in + */ +function checkid_immediate_mode () { + if (! isset($_REQUEST['openid_mode']) || $_REQUEST['openid_mode'] != 'checkid_immediate') + error_500(); + + checkid(false); +} + + +/** + * Handle a consumer's request to see if the user is logged in, but be willing + * to wait for them to perform a login if they're not + */ +function checkid_setup_mode () { + if (! isset($_REQUEST['openid_mode']) || $_REQUEST['openid_mode'] != 'checkid_setup') + error_500(); + + checkid(true); +} + + +/** + * Handle errors + */ +function error_mode () { + isset($_REQUEST['openid_error']) + ? wrap_html($_REQUEST['openid_error']) + : error_500(); +} + + +/** + * Show a user if they are logged in or not + * @global array $profile + */ +function id_res_mode () { + global $profile; + + user_session(); + + if ($profile['authorized']) + wrap_html('You are logged in as ' . $_SESSION['auth_username']); + + wrap_html('You are not logged in'); +} + + +/** + * Allow a user to perform a static login + * @global array $profile + */ +function login_mode () { + global $profile; + + user_session(); + + if ($profile['authorized']) + id_res_mode(); + + $keys = array( + 'mode' => 'checkid_setup', + 'identity' => $profile['idp_url'], + 'return_to' => $profile['idp_url'] + ); + + wrap_keyed_redirect($profile['idp_url'], $keys); +} + + +/** + * Allow a user to perform a static logout + * @global array $profile + */ +function logout_mode () { + global $profile; + + user_session(); + + if (! $profile['authorized']) + wrap_html('You were not logged in'); + + $_SESSION = array(); + session_destroy(); + debug('User session destroyed.'); + + header('HTTP/1.0 401 Unauthorized'); + wrap_redirect($profile['idp_url']); +} + + +/** + * The default information screen + * @global array $profile + */ +function no_mode () { + global $profile; + + wrap_html('This is an OpenID server endpoint. For more information, see http://openid.net/
    Server: ' . $profile['idp_url'] . '
    Realm: ' . $profile['php_realm'] . '
    Login' . ($profile['allow_test'] === true ? ' | Test' : null)); +} + + +/** + * Testing for setup + * @global array $profile + */ +function test_mode () { + global $profile, $p, $g; + + if ($profile['allow_test'] != true) + error_403(); + + @ini_set('max_execution_time', 180); + + $test_expire = time() + 120; + $test_ss_enc = 'W7hvmld2yEYdDb0fHfSkKhQX+PM='; + $test_ss = base64_decode($test_ss_enc); + $test_token = "alpha:bravo\ncharlie:delta\necho:foxtrot"; + $test_server_private = '11263846781670293092494395517924811173145217135753406847875706165886322533899689335716152496005807017390233667003995430954419468996805220211293016296351031812246187748601293733816011832462964410766956326501185504714561648498549481477143603650090931135412673422192550825523386522507656442905243832471167330268'; + $test_client_public = base64_decode('AL63zqI5a5p8HdXZF5hFu8p+P9GOb816HcHuvNOhqrgkKdA3fO4XEzmldlb37nv3+xqMBgWj6gxT7vfuFerEZLBvuWyVvR7IOGZmx0BAByoq3fxYd3Fpe2Coxngs015vK37otmH8e83YyyGo5Qua/NAf13yz1PVuJ5Ctk7E+YdVc'); + + $res = array(); + + // bcmath + $res['bcmath'] = extension_loaded('bcmath') + ? 'pass' : 'warn - not loaded'; + + // gmp + if ($profile['allow_gmp']) { + $res['gmp'] = extension_loaded('gmp') + ? 'pass' : 'warn - not loaded'; + } else { + $res['gmp'] = 'pass - n/a'; + } + + // sys_get_temp_dir + $res['logfile'] = is_writable($profile['logfile']) + ? 'pass' : "warn - log is not writable"; + + // session & new_assoc + user_session(); + list($test_assoc, $test_new_ss) = new_assoc($test_expire); + $res['session'] = ($test_assoc != session_id()) + ? 'pass' : 'fail'; + + // secret + @session_unregister('shared_secret'); + list($check, $check2) = secret($test_assoc); + $res['secret'] = ($check == $test_new_ss) + ? 'pass' : 'fail'; + + // expire + $res['expire'] = ($check2 <= $test_expire) + ? 'pass' : 'fail'; + + // base64 + $res['base64'] = (base64_encode($test_ss) == $test_ss_enc) + ? 'pass' : 'fail'; + + // hmac + $test_sig = base64_decode('/VXgHvZAOdoz/OTa5+XJXzSGhjs='); + $check = hmac($test_ss, $test_token); + $res['hmac'] = ($check == $test_sig) + ? 'pass' : sprintf("fail - '%s'", base64_encode($check)); + + if ($profile['use_bigmath']) { + // bigmath powmod + $test_server_public = '102773334773637418574009974502372885384288396853657336911033649141556441102566075470916498748591002884433213640712303846640842555822818660704173387461364443541327856226098159843042567251113889701110175072389560896826887426539315893475252988846151505416694218615764823146765717947374855806613410142231092856731'; + $check = bmpowmod($g, $test_server_private, $p); + $res['bmpowmod-1'] = ($check == $test_server_public) + ? 'pass' : sprintf("fail - '%s'", $check); + + // long + $test_client_long = '133926731803116519408547886573524294471756220428015419404483437186057383311250738749035616354107518232016420809434801736658109316293127101479053449990587221774635063166689561125137927607200322073086097478667514042144489248048756916881344442393090205172004842481037581607299263456852036730858519133859409417564'; + $res['long'] = (long($test_client_public) == $test_client_long) + ? 'pass' : 'fail'; + + // bigmath powmod 2 + $test_client_share = '19333275433742428703546496981182797556056709274486796259858099992516081822015362253491867310832140733686713353304595602619444380387600756677924791671971324290032515367930532292542300647858206600215875069588627551090223949962823532134061941805446571307168890255137575975911397744471376862555181588554632928402'; + $check = bmpowmod($test_client_long, $test_server_private, $p); + $res['bmpowmod-2'] = ($check == $test_client_share) + ? 'pass' : sprintf("fail - '%s'", $check); + + // bin + $test_client_mac_s1 = base64_decode('G4gQQkYM6QmAzhKbVKSBahFesPL0nL3F2MREVwEtnVRRYI0ifl9zmPklwTcvURt3QTiGBd+9Dn3ESLk5qka6IO5xnILcIoBT8nnGVPiOZvTygfuzKp4tQ2mXuIATJoa7oXRGmBWtlSdFapH5Zt6NJj4B83XF/jzZiRwdYuK4HJI='); + $check = bin($test_client_share); + $res['bin'] = ($check == $test_client_mac_s1) + ? 'pass' : sprintf("fail - '%s'", base64_encode($check)); + + } else { + $res['bigmath'] = 'fail - big math functions are not available.'; + } + + // sha1_20 + $test_client_mac_s1 = base64_decode('G4gQQkYM6QmAzhKbVKSBahFesPL0nL3F2MREVwEtnVRRYI0ifl9zmPklwTcvURt3QTiGBd+9Dn3ESLk5qka6IO5xnILcIoBT8nnGVPiOZvTygfuzKp4tQ2mXuIATJoa7oXRGmBWtlSdFapH5Zt6NJj4B83XF/jzZiRwdYuK4HJI='); + $test_client_mac_s2 = base64_decode('0Mb2t9d/HvAZyuhbARJPYdx3+v4='); + $check = sha1_20($test_client_mac_s1); + $res['sha1_20'] = ($check == $test_client_mac_s2) + ? 'pass' : sprintf("fail - '%s'", base64_encode($check)); + + // x_or + $test_client_mac_s3 = base64_decode('i36ZLYAJ1rYEx1VEHObrS8hgAg0='); + $check = x_or($test_client_mac_s2, $test_ss); + $res['x_or'] = ($check == $test_client_mac_s3) + ? 'pass' : sprintf("fail - '%s'", base64_encode($check)); + + $out = "
    - " type="checkbox" name="groups[]" value="" /> - ">
    + " type="checkbox" name="groups[]" value="" /> + ">
    @@ -82,8 +82,8 @@ - " type="checkbox" name="groups[]" value="" /> - ">
    + " type="checkbox" name="groups[]" value="" /> + ">
    From ee0f1490e1872cbe6071f5758e292ae1646ab1af Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 21 Jun 2011 19:28:46 +0200 Subject: [PATCH 071/111] Multiply changes to user system keeping tracked of the logged in user is no longer done by the active backend but by oc_user directly instead multiply backends can be active at the same time, allowing alternative authentication procedures like openid or tokens to be used next to the regular user system --- lib/User/backend.php | 68 ++++++++++++----------------- lib/User/database.php | 97 +++++++++--------------------------------- lib/base.php | 2 +- lib/user.php | 99 ++++++++++++++++++++++++++++++++++--------- 4 files changed, 127 insertions(+), 139 deletions(-) diff --git a/lib/User/backend.php b/lib/User/backend.php index e99016a521..8ea7f78190 100644 --- a/lib/User/backend.php +++ b/lib/User/backend.php @@ -21,7 +21,10 @@ * */ - +/** + * error code for functions not provided by the storage provider + */ +define('OC_USER_BACKEND_NOT_IMPLEMENTED',-501); /** * abstract base class for user management @@ -37,7 +40,9 @@ abstract class OC_USER_BACKEND { * Creates a new user. Basic checking of username is done in OC_USER * itself, not in its subclasses. */ - public static function createUser($uid, $password){} + public function createUser($uid, $password){ + return OC_USER_BACKEND_NOT_IMPLEMENTED; + } /** * @brief delete a user @@ -46,41 +51,9 @@ abstract class OC_USER_BACKEND { * * Deletes a user */ - public static function deleteUser( $uid ){} - - /** - * @brief Try to login a user - * @param $uid The username of the user to log in - * @param $password The password of the user - * @returns true/false - * - * Log in a user - if the password is ok - */ - public static function login($uid, $password){} - - /** - * @brief Kick the user - * @returns true - * - * Logout, destroys session - */ - public static function logout(){} - - /** - * @brief Check if the user is logged in - * @returns true/false - * - * Checks if the user is logged in - */ - public static function isLoggedIn(){} - - /** - * @brief Autogenerate a password - * @returns string - * - * generates a password - */ - public static function generatePassword(){} + public function deleteUser( $uid ){ + return OC_USER_BACKEND_NOT_IMPLEMENTED; + } /** * @brief Set password @@ -90,7 +63,9 @@ abstract class OC_USER_BACKEND { * * Change the password of a user */ - public static function setPassword($uid, $password){} + public function setPassword($uid, $password){ + return OC_USER_BACKEND_NOT_IMPLEMENTED; + } /** * @brief Check if the password is correct @@ -100,7 +75,9 @@ abstract class OC_USER_BACKEND { * * Check if the password is correct without logging in the user */ - public static function checkPassword($uid, $password){} + public function checkPassword($uid, $password){ + return OC_USER_BACKEND_NOT_IMPLEMENTED; + } /** * @brief Get a list of all users @@ -108,5 +85,16 @@ abstract class OC_USER_BACKEND { * * Get a list of all users. */ - public static function getUsers(){} + public function getUsers(){ + return OC_USER_BACKEND_NOT_IMPLEMENTED; + } + + /** + * @brief check if a user exists + * @param string $uid the username + * @return boolean + */ + public function userExists($uid){ + return OC_USER_BACKEND_NOT_IMPLEMENTED; + } } diff --git a/lib/User/database.php b/lib/User/database.php index eeabb592c2..0396ac3095 100644 --- a/lib/User/database.php +++ b/lib/User/database.php @@ -50,12 +50,8 @@ class OC_USER_DATABASE extends OC_USER_BACKEND { * Creates a new user. Basic checking of username is done in OC_USER * itself, not in its subclasses. */ - public static function createUser( $uid, $password ){ - // Check if the user already exists - $query = OC_DB::prepare( "SELECT * FROM `*PREFIX*users` WHERE uid = ?" ); - $result = $query->execute( array( $uid )); - - if ( $result->numRows() > 0 ){ + public function createUser( $uid, $password ){ + if( $this->userExists($uid) ){ return false; } else{ @@ -73,76 +69,13 @@ class OC_USER_DATABASE extends OC_USER_BACKEND { * * Deletes a user */ - public static function deleteUser( $uid ){ + public function deleteUser( $uid ){ // Delete user-group-relation $query = OC_DB::prepare( "DELETE FROM `*PREFIX*users` WHERE uid = ?" ); $result = $query->execute( array( $uid )); return true; } - /** - * @brief Try to login a user - * @param $uid The username of the user to log in - * @param $password The password of the user - * @returns true/false - * - * Log in a user - if the password is ok - */ - public static function login( $uid, $password ){ - // Query - $query = OC_DB::prepare( "SELECT uid FROM *PREFIX*users WHERE uid = ? AND password = ?" ); - $result = $query->execute( array( $uid, sha1( $password ))); - - if( $result->numRows() > 0 ){ - // Set username if name and password are known - $row = $result->fetchRow(); - $_SESSION['user_id'] = $row["uid"]; - OC_LOG::add( "core", $_SESSION['user_id'], "login" ); - return true; - } - else{ - return false; - } - } - - /** - * @brief Kick the user - * @returns true - * - * Logout, destroys session - */ - public static function logout(){ - OC_LOG::add( "core", $_SESSION['user_id'], "logout" ); - $_SESSION['user_id'] = false; - - return true; - } - - /** - * @brief Check if the user is logged in - * @returns true/false - * - * Checks if the user is logged in - */ - public static function isLoggedIn() { - if( isset($_SESSION['user_id']) AND $_SESSION['user_id'] ){ - return true; - } - else{ - return false; - } - } - - /** - * @brief Autogenerate a password - * @returns string - * - * generates a password - */ - public static function generatePassword(){ - return uniqId(); - } - /** * @brief Set password * @param $uid The username @@ -151,12 +84,8 @@ class OC_USER_DATABASE extends OC_USER_BACKEND { * * Change the password of a user */ - public static function setPassword( $uid, $password ){ - // Check if the user already exists - $query = OC_DB::prepare( "SELECT * FROM `*PREFIX*users` WHERE uid = ?" ); - $result = $query->execute( array( $uid )); - - if( $result->numRows() > 0 ){ + public function setPassword( $uid, $password ){ + if( $this->userExists($uid) ){ $query = OC_DB::prepare( "UPDATE *PREFIX*users SET password = ? WHERE uid = ?" ); $result = $query->execute( array( sha1( $password ), $uid )); @@ -175,7 +104,7 @@ class OC_USER_DATABASE extends OC_USER_BACKEND { * * Check if the password is correct without logging in the user */ - public static function checkPassword( $uid, $password ){ + public function checkPassword( $uid, $password ){ $query = OC_DB::prepare( "SELECT uid FROM *PREFIX*users WHERE uid = ? AND password = ?" ); $result = $query->execute( array( $uid, sha1( $password ))); @@ -193,7 +122,7 @@ class OC_USER_DATABASE extends OC_USER_BACKEND { * * Get a list of all users. */ - public static function getUsers(){ + public function getUsers(){ $query = OC_DB::prepare( "SELECT uid FROM *PREFIX*users" ); $result = $query->execute(); @@ -203,4 +132,16 @@ class OC_USER_DATABASE extends OC_USER_BACKEND { } return $users; } + + /** + * @brief check if a user exists + * @param string $uid the username + * @return boolean + */ + public function userExists($uid){ + $query = OC_DB::prepare( "SELECT * FROM `*PREFIX*users` WHERE uid = ?" ); + $result = $query->execute( array( $uid )); + + return $result->numRows() > 0; + } } diff --git a/lib/base.php b/lib/base.php index 1baf5dc167..e93c471272 100644 --- a/lib/base.php +++ b/lib/base.php @@ -93,7 +93,7 @@ require_once('search.php'); $error=(count(OC_UTIL::checkServer())>0); -OC_USER::setBackend( OC_CONFIG::getValue( "userbackend", "database" )); +OC_USER::useBackend( OC_CONFIG::getValue( "userbackend", "database" )); OC_GROUP::setBackend( OC_CONFIG::getValue( "groupbackend", "database" )); // Set up file system unless forbidden diff --git a/lib/user.php b/lib/user.php index 09501e59c5..2e11a30e85 100644 --- a/lib/user.php +++ b/lib/user.php @@ -40,7 +40,7 @@ if( !OC_CONFIG::getValue( "installed", false )){ */ class OC_USER { // The backend used for user management - private static $_backend = null; + private static $_usedBackends = array(); // Backends available (except database) private static $_backends = array(); @@ -66,15 +66,25 @@ class OC_USER { public static function getBackends(){ return self::$_backends; } + + /** + * @brief gets used backends + * @returns array of backends + * + * Returns the names of all used backends. + */ + public static function getUsedBackends(){ + return array_keys(self::$_usedBackends); + } /** - * @brief Sets the backend + * @brief Adds the backend to the list of used backends * @param $backend default: database The backend to use for user managment * @returns true/false * * Set the User Authentication Module */ - public static function setBackend( $backend = 'database' ){ + public static function useBackend( $backend = 'database' ){ // You'll never know what happens if( null === $backend OR !is_string( $backend )){ $backend = 'database'; @@ -86,11 +96,11 @@ class OC_USER { case 'mysql': case 'sqlite': require_once('User/database.php'); - self::$_backend = new OC_USER_DATABASE(); + self::$_usedBackends[$backend] = new OC_USER_DATABASE(); break; default: $className = 'OC_USER_' . strToUpper($backend); - self::$_backend = new $className(); + self::$_usedBackends[$backend] = new $className(); break; } @@ -119,7 +129,7 @@ class OC_USER { return false; } // Check if user already exists - if( in_array( $uid, self::getUsers())){ + if( self::userExists($uid) ){ return false; } @@ -127,13 +137,17 @@ class OC_USER { $run = true; OC_HOOK::emit( "OC_USER", "pre_createUser", array( "run" => &$run, "uid" => $uid, "password" => $password )); - if( $run && self::$_backend->createUser( $uid, $password )){ - OC_HOOK::emit( "OC_USER", "post_createUser", array( "uid" => $uid, "password" => $password )); - return true; - } - else{ - return false; + if( $run ){ + //create the user in the first backend that supports creating users + foreach(self::$_usedBackends as $backend){ + $result=$backend->createUser($uid,$password); + if($result!==OC_USER_BACKEND_NOT_IMPLEMENTED){ + OC_HOOK::emit( "OC_USER", "post_createUser", array( "uid" => $uid, "password" => $password )); + return true; + } + } } + return false; } /** @@ -147,7 +161,11 @@ class OC_USER { $run = true; OC_HOOK::emit( "OC_USER", "pre_deleteUser", array( "run" => &$run, "uid" => $uid )); - if( $run && self::$_backend->deleteUser( $uid )){ + if( $run ){ + //delete the user from all backends + foreach(self::$_usedBackends as $backend){ + $backend->deleteUser($uid); + } // We have to delete the user from all groups foreach( OC_GROUP::getUserGroups( $uid ) as $i ){ OC_GROUP::removeFromGroup( $uid, $i ); @@ -174,7 +192,9 @@ class OC_USER { $run = true; OC_HOOK::emit( "OC_USER", "pre_login", array( "run" => &$run, "uid" => $uid )); - if( $run && self::$_backend->login( $uid, $password )){ + if( $run && self::checkPassword( $uid, $password )){ + $_SESSION['user_id'] = $uid; + OC_LOG::add( "core", $_SESSION['user_id'], "login" ); OC_HOOK::emit( "OC_USER", "post_login", array( "uid" => $uid )); return true; } @@ -191,7 +211,9 @@ class OC_USER { */ public static function logout(){ OC_HOOK::emit( "OC_USER", "logout", array()); - return self::$_backend->logout(); + OC_LOG::add( "core", $_SESSION['user_id'], "logout" ); + $_SESSION['user_id'] = false; + return true; } /** @@ -201,7 +223,12 @@ class OC_USER { * Checks if the user is logged in */ public static function isLoggedIn(){ - return self::$_backend->isLoggedIn(); + if( isset($_SESSION['user_id']) AND $_SESSION['user_id'] ){ + return true; + } + else{ + return false; + } } /** @@ -211,7 +238,7 @@ class OC_USER { * generates a password */ public static function generatePassword(){ - return substr( md5( uniqId().time()), 0, 10 ); + return uniqId(); } /** @@ -226,7 +253,12 @@ class OC_USER { $run = true; OC_HOOK::emit( "OC_USER", "pre_setPassword", array( "run" => &$run, "uid" => $uid, "password" => $password )); - if( $run && self::$_backend->setPassword( $uid, $password )){ + if( $run ){ + foreach(self::$_usedBackends as $backend){ + if($backend->userExists($uid)){ + $backend->setPassword($uid,$password); + } + } OC_HOOK::emit( "OC_USER", "post_setPassword", array( "uid" => $uid, "password" => $password )); return true; } @@ -244,7 +276,12 @@ class OC_USER { * Check if the password is correct without logging in the user */ public static function checkPassword( $uid, $password ){ - return self::$_backend->checkPassword( $uid, $password ); + foreach(self::$_usedBackends as $backend){ + $result=$backend->checkPassword( $uid, $password ); + if($result===true){ + return true; + } + } } /** @@ -254,6 +291,28 @@ class OC_USER { * Get a list of all users. */ public static function getUsers(){ - return self::$_backend->getUsers(); + $users=array(); + foreach(self::$_usedBackends as $backend){ + $result=$backend->getUsers(); + if($result!=OC_USER_BACKEND_NOT_IMPLEMENTED){ + $users=array_merge($users,$result); + } + } + return $users; + } + + /** + * @brief check if a user exists + * @param string $uid the username + * @return boolean + */ + public static function userExists($uid){ + foreach(self::$_usedBackends as $backend){ + $result=$backend->userExists($uid); + if($result===true){ + return true; + } + } + return false; } } From e047feb2ad90c3b103c92d35f794988767b2ba21 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Tue, 21 Jun 2011 22:16:41 +0200 Subject: [PATCH 072/111] install shipped apps also in "installed apps" page --- admin/apps.php | 3 +++ lib/installer.php | 38 ++++++++++++++++++++++++++++++++++++++ lib/setup.php | 28 +--------------------------- 3 files changed, 42 insertions(+), 27 deletions(-) diff --git a/admin/apps.php b/admin/apps.php index 5eec7e626d..56e76d139d 100644 --- a/admin/apps.php +++ b/admin/apps.php @@ -22,6 +22,7 @@ */ require_once('../lib/base.php'); +include_once('../lib/installer.php'); require( 'template.php' ); if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){ header( "Location: ".OC_HELPER::linkTo( "", "index.php" )); @@ -42,6 +43,8 @@ if($installed){ $apps = OC_APPCONFIG::getApps(); $records = array(); + OC_INSTALLER::installShippedApps(false); + OC_APP::setActiveNavigationEntry( "core_apps_installed" ); foreach($apps as $app){ $info=OC_APP::getAppInfo("$SERVERROOT/apps/$app/appinfo/info.xml"); diff --git a/lib/installer.php b/lib/installer.php index 91b7ea7da6..a237caa098 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -236,4 +236,42 @@ class OC_INSTALLER{ // TODO: write function return true; } + + /** + * @brief Installs shipped apps + * @param $enabled + * + * This function installs all apps found in the 'apps' directory; + * If $enabled is true, apps are installed as enabled. + * If $enabled is false, apps are installed as disabled. + */ + public static function installShippedApps( $enabled ){ + global $SERVERROOT; + $dir = opendir( "$SERVERROOT/apps" ); + while( false !== ( $filename = readdir( $dir ))){ + if( substr( $filename, 0, 1 ) != '.' and is_dir("$SERVERROOT/apps/$filename") ){ + if( file_exists( "$SERVERROOT/apps/$filename/appinfo/app.php" )){ + if(!OC_INSTALLER::isInstalled($filename)){ + //install the database + if(is_file("$SERVERROOT/apps/$filename/appinfo/database.xml")){ + OC_DB::createDbFromStructure("$SERVERROOT/apps/$filename/appinfo/database.xml"); + } + + //run appinfo/install.php + if(is_file("$SERVERROOT/apps/$filename/appinfo/install.php")){ + include("$SERVERROOT/apps/$filename/appinfo/install.php"); + } + $info=OC_APP::getAppInfo("$SERVERROOT/apps/$filename/appinfo/info.xml"); + OC_APPCONFIG::setValue($filename,'installed_version',$info['version']); + if( $enabled ){ + OC_APPCONFIG::setValue($filename,'enabled','yes'); + }else{ + OC_APPCONFIG::setValue($filename,'enabled','no'); + } + } + } + } + } + closedir( $dir ); + } } diff --git a/lib/setup.php b/lib/setup.php index bdb5dcc4e2..281f24db50 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -136,7 +136,7 @@ class OC_SETUP { OC_GROUP::addToGroup($username, 'admin'); //guess what this does - self::installShippedApps(); + OC_INSTALLER::installShippedApps(true); //create htaccess files for apache hosts self::createHtaccess(); //TODO detect if apache is used @@ -186,32 +186,6 @@ class OC_SETUP { $content = "deny from all"; file_put_contents(OC_CONFIG::getValue('datadirectory', $SERVERROOT.'/data').'/.htaccess', $content); } - - private static function installShippedApps(){ - global $SERVERROOT; - $dir = opendir( "$SERVERROOT/apps" ); - while( false !== ( $filename = readdir( $dir ))){ - if( substr( $filename, 0, 1 ) != '.' and is_dir("$SERVERROOT/apps/$filename") ){ - if( file_exists( "$SERVERROOT/apps/$filename/appinfo/app.php" )){ - if(!OC_INSTALLER::isInstalled($filename)){ - //install the database - if(is_file("$SERVERROOT/apps/$filename/appinfo/database.xml")){ - OC_DB::createDbFromStructure("$SERVERROOT/apps/$filename/appinfo/database.xml"); - } - - //run appinfo/install.php - if(is_file("$SERVERROOT/apps/$filename/appinfo/install.php")){ - include("$SERVERROOT/apps/$filename/appinfo/install.php"); - } - $info=OC_APP::getAppInfo("$SERVERROOT/apps/$filename/appinfo/info.xml"); - OC_APPCONFIG::setValue($filename,'installed_version',$info['version']); - OC_APPCONFIG::setValue($filename,'enabled','yes'); - } - } - } - } - closedir( $dir ); - } } ?> From 6a726e2488092b58d9e773f2771c4452ff337a63 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Tue, 21 Jun 2011 22:35:36 +0200 Subject: [PATCH 073/111] changed app enable status to buttons --- admin/css/apps.css | 9 +++++---- admin/js/apps.js | 19 ++++++++++--------- admin/templates/appsinst.php | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/admin/css/apps.css b/admin/css/apps.css index fbbd4fce4b..cd427a3c53 100644 --- a/admin/css/apps.css +++ b/admin/css/apps.css @@ -13,16 +13,14 @@ table td.version, table td.enabled, table td.disabled text-align: center; } -table td.enabled +input[type="button"].enabled { color: #006600; - font-weight: bold; } -table td.disabled +input[type="button"].disabled { color: #660000; - font-weight: bold; } .preview @@ -65,3 +63,6 @@ table td.name a } +input[type="button"].appbutton { padding:0.1em 1em; border:1px solid #999; font-weight:bold; font-size:0.9em; cursor:pointer; } +input[type="button"]:hover.appbutton, form input[type="submit"]:focus { border:1px solid #999; background-color:#999; outline:0; } +input[type="button"]:active.appbutton { outline:0; } \ No newline at end of file diff --git a/admin/js/apps.js b/admin/js/apps.js index 4d8c68171b..ee9d814eb0 100644 --- a/admin/js/apps.js +++ b/admin/js/apps.js @@ -1,17 +1,18 @@ -$("div[x-use='appenableddiv']").live( "click", function(){ +$("input[x-use='appenablebutton']").live( "click", function(){ appid = $(this).parent().parent().attr("x-uid"); - if($(this).text() == "enabled"){ - $(this).html( "disabled" ); - $(this).parent().removeClass( "enabled" ); - $(this).parent().addClass( "disabled" ); + //alert("dsfsdfsdf"); + if($(this).val() == "enabled"){ + $(this).attr("value","disabled"); + $(this).removeClass( "enabled" ); + $(this).addClass( "disabled" ); //$.post( "ajax/disableapp.php", $(appid).serialize(), function(data){} ); $.post( "ajax/disableapp.php", { appid: appid }, function(data){ alert(data.status);}); } - else if($(this).text() == "disabled"){ - $(this).html( "enabled" ); - $(this).parent().removeClass( "disabled" ); - $(this).parent().addClass( "enabled" ); + else if($(this).val() == "disabled"){ + $(this).attr("value","enabled"); + $(this).removeClass( "disabled" ); + $(this).addClass( "enabled" ); $.post( "ajax/enableapp.php", { appid: appid }, function(data){ alert(data.status);} ); } }); \ No newline at end of file diff --git a/admin/templates/appsinst.php b/admin/templates/appsinst.php index 482273da1d..0e97df6add 100644 --- a/admin/templates/appsinst.php +++ b/admin/templates/appsinst.php @@ -20,7 +20,7 @@
    t( $app['enabled'] ? 'enabled' : 'disabled' ); ?>
    ' class='appbutton prettybutton '/>
    \n"; + foreach ($res as $test => $stat) { + $code = substr($stat, 0, 4); + $color = ($code == 'pass') ? '#9f9' + : (($code == 'warn') ? '#ff9' : '#f99'); + $out .= sprintf("\n", $test, $color, $stat); + } + $out .= "
    %s%s
    "; + + wrap_html( $out ); +} + + +// Support functions + +/** + * Prefix the keys of an array with 'openid.' + * @param array $array + * @return array + */ +function append_openid ($array) { + $keys = array_keys($array); + $vals = array_values($array); + + $r = array(); + for ($i=0; $i $rl ) { + $r = str_repeat("0", $ll-$rl) . $r; + $o = $ll; + + } else { + $o = $ll; + } + + $v = ''; + $carry = 0; + + for ($i = $o-1; $i >= 0; $i--) { + $d = (int)$l[$i] + (int)$r[$i] + $carry; + if ($d <= 9) { + $carry = 0; + + } else { + $carry = 1; + $d -= 10; + } + $v = (string) $d . $v; + } + + if ($carry > 0) + $v = "1" . $v; + + return $v; +} + +/** + * Create a big math comparison function + * @param string $l + * @param string $r + * @return string + */ +function bmcomp($l, $r) { + if (function_exists('bccomp')) + return bccomp($l, $r); + + global $profile; + if ($profile['use_gmp']) + return gmp_strval(gmp_cmp($l, $r)); + + $l = strval($l); $r = strval($r); + $ll = strlen($l); $lr = strlen($r); + if ($ll != $lr) + return ($ll > $lr) ? 1 : -1; + + return strcmp($l, $r); +} + +/** + * Create a big math division function + * @param string $l + * @param string $r + * @param int $z + * @return string + * @url http://www.icosaedro.it/bigint Inspired by + */ +function bmdiv($l, $r, $z = 0) { + if (function_exists('bcdiv')) + return ($z == 0) ? bcdiv($l, $r) : bcmod($l, $r); + + global $profile; + if ($profile['use_gmp']) + return gmp_strval(($z == 0) ? gmp_div_q($l, $r) : gmp_mod($l, $r)); + + $l = strval($l); $r = strval($r); + $v = '0'; + + while (true) { + if( bmcomp($l, $r) < 0 ) + break; + + $delta = strlen($l) - strlen($r); + if ($delta >= 1) { + $zeroes = str_repeat("0", $delta); + $r2 = $r . $zeroes; + + if (strcmp($l, $r2) >= 0) { + $v = bmadd($v, "1" . $zeroes); + $l = bmsub($l, $r2); + + } else { + $zeroes = str_repeat("0", $delta - 1); + $v = bmadd($v, "1" . $zeroes); + $l = bmsub($l, $r . $zeroes); + } + + } else { + $l = bmsub($l, $r); + $v = bmadd($v, "1"); + } + } + + return ($z == 0) ? $v : $l; +} + +/** + * Create a big math multiplication function + * @param string $l + * @param string $r + * @return string + * @url http://www.icosaedro.it/bigint Inspired by + */ +function bmmul($l, $r) { + if (function_exists('bcmul')) + return bcmul($l, $r); + + global $profile; + if ($profile['use_gmp']) + return gmp_strval(gmp_mul($l, $r)); + + $l = strval($l); $r = strval($r); + + $v = '0'; + $z = ''; + + for( $i = strlen($r)-1; $i >= 0; $i-- ){ + $bd = (int) $r[$i]; + $carry = 0; + $p = ""; + for( $j = strlen($l)-1; $j >= 0; $j-- ){ + $ad = (int) $l[$j]; + $pd = $ad * $bd + $carry; + if( $pd <= 9 ){ + $carry = 0; + } else { + $carry = (int) ($pd / 10); + $pd = $pd % 10; + } + $p = (string) $pd . $p; + } + if( $carry > 0 ) + $p = (string) $carry . $p; + $p = $p . $z; + $z .= "0"; + $v = bmadd($v, $p); + } + + return $v; +} + +/** + * Create a big math modulus function + * @param string $value + * @param string $mod + * @return string + */ +function bmmod( $value, $mod ) { + if (function_exists('bcmod')) + return bcmod($value, $mod); + + global $profile; + if ($profile['use_gmp']) + return gmp_strval(gmp_mod($value, $mod)); + + $r = bmdiv($value, $mod, 1); + return $r; +} + +/** + * Create a big math power function + * @param string $value + * @param string $exponent + * @return string + */ +function bmpow ($value, $exponent) { + if (function_exists('bcpow')) + return bcpow($value, $exponent); + + global $profile; + if ($profile['use_gmp']) + return gmp_strval(gmp_pow($value, $exponent)); + + $r = '1'; + while ($exponent) { + $r = bmmul($r, $value, 100); + $exponent--; + } + return (string)rtrim($r, '0.'); +} + +/** + * Create a big math 'powmod' function + * @param string $value + * @param string $exponent + * @param string $mod + * @return string + * @url http://php.net/manual/en/function.bcpowmod.php#72704 Borrowed from + */ +function bmpowmod ($value, $exponent, $mod) { + if (function_exists('bcpowmod')) + return bcpowmod($value, $exponent, $mod); + + global $profile; + if ($profile['use_gmp']) + return gmp_strval(gmp_powm($value, $exponent, $mod)); + + $r = ''; + while ($exponent != '0') { + $t = bmmod($exponent, '4096'); + $r = substr("000000000000" . decbin(intval($t)), -12) . $r; + $exponent = bmdiv($exponent, '4096'); + } + + $r = preg_replace("!^0+!","",$r); + + if ($r == '') + $r = '0'; + $value = bmmod($value, $mod); + $erb = strrev($r); + $q = '1'; + $a[0] = $value; + + for ($i = 1; $i < strlen($erb); $i++) { + $a[$i] = bmmod( bmmul($a[$i-1], $a[$i-1]), $mod ); + } + + for ($i = 0; $i < strlen($erb); $i++) { + if ($erb[$i] == "1") { + $q = bmmod( bmmul($q, $a[$i]), $mod ); + } + } + + return($q); +} + +/** + * Create a big math subtraction function + * @param string $l + * @param string $r + * @return string + * @url http://www.icosaedro.it/bigint Inspired by + */ +function bmsub($l, $r) { + if (function_exists('bcsub')) + return bcsub($l, $r); + + global $profile; + if ($profile['use_gmp']) + return gmp_strval(gmp_sub($l, $r)); + + + $l = strval($l); $r = strval($r); + $ll = strlen($l); $rl = strlen($r); + + if ($ll < $rl) { + $l = str_repeat("0", $rl-$ll) . $l; + $o = $rl; + } elseif ( $ll > $rl ) { + $r = str_repeat("0", $ll-$rl) . (string)$r; + $o = $ll; + } else { + $o = $ll; + } + + if (strcmp($l, $r) >= 0) { + $sign = ''; + } else { + $x = $l; $l = $r; $r = $x; + $sign = '-'; + } + + $v = ''; + $carry = 0; + + for ($i = $o-1; $i >= 0; $i--) { + $d = ($l[$i] - $r[$i]) - $carry; + if ($d < 0) { + $carry = 1; + $d += 10; + } else { + $carry = 0; + } + $v = (string) $d . $v; + } + + return $sign . ltrim($v, '0'); +} + + +/** + * Get a binary value + * @param integer $n + * @return string + * @url http://openidenabled.com Borrowed from PHP-OpenID + */ +function bin ($n) { + $bytes = array(); + while (bmcomp($n, 0) > 0) { + array_unshift($bytes, bmmod($n, 256)); + $n = bmdiv($n, bmpow(2,8)); + } + + if ($bytes && ($bytes[0] > 127)) + array_unshift($bytes, 0); + + $b = ''; + foreach ($bytes as $byte) + $b .= pack('C', $byte); + + return $b; +} + + +/** + * Debug logging + * @param mixed $x + * @param string $m + */ +function debug ($x, $m = null) { + global $profile; + + if (! isset($profile['debug']) || $profile['debug'] === false) + return true; + + if (! is_writable(dirname($profile['logfile'])) &! is_writable($profile['logfile'])) + error_500('Cannot write to debug log: ' . $profile['logfile']); + + if (is_array($x)) { + ob_start(); + print_r($x); + $x = $m . ($m != null ? "\n" : '') . ob_get_clean(); + + } else { + $x .= "\n"; + } + + error_log($x . "\n", 3, $profile['logfile']); +} + + +/** + * Destroy a consumer's assoc handle + * @param string $id + */ +function destroy_assoc_handle ( $id ) { + debug("Destroying session: $id"); + + $sid = session_id(); + session_write_close(); + + session_id($id); + session_start(); + session_destroy(); + + session_id($sid); + session_start(); +} + + +/** + * Return an error message to the user + * @param string $message + */ +function error_400 ( $message = 'Bad Request' ) { + header("HTTP/1.1 400 Bad Request"); + wrap_html($message); +} + + +/** + * Return an error message to the user + * @param string $message + */ +function error_403 ( $message = 'Forbidden' ) { + header("HTTP/1.1 403 Forbidden"); + wrap_html($message); +} + + +/** + * Return an error message to the user + * @param string $message + */ +function error_500 ( $message = 'Internal Server Error' ) { + header("HTTP/1.1 500 Internal Server Error"); + wrap_html($message); +} + + +/** + * Return an error message to the consumer + * @param string $message + */ +function error_get ( $url, $message = 'Bad Request') { + wrap_keyed_redirect($url, array('mode' => 'error', 'error' => $message)); +} + + +/** + * Return an error message to the consumer + * @param string $message + */ +function error_post ( $message = 'Bad Request' ) { + header("HTTP/1.1 400 Bad Request"); + echo ('error:' . $message); + exit(0); +} + + +/** + * Do an HMAC + * @param string $key + * @param string $data + * @param string $hash + * @return string + * @url http://php.net/manual/en/function.sha1.php#39492 Borrowed from + */ +function hmac($key, $data, $hash = 'sha1_20') { + $blocksize=64; + + if (strlen($key) > $blocksize) + $key = $hash($key); + + $key = str_pad($key, $blocksize,chr(0x00)); + $ipad = str_repeat(chr(0x36),$blocksize); + $opad = str_repeat(chr(0x5c),$blocksize); + + $h1 = $hash(($key ^ $ipad) . $data); + $hmac = $hash(($key ^ $opad) . $h1); + return $hmac; +} + + +if (! function_exists('http_build_query')) { +/** + * Create function if missing + * @param array $array + * @return string + */ +function http_build_query ($array) { + $r = array(); + foreach ($array as $key => $val) + $r[] = sprintf('%s=%s', urlencode($key), urlencode($val)); + return implode('&', $r); +}} + + +/** + * Turn a binary back into a long + * @param string $b + * @return integer + * @url http://openidenabled.com Borrowed from PHP-OpenID + */ +function long($b) { + $bytes = array_merge(unpack('C*', $b)); + $n = 0; + foreach ($bytes as $byte) { + $n = bmmul($n, bmpow(2,8)); + $n = bmadd($n, $byte); + } + return $n; +} + + +/** + * Create a new consumer association + * @param integer $expiration + * @return array + */ +function new_assoc ( $expiration ) { + if (isset($_SESSION) && is_array($_SESSION)) { + $sid = session_id(); + $dat = session_encode(); + session_write_close(); + } + + session_start(); + session_regenerate_id('false'); + + $id = session_id(); + $shared_secret = new_secret(); + debug('Started new assoc session: ' . $id); + + $_SESSION = array(); + $_SESSION['expiration'] = $expiration; + $_SESSION['shared_secret'] = base64_encode($shared_secret); + + session_write_close(); + + if (isset($sid)) { + session_id($sid); + session_start(); + $_SESSION = array(); + session_decode($dat); + } + + return array($id, $shared_secret); +} + + +/** + * Create a new shared secret + * @return string + */ +function new_secret () { + $r = ''; + for($i=0; $i<20; $i++) + $r .= chr(mt_rand(0, 255)); + + debug("Generated new key: hash = '" . md5($r) . "', length = '" . strlen($r) . "'"); + return $r; +} + + +/** + * Random number generation + * @param integer max + * @return integer + */ +function random ( $max ) { + if (strlen($max) < 4) + return mt_rand(1, $max - 1); + + $r = ''; + for($i=1; $i= 0 && ($pr_host[$break] != '*' || substr_count(substr($pr_host, 0, $break), '.') < 2)) + return false; + + // now compare the paths + $break = str_diff_at($parts['child']['path'], $parts['parent']['path']); + if ($break >= 0 + && ($break < strlen($parts['parent']['path']) && $parts['parent']['path'][$break] != '*') + || ($break > strlen($parts['child']['path']))) + return false; + + return true; +} + + +/** + * Create a user session + * @global array $profile + * @global array $proto + */ +function user_session () { + global $proto, $profile; + + session_name('phpMyID_Server'); + @session_start(); + + $profile['authorized'] = (isset($_SESSION['auth_username']) + && $_SESSION['auth_username'] == $profile['auth_username']) + ? true + : false; + + debug('Started user session: ' . session_id() . ' Auth? ' . $profile['authorized']); +} + + +/** + * Return HTML + * @global string $charset + * @param string $message + */ +function wrap_html ( $message ) { + global $charset, $profile; + header('Content-Type: text/html; charset=' . $charset); + $html= ' + + +phpMyID + + +' . implode("\n", $profile['opt_headers']) . ' + + + + +

    ' . $message . '

    + + +'; + error_log($html); + echo $html; + exit(0); +} + + +/** + * Return a key-value pair in plain text + * @global string $charset + * @param array $keys + */ +function wrap_kv ( $keys ) { + global $charset; + + debug($keys, 'Wrapped key/vals'); + header('Content-Type: text/plain; charset=' . $charset); + foreach ($keys as $key => $value) + printf("%s:%s\n", $key, $value); + + exit(0); +} + + +/** + * Redirect, with OpenID keys + * @param string $url + * @param array @keys + */ +function wrap_keyed_redirect ($url, $keys) { + $keys = append_openid($keys); + debug($keys, 'Location keys'); + + $q = strpos($url, '?') ? '&' : '?'; + wrap_redirect($url . $q . http_build_query($keys)); +} + + +/** + * Redirect the browser + * @global string $charset + * @param string $url + */ +function wrap_redirect ($url) { + header('HTTP/1.1 302 Found'); + header('Location: ' . $url); + debug('Location: ' . $url); + exit(0); +} + +/** + * Return an HTML refresh + * @global string $charset + * @param string $url + */ +function wrap_refresh ($url) { + global $charset; + + header('Content-Type: text/html; charset=' . $charset); + echo ' + + +phpMyID + + + +

    Redirecting to ' . $url . '

    + + +'; + + debug('Refresh: ' . $url); + exit(0); +} + + +/** + * Implement binary x_or + * @param string $a + * @param string $b + * @return string + */ +function x_or ($a, $b) { + $r = ""; + + for ($i = 0; $i < strlen($b); $i++) + $r .= $a[$i] ^ $b[$i]; + debug("Xor size: " . strlen($r)); + return $r; +} + + + +/* + * App Initialization + */ +// Determine the charset to use +$GLOBALS['charset'] = 'iso-8859-1'; + +// Set the internal encoding +if (function_exists('mb_internal_encoding')) + mb_internal_encoding($charset); + +// Avoid problems with non-default arg_separator.output settings +// Credit for this goes to user 'prelog' on the forums +ini_set('arg_separator.output', '&'); + +// Do a check to be sure everything is set up correctly +self_check(); + + +/** + * Determine the HTTP request port + * @name $port + * @global integer $GLOBALS['port'] + */ +$GLOBALS['port'] = ((isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on' && $_SERVER['SERVER_PORT'] == 443) + || $_SERVER['SERVER_PORT'] == 80) + ? '' + : ':' . $_SERVER['SERVER_PORT']; + + +error_log($_SERVER['HTTP_HOST']); +/** + * Determine the HTTP request protocol + * @name $proto + * @global string $GLOBALS['proto'] + */ +$GLOBALS['proto'] = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') ? 'https' : 'http'; + +// Set the authorization state - DO NOT OVERRIDE +$profile['authorized'] = false; + +// Set a default IDP URL +if (! array_key_exists('idp_url', $profile)) + $profile['idp_url'] = sprintf("%s://%s%s%s", + $proto, + $_SERVER['SERVER_NAME'], + $port, + $_SERVER['PHP_SELF']); + +// Determine the requested URL - DO NOT OVERRIDE +$profile['req_url'] = sprintf("%s://%s%s", + $proto, + $_SERVER['HTTP_HOST'], +// $port,//host already includes the path + $_SERVER["REQUEST_URI"]); + +error_log($profile['req_url']); + +// Set the default allowance for testing +if (! array_key_exists('allow_test', $profile)) + $profile['allow_test'] = false; + +// Set the default allowance for gmp +if (! array_key_exists('allow_gmp', $profile)) + $profile['allow_gmp'] = false; + +// Set the default force bigmath - BAD IDEA to override this +if (! array_key_exists('force_bigmath', $profile)) + $profile['force_bigmath'] = false; + +// Determine if GMP is usable +$profile['use_gmp'] = (extension_loaded('gmp') && $profile['allow_gmp']) ? true : false; + +// Determine if I can perform big math functions +$profile['use_bigmath'] = (extension_loaded('bcmath') || $profile['use_gmp'] || $profile['force_bigmath']) ? true : false; + +// Set a default authentication domain +if (! array_key_exists('auth_domain', $profile)) + $profile['auth_domain'] = $profile['req_url'] . ' ' . $profile['idp_url']; + +// Set a default authentication realm +if (! array_key_exists('auth_realm', $profile)) + $profile['auth_realm'] = 'phpMyID'; + +// Determine the realm for digest authentication - DO NOT OVERRIDE +$profile['php_realm'] = $profile['auth_realm'] . (ini_get('safe_mode') ? '-' . getmyuid() : ''); + +// Set a default lifetime - the lesser of GC and cache time +if (! array_key_exists('lifetime', $profile)) { + $sce = session_cache_expire() * 60; + $gcm = ini_get('session.gc_maxlifetime'); + $profile['lifetime'] = $sce < $gcm ? $sce : $gcm; +} + +// Set a default log file +if (! array_key_exists('logfile', $profile)) + $profile['logfile'] = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $profile['auth_realm'] . '.debug.log'; + + +/* + * Optional Initialization + */ +// Setup optional headers +$profile['opt_headers'] = array(); + +// Determine if I should add microid stuff +if (array_key_exists('microid', $profile)) { + $hash = sha1($profile['idp_url']); + $values = is_array($profile['microid']) ? $profile['microid'] : array($profile['microid']); + + foreach ($values as $microid) { + preg_match('/^([a-z]+)/i', $microid, $mtx); + $profile['opt_headers'][] = sprintf('', $mtx[1], $proto, sha1(sha1($microid) . $hash)); + } +} + +// Determine if I should add pavatar stuff +if (array_key_exists('pavatar', $profile)) + $profile['opt_headers'][] = sprintf('', $profile['pavatar']); + + +/* + * Do it + */ +// Decide which runmode, based on user request or default +$run_mode = (isset($_REQUEST['openid_mode']) + && in_array($_REQUEST['openid_mode'], $known['openid_modes'])) + ? $_REQUEST['openid_mode'] + : 'no'; + +// Run in the determined runmode +debug("Run mode: $run_mode at: " . time()); +debug($_REQUEST, 'Request params'); +call_user_func($run_mode . '_mode'); +?> diff --git a/apps/user_openid/settings.php b/apps/user_openid/settings.php new file mode 100644 index 0000000000..76316de100 --- /dev/null +++ b/apps/user_openid/settings.php @@ -0,0 +1,24 @@ +assign('identity',$identity); +$tmpl->assign('user',OC_USER::getUser()); + +$tmpl->printPage(); + +?> diff --git a/apps/user_openid/templates/settings.php b/apps/user_openid/templates/settings.php new file mode 100644 index 0000000000..7a1b530fbc --- /dev/null +++ b/apps/user_openid/templates/settings.php @@ -0,0 +1,7 @@ +
    +
    + t( 'OpenID identity' );?> +
    + +
    +
    diff --git a/apps/user_openid/user.php b/apps/user_openid/user.php new file mode 100644 index 0000000000..9ca1fd47c9 --- /dev/null +++ b/apps/user_openid/user.php @@ -0,0 +1,34 @@ +. +* +*/ + +$USERNAME=substr($_SERVER["REQUEST_URI"],strpos($_SERVER["REQUEST_URI"],'.php/')+5); +if(strpos($USERNAME,'?')){ + $USERNAME=substr($USERNAME,0,strpos($USERNAME,'?')); +} + +require_once '../../lib/base.php'; + +require_once 'phpmyid.php'; + + +?> \ No newline at end of file diff --git a/apps/user_openid/user_openid.php b/apps/user_openid/user_openid.php new file mode 100644 index 0000000000..d4bcefeb26 --- /dev/null +++ b/apps/user_openid/user_openid.php @@ -0,0 +1,73 @@ +. + * + */ + +require_once('User/backend.php'); +require_once('class.openid.v3.php'); + +/** + * Class for user management in a SQL Database (e.g. MySQL, SQLite) + */ +class OC_USER_OPENID extends OC_USER_BACKEND { + /** + * @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 ){ + global $WEBROOT; + // Get identity from user and redirect browser to OpenID Server + $openid = new SimpleOpenID; + $openid->SetIdentity($uid); + $openid->SetTrustRoot('http://' . $_SERVER["HTTP_HOST"]); + if ($openid->GetOpenIDServer()){ + $openid->SetApprovedURL('http://' . $_SERVER["HTTP_HOST"] . $WEBROOT); // Send Response from OpenID server to this script + $openid->Redirect(); // This will redirect user to OpenID Server + exit; + }else{ + $error = $openid->GetError(); + echo "ERROR CODE: " . $error['code'] . "
    "; + echo "ERROR DESCRIPTION: " . $error['description'] . "
    "; + } + exit; + } + + /** + * find the user that can be authenticated with an openid identity + */ + public static function findUserForIdentity($identity){ + $query=OC_DB::prepare('SELECT userid FROM *PREFIX*preferences WHERE appid=? AND configkey=? AND configvalue=?'); + $result=$query->execute(array('user_openid','identity',$identity))->fetchAll(); + if(count($result)>0){ + return $result[0]['userid']; + }else{ + return false; + } + } +} + + + +?> \ No newline at end of file From 1ce24d892b0e1ebb568930cee882d2be68c32240 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 23 Jun 2011 17:58:27 +0200 Subject: [PATCH 087/111] don't show errors when the login isn't an openid identity --- apps/user_openid/user_openid.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/user_openid/user_openid.php b/apps/user_openid/user_openid.php index d4bcefeb26..ddf5cc9bc2 100644 --- a/apps/user_openid/user_openid.php +++ b/apps/user_openid/user_openid.php @@ -47,9 +47,7 @@ class OC_USER_OPENID extends OC_USER_BACKEND { $openid->Redirect(); // This will redirect user to OpenID Server exit; }else{ - $error = $openid->GetError(); - echo "ERROR CODE: " . $error['code'] . "
    "; - echo "ERROR DESCRIPTION: " . $error['description'] . "
    "; + return false; } exit; } From 6452f5b5cb76b4a26ae8f114a55d09cfd482be52 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Thu, 23 Jun 2011 18:18:48 +0200 Subject: [PATCH 088/111] OpenID now won't load if curl is not available --- apps/user_openid/appinfo/app.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/user_openid/appinfo/app.php b/apps/user_openid/appinfo/app.php index fb3de10e2a..2e238ed3f2 100644 --- a/apps/user_openid/appinfo/app.php +++ b/apps/user_openid/appinfo/app.php @@ -1,5 +1,10 @@ "user_openid_settings", 'order'=>1, "href" => OC_HELPER::linkTo( "user_openid", "settings.php" ), "name" => "OpenID")); From 8b76590f5db0c2c94dcf3e868d0e39494a1e39b1 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 23 Jun 2011 18:23:06 +0200 Subject: [PATCH 089/111] fix creating users --- lib/user.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/user.php b/lib/user.php index 33ee5b8762..25f555b47b 100644 --- a/lib/user.php +++ b/lib/user.php @@ -166,7 +166,9 @@ class OC_USER { if( $run ){ //delete the user from all backends foreach(self::$_usedBackends as $backend){ - $backend->deleteUser($uid); + if($backend->implementsActions(OC_USER_BACKEND_DELETE_USER)){ + $backend->deleteUser($uid); + } } // We have to delete the user from all groups foreach( OC_GROUP::getUserGroups( $uid ) as $i ){ @@ -270,8 +272,10 @@ class OC_USER { if( $run ){ foreach(self::$_usedBackends as $backend){ - if($backend->userExists($uid)){ - $backend->setPassword($uid,$password); + if($backend->implementsActions(OC_USER_BACKEND_SET_PASSWORD)){ + if($backend->userExists($uid)){ + $backend->setPassword($uid,$password); + } } } OC_HOOK::emit( "OC_USER", "post_setPassword", array( "uid" => $uid, "password" => $password )); @@ -292,9 +296,11 @@ class OC_USER { */ public static function checkPassword( $uid, $password ){ foreach(self::$_usedBackends as $backend){ - $result=$backend->checkPassword( $uid, $password ); - if($result===true){ - return true; + if($backend->implementsActions(OC_USER_BACKEND_CHECK_PASSWORD)){ + $result=$backend->checkPassword( $uid, $password ); + if($result===true){ + return true; + } } } } @@ -322,9 +328,11 @@ class OC_USER { */ public static function userExists($uid){ foreach(self::$_usedBackends as $backend){ - $result=$backend->userExists($uid); - if($result===true){ - return true; + if($backend->implementsActions(OC_USER_BACKEND_USER_EXISTS)){ + $result=$backend->userExists($uid); + if($result===true){ + return true; + } } } return false; From 5aa8f16bbf95b3de867a4c5e3cf1e862885e5568 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Thu, 23 Jun 2011 23:14:09 +0200 Subject: [PATCH 090/111] forbid indexes --- .htaccess | 1 + 1 file changed, 1 insertion(+) diff --git a/.htaccess b/.htaccess index 58230365bf..f2172f4357 100644 --- a/.htaccess +++ b/.htaccess @@ -2,3 +2,4 @@ ErrorDocument 404 //owncloud/templates/404.php php_value upload_max_filesize 20M php_value post_max_size 20M SetEnv htaccessWorking true +Options -Indexes From 0bf67298d142b157712ce345e1d999ff2ab9ea49 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Thu, 23 Jun 2011 23:41:53 +0200 Subject: [PATCH 091/111] no indexing in generated htaccess --- lib/files.php | 1 + lib/setup.php | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/files.php b/lib/files.php index fca311833b..0e7e44ec2a 100644 --- a/lib/files.php +++ b/lib/files.php @@ -297,6 +297,7 @@ class OC_FILES { $content.= "php_value upload_max_filesize $size\n";//upload limit $content.= "php_value post_max_size $size\n"; $content.= "SetEnv htaccessWorking true\n"; + $content.= "Options -Indexes\n"; @file_put_contents($SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it } } diff --git a/lib/setup.php b/lib/setup.php index 0a8c9650cb..a3cefad62b 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -188,6 +188,7 @@ class OC_SETUP { $content.= "php_value upload_max_filesize 20M\n";//upload limit $content.= "php_value post_max_size 20M\n"; $content.= "SetEnv htaccessWorking true\n"; + $content.= "Options -Indexes\n"; @file_put_contents($SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it $content = "deny from all"; From 2073d3b08e97675a1f418b44a4e7c72039da2149 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Thu, 23 Jun 2011 23:47:46 +0200 Subject: [PATCH 092/111] fix 404 --- .htaccess | 2 +- core/templates/404.php | 2 +- lib/files.php | 2 +- lib/setup.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.htaccess b/.htaccess index f2172f4357..c818c9ca2e 100644 --- a/.htaccess +++ b/.htaccess @@ -1,4 +1,4 @@ -ErrorDocument 404 //owncloud/templates/404.php +ErrorDocument 404 //core/templates/404.php php_value upload_max_filesize 20M php_value post_max_size 20M SetEnv htaccessWorking true diff --git a/core/templates/404.php b/core/templates/404.php index b287571d16..b78828e630 100644 --- a/core/templates/404.php +++ b/core/templates/404.php @@ -1,6 +1,6 @@ Date: Thu, 23 Jun 2011 22:51:25 +0200 Subject: [PATCH 093/111] Add user_ldap plugin --- apps/user_ldap/appinfo/app.php | 36 ++++++++++++++++ apps/user_ldap/appinfo/info.xml | 10 +++++ apps/user_ldap/settings.php | 48 +++++++++++++++++++++ apps/user_ldap/templates/settings.php | 24 +++++++++++ apps/user_ldap/user_ldap.php | 62 +++++++++++++++++++++++++++ 5 files changed, 180 insertions(+) create mode 100644 apps/user_ldap/appinfo/app.php create mode 100644 apps/user_ldap/appinfo/info.xml create mode 100644 apps/user_ldap/settings.php create mode 100644 apps/user_ldap/templates/settings.php create mode 100644 apps/user_ldap/user_ldap.php diff --git a/apps/user_ldap/appinfo/app.php b/apps/user_ldap/appinfo/app.php new file mode 100644 index 0000000000..f7ce4f87a6 --- /dev/null +++ b/apps/user_ldap/appinfo/app.php @@ -0,0 +1,36 @@ +. +* +*/ + +require_once('apps/user_ldap/user_ldap.php'); + +// register user backend +OC_USER::useBackend( "LDAP" ); + +// add settings page to navigation +$entry = array( + 'id' => "user_ldap_settings", + 'order'=>1, + 'href' => OC_HELPER::linkTo( "user_ldap", "settings.php" ), + 'name' => 'LDAP' +); +OC_APP::addNavigationSubEntry( "core_users", $entry); diff --git a/apps/user_ldap/appinfo/info.xml b/apps/user_ldap/appinfo/info.xml new file mode 100644 index 0000000000..9a6ee1436f --- /dev/null +++ b/apps/user_ldap/appinfo/info.xml @@ -0,0 +1,10 @@ + + + user_ldap + LDAP user backend + Authenticate Users by LDAP + 0.1 + AGPL + Dominik Schmidt + 2 + diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php new file mode 100644 index 0000000000..22f817e7ca --- /dev/null +++ b/apps/user_ldap/settings.php @@ -0,0 +1,48 @@ +. + * + */ + +require_once('../../lib/base.php'); +require( 'template.php' ); + +if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )){ + header( "Location: ".OC_HELPER::linkTo( "index.php" )); + exit(); +} + +$params = array('ldap_host', 'ldap_dn', 'ldap_password', 'ldap_base', 'ldap_filter'); + +foreach($params as $param){ + if(isset($_POST[$param])){ + OC_APPCONFIG::setValue('user_ldap', $param, $_POST[$param]); + } +} +OC_APP::setActiveNavigationEntry( "user_ldap_settings" ); + + +// fill template +$tmpl = new OC_TEMPLATE( 'user_ldap', 'settings', 'admin' ); +foreach($params as $param){ + $value = OC_APPCONFIG::getValue('user_ldap', $param,''); + $tmpl->assign($param, $value); +} +$tmpl->printPage(); diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php new file mode 100644 index 0000000000..5f7ee671ce --- /dev/null +++ b/apps/user_ldap/templates/settings.php @@ -0,0 +1,24 @@ +
    +
    + LDAP +
    +
    + Host: * +
    +
    + DN: +
    +
    + Password: +
    +
    + Base: * +
    +
    + Filter * (use %uid placeholder): +
    +
    + +
    * required +
    +
    \ No newline at end of file diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php new file mode 100644 index 0000000000..52f8806429 --- /dev/null +++ b/apps/user_ldap/user_ldap.php @@ -0,0 +1,62 @@ +. + * + */ + +require_once('User/backend.php'); + +class OC_USER_LDAP extends OC_USER_BACKEND { + + public function checkPassword( $uid, $password ) { + $ldap_host = OC_APPCONFIG::getValue('user_ldap', 'ldap_host',''); + $ldap_dn = OC_APPCONFIG::getValue('user_ldap', 'ldap_dn',''); + $ldap_password = OC_APPCONFIG::getValue('user_ldap', 'ldap_password',''); + $ldap_base = OC_APPCONFIG::getValue('user_ldap', 'ldap_base',''); + $ldap_filter = OC_APPCONFIG::getValue('user_ldap', 'ldap_filter',''); + + // connect to server + $ds = ldap_connect( $ldap_host ); + if( !$ds ) + return false; + + // login for search + if(!empty($ldap_dn)) { + $ldap_login = @ldap_bind( $ds, $ldap_dn, $ldap_password ); + if(!$ldap_login) + return false; + } + + // get dn + $filter = str_replace("%uid", $uid, $ldap_filter); + $sr = ldap_search( $ds, $ldap_base, $filter ); + $entries = ldap_get_entries( $ds, $sr ); + + if( $entries["count"] == 0 ) + return false; + + $dn = $entries[0]["dn"]; + $result = @ldap_bind( $ds, $dn, $password ); + + return $result; + } +} + +?> From 612f8cb9546a0607defe7a0ff5fd8048bbfdf92c Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 23 Jun 2011 23:17:10 +0200 Subject: [PATCH 094/111] user_ldap: add port setting --- apps/user_ldap/appinfo/app.php | 3 +++ apps/user_ldap/settings.php | 6 +++++- apps/user_ldap/templates/settings.php | 3 +++ apps/user_ldap/user_ldap.php | 5 ++++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/apps/user_ldap/appinfo/app.php b/apps/user_ldap/appinfo/app.php index f7ce4f87a6..67b61989f7 100644 --- a/apps/user_ldap/appinfo/app.php +++ b/apps/user_ldap/appinfo/app.php @@ -23,6 +23,9 @@ require_once('apps/user_ldap/user_ldap.php'); +// define LDAP_DEFAULT_PORT +define("OC_USER_BACKEND_LDAP_DEFAULT_PORT", 389); + // register user backend OC_USER::useBackend( "LDAP" ); diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php index 22f817e7ca..f7aff1b461 100644 --- a/apps/user_ldap/settings.php +++ b/apps/user_ldap/settings.php @@ -29,7 +29,7 @@ if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( OC_USER::getUser(), 'admin' )) exit(); } -$params = array('ldap_host', 'ldap_dn', 'ldap_password', 'ldap_base', 'ldap_filter'); +$params = array('ldap_host', 'ldap_port', 'ldap_dn', 'ldap_password', 'ldap_base', 'ldap_filter'); foreach($params as $param){ if(isset($_POST[$param])){ @@ -45,4 +45,8 @@ foreach($params as $param){ $value = OC_APPCONFIG::getValue('user_ldap', $param,''); $tmpl->assign($param, $value); } + +// ldap_port has a default value +$tmpl->assign( 'ldap_port', OC_APPCONFIG::getValue('user_ldap', 'ldap_port', OC_USER_BACKEND_LDAP_DEFAULT_PORT)); + $tmpl->printPage(); diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php index 5f7ee671ce..0145736e80 100644 --- a/apps/user_ldap/templates/settings.php +++ b/apps/user_ldap/templates/settings.php @@ -5,6 +5,9 @@
    Host: *
    +
    + Port: * +
    DN:
    diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php index 52f8806429..cd4a92a7b1 100644 --- a/apps/user_ldap/user_ldap.php +++ b/apps/user_ldap/user_ldap.php @@ -25,15 +25,18 @@ require_once('User/backend.php'); class OC_USER_LDAP extends OC_USER_BACKEND { + + public function checkPassword( $uid, $password ) { $ldap_host = OC_APPCONFIG::getValue('user_ldap', 'ldap_host',''); + $ldap_port = OC_APPCONFIG::getValue('user_ldap', 'ldap_port', OC_USER_BACKEND_LDAP_DEFAULT_PORT); $ldap_dn = OC_APPCONFIG::getValue('user_ldap', 'ldap_dn',''); $ldap_password = OC_APPCONFIG::getValue('user_ldap', 'ldap_password',''); $ldap_base = OC_APPCONFIG::getValue('user_ldap', 'ldap_base',''); $ldap_filter = OC_APPCONFIG::getValue('user_ldap', 'ldap_filter',''); // connect to server - $ds = ldap_connect( $ldap_host ); + $ds = ldap_connect( $ldap_host, $ldap_port ); if( !$ds ) return false; From d4618d633a2240c15b19c8c2b40fb05f1d2d7334 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 23 Jun 2011 23:19:04 +0200 Subject: [PATCH 095/111] user_ldap: use input-type-password for ldap_password --- apps/user_ldap/templates/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php index 0145736e80..5dddb71a02 100644 --- a/apps/user_ldap/templates/settings.php +++ b/apps/user_ldap/templates/settings.php @@ -12,7 +12,7 @@ DN:
    - Password: + Password:
    Base: * From 5f29f8a8310823ed99b0d627ea03c9ff3e5efcb3 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 23 Jun 2011 23:41:02 +0200 Subject: [PATCH 096/111] user_ldap: implement userExists --- apps/user_ldap/user_ldap.php | 70 +++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 21 deletions(-) diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php index cd4a92a7b1..1718a307cc 100644 --- a/apps/user_ldap/user_ldap.php +++ b/apps/user_ldap/user_ldap.php @@ -25,41 +25,69 @@ require_once('User/backend.php'); class OC_USER_LDAP extends OC_USER_BACKEND { + protected $ds; + // cached settings + protected $ldap_host; + protected $ldap_port; + protected $ldap_dn; + protected $ldap_password; + protected $ldap_base; + protected $ldap_filter; - public function checkPassword( $uid, $password ) { - $ldap_host = OC_APPCONFIG::getValue('user_ldap', 'ldap_host',''); - $ldap_port = OC_APPCONFIG::getValue('user_ldap', 'ldap_port', OC_USER_BACKEND_LDAP_DEFAULT_PORT); - $ldap_dn = OC_APPCONFIG::getValue('user_ldap', 'ldap_dn',''); - $ldap_password = OC_APPCONFIG::getValue('user_ldap', 'ldap_password',''); - $ldap_base = OC_APPCONFIG::getValue('user_ldap', 'ldap_base',''); - $ldap_filter = OC_APPCONFIG::getValue('user_ldap', 'ldap_filter',''); + function __construct() { + $this->ldap_host = OC_APPCONFIG::getValue('user_ldap', 'ldap_host',''); + $this->ldap_port = OC_APPCONFIG::getValue('user_ldap', 'ldap_port', OC_USER_BACKEND_LDAP_DEFAULT_PORT ); + $this->ldap_dn = OC_APPCONFIG::getValue('user_ldap', 'ldap_dn',''); + $this->ldap_password = OC_APPCONFIG::getValue('user_ldap', 'ldap_password',''); + $this->ldap_base = OC_APPCONFIG::getValue('user_ldap', 'ldap_base',''); + $this->ldap_filter = OC_APPCONFIG::getValue('user_ldap', 'ldap_filter',''); + } - // connect to server - $ds = ldap_connect( $ldap_host, $ldap_port ); - if( !$ds ) - return false; + private function getDs() { + if(!$this->ds) { + $this->ds = ldap_connect( $this->ldap_host, $this->ldap_port ); + } - // login for search - if(!empty($ldap_dn)) { - $ldap_login = @ldap_bind( $ds, $ldap_dn, $ldap_password ); + // login + if(!empty($this->ldap_dn)) { + $ldap_login = @ldap_bind( $this->ds, $this->ldap_dn, $this->ldap_password ); if(!$ldap_login) return false; } + return $this->ds; + } + + private function getDn( $uid ) { + // connect to server + $ds = $this->getDs(); + if( !$ds ) + return false; + // get dn - $filter = str_replace("%uid", $uid, $ldap_filter); - $sr = ldap_search( $ds, $ldap_base, $filter ); - $entries = ldap_get_entries( $ds, $sr ); + $filter = str_replace("%uid", $uid, $this->ldap_filter); + $sr = ldap_search( $this->getDs(), $this->ldap_base, $filter ); + $entries = ldap_get_entries( $this->getDs(), $sr ); if( $entries["count"] == 0 ) return false; - $dn = $entries[0]["dn"]; - $result = @ldap_bind( $ds, $dn, $password ); - - return $result; + return $entries[0]["dn"]; } + public function checkPassword( $uid, $password ) { + $dn = $this->getDn( $uid ); + if( !$dn ) + return false; + + return @ldap_bind( $this->getDs(), $dn, $password ); + } + + public function userExists( $uid ) { + $dn = getDn($uid); + return !empty($dn); + } + } ?> From 735738fe6fbdc3afb6a9fd1d5fbec36b5020f9aa Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 23 Jun 2011 23:54:39 +0200 Subject: [PATCH 097/111] user_ldap: close ldap connection in dtor --- apps/user_ldap/user_ldap.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php index 1718a307cc..1ee9809b3b 100644 --- a/apps/user_ldap/user_ldap.php +++ b/apps/user_ldap/user_ldap.php @@ -44,6 +44,12 @@ class OC_USER_LDAP extends OC_USER_BACKEND { $this->ldap_filter = OC_APPCONFIG::getValue('user_ldap', 'ldap_filter',''); } + function __destruct() { + // close the connection + if( $this->ds ) + ldap_unbind($this->ds); + } + private function getDs() { if(!$this->ds) { $this->ds = ldap_connect( $this->ldap_host, $this->ldap_port ); From 53cb4c16ed85b09706676540e8bf704188f32c41 Mon Sep 17 00:00:00 2001 From: Kamil Domanski Date: Fri, 24 Jun 2011 00:24:45 +0200 Subject: [PATCH 098/111] add template to openid request page --- apps/user_openid/phpmyid.php | 7 ++++--- apps/user_openid/templates/nomode.php | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 apps/user_openid/templates/nomode.php diff --git a/apps/user_openid/phpmyid.php b/apps/user_openid/phpmyid.php index 719bbd954c..330cd466c4 100644 --- a/apps/user_openid/phpmyid.php +++ b/apps/user_openid/phpmyid.php @@ -12,6 +12,8 @@ * @version 0.9 */ +require( 'template.php' ); + /** * Set a constant to indicate that phpMyID is running @@ -558,9 +560,8 @@ function logout_mode () { * @global array $profile */ function no_mode () { - global $profile; - - wrap_html('This is an OpenID server endpoint. For more information, see http://openid.net/
    Server: ' . $profile['idp_url'] . '
    Realm: ' . $profile['php_realm'] . '
    Login' . ($profile['allow_test'] === true ? ' | Test' : null)); + $tmpl = new OC_TEMPLATE( 'user_openid', 'nomode', 'guest' ); + $tmpl->printPage(); } diff --git a/apps/user_openid/templates/nomode.php b/apps/user_openid/templates/nomode.php new file mode 100644 index 0000000000..13a1a89493 --- /dev/null +++ b/apps/user_openid/templates/nomode.php @@ -0,0 +1,23 @@ + + +
    + " alt="ownCloud" /> +
      +
    • +
      +

      t('This is an OpenID server endpoint. For more information, see http://openid.net/'));?>

      +

      t('Server: ').$profile['idp_url']); ?> +

      t('Realm: ').$profile['php_realm']); ?> +

      t('Login')); ?> + + | Test + +

      +
    • +
    +
    + From 1aa8399915bc6148fab3ad8e3eae736e9a135c09 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 24 Jun 2011 17:06:02 +0200 Subject: [PATCH 099/111] show error on openid request page when no user is selected --- apps/user_openid/phpmyid.php | 4 +++- apps/user_openid/templates/nomode.php | 21 +++++++++++++-------- apps/user_openid/user.php | 4 ++++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/apps/user_openid/phpmyid.php b/apps/user_openid/phpmyid.php index 330cd466c4..5b04684cd7 100644 --- a/apps/user_openid/phpmyid.php +++ b/apps/user_openid/phpmyid.php @@ -560,7 +560,9 @@ function logout_mode () { * @global array $profile */ function no_mode () { + global $USERNAME; $tmpl = new OC_TEMPLATE( 'user_openid', 'nomode', 'guest' ); + $tmpl->assign('user',$USERNAME); $tmpl->printPage(); } @@ -1669,7 +1671,7 @@ if (! array_key_exists('auth_domain', $profile)) // Set a default authentication realm if (! array_key_exists('auth_realm', $profile)) - $profile['auth_realm'] = 'phpMyID'; + $profile['auth_realm'] = 'ownCloud'; // Determine the realm for digest authentication - DO NOT OVERRIDE $profile['php_realm'] = $profile['auth_realm'] . (ini_get('safe_mode') ? '-' . getmyuid() : ''); diff --git a/apps/user_openid/templates/nomode.php b/apps/user_openid/templates/nomode.php index 13a1a89493..f85d28cdc9 100644 --- a/apps/user_openid/templates/nomode.php +++ b/apps/user_openid/templates/nomode.php @@ -5,17 +5,22 @@ global $profile; ?>
    - " alt="ownCloud" /> + " alt="ownCloud" />
    • -

      t('This is an OpenID server endpoint. For more information, see http://openid.net/'));?>

      -

      t('Server: ').$profile['idp_url']); ?> -

      t('Realm: ').$profile['php_realm']); ?> -

      t('Login')); ?> - - | Test - +

      t('This is an OpenID server endpoint. For more information, see '));?>http://openid.net/

      + +

      t('Identity: ').$profile['idp_url']); ?>

      +

      t('Realm: ').$profile['php_realm']); ?>

      +

      t('User: ').$_['user']); ?> +

      t('Login')); ?> + + Test + + +

      t('Error: No user Selected')); ?>

      +
    diff --git a/apps/user_openid/user.php b/apps/user_openid/user.php index 9ca1fd47c9..2199e5f9e5 100644 --- a/apps/user_openid/user.php +++ b/apps/user_openid/user.php @@ -28,6 +28,10 @@ if(strpos($USERNAME,'?')){ require_once '../../lib/base.php'; +if(!OC_USER::userExists($USERNAME)){ + $USERNAME=''; +} + require_once 'phpmyid.php'; From 4d11e920be943bdd60c86e46b8f6c922dea87c79 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 24 Jun 2011 18:02:19 +0200 Subject: [PATCH 100/111] provide an option to add custom elements to the header of templates --- core/templates/layout.admin.php | 12 ++++++++++++ core/templates/layout.guest.php | 13 +++++++++++++ core/templates/layout.user.php | 12 ++++++++++++ lib/template.php | 22 ++++++++++++++++++++-- 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/core/templates/layout.admin.php b/core/templates/layout.admin.php index 1fcd4568f8..8668aa64fd 100644 --- a/core/templates/layout.admin.php +++ b/core/templates/layout.admin.php @@ -13,6 +13,18 @@ + + $value){ + echo "$name='$value' "; + }; + echo '>'; + echo $header['text']; + echo ''; + ?> + + diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php index ce99b00b9f..5655a64d8d 100644 --- a/core/templates/layout.guest.php +++ b/core/templates/layout.guest.php @@ -13,6 +13,19 @@ + + + $value){ + echo "$name='$value' "; + }; + echo '>'; + echo $header['text']; + echo ''; + ?> + + diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index f21db202a8..2a9a817498 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -13,6 +13,18 @@ + + $value){ + echo "$name='$value' "; + }; + echo '>'; + echo $header['text']; + echo ''; + ?> + + diff --git a/lib/template.php b/lib/template.php index 69065e1ea1..992fa2de76 100644 --- a/lib/template.php +++ b/lib/template.php @@ -76,6 +76,7 @@ class OC_TEMPLATE{ private $vars; // Vars private $template; // The path to the template private $l10n; // The l10n-Object + private $headers=array(); //custom headers /** * @brief Constructor @@ -151,6 +152,16 @@ class OC_TEMPLATE{ $this->vars[$key] = array( $value ); } } + + /** + * @brief Add a custom element to the header + * @param string tag tag name of the element + * @param array $attributes array of attrobutes for the element + * @param string $text the text content for the element + */ + public function addHeader( $tag, $attributes, $text=''){ + $this->headers[]=array('tag'=>$tag,'attributes'=>$attributes,'text'=>$text); + } /** * @brief Prints the proceeded template @@ -195,7 +206,9 @@ class OC_TEMPLATE{ $search=new OC_TEMPLATE( 'core', 'part.searchbox'); $search->assign('searchurl',OC_HELPER::linkTo( 'search', 'index.php' )); $page->assign('searchbox', $search->fetchPage()); - // Add menu data + + // Add custom headers + $page->assign('headers',$this->headers); // Add navigation entry $page->assign( "navigation", OC_APP::getNavigation()); @@ -206,6 +219,10 @@ class OC_TEMPLATE{ $search=new OC_TEMPLATE( 'core', 'part.searchbox'); $search->assign('searchurl',OC_HELPER::linkTo( 'search', 'index.php' )); $page->assign('searchbox', $search->fetchPage()); + + // Add custom headers + $page->assign('headers',$this->headers); + // Add menu data if( OC_GROUP::inGroup( $_SESSION["user_id"], "admin" )){ $page->assign( "adminnavigation", OC_APP::getAdminNavigation()); @@ -215,7 +232,8 @@ class OC_TEMPLATE{ else { $page = new OC_TEMPLATE( "core", "layout.guest" ); - // Add data if required + // Add custom headers + $page->assign('headers',$this->headers); } // Add the css and js files From 7d2784c4c3145c8dcf15fb357f2325ae29d65717 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 24 Jun 2011 18:02:51 +0200 Subject: [PATCH 101/111] add openid headers to openid request page --- apps/user_openid/phpmyid.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/user_openid/phpmyid.php b/apps/user_openid/phpmyid.php index 5b04684cd7..69cd711162 100644 --- a/apps/user_openid/phpmyid.php +++ b/apps/user_openid/phpmyid.php @@ -560,8 +560,10 @@ function logout_mode () { * @global array $profile */ function no_mode () { - global $USERNAME; + global $USERNAME, $profile; $tmpl = new OC_TEMPLATE( 'user_openid', 'nomode', 'guest' ); + $tmpl->addHeader('link',array('rel'=>'openid.server', 'href'=>$profile['req_url'])); + $tmpl->addHeader('link',array('rel'=>'openid.delegate', 'href'=>$profile['idp_url'])); $tmpl->assign('user',$USERNAME); $tmpl->printPage(); } From 2098cbd8222fe7657fec5538798426495a9b9888 Mon Sep 17 00:00:00 2001 From: Aamir Khan Date: Sat, 25 Jun 2011 01:14:28 +0530 Subject: [PATCH 102/111] redirect_url to be respected in linkTo function --- lib/helper.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) mode change 100644 => 100755 lib/helper.php diff --git a/lib/helper.php b/lib/helper.php old mode 100644 new mode 100755 index 8cd6ebf75a..96d5bfad82 --- a/lib/helper.php +++ b/lib/helper.php @@ -29,11 +29,12 @@ class OC_HELPER { * @brief Creates an url * @param $app app * @param $file file + * @param $redirect_url redirect_url variable is appended to the URL * @returns the url * * Returns a url to the given app and file. */ - public static function linkTo( $app, $file ){ + public static function linkTo( $app, $file , $redirect_url=NULL ){ global $WEBROOT; global $SERVERROOT; @@ -41,20 +42,26 @@ class OC_HELPER { $app .= '/'; // Check if the app is in the app folder if( file_exists( $SERVERROOT . '/apps/'. $app.$file )){ - return $WEBROOT . '/apps/' . $app . $file; + $urlLinkTo = $WEBROOT . '/apps/' . $app . $file; } else{ - return $WEBROOT . '/' . $app . $file; + $urlLinkTo = $WEBROOT . '/' . $app . $file; } } else{ if( file_exists( $SERVERROOT . '/core/'. $file )){ - return $WEBROOT . '/core/'.$file; + $urlLinkTo = $WEBROOT . '/core/'.$file; } else{ - return $WEBROOT . '/'.$file; + $urlLinkTo = $WEBROOT . '/'.$file; } } + + if($redirect_url) + return $urlLinkTo.'?redirect_url='.$redirect_url; + else + return $urlLinkTo; + } /** From 155f62bcf6082264f402d634ebbef9fe78dda3a3 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 24 Jun 2011 22:06:40 +0200 Subject: [PATCH 103/111] allow plugins/apps to add custom headers to all pages --- lib/base.php | 11 +++++++++++ lib/template.php | 16 +++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/base.php b/lib/base.php index 0453e272a4..6aac2d9855 100644 --- a/lib/base.php +++ b/lib/base.php @@ -120,6 +120,7 @@ if(!$error and !$RUNTIME_NOAPPS ){ class OC_UTIL { public static $scripts=array(); public static $styles=array(); + public static $headers=array(); private static $fsSetup=false; // Can be set up @@ -231,6 +232,16 @@ class OC_UTIL { } } + /** + * @brief Add a custom element to the header + * @param string tag tag name of the element + * @param array $attributes array of attrobutes for the element + * @param string $text the text content for the element + */ + public static function addHeader( $tag, $attributes, $text=''){ + self::$headers[]=array('tag'=>$tag,'attributes'=>$attributes,'text'=>$text); + } + /** * formats a timestamp in the "right" way * diff --git a/lib/template.php b/lib/template.php index 992fa2de76..9393fe6908 100644 --- a/lib/template.php +++ b/lib/template.php @@ -206,9 +206,6 @@ class OC_TEMPLATE{ $search=new OC_TEMPLATE( 'core', 'part.searchbox'); $search->assign('searchurl',OC_HELPER::linkTo( 'search', 'index.php' )); $page->assign('searchbox', $search->fetchPage()); - - // Add custom headers - $page->assign('headers',$this->headers); // Add navigation entry $page->assign( "navigation", OC_APP::getNavigation()); @@ -220,9 +217,6 @@ class OC_TEMPLATE{ $search->assign('searchurl',OC_HELPER::linkTo( 'search', 'index.php' )); $page->assign('searchbox', $search->fetchPage()); - // Add custom headers - $page->assign('headers',$this->headers); - // Add menu data if( OC_GROUP::inGroup( $_SESSION["user_id"], "admin" )){ $page->assign( "adminnavigation", OC_APP::getAdminNavigation()); @@ -232,8 +226,6 @@ class OC_TEMPLATE{ else { $page = new OC_TEMPLATE( "core", "layout.guest" ); - // Add custom headers - $page->assign('headers',$this->headers); } // Add the css and js files @@ -259,7 +251,13 @@ class OC_TEMPLATE{ $page->append( "cssfiles", "$WEBROOT/core/$style.css" ); } } - + + // Add custom headers + $page->assign('headers',$this->headers); + foreach(OC_UTIL::$headers as $header){ + $page->append('headers',$header); + } + // Add css files and js files $page->assign( "content", $data ); return $page->fetchPage(); From 4ac25942dee332b3227501e50525101a5f85fc6b Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 24 Jun 2011 22:07:26 +0200 Subject: [PATCH 104/111] you can now use your owncloud url as openid provider --- apps/user_openid/appinfo/app.php | 4 +++ apps/user_openid/phpmyid.php | 50 ++++++++++++++++++++------------ apps/user_openid/user.php | 11 ++++++- 3 files changed, 45 insertions(+), 20 deletions(-) diff --git a/apps/user_openid/appinfo/app.php b/apps/user_openid/appinfo/app.php index 2e238ed3f2..d6eacfc0a3 100644 --- a/apps/user_openid/appinfo/app.php +++ b/apps/user_openid/appinfo/app.php @@ -5,6 +5,10 @@ if (!in_array ('curl', get_loaded_extensions())){ return; } +$urlBase=((isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST']; +OC_UTIL::addHeader('link',array('rel'=>'openid.server', 'href'=>$urlBase.OC_HELPER::linkTo( "user_openid", "user.php" ).'/')); +OC_UTIL::addHeader('link',array('rel'=>'openid.delegate', 'href'=>$urlBase.OC_HELPER::linkTo( "user_openid", "user.php" ).'/')); + require_once 'apps/user_openid/user_openid.php'; OC_APP::addSettingsPage( array( "id" => "user_openid_settings", 'order'=>1, "href" => OC_HELPER::linkTo( "user_openid", "settings.php" ), "name" => "OpenID")); diff --git a/apps/user_openid/phpmyid.php b/apps/user_openid/phpmyid.php index 69cd711162..7991b87c6d 100644 --- a/apps/user_openid/phpmyid.php +++ b/apps/user_openid/phpmyid.php @@ -198,16 +198,18 @@ function associate_mode () { function authorize_mode () { global $profile; global $USERNAME; + global $IDENTITY; // this is a user session // the user needs refresh urls in their session to access this mode if (! isset($_SESSION['post_auth_url']) || ! isset($_SESSION['cancel_auth_url'])) error_500('You may not access this mode directly.'); - + + $profile['idp_url']=$IDENTITY; if (isset($_SERVER['PHP_AUTH_USER']) && $profile['authorized'] === false && $_SERVER['PHP_AUTH_USER']==$USERNAME) { if (OC_USER::checkPassword($USERNAME, $_SERVER['PHP_AUTH_PW'])) {// successful login! - + error_log('success'); // return to the refresh url if they get in $_SESSION['openid_auth']=true; $_SESSION['openid_user']=$USERNAME; @@ -367,7 +369,7 @@ function checkid ( $wait ) { } // transfer the user to the url accept mode if they're paranoid - if ($wait == 1 && isset($profile['paranoid']) && $profile['paranoid'] === true && (! session_is_registered('accepted_url') || $_SESSION['accepted_url'] != $trust_root)) { + if ($wait == 1 && isset($profile['paranoid']) && $profile['paranoid'] === true && (! isset($_SESSION['accepted_url']) || $_SESSION['accepted_url'] != $trust_root)) { $_SESSION['cancel_accept_url'] = $cancel_url; $_SESSION['post_accept_url'] = $profile['req_url']; $_SESSION['unaccepted_url'] = $trust_root; @@ -381,11 +383,11 @@ function checkid ( $wait ) { } // make sure i am this identifier - if ($identity != $profile['idp_url']) { - debug("Invalid identity: $identity"); - debug("IdP URL: " . $profile['idp_url']); - error_get($return_to, "Invalid identity: '$identity'"); - } +// if ($identity != $profile['idp_url']) { +// debug("Invalid identity: $identity"); +// debug("IdP URL: " . $profile['idp_url']); +// error_get($return_to, "Invalid identity: '$identity'"); +// } // begin setting up return keys $keys = array( @@ -393,9 +395,9 @@ function checkid ( $wait ) { ); // if the user is not logged in, transfer to the authorization mode - if ($_SESSION['openid_auth'] === false || $USERNAME != $_SESSION['openid_user']) { + if ($USERNAME=='' || $_SESSION['openid_auth'] === false || $USERNAME != $_SESSION['openid_user']) { // users can only be logged in to one url at a time - $_SESSION['auth_username'] = null; + $_SESSION['openid_user'] = null; $_SESSION['auth_url'] = null; if ($wait) { @@ -562,6 +564,9 @@ function logout_mode () { function no_mode () { global $USERNAME, $profile; $tmpl = new OC_TEMPLATE( 'user_openid', 'nomode', 'guest' ); + if(substr($profile['req_url'],-1,1)!=='/'){//the identity should always end with a / + $profile['req_url'].='/'; + } $tmpl->addHeader('link',array('rel'=>'openid.server', 'href'=>$profile['req_url'])); $tmpl->addHeader('link',array('rel'=>'openid.delegate', 'href'=>$profile['idp_url'])); $tmpl->assign('user',$USERNAME); @@ -1267,11 +1272,11 @@ function secret ( $handle ) { session_start(); debug('Started session to acquire key: ' . session_id()); - $secret = session_is_registered('shared_secret') + $secret = isset($_SESSION['shared_secret']) ? base64_decode($_SESSION['shared_secret']) : false; - $expiration = session_is_registered('expiration') + $expiration = isset($_SESSION['expiration']) ? $_SESSION['expiration'] : null; @@ -1632,22 +1637,29 @@ $GLOBALS['proto'] = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') ? 'h // Set the authorization state - DO NOT OVERRIDE $profile['authorized'] = false; +global $IDENTITY; +global $USERNAME; + // Set a default IDP URL if (! array_key_exists('idp_url', $profile)) - $profile['idp_url'] = sprintf("%s://%s%s%s", - $proto, - $_SERVER['SERVER_NAME'], - $port, - $_SERVER['PHP_SELF']); + $profile['idp_url'] = $IDENTITY; -// Determine the requested URL - DO NOT OVERRIDE +//Determine the requested URL - DO NOT OVERRIDE $profile['req_url'] = sprintf("%s://%s%s", $proto, $_SERVER['HTTP_HOST'], // $port,//host already includes the path $_SERVER["REQUEST_URI"]); -error_log($profile['req_url']); +$fullId=urlencode('.php/'.$USERNAME); +$incompleteId=urlencode('.php/'); + +if(!strpos($profile['req_url'],$fullId)){ + $profile['req_url']=str_replace($incompleteId,$fullId,$profile['req_url']); +} + +error_log('inc id: '.$fullId); +error_log('req url: '.$profile['req_url']); // Set the default allowance for testing if (! array_key_exists('allow_test', $profile)) diff --git a/apps/user_openid/user.php b/apps/user_openid/user.php index 2199e5f9e5..52af9ba3a5 100644 --- a/apps/user_openid/user.php +++ b/apps/user_openid/user.php @@ -22,15 +22,24 @@ */ $USERNAME=substr($_SERVER["REQUEST_URI"],strpos($_SERVER["REQUEST_URI"],'.php/')+5); -if(strpos($USERNAME,'?')){ +if(strpos($USERNAME,'?')!==false){ $USERNAME=substr($USERNAME,0,strpos($USERNAME,'?')); } + +if($USERNAME=='' and isset($_SERVER['PHP_AUTH_USER'])){ + $USERNAME=$_SERVER['PHP_AUTH_USER']; +} + +$RUNTIME_NOAPPS=true; +$RUNTIME_NOAPPS=false; require_once '../../lib/base.php'; if(!OC_USER::userExists($USERNAME)){ $USERNAME=''; } +global $WEBROOT; +$IDENTITY=((isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].$WEBROOT.'/apps/user_openid/user.php/'.$USERNAME; require_once 'phpmyid.php'; From f40a1cad8b55bafa08d7e96415d4d2f9c7059a38 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 26 Jun 2011 00:59:09 +0200 Subject: [PATCH 105/111] not all http server add index.php to $_SERVER[SCRIPT_NAME], do it manually this fixes incorect generated links in some cases --- lib/base.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/base.php b/lib/base.php index 6aac2d9855..c5a0403e3b 100644 --- a/lib/base.php +++ b/lib/base.php @@ -35,7 +35,11 @@ $SERVERROOT=substr(__FILE__,0,-13); $DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']); $SERVERROOT=str_replace("\\",'/',$SERVERROOT); $SUBURI=substr(realpath($_SERVER["SCRIPT_FILENAME"]),strlen($SERVERROOT)); -$WEBROOT=substr($_SERVER["SCRIPT_NAME"],0,strlen($_SERVER["SCRIPT_NAME"])-strlen($SUBURI)); +$scriptName=$_SERVER["SCRIPT_NAME"]; +if(substr($scriptName,-1)=='/'){//if the script isn't a file assume index.php + $scriptName.='index.php'; +} +$WEBROOT=substr($scriptName,0,strlen($scriptName)-strlen($SUBURI)); From f2845bbea877e6ddaba897879b0625c0535b5fe1 Mon Sep 17 00:00:00 2001 From: Kunal Ghosh Date: Sat, 2 Jul 2011 07:17:05 +0530 Subject: [PATCH 106/111] Fix to make the Unlock mechanism of WebDAV work. Previously when using unlock in cadaver etc was used the lock entry corresponding to the file was not deleted in the sqlite database table oc_locks. The error was because the delete query in the Unlock function was not getting executed :) --- lib/HTTP/WebDAV/Server/Filesystem.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/HTTP/WebDAV/Server/Filesystem.php b/lib/HTTP/WebDAV/Server/Filesystem.php index 164892c9d8..5f26164362 100644 --- a/lib/HTTP/WebDAV/Server/Filesystem.php +++ b/lib/HTTP/WebDAV/Server/Filesystem.php @@ -687,9 +687,14 @@ VALUES (?,?,?,?,?,'timeout',?,?)"); function UNLOCK(&$options) { $query = OC_DB::prepare("DELETE FROM *PREFIX*locks + WHERE path = '$options[path]' + AND token = '$options[token]'"); + /* + $query = OC_DB::prepare("DELETE FROM *PREFIX*locks WHERE path = ? AND token = ?"); - $query->execute(array($options[path]),$options[token]); + */ + $query->execute();#array($options[path]),$options[token]); return PEAR::isError($result) ? "409 Conflict" : "204 No Content"; } From 1daeb13dd9ac4367eadb1265e07e17fced74413d Mon Sep 17 00:00:00 2001 From: Hans Bakker Date: Sun, 3 Jul 2011 01:52:17 +0200 Subject: [PATCH 107/111] Usability improvements: -Added javascript to enable/disable radiobuttons -Added labels --- files/templates/admin.php | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/files/templates/admin.php b/files/templates/admin.php index 74b99b771c..4dde9c510c 100644 --- a/files/templates/admin.php +++ b/files/templates/admin.php @@ -1,16 +1,26 @@ -
    + + - t( 'Maximum upload size' ); ?> '/>
    + '/>
    - t( 'Allow public folders' ); ?>
    +
    - t( '(if public is enabled)' ); ?>
    - t( 'separated from webdav storage' ); ?>
    - t( 'let the user decide' ); ?>
    - t( 'folder "/public" in webdav storage' ); ?>
    - t( '(endif)' ); ?>
    +
    +
    +
    + +
    - t( 'Allow downloading shared files' ); ?>
    - t( 'Allow uploading in shared directory' ); ?>
    +
    +
    From f893f1461537dabe4a044de12f124739c349ae0f Mon Sep 17 00:00:00 2001 From: Hans Bakker Date: Mon, 4 Jul 2011 00:16:49 +0200 Subject: [PATCH 108/111] Improved the dutch l10n files --- l10n/nl/admin.po | 14 +++++++------- l10n/nl/core.po | 21 ++++++++++----------- l10n/nl/log.po | 4 ++-- l10n/nl/settings.po | 8 ++++---- 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/l10n/nl/admin.po b/l10n/nl/admin.po index 2feccb46b9..275fd66860 100644 --- a/l10n/nl/admin.po +++ b/l10n/nl/admin.po @@ -23,15 +23,15 @@ msgstr "Meer informatie" #: ../templates/app.php:24 msgid "INSTALL" -msgstr "Instaleer" +msgstr "Installeer" #: ../templates/app_noconn.php:6 ../templates/apps.php:6 msgid "Apps Repository" -msgstr "Applicatie Database" +msgstr "Applicatiedatabase" #: ../templates/app_noconn.php:7 msgid "Cannot connect to apps repository" -msgstr "Kan geen verbinding maken met de applicatie database" +msgstr "Kan geen verbinding maken met de applicatiedatabase" #: ../templates/apps.php:13 ../templates/users.php:6 ../templates/users.php:20 #: ../templates/users.php:50 @@ -48,7 +48,7 @@ msgstr "Administratie" #: ../templates/system.php:7 msgid "System Settings" -msgstr "Systeem Instellingen" +msgstr "Systeeminstellingen" #: ../templates/users.php:7 ../templates/users.php:46 msgid "Groups" @@ -56,7 +56,7 @@ msgstr "Groepen" #: ../templates/users.php:13 msgid "Add user" -msgstr "Voeg gebruiker toe" +msgstr "Gebruiker toevoegen" #: ../templates/users.php:21 msgid "Password" @@ -64,7 +64,7 @@ msgstr "Wachtwoord" #: ../templates/users.php:30 msgid "Create user" -msgstr "Maak gebruiker aan" +msgstr "Gebruiker aanmaken" #: ../templates/users.php:40 ../templates/users.php:68 msgid "remove" @@ -72,7 +72,7 @@ msgstr "verwijder" #: ../templates/users.php:58 msgid "Create group" -msgstr "Maak groep aan" +msgstr "Groep aanmaken" #: ../templates/users.php:94 msgid "Force new password:" diff --git a/l10n/nl/core.po b/l10n/nl/core.po index 9aa3851d86..211d93503d 100644 --- a/l10n/nl/core.po +++ b/l10n/nl/core.po @@ -27,11 +27,11 @@ msgstr "Welkom by ownCloud, jouw persoonlijke cloud" #: ../templates/installation.php:7 msgid "To finish the installation, please follow the steps below." -msgstr "Volg de volgende stappen om de instalatie af te ronden." +msgstr "Volg de volgende stappen om de installatie te voltooien." #: ../templates/installation.php:26 msgid "Create an admin account." -msgstr "Maak een administrator account. aan" +msgstr "Maak een administrator account aan" #: ../templates/installation.php:27 msgid "Login:" @@ -51,16 +51,15 @@ msgstr "Bepaal waar de gegevens opgeslagen moeten woorden." #: ../templates/installation.php:35 msgid "Data directory:" -msgstr "Gegevens map:" +msgstr "Gegevensmap:" #: ../templates/installation.php:39 msgid "Configure your database." -msgstr "Stel de database in." +msgstr "Stel je database in." #: ../templates/installation.php:43 msgid "I will use a SQLite database. You have nothing to do!" -msgstr "" -"Er zan een SQLite database gebruikt woorden, je hoeft niks in te stellen." +msgstr "Er zan een SQLite database gebruikt woorden, je hoeft niks in te stellen." #: ../templates/installation.php:46 msgid "SQLite" @@ -76,15 +75,15 @@ msgstr "Host:" #: ../templates/installation.php:60 msgid "Database name:" -msgstr "Database naam:" +msgstr "Databasenaam:" #: ../templates/installation.php:61 msgid "Table prefix:" -msgstr "Voorvoegsel voor tabelnaamen:" +msgstr "Voorvoegsel voor tabelnamen:" #: ../templates/installation.php:62 msgid "MySQL user login:" -msgstr "MySQL gebruikers naam." +msgstr "MySQL gebruikersnaam." #: ../templates/installation.php:63 msgid "MySQL user password:" @@ -92,7 +91,7 @@ msgstr "MySQL wachtwoord" #: ../templates/installation.php:68 msgid "Finish setup" -msgstr "Instalatie afronden" +msgstr "Installatie afronden" #: ../templates/layout.guest.php:20 msgid "" @@ -108,7 +107,7 @@ msgstr "Aanmelden mislukt." #: ../templates/logout.php:1 msgid "You are logged out." -msgstr "Je bent afgemend." +msgstr "Je bent afgemeld." #: ../templates/part.pagenavi.php:6 msgid "prev" diff --git a/l10n/nl/log.po b/l10n/nl/log.po index a071faeccf..3bf2f43a92 100644 --- a/l10n/nl/log.po +++ b/l10n/nl/log.po @@ -59,9 +59,9 @@ msgstr "Wat" #: ../templates/index.php:27 msgid "When" -msgstr "Waneer" +msgstr "Wanneer" #: ../templates/index.php:45 msgid "Clear log entries before" -msgstr "Verwijder logboek element ouder dan" +msgstr "Verwijder logboekitem ouder dan" diff --git a/l10n/nl/settings.po b/l10n/nl/settings.po index 11c325d5fc..088b2ef16e 100644 --- a/l10n/nl/settings.po +++ b/l10n/nl/settings.po @@ -19,7 +19,7 @@ msgstr "" #: ../templates/index.php:3 msgid "Account information" -msgstr "Gebruiks gegevens" +msgstr "Gebruikersgegevens" #: ../templates/index.php:5 msgid "You're currently using" @@ -59,7 +59,7 @@ msgstr "Taal" #: ../ajax/changepassword.php:13 ../ajax/setlanguage.php:13 msgid "Authentication error" -msgstr "Authenticatie fout." +msgstr "Authenticatiefout." #: ../ajax/changepassword.php:19 msgid "You have to enter the old and the new password!" @@ -75,7 +75,7 @@ msgstr "Wachtwoord aangepast" #: ../ajax/changepassword.php:34 msgid "Unable to change password" -msgstr "Wachtwoord aanpassen is niet mogenlijk" +msgstr "Wachtwoord aanpassen is niet mogelijk" #: ../ajax/setlanguage.php:21 msgid "Language changed" @@ -83,4 +83,4 @@ msgstr "Taal aangepast" #: ../ajax/setlanguage.php:23 msgid "Invalid request" -msgstr "Ongeldige aanvraag" +msgstr "Ongeldig verzoek" From f989871501fd9b365aee843ec75b88acc3f8bd15 Mon Sep 17 00:00:00 2001 From: Hans Bakker Date: Mon, 4 Jul 2011 00:39:04 +0200 Subject: [PATCH 109/111] More nl l10n improvements --- admin/l10n/nl.php | 18 +++++++++--------- core/l10n/nl.php | 28 ++++++++++++++-------------- l10n/nl/admin.po | 4 ++-- l10n/nl/core.po | 16 ++++++++-------- l10n/nl/settings.po | 6 +++--- log/l10n/nl.php | 4 ++-- settings/l10n/nl.php | 14 +++++++------- 7 files changed, 45 insertions(+), 45 deletions(-) diff --git a/admin/l10n/nl.php b/admin/l10n/nl.php index a762559e08..cfbc1b0f51 100644 --- a/admin/l10n/nl.php +++ b/admin/l10n/nl.php @@ -1,20 +1,20 @@ "Meer informatie", -"INSTALL" => "Instaleer", -"Apps Repository" => "Applicatie Database", -"Cannot connect to apps repository" => "Kan geen verbinding maken met de applicatie database", +"INSTALL" => "Installeer", +"Apps Repository" => "Applicatiedatabase", +"Cannot connect to apps repository" => "Kan geen verbinding maken met de applicatiedatabase", "Name" => "Naam", "Modified" => "Laatst aangepast", "Administration" => "Administratie", -"System Settings" => "Systeem Instellingen", +"System Settings" => "Systeeminstellingen", "Groups" => "Groepen", -"Add user" => "Voeg gebruiker toe", +"Add user" => "Gebruiker toevoegen", "Password" => "Wachtwoord", -"Create user" => "Maak gebruiker aan", +"Create user" => "Gebruiker aanmaken", "remove" => "verwijder", -"Create group" => "Maak groep aan", +"Create group" => "Groep aanmaken", "Force new password:" => "Forceer nieuw wachtwoord:", "Set" => "Ok", -"Do you really want to delete user" => "Weet je zeker dat je deze gebruiker wil verwijderen", -"Do you really want to delete group" => "Weet je zeker dat je deze groep wil verwijderen" +"Do you really want to delete user" => "Wilt u deze gebruiker verwijderen", +"Do you really want to delete group" => "Wilt u deze groep verwijderen" ); diff --git a/core/l10n/nl.php b/core/l10n/nl.php index bbffcd0831..66d9650597 100644 --- a/core/l10n/nl.php +++ b/core/l10n/nl.php @@ -1,26 +1,26 @@ "Fout 404, Cloud niet gevonden.", -"Welcome to ownCloud, your personnal cloud." => "Welkom by ownCloud, jouw persoonlijke cloud", -"To finish the installation, please follow the steps below." => "Volg de volgende stappen om de instalatie af te ronden.", -"Create an admin account." => "Maak een administrator account. aan", +"Welcome to ownCloud, your personnal cloud." => "Welkom by ownCloud, uw persoonlijke cloud", +"To finish the installation, please follow the steps below." => "Volg de volgende stappen om de installatie te voltooien.", +"Create an admin account." => "Maak een beheerdersaccount aan", "Login:" => "Gebruikersnaam:", "Password:" => "Wachtwoord:", "Advanced" => "Geavanceerd", -"Set where to store the data." => "Bepaal waar de gegevens opgeslagen moeten woorden.", -"Data directory:" => "Gegevens map:", -"Configure your database." => "Stel de database in.", -"I will use a SQLite database. You have nothing to do!" => "Er zan een SQLite database gebruikt woorden, je hoeft niks in te stellen.", +"Set where to store the data." => "Bepaal de opslaglocatie.", +"Data directory:" => "Gegevensmap:", +"Configure your database." => "Configureer uw database.", +"I will use a SQLite database. You have nothing to do!" => "Er zal een SQLite database gebruikt worden. U hoeft geen verdere instellingen te maken.", "SQLite" => "SQLite", -"I will use a MySQL database." => "Er zal een MySQL database gebruikt woorden.", +"I will use a MySQL database." => "Er zal een MySQL database gebruikt worden.", "Host:" => "Host:", -"Database name:" => "Database naam:", -"Table prefix:" => "Voorvoegsel voor tabelnaamen:", -"MySQL user login:" => "MySQL gebruikers naam.", +"Database name:" => "Databasenaam:", +"Table prefix:" => "Voorvoegsel voor tabelnamen:", +"MySQL user login:" => "MySQL gebruikersnaam.", "MySQL user password:" => "MySQL wachtwoord", -"Finish setup" => "Instalatie afronden", -"ownCloud is a personal cloud which runs on your own server.

    " => "ownCloud is een persoonlijke cloud die op je eigen server draait.

    ", +"Finish setup" => "Installatie afronden", +"ownCloud is a personal cloud which runs on your own server.

    " => "ownCloud is een persoonlijke cloud die op uw eigen server draait.

    ", "Login failed!" => "Aanmelden mislukt.", -"You are logged out." => "Je bent afgemend.", +"You are logged out." => "U bent afgemeld.", "prev" => "vorige", "next" => "volgende", "Search" => "Zoeken" diff --git a/l10n/nl/admin.po b/l10n/nl/admin.po index 275fd66860..506d5906b8 100644 --- a/l10n/nl/admin.po +++ b/l10n/nl/admin.po @@ -84,9 +84,9 @@ msgstr "Ok" #: ../templates/users.php:102 msgid "Do you really want to delete user" -msgstr "Weet je zeker dat je deze gebruiker wil verwijderen" +msgstr "Wilt u deze gebruiker verwijderen" #: ../templates/users.php:109 msgid "Do you really want to delete group" -msgstr "Weet je zeker dat je deze groep wil verwijderen" +msgstr "Wilt u deze groep verwijderen" diff --git a/l10n/nl/core.po b/l10n/nl/core.po index 211d93503d..3923dcb413 100644 --- a/l10n/nl/core.po +++ b/l10n/nl/core.po @@ -23,7 +23,7 @@ msgstr "Fout 404, Cloud niet gevonden." #: ../templates/installation.php:6 msgid "Welcome to ownCloud, your personnal cloud." -msgstr "Welkom by ownCloud, jouw persoonlijke cloud" +msgstr "Welkom by ownCloud, uw persoonlijke cloud" #: ../templates/installation.php:7 msgid "To finish the installation, please follow the steps below." @@ -31,7 +31,7 @@ msgstr "Volg de volgende stappen om de installatie te voltooien." #: ../templates/installation.php:26 msgid "Create an admin account." -msgstr "Maak een administrator account aan" +msgstr "Maak een beheerdersaccount aan" #: ../templates/installation.php:27 msgid "Login:" @@ -47,7 +47,7 @@ msgstr "Geavanceerd" #: ../templates/installation.php:34 msgid "Set where to store the data." -msgstr "Bepaal waar de gegevens opgeslagen moeten woorden." +msgstr "Bepaal de opslaglocatie." #: ../templates/installation.php:35 msgid "Data directory:" @@ -55,11 +55,11 @@ msgstr "Gegevensmap:" #: ../templates/installation.php:39 msgid "Configure your database." -msgstr "Stel je database in." +msgstr "Configureer uw database." #: ../templates/installation.php:43 msgid "I will use a SQLite database. You have nothing to do!" -msgstr "Er zan een SQLite database gebruikt woorden, je hoeft niks in te stellen." +msgstr "Er zal een SQLite database gebruikt worden. U hoeft geen verdere instellingen te maken." #: ../templates/installation.php:46 msgid "SQLite" @@ -67,7 +67,7 @@ msgstr "SQLite" #: ../templates/installation.php:53 msgid "I will use a MySQL database." -msgstr "Er zal een MySQL database gebruikt woorden." +msgstr "Er zal een MySQL database gebruikt worden." #: ../templates/installation.php:59 msgid "Host:" @@ -99,7 +99,7 @@ msgid "" "on your own server.

    " msgstr "" "ownCloud is een persoonlijke cloud die " -"op je eigen server draait.

    " +"op uw eigen server draait.

    " #: ../templates/login.php:6 msgid "Login failed!" @@ -107,7 +107,7 @@ msgstr "Aanmelden mislukt." #: ../templates/logout.php:1 msgid "You are logged out." -msgstr "Je bent afgemeld." +msgstr "U bent afgemeld." #: ../templates/part.pagenavi.php:6 msgid "prev" diff --git a/l10n/nl/settings.po b/l10n/nl/settings.po index 088b2ef16e..866e8b702c 100644 --- a/l10n/nl/settings.po +++ b/l10n/nl/settings.po @@ -23,7 +23,7 @@ msgstr "Gebruikersgegevens" #: ../templates/index.php:5 msgid "You're currently using" -msgstr "Je gebruikt momenteel" +msgstr "U gebruikt momenteel" #: ../templates/index.php:5 msgid "of your" @@ -39,7 +39,7 @@ msgstr "Wachtwoord aanpassen" #: ../templates/index.php:12 msgid "Your password got changed" -msgstr "Je wachtwoord is aangepast" +msgstr "Uw wachtwoord is aangepast" #: ../templates/index.php:15 msgid "Old password:" @@ -63,7 +63,7 @@ msgstr "Authenticatiefout." #: ../ajax/changepassword.php:19 msgid "You have to enter the old and the new password!" -msgstr "Je moet het oude en nieuwe wachtwoord invullen." +msgstr "U moet het oude en nieuwe wachtwoord invullen." #: ../ajax/changepassword.php:25 msgid "Your old password is wrong!" diff --git a/log/l10n/nl.php b/log/l10n/nl.php index 59e9fa04d2..f381619b5f 100644 --- a/log/l10n/nl.php +++ b/log/l10n/nl.php @@ -9,6 +9,6 @@ "Show:" => "Laat", "entries per page." => "resulaten per pagina zien", "What" => "Wat", -"When" => "Waneer", -"Clear log entries before" => "Verwijder logboek element ouder dan" +"When" => "Wanneer", +"Clear log entries before" => "Verwijder logboekitem ouder dan" ); diff --git a/settings/l10n/nl.php b/settings/l10n/nl.php index f05e7cc7c2..3c2f3dbd27 100644 --- a/settings/l10n/nl.php +++ b/settings/l10n/nl.php @@ -1,19 +1,19 @@ "Gebruiks gegevens", -"You're currently using" => "Je gebruikt momenteel", +"Account information" => "Gebruikersgegevens", +"You're currently using" => "U gebruikt momenteel", "of your" => "van de", "space" => "beschikbare ruimte.", "Change Password" => "Wachtwoord aanpassen", -"Your password got changed" => "Je wachtwoord is aangepast", +"Your password got changed" => "Uw wachtwoord is aangepast", "Old password:" => "Oud wachtwoord:", "New password" => "Nieuw wachtwoord", "Show new password" => "Toon nieuw wachtwoord", "Language" => "Taal", -"Authentication error" => "Authenticatie fout.", -"You have to enter the old and the new password!" => "Je moet het oude en nieuwe wachtwoord invullen.", +"Authentication error" => "Authenticatiefout.", +"You have to enter the old and the new password!" => "U moet het oude en nieuwe wachtwoord invullen.", "Your old password is wrong!" => "Het oude wachtwoord is verkeerd.", "Password changed" => "Wachtwoord aangepast", -"Unable to change password" => "Wachtwoord aanpassen is niet mogenlijk", +"Unable to change password" => "Wachtwoord aanpassen is niet mogelijk", "Language changed" => "Taal aangepast", -"Invalid request" => "Ongeldige aanvraag" +"Invalid request" => "Ongeldig verzoek" ); From 7f0dc638ae5bb651baa171825921055d95cb1c63 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Mon, 4 Jul 2011 19:04:15 +0200 Subject: [PATCH 110/111] Hopefully fix errors if ldap plugin is not configured --- apps/user_ldap/user_ldap.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php index 1ee9809b3b..d6ed8c741e 100644 --- a/apps/user_ldap/user_ldap.php +++ b/apps/user_ldap/user_ldap.php @@ -26,6 +26,7 @@ require_once('User/backend.php'); class OC_USER_LDAP extends OC_USER_BACKEND { protected $ds; + protected $configured = false; // cached settings protected $ldap_host; @@ -42,6 +43,17 @@ class OC_USER_LDAP extends OC_USER_BACKEND { $this->ldap_password = OC_APPCONFIG::getValue('user_ldap', 'ldap_password',''); $this->ldap_base = OC_APPCONFIG::getValue('user_ldap', 'ldap_base',''); $this->ldap_filter = OC_APPCONFIG::getValue('user_ldap', 'ldap_filter',''); + + if( !empty($this->ldap_host) + && !empty($this->ldap_port) + && !empty($this->ldap_dn) + && !empty($this->ldap_password) + && !empty($this->ldap_base) + && !empty($this->ldap_filter) + ) + { + $this->configured = true; + } } function __destruct() { @@ -66,6 +78,9 @@ class OC_USER_LDAP extends OC_USER_BACKEND { } private function getDn( $uid ) { + if(!$this->configured) + return false; + // connect to server $ds = $this->getDs(); if( !$ds ) @@ -90,7 +105,7 @@ class OC_USER_LDAP extends OC_USER_BACKEND { } public function userExists( $uid ) { - $dn = getDn($uid); + $dn = $this->getDn($uid); return !empty($dn); } From 53ae56097de2098a2ffd1a8dd1076825bc93305d Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Mon, 4 Jul 2011 21:46:20 +0200 Subject: [PATCH 111/111] applied Ryan's patch for Bug 276007 - Folder list does not get updated when creating the first folder. --- files/js/filelist.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/files/js/filelist.js b/files/js/filelist.js index 14cce8a389..089a34581d 100644 --- a/files/js/filelist.js +++ b/files/js/filelist.js @@ -49,6 +49,10 @@ FileList={ } } } - $(fileElements[pos]).after(element); + if(fileElements.length){ + $(fileElements[pos]).after(element); + }else{ + $('#fileList').append(element); + } } -} \ No newline at end of file +}