From 8256650da881214e652353c9b79a5ba7964965e5 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 14 Dec 2012 22:52:40 +0100 Subject: Fix "No space found after comma in function call" --- lib/helper.php | 2 +- lib/l10n.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/helper.php b/lib/helper.php index 5dec7fadfb4..be4e4e52677 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -540,7 +540,7 @@ class OC_Helper { mkdir($tmpDirNoClean); } $file=$tmpDirNoClean.md5(time().rand()).$postfix; - $fh=fopen($file,'w'); + $fh=fopen($file, 'w'); fclose($fh); return $file; } diff --git a/lib/l10n.php b/lib/l10n.php index b83d8ff86db..cb67cfd4ed6 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -294,12 +294,12 @@ class OC_L10N{ } foreach($accepted_languages as $i) { $temp = explode(';', $i); - $temp[0] = str_replace('-','_',$temp[0]); + $temp[0] = str_replace('-', '_', $temp[0]); if( ($key = array_search($temp[0], $available)) !== false) { return $available[$key]; } foreach($available as $l) { - if ( $temp[0] == substr($l,0,2) ) { + if ( $temp[0] == substr($l, 0, 2) ) { return $l; } } -- cgit v1.2.3 From f39454ed12018402f38a8f6bf99fc94d676a0a3a Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 14 Dec 2012 23:04:42 +0100 Subject: Fix "Line indented incorrectly" --- apps/files_versions/history.php | 4 +-- apps/user_ldap/lib/access.php | 2 +- apps/user_ldap/lib/connection.php | 8 +++--- apps/user_webdavauth/settings.php | 6 ++-- lib/db.php | 6 ++-- lib/migrate.php | 2 +- lib/ocsclient.php | 8 +++--- lib/request.php | 2 +- lib/templatelayout.php | 10 +++---- lib/updater.php | 18 ++++++------ lib/util.php | 58 +++++++++++++++++++-------------------- 11 files changed, 62 insertions(+), 62 deletions(-) (limited to 'lib') diff --git a/apps/files_versions/history.php b/apps/files_versions/history.php index deff735cedc..d4c278ebd85 100644 --- a/apps/files_versions/history.php +++ b/apps/files_versions/history.php @@ -33,7 +33,7 @@ if ( isset( $_GET['path'] ) ) { $versions = new OCA_Versions\Storage(); // roll back to old version if button clicked - if( isset( $_GET['revert'] ) ) { + if( isset( $_GET['revert'] ) ) { if( $versions->rollback( $path, $_GET['revert'] ) ) { @@ -52,7 +52,7 @@ if ( isset( $_GET['path'] ) ) { } // show the history only if there is something to show - if( OCA_Versions\Storage::isversioned( $path ) ) { + if( OCA_Versions\Storage::isversioned( $path ) ) { $count = 999; //show the newest revisions $versions = OCA_Versions\Storage::getVersions( $path, $count); diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index 91f56ad882e..e1eea2f46c0 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -356,7 +356,7 @@ abstract class Access { ); } $res = $query->execute(array($dn))->fetchOne(); - if($res) { + if($res) { return $res; } return false; diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php index 687e2692270..b14cdafff89 100644 --- a/apps/user_ldap/lib/connection.php +++ b/apps/user_ldap/lib/connection.php @@ -338,11 +338,11 @@ class Connection { } $this->ldapConnectionRes = ldap_connect($this->config['ldapHost'], $this->config['ldapPort']); if(ldap_set_option($this->ldapConnectionRes, LDAP_OPT_PROTOCOL_VERSION, 3)) { - if(ldap_set_option($this->ldapConnectionRes, LDAP_OPT_REFERRALS, 0)) { - if($this->config['ldapTLS']) { - ldap_start_tls($this->ldapConnectionRes); - } + if(ldap_set_option($this->ldapConnectionRes, LDAP_OPT_REFERRALS, 0)) { + if($this->config['ldapTLS']) { + ldap_start_tls($this->ldapConnectionRes); } + } } return $this->bind(); diff --git a/apps/user_webdavauth/settings.php b/apps/user_webdavauth/settings.php index 497a3385caa..910073c7841 100755 --- a/apps/user_webdavauth/settings.php +++ b/apps/user_webdavauth/settings.php @@ -23,9 +23,9 @@ if($_POST) { - if(isset($_POST['webdav_url'])) { - OC_CONFIG::setValue('user_webdavauth_url', strip_tags($_POST['webdav_url'])); - } + if(isset($_POST['webdav_url'])) { + OC_CONFIG::setValue('user_webdavauth_url', strip_tags($_POST['webdav_url'])); + } } // fill template diff --git a/lib/db.php b/lib/db.php index 6524db7581a..7e60b41d230 100644 --- a/lib/db.php +++ b/lib/db.php @@ -445,9 +445,9 @@ class OC_DB { * http://www.sqlite.org/lang_createtable.html * http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions037.htm */ - if( $CONFIG_DBTYPE == 'pgsql' ) { //mysql support it too but sqlite doesn't - $content = str_replace( '0000-00-00 00:00:00', 'CURRENT_TIMESTAMP', $content ); - } + if( $CONFIG_DBTYPE == 'pgsql' ) { //mysql support it too but sqlite doesn't + $content = str_replace( '0000-00-00 00:00:00', 'CURRENT_TIMESTAMP', $content ); + } file_put_contents( $file2, $content ); diff --git a/lib/migrate.php b/lib/migrate.php index 2cc0a3067b8..f41441bedbb 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -78,7 +78,7 @@ class OC_Migrate{ * @param otional $path string path to zip output folder * @return false on error, path to zip on success */ - public static function export( $uid=null, $type='user', $path=null ) { + public static function export( $uid=null, $type='user', $path=null ) { $datadir = OC_Config::getValue( 'datadirectory' ); // Validate export type $types = array( 'user', 'instance', 'system', 'userfiles' ); diff --git a/lib/ocsclient.php b/lib/ocsclient.php index 12e5026a877..24081425f1e 100644 --- a/lib/ocsclient.php +++ b/lib/ocsclient.php @@ -44,10 +44,10 @@ class OC_OCSClient{ * @returns string of the KB server * This function returns the url of the OCS knowledge base server. It´s possible to set it in the config file or it will fallback to the default */ - private static function getKBURL() { - $url = OC_Config::getValue('knowledgebaseurl', 'http://api.apps.owncloud.com/v1'); - return($url); - } + private static function getKBURL() { + $url = OC_Config::getValue('knowledgebaseurl', 'http://api.apps.owncloud.com/v1'); + return($url); + } /** * @brief Get the content of an OCS url call. diff --git a/lib/request.php b/lib/request.php index c975c84a711..782ed26a415 100755 --- a/lib/request.php +++ b/lib/request.php @@ -74,7 +74,7 @@ class OC_Request { switch($encoding) { case 'ISO-8859-1' : - $path_info = utf8_encode($path_info); + $path_info = utf8_encode($path_info); } // end copy diff --git a/lib/templatelayout.php b/lib/templatelayout.php index 1a0570a270d..87b5620932c 100644 --- a/lib/templatelayout.php +++ b/lib/templatelayout.php @@ -97,13 +97,13 @@ class OC_TemplateLayout extends OC_Template { * @param $web base for path * @param $file the filename */ - static public function appendIfExist(&$files, $root, $webroot, $file) { - if (is_file($root.'/'.$file)) { + static public function appendIfExist(&$files, $root, $webroot, $file) { + if (is_file($root.'/'.$file)) { $files[] = array($root, $webroot, $file); return true; - } - return false; - } + } + return false; + } static public function findStylesheetFiles($styles) { // Read the selected theme from the config file diff --git a/lib/updater.php b/lib/updater.php index 11081eded63..d44ac108380 100644 --- a/lib/updater.php +++ b/lib/updater.php @@ -52,18 +52,18 @@ class OC_Updater{ ) ); $xml=@file_get_contents($url, 0, $ctx); - if($xml==false) { - return array(); - } - $data=@simplexml_load_string($xml); + if($xml==false) { + return array(); + } + $data=@simplexml_load_string($xml); $tmp=array(); - $tmp['version'] = $data->version; - $tmp['versionstring'] = $data->versionstring; - $tmp['url'] = $data->url; - $tmp['web'] = $data->web; + $tmp['version'] = $data->version; + $tmp['versionstring'] = $data->versionstring; + $tmp['url'] = $data->url; + $tmp['web'] = $data->web; - return $tmp; + return $tmp; } public static function ShowUpdatingHint() { diff --git a/lib/util.php b/lib/util.php index 34c4d4f9b11..fc1c889c31d 100755 --- a/lib/util.php +++ b/lib/util.php @@ -586,7 +586,7 @@ class OC_Util { /** * Check if the ownCloud server can connect to the internet */ - public static function isinternetconnectionworking() { + public static function isinternetconnectionworking() { // try to connect to owncloud.org to see if http connections to the internet are possible. $connected = @fsockopen("www.owncloud.org", 80); @@ -685,34 +685,34 @@ class OC_Util { * If not, file_get_element is used. */ - public static function getUrlContent($url){ + public static function getUrlContent($url){ - if (function_exists('curl_init')) { - - $curl = curl_init(); - - curl_setopt($curl, CURLOPT_HEADER, 0); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); - curl_setopt($curl, CURLOPT_URL, $url); - curl_setopt($curl, CURLOPT_USERAGENT, "ownCloud Server Crawler"); - $data = curl_exec($curl); - curl_close($curl); - - } else { - - $ctx = stream_context_create( - array( - 'http' => array( - 'timeout' => 10 - ) - ) - ); - $data=@file_get_contents($url, 0, $ctx); - - } - - return $data; - } + if (function_exists('curl_init')) { + + $curl = curl_init(); + + curl_setopt($curl, CURLOPT_HEADER, 0); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_USERAGENT, "ownCloud Server Crawler"); + $data = curl_exec($curl); + curl_close($curl); + + } else { + + $ctx = stream_context_create( + array( + 'http' => array( + 'timeout' => 10 + ) + ) + ); + $data=@file_get_contents($url, 0, $ctx); + + } + + return $data; + } } -- cgit v1.2.3 From 85bd28c5081e7c2fea236c4528c23be283aa7350 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 14 Dec 2012 23:22:46 +0100 Subject: Fix some of "Closing brace must be on a line by itself" --- apps/files_versions/templates/history.php | 4 +++- lib/files.php | 4 +++- lib/templatelayout.php | 20 ++++++++++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/apps/files_versions/templates/history.php b/apps/files_versions/templates/history.php index 854d032da62..cc5a494f19e 100644 --- a/apps/files_versions/templates/history.php +++ b/apps/files_versions/templates/history.php @@ -23,7 +23,9 @@ if( isset( $_['message'] ) ) { echo ' '; echo OCP\Util::formatDate( doubleval($v['version']) ); echo ' Revert

'; - if ( $v['cur'] ) { echo ' (Current)'; } + if ( $v['cur'] ) { + echo ' (Current)'; + } echo '

'; } diff --git a/lib/files.php b/lib/files.php index b4a4145a493..152ed8f34a7 100644 --- a/lib/files.php +++ b/lib/files.php @@ -492,7 +492,9 @@ class OC_Files { if(is_writable(OC::$SERVERROOT.'/.htaccess')) { file_put_contents(OC::$SERVERROOT.'/.htaccess', $htaccess); return OC_Helper::computerFileSize($size); - } else { OC_Log::write('files', 'Can\'t write upload limit to '.OC::$SERVERROOT.'/.htaccess. Please check the file permissions', OC_Log::WARN); } + } else { + OC_Log::write('files', 'Can\'t write upload limit to '.OC::$SERVERROOT.'/.htaccess. Please check the file permissions', OC_Log::WARN); + } return false; } diff --git a/lib/templatelayout.php b/lib/templatelayout.php index 87b5620932c..4173e008ba7 100644 --- a/lib/templatelayout.php +++ b/lib/templatelayout.php @@ -130,8 +130,14 @@ class OC_TemplateLayout extends OC_Template { // or in apps? foreach( OC::$APPSROOTS as $apps_dir) { - if(self::appendIfExist($files, $apps_dir['path'], $apps_dir['url'], "$style$fext.css")) { $append =true; break; } - elseif(self::appendIfExist($files, $apps_dir['path'], $apps_dir['url'], "$style.css")) { $append =true; break; } + if(self::appendIfExist($files, $apps_dir['path'], $apps_dir['url'], "$style$fext.css")) { + $append = true; + break; + } + elseif(self::appendIfExist($files, $apps_dir['path'], $apps_dir['url'], "$style.css")) { + $append = true; + break; + } } if(! $append) { echo('css file not found: style:'.$style.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); @@ -192,8 +198,14 @@ class OC_TemplateLayout extends OC_Template { // Is it part of an app? $append = false; foreach( OC::$APPSROOTS as $apps_dir) { - if(self::appendIfExist($files, $apps_dir['path'], OC::$WEBROOT.$apps_dir['url'], "$script$fext.js")) { $append =true; break; } - elseif(self::appendIfExist($files, $apps_dir['path'], OC::$WEBROOT.$apps_dir['url'], "$script.js")) { $append =true; break; } + if(self::appendIfExist($files, $apps_dir['path'], OC::$WEBROOT.$apps_dir['url'], "$script$fext.js")) { + $append = true; + break; + } + elseif(self::appendIfExist($files, $apps_dir['path'], OC::$WEBROOT.$apps_dir['url'], "$script.js")) { + $append = true; + break; + } } if(! $append) { echo('js file not found: script:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); -- cgit v1.2.3 From 2ef2dc4ddabc8b5d86d7a9a5a936ecf3901615cc Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 14 Dec 2012 23:38:38 +0100 Subject: Fix "There must be a single space between the closing parenthesis and the opening brace" --- apps/files_sharing/public.php | 2 +- lib/filecache.php | 6 +++--- lib/request.php | 4 ++-- settings/ajax/togglegroups.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index 71c18380a3b..fef0ed8a8c2 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -160,7 +160,7 @@ if ($linkItem) { exit(); } } - $basePath = substr($pathAndUser['path'] , strlen('/'.$fileOwner.'/files')); + $basePath = substr($pathAndUser['path'], strlen('/'.$fileOwner.'/files')); $path = $basePath; if (isset($_GET['path'])) { $path .= $_GET['path']; diff --git a/lib/filecache.php b/lib/filecache.php index bbf55bc1f86..c3256c783e6 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -355,7 +355,7 @@ class OC_FileCache{ if($sizeDiff==0) return; $item = OC_FileCache_Cached::get($path); //stop walking up the filetree if we hit a non-folder or reached to root folder - if($path == '/' || $path=='' || $item['mimetype'] !== 'httpd/unix-directory'){ + if($path == '/' || $path=='' || $item['mimetype'] !== 'httpd/unix-directory') { return; } $id = $item['id']; @@ -363,13 +363,13 @@ class OC_FileCache{ $query=OC_DB::prepare('UPDATE `*PREFIX*fscache` SET `size`=`size`+? WHERE `id`=?'); $query->execute(array($sizeDiff, $id)); $path=dirname($path); - if($path == '' or $path =='/'){ + if($path == '' or $path =='/') { return; } $parent = OC_FileCache_Cached::get($path); $id = $parent['id']; //stop walking up the filetree if we hit a non-folder - if($parent['mimetype'] !== 'httpd/unix-directory'){ + if($parent['mimetype'] !== 'httpd/unix-directory') { return; } } diff --git a/lib/request.php b/lib/request.php index 782ed26a415..99a77e1b59e 100755 --- a/lib/request.php +++ b/lib/request.php @@ -18,7 +18,7 @@ class OC_Request { if(OC::$CLI) { return 'localhost'; } - if(OC_Config::getValue('overwritehost', '')<>''){ + if(OC_Config::getValue('overwritehost', '')<>'') { return OC_Config::getValue('overwritehost'); } if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { @@ -43,7 +43,7 @@ class OC_Request { * Returns the server protocol. It respects reverse proxy servers and load balancers */ public static function serverProtocol() { - if(OC_Config::getValue('overwriteprotocol', '')<>''){ + if(OC_Config::getValue('overwriteprotocol', '')<>'') { return OC_Config::getValue('overwriteprotocol'); } if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) { diff --git a/settings/ajax/togglegroups.php b/settings/ajax/togglegroups.php index f82ece4aee1..83d455550ae 100644 --- a/settings/ajax/togglegroups.php +++ b/settings/ajax/togglegroups.php @@ -7,7 +7,7 @@ $success = true; $username = $_POST["username"]; $group = $_POST["group"]; -if($username == OC_User::getUser() && $group == "admin" && OC_Group::inGroup($username, 'admin')){ +if($username == OC_User::getUser() && $group == "admin" && OC_Group::inGroup($username, 'admin')) { $l = OC_L10N::get('core'); OC_JSON::error(array( 'data' => array( 'message' => $l->t('Admins can\'t remove themself from the admin group')))); exit(); -- cgit v1.2.3 From 68562dafb4a814072aa0cd537b0d035f75e7a70f Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 14 Dec 2012 23:16:32 +0100 Subject: More whitespace fixes --- apps/user_ldap/lib/access.php | 18 ++--- lib/app.php | 20 +++--- lib/migrate.php | 160 +++++++++++++++++++++--------------------- lib/public/contacts.php | 33 ++++----- settings/js/users.js | 2 +- 5 files changed, 117 insertions(+), 116 deletions(-) (limited to 'lib') diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index e1eea2f46c0..a4123cde57a 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -347,20 +347,20 @@ abstract class Access { } private function findMappedGroup($dn) { - static $query = null; + static $query = null; if(is_null($query)) { $query = \OCP\DB::prepare(' - SELECT `owncloud_name` - FROM `'.$this->getMapTable(false).'` - WHERE `ldap_dn` = ?' - ); + SELECT `owncloud_name` + FROM `'.$this->getMapTable(false).'` + WHERE `ldap_dn` = ?' + ); } - $res = $query->execute(array($dn))->fetchOne(); + $res = $query->execute(array($dn))->fetchOne(); if($res) { - return $res; - } + return $res; + } return false; - } + } private function ldap2ownCloudNames($ldapObjects, $isUsers) { diff --git a/lib/app.php b/lib/app.php index 5d4fbbd9c23..be6d5ab3dd3 100755 --- a/lib/app.php +++ b/lib/app.php @@ -597,16 +597,16 @@ class OC_App{ $app1[$i]['internal'] = $app1[$i]['active'] = 0; // rating img - if($app['score']>=0 and $app['score']<5) $img=OC_Helper::imagePath( "core", "rating/s1.png" ); - elseif($app['score']>=5 and $app['score']<15) $img=OC_Helper::imagePath( "core", "rating/s2.png" ); - elseif($app['score']>=15 and $app['score']<25) $img=OC_Helper::imagePath( "core", "rating/s3.png" ); - elseif($app['score']>=25 and $app['score']<35) $img=OC_Helper::imagePath( "core", "rating/s4.png" ); - elseif($app['score']>=35 and $app['score']<45) $img=OC_Helper::imagePath( "core", "rating/s5.png" ); - elseif($app['score']>=45 and $app['score']<55) $img=OC_Helper::imagePath( "core", "rating/s6.png" ); - elseif($app['score']>=55 and $app['score']<65) $img=OC_Helper::imagePath( "core", "rating/s7.png" ); - elseif($app['score']>=65 and $app['score']<75) $img=OC_Helper::imagePath( "core", "rating/s8.png" ); - elseif($app['score']>=75 and $app['score']<85) $img=OC_Helper::imagePath( "core", "rating/s9.png" ); - elseif($app['score']>=85 and $app['score']<95) $img=OC_Helper::imagePath( "core", "rating/s10.png" ); + if($app['score']>=0 and $app['score']<5) $img=OC_Helper::imagePath( "core", "rating/s1.png" ); + elseif($app['score']>=5 and $app['score']<15) $img=OC_Helper::imagePath( "core", "rating/s2.png" ); + elseif($app['score']>=15 and $app['score']<25) $img=OC_Helper::imagePath( "core", "rating/s3.png" ); + elseif($app['score']>=25 and $app['score']<35) $img=OC_Helper::imagePath( "core", "rating/s4.png" ); + elseif($app['score']>=35 and $app['score']<45) $img=OC_Helper::imagePath( "core", "rating/s5.png" ); + elseif($app['score']>=45 and $app['score']<55) $img=OC_Helper::imagePath( "core", "rating/s6.png" ); + elseif($app['score']>=55 and $app['score']<65) $img=OC_Helper::imagePath( "core", "rating/s7.png" ); + elseif($app['score']>=65 and $app['score']<75) $img=OC_Helper::imagePath( "core", "rating/s8.png" ); + elseif($app['score']>=75 and $app['score']<85) $img=OC_Helper::imagePath( "core", "rating/s9.png" ); + elseif($app['score']>=85 and $app['score']<95) $img=OC_Helper::imagePath( "core", "rating/s10.png" ); elseif($app['score']>=95 and $app['score']<100) $img=OC_Helper::imagePath( "core", "rating/s11.png" ); $app1[$i]['score'] = ' Score: '.$app['score'].'%'; diff --git a/lib/migrate.php b/lib/migrate.php index f41441bedbb..5ff8e338a44 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -80,65 +80,65 @@ class OC_Migrate{ */ public static function export( $uid=null, $type='user', $path=null ) { $datadir = OC_Config::getValue( 'datadirectory' ); - // Validate export type - $types = array( 'user', 'instance', 'system', 'userfiles' ); - if( !in_array( $type, $types ) ) { - OC_Log::write( 'migration', 'Invalid export type', OC_Log::ERROR ); - return json_encode( array( 'success' => false ) ); - } - self::$exporttype = $type; - // Userid? - if( self::$exporttype == 'user' ) { - // Check user exists - self::$uid = is_null($uid) ? OC_User::getUser() : $uid; - if(!OC_User::userExists(self::$uid)) { - return json_encode( array( 'success' => false) ); - } - } - // Calculate zipname - if( self::$exporttype == 'user' ) { - $zipname = 'oc_export_' . self::$uid . '_' . date("y-m-d_H-i-s") . '.zip'; - } else { - $zipname = 'oc_export_' . self::$exporttype . '_' . date("y-m-d_H-i-s") . '.zip'; - } - // Calculate path - if( self::$exporttype == 'user' ) { - self::$zippath = $datadir . '/' . self::$uid . '/' . $zipname; - } else { - if( !is_null( $path ) ) { - // Validate custom path - if( !file_exists( $path ) || !is_writeable( $path ) ) { - OC_Log::write( 'migration', 'Path supplied is invalid.', OC_Log::ERROR ); - return json_encode( array( 'success' => false ) ); - } - self::$zippath = $path . $zipname; - } else { - // Default path - self::$zippath = get_temp_dir() . '/' . $zipname; - } - } - // Create the zip object - if( !self::createZip() ) { - return json_encode( array( 'success' => false ) ); - } - // Do the export - self::findProviders(); - $exportdata = array(); - switch( self::$exporttype ) { - case 'user': - // Connect to the db - self::$dbpath = $datadir . '/' . self::$uid . '/migration.db'; - if( !self::connectDB() ) { - return json_encode( array( 'success' => false ) ); - } - self::$content = new OC_Migration_Content( self::$zip, self::$MDB2 ); - // Export the app info - $exportdata = self::exportAppData(); + // Validate export type + $types = array( 'user', 'instance', 'system', 'userfiles' ); + if( !in_array( $type, $types ) ) { + OC_Log::write( 'migration', 'Invalid export type', OC_Log::ERROR ); + return json_encode( array( 'success' => false ) ); + } + self::$exporttype = $type; + // Userid? + if( self::$exporttype == 'user' ) { + // Check user exists + self::$uid = is_null($uid) ? OC_User::getUser() : $uid; + if(!OC_User::userExists(self::$uid)) { + return json_encode( array( 'success' => false) ); + } + } + // Calculate zipname + if( self::$exporttype == 'user' ) { + $zipname = 'oc_export_' . self::$uid . '_' . date("y-m-d_H-i-s") . '.zip'; + } else { + $zipname = 'oc_export_' . self::$exporttype . '_' . date("y-m-d_H-i-s") . '.zip'; + } + // Calculate path + if( self::$exporttype == 'user' ) { + self::$zippath = $datadir . '/' . self::$uid . '/' . $zipname; + } else { + if( !is_null( $path ) ) { + // Validate custom path + if( !file_exists( $path ) || !is_writeable( $path ) ) { + OC_Log::write( 'migration', 'Path supplied is invalid.', OC_Log::ERROR ); + return json_encode( array( 'success' => false ) ); + } + self::$zippath = $path . $zipname; + } else { + // Default path + self::$zippath = get_temp_dir() . '/' . $zipname; + } + } + // Create the zip object + if( !self::createZip() ) { + return json_encode( array( 'success' => false ) ); + } + // Do the export + self::findProviders(); + $exportdata = array(); + switch( self::$exporttype ) { + case 'user': + // Connect to the db + self::$dbpath = $datadir . '/' . self::$uid . '/migration.db'; + if( !self::connectDB() ) { + return json_encode( array( 'success' => false ) ); + } + self::$content = new OC_Migration_Content( self::$zip, self::$MDB2 ); + // Export the app info + $exportdata = self::exportAppData(); // Add the data dir to the zip self::$content->addDir(OC_User::getHome(self::$uid), true, '/' ); - break; - case 'instance': - self::$content = new OC_Migration_Content( self::$zip ); + break; + case 'instance': + self::$content = new OC_Migration_Content( self::$zip ); // Creates a zip that is compatable with the import function $dbfile = tempnam( get_temp_dir(), "owncloud_export_data_" ); OC_DB::getDbStructure( $dbfile, 'MDB2_SCHEMA_DUMP_ALL'); @@ -155,32 +155,32 @@ class OC_Migrate{ foreach(OC_User::getUsers() as $user) { self::$content->addDir(OC_User::getHome($user), true, "/userdata/" ); } - break; + break; case 'userfiles': self::$content = new OC_Migration_Content( self::$zip ); // Creates a zip with all of the users files foreach(OC_User::getUsers() as $user) { self::$content->addDir(OC_User::getHome($user), true, "/" ); } - break; + break; case 'system': self::$content = new OC_Migration_Content( self::$zip ); // Creates a zip with the owncloud system files self::$content->addDir( OC::$SERVERROOT . '/', false, '/'); foreach (array(".git", "3rdparty", "apps", "core", "files", "l10n", "lib", "ocs", "search", "settings", "tests") as $dir) { - self::$content->addDir( OC::$SERVERROOT . '/' . $dir, true, "/"); + self::$content->addDir( OC::$SERVERROOT . '/' . $dir, true, "/"); } - break; - } - if( !$info = self::getExportInfo( $exportdata ) ) { - return json_encode( array( 'success' => false ) ); - } - // Add the export info json to the export zip - self::$content->addFromString( $info, 'export_info.json' ); - if( !self::$content->finish() ) { - return json_encode( array( 'success' => false ) ); - } - return json_encode( array( 'success' => true, 'data' => self::$zippath ) ); + break; + } + if( !$info = self::getExportInfo( $exportdata ) ) { + return json_encode( array( 'success' => false ) ); + } + // Add the export info json to the export zip + self::$content->addFromString( $info, 'export_info.json' ); + if( !self::$content->finish() ) { + return json_encode( array( 'success' => false ) ); + } + return json_encode( array( 'success' => true, 'data' => self::$zippath ) ); } /** @@ -254,7 +254,7 @@ class OC_Migrate{ OC_Log::write( 'migration', 'Failed to delete the extracted zip', OC_Log::ERROR ); } return json_encode( array( 'success' => true, 'data' => $appsimported ) ); - break; + break; case 'instance': /* * EXPERIMENTAL @@ -281,7 +281,7 @@ class OC_Migrate{ // Done return json_encode( array( 'success' => true ) ); */ - break; + break; } } @@ -319,10 +319,10 @@ class OC_Migrate{ static private function extractZip( $path ) { self::$zip = new ZipArchive; // Validate path - if( !file_exists( $path ) ) { - OC_Log::write( 'migration', 'Zip not found', OC_Log::ERROR ); - return false; - } + if( !file_exists( $path ) ) { + OC_Log::write( 'migration', 'Zip not found', OC_Log::ERROR ); + return false; + } if ( self::$zip->open( $path ) != true ) { OC_Log::write( 'migration', "Failed to open zip file", OC_Log::ERROR ); return false; @@ -555,9 +555,9 @@ class OC_Migrate{ if ( self::$zip->open( self::$zippath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE ) !== true ) { OC_Log::write('migration', 'Failed to create the zip with error: '.self::$zip->getStatusString(), OC_Log::ERROR); return false; - } else { - return true; - } + } else { + return true; + } } /** diff --git a/lib/public/contacts.php b/lib/public/contacts.php index 4cf57ed8ff2..88d812e735a 100644 --- a/lib/public/contacts.php +++ b/lib/public/contacts.php @@ -54,29 +54,30 @@ namespace OCP { * Example: * Following function shows how to search for contacts for the name and the email address. * - * public static function getMatchingRecipient($term) { - * // The API is not active -> nothing to do + * public static function getMatchingRecipient($term) { + * // The API is not active -> nothing to do * if (!\OCP\Contacts::isEnabled()) { - * return array(); + * return array(); * } * * $result = \OCP\Contacts::search($term, array('FN', 'EMAIL')); * $receivers = array(); * foreach ($result as $r) { - * $id = $r['id']; - * $fn = $r['FN']; - * $email = $r['EMAIL']; - * if (!is_array($email)) { - * $email = array($email); - * } + * $id = $r['id']; + * $fn = $r['FN']; + * $email = $r['EMAIL']; + * if (!is_array($email)) { + * $email = array($email); + * } * - * // loop through all email addresses of this contact - * foreach ($email as $e) { - * $displayName = $fn . " <$e>"; - * $receivers[] = array('id' => $id, - * 'label' => $displayName, - * 'value' => $displayName); - * } + * // loop through all email addresses of this contact + * foreach ($email as $e) { + * $displayName = $fn . " <$e>"; + * $receivers[] = array( + * 'id' => $id, + * 'label' => $displayName, + * 'value' => $displayName); + * } * } * * return $receivers; diff --git a/settings/js/users.js b/settings/js/users.js index f2ce69cf311..f148a43a480 100644 --- a/settings/js/users.js +++ b/settings/js/users.js @@ -64,7 +64,7 @@ var UserList={ } } }); - } + } }, add:function(username, groups, subadmin, quota, sort) { -- cgit v1.2.3 From df7d6cb26c0e54e9df509b4a739b4d41c87fcb98 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 14 Dec 2012 23:50:21 +0100 Subject: More style fixes --- apps/user_ldap/lib/access.php | 2 +- core/templates/logout.php | 2 +- lib/l10n.php | 10 ++++++---- lib/util.php | 3 +-- settings/templates/settings.php | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index a4123cde57a..f888577aedb 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -619,7 +619,7 @@ abstract class Access { //a) paged search insuccessful, though attempted //b) no paged search, but limit set if((!$this->pagedSearchedSuccessful - && $pagedSearchOK) + && $pagedSearchOK) || ( !$pagedSearchOK && !is_null($limit) diff --git a/core/templates/logout.php b/core/templates/logout.php index 8cbbdd9cc8d..2247ed8e70f 100644 --- a/core/templates/logout.php +++ b/core/templates/logout.php @@ -1 +1 @@ -t( 'You are logged out.' ); ?> \ No newline at end of file +t( 'You are logged out.' ); diff --git a/lib/l10n.php b/lib/l10n.php index cb67cfd4ed6..f70dfa5e34e 100644 --- a/lib/l10n.php +++ b/lib/l10n.php @@ -115,10 +115,12 @@ class OC_L10N{ $i18ndir = self::findI18nDir($app); // Localization is in /l10n, Texts are in $i18ndir // (Just no need to define date/time format etc. twice) - if((OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC_App::getAppPath($app).'/l10n/') || - OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC::$SERVERROOT.'/core/l10n/') || - OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC::$SERVERROOT.'/lib/l10n/') || - OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC::$SERVERROOT.'/settings')) && file_exists($i18ndir.$lang.'.php')) { + if((OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC_App::getAppPath($app).'/l10n/') + || OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC::$SERVERROOT.'/core/l10n/') + || OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC::$SERVERROOT.'/lib/l10n/') + || OC_Helper::issubdirectory($i18ndir.$lang.'.php', OC::$SERVERROOT.'/settings') + ) + && file_exists($i18ndir.$lang.'.php')) { // Include the file, save the data from $CONFIG include strip_tags($i18ndir).strip_tags($lang).'.php'; if(isset($TRANSLATIONS) && is_array($TRANSLATIONS)) { diff --git a/lib/util.php b/lib/util.php index fc1c889c31d..fc50123b4fe 100755 --- a/lib/util.php +++ b/lib/util.php @@ -331,8 +331,7 @@ class OC_Util { $parameters[$value] = true; } if (!empty($_POST['user'])) { - $parameters["username"] = - OC_Util::sanitizeHTML($_POST['user']).'"'; + $parameters["username"] = OC_Util::sanitizeHTML($_POST['user']).'"'; $parameters['user_autofocus'] = false; } else { $parameters["username"] = ''; diff --git a/settings/templates/settings.php b/settings/templates/settings.php index 12368a1cdb6..de8092eeaff 100644 --- a/settings/templates/settings.php +++ b/settings/templates/settings.php @@ -6,4 +6,4 @@ \ No newline at end of file +}; -- cgit v1.2.3 From 4301cd7f61f0cf07458f49430c098aac04882fbc Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 16 Dec 2012 20:29:36 +0100 Subject: wrap hooks into a try, catch to prevent a faulty app from crashing the request --- lib/hook.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/hook.php b/lib/hook.php index 26a53693748..4da331bb5d8 100644 --- a/lib/hook.php +++ b/lib/hook.php @@ -59,7 +59,11 @@ class OC_Hook{ // Call all slots foreach( self::$registered[$signalclass][$signalname] as $i ) { - call_user_func( array( $i["class"], $i["name"] ), $params ); + try { + call_user_func( array( $i["class"], $i["name"] ), $params ); + } catch (Exception $e){ + OC_Log::write('hook', 'error while running hook (' . $i["class"] . '::' . $i["name"] . '): '.$e->getMessage(), OC_Log::ERROR); + } } // return true -- cgit v1.2.3