diff --git a/apps/bookmarks/ajax/editBookmark.php b/apps/bookmarks/ajax/editBookmark.php old mode 100644 new mode 100755 index a834cd216e..5bed9d0844 --- a/apps/bookmarks/ajax/editBookmark.php +++ b/apps/bookmarks/ajax/editBookmark.php @@ -30,7 +30,7 @@ $RUNTIME_NOSETUPFS=true; OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('bookmarks'); -$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" ); +$CONFIG_DBTYPE = OCP\Config::getSystemValue( "dbtype", "sqlite" ); if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){ $_ut = "strftime('%s','now')"; } elseif($CONFIG_DBTYPE == 'pgsql') { diff --git a/apps/bookmarks/bookmarksHelper.php b/apps/bookmarks/bookmarksHelper.php index 25c9b4cc7f..e299f9ee19 100755 --- a/apps/bookmarks/bookmarksHelper.php +++ b/apps/bookmarks/bookmarksHelper.php @@ -72,7 +72,7 @@ function getURLMetadata($url) { } function addBookmark($url, $title, $tags='') { - $CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" ); + $CONFIG_DBTYPE = OCP\Config::getSystemValue( "dbtype", "sqlite" ); if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){ $_ut = "strftime('%s','now')"; } elseif($CONFIG_DBTYPE == 'pgsql') { diff --git a/apps/bookmarks/lib/bookmarks.php b/apps/bookmarks/lib/bookmarks.php index 3f27af0955..cbc50fdb81 100755 --- a/apps/bookmarks/lib/bookmarks.php +++ b/apps/bookmarks/lib/bookmarks.php @@ -35,7 +35,7 @@ class OC_Bookmarks_Bookmarks{ */ public static function findBookmarks($offset, $sqlSortColumn, $filter, $filterTagOnly){ //OCP\Util::writeLog('bookmarks', 'findBookmarks ' .$offset. ' '.$sqlSortColumn.' '. $filter.' '. $filterTagOnly ,OCP\Util::DEBUG); - $CONFIG_DBTYPE = OC_Config::getValue( 'dbtype', 'sqlite' ); + $CONFIG_DBTYPE = OCP\Config::getSystemValue( 'dbtype', 'sqlite' ); $params=array(OCP\USER::getUser()); diff --git a/apps/files/admin.php b/apps/files/admin.php index c14a97568f..a59a73f0a5 100755 --- a/apps/files/admin.php +++ b/apps/files/admin.php @@ -40,14 +40,14 @@ if($_POST) { } if(isset($_POST['maxZipInputSize'])) { $maxZipInputSize=$_POST['maxZipInputSize']; - OC_Config::setValue('maxZipInputSize', OCP\Util::computerFileSize($maxZipInputSize)); + OCP\Config::setSystemValue('maxZipInputSize', OCP\Util::computerFileSize($maxZipInputSize)); } if(isset($_POST['submitFilesAdminSettings'])) { - OC_Config::setValue('allowZipDownload', isset($_POST['allowZipDownload'])); + OCP\Config::setSystemValue('allowZipDownload', isset($_POST['allowZipDownload'])); } } -$maxZipInputSize = OCP\Util::humanFileSize(OC_Config::getValue('maxZipInputSize', OCP\Util::computerFileSize('800 MB'))); -$allowZipDownload = intval(OC_Config::getValue('allowZipDownload', true)); +$maxZipInputSize = OCP\Util::humanFileSize(OCP\Config::getSystemValue('maxZipInputSize', OCP\Util::computerFileSize('800 MB'))); +$allowZipDownload = intval(OCP\Config::getSystemValue('allowZipDownload', true)); OCP\App::setActiveNavigationEntry( "files_administration" ); diff --git a/apps/files/index.php b/apps/files/index.php index 86b877115c..e2a0eb80a0 100755 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -96,7 +96,7 @@ $tmpl->assign( 'readonly', !OC_Filesystem::is_writable($dir)); $tmpl->assign( "files", $files ); $tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign( 'uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); -$tmpl->assign( 'allowZipDownload', intval(OC_Config::getValue('allowZipDownload', true))); +$tmpl->assign( 'allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); $tmpl->printPage(); ?> diff --git a/apps/files_versions/ajax/togglesettings.php b/apps/files_versions/ajax/togglesettings.php old mode 100644 new mode 100755 index 8cb5057672..49e314f86a --- a/apps/files_versions/ajax/togglesettings.php +++ b/apps/files_versions/ajax/togglesettings.php @@ -2,10 +2,10 @@ OC_JSON::checkAppEnabled('files_versions'); OC_JSON::checkAdminUser(); -if (OC_Config::getValue('versions', 'true')=='true') { - OC_Config::setValue('versions', 'false'); +if (OCP\Config::getSystemValue('versions', 'true')=='true') { + OCP\Config::setSystemValue('versions', 'false'); } else { - OC_Config::setValue('versions', 'true'); + OCP\Config::setSystemValue('versions', 'true'); } ?> diff --git a/apps/files_versions/templates/settings.php b/apps/files_versions/templates/settings.php old mode 100644 new mode 100755 index 7488247316..c3a856bc19 --- a/apps/files_versions/templates/settings.php +++ b/apps/files_versions/templates/settings.php @@ -1,5 +1,5 @@
diff --git a/apps/files_versions/versions.php b/apps/files_versions/versions.php index 5f8767fd76..082dfbf7fd 100755 --- a/apps/files_versions/versions.php +++ b/apps/files_versions/versions.php @@ -42,9 +42,9 @@ class Storage { * init the versioning and create the versions folder. */ public static function init() { - if(\OC_Config::getValue('files_versions', Storage::DEFAULTENABLED)=='true') { + if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { // create versions folder - $foldername=\OC_Config::getValue('datadirectory').'/'. \OCP\USER::getUser() .'/'.\OC_Config::getValue('files_versionsfolder', Storage::DEFAULTFOLDER); + $foldername=\OCP\Config::getSystemValue('datadirectory').'/'. \OCP\USER::getUser() .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); if(!is_dir($foldername)){ mkdir($foldername); } @@ -56,7 +56,7 @@ class Storage { * listen to write event. */ public static function write_hook($params) { - if(\OC_Config::getValue('files_versions', Storage::DEFAULTENABLED)=='true') { + if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { $path = $params[\OC_Filesystem::signal_param_path]; if($path<>'') Storage::store($path); } @@ -68,9 +68,9 @@ class Storage { * store a new version of a file. */ public static function store($filename) { - if(\OC_Config::getValue('files_versions', Storage::DEFAULTENABLED)=='true') { - $versionsfoldername=\OC_Config::getValue('datadirectory').'/'. \OCP\USER::getUser() .'/'.\OC_Config::getValue('files_versionsfolder', Storage::DEFAULTFOLDER); - $filesfoldername=\OC_Config::getValue('datadirectory').'/'. \OCP\USER::getUser() .'/files'; + if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { + $versionsfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. \OCP\USER::getUser() .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); + $filesfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. \OCP\USER::getUser() .'/files'; Storage::init(); // check if filename is a directory @@ -79,7 +79,7 @@ class Storage { } // check filetype blacklist - $blacklist=explode(' ',\OC_Config::getValue('files_versionsblacklist', Storage::DEFAULTBLACKLIST)); + $blacklist=explode(' ',\OCP\Config::getSystemValue('files_versionsblacklist', Storage::DEFAULTBLACKLIST)); foreach($blacklist as $bl) { $parts=explode('.', $filename); $ext=end($parts); @@ -89,7 +89,7 @@ class Storage { } // check filesize - if(filesize($filesfoldername.$filename)>\OC_Config::getValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)){ + if(filesize($filesfoldername.$filename)>\OCP\Config::getSystemValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)){ return false; } @@ -122,11 +122,11 @@ class Storage { */ public static function rollback($filename,$revision) { - if(\OC_Config::getValue('files_versions', Storage::DEFAULTENABLED)=='true') { + if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { - $versionsfoldername=\OC_Config::getValue('datadirectory').'/'. \OCP\USER::getUser() .'/'.\OC_Config::getValue('files_versionsfolder', Storage::DEFAULTFOLDER); + $versionsfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. \OCP\USER::getUser() .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); - $filesfoldername=\OC_Config::getValue('datadirectory').'/'. \OCP\USER::getUser() .'/files'; + $filesfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. \OCP\USER::getUser() .'/files'; // rollback if ( @copy($versionsfoldername.$filename.'.v'.$revision,$filesfoldername.$filename) ) { @@ -147,8 +147,8 @@ class Storage { * check if old versions of a file exist. */ public static function isversioned($filename) { - if(\OC_Config::getValue('files_versions', Storage::DEFAULTENABLED)=='true') { - $versionsfoldername=\OC_Config::getValue('datadirectory').'/'. \OCP\USER::getUser() .'/'.\OC_Config::getValue('files_versionsfolder', Storage::DEFAULTFOLDER); + if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { + $versionsfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. \OCP\USER::getUser() .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); // check for old versions $matches=glob($versionsfoldername.$filename.'.v*'); @@ -168,8 +168,8 @@ class Storage { * get a list of old versions of a file. */ public static function getversions($filename,$count=0) { - if(\OC_Config::getValue('files_versions', Storage::DEFAULTENABLED)=='true') { - $versionsfoldername=\OC_Config::getValue('datadirectory').'/'. \OCP\USER::getUser() .'/'.\OC_Config::getValue('files_versionsfolder', Storage::DEFAULTFOLDER); + if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { + $versionsfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. \OCP\USER::getUser() .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); $versions=array(); // fetch for old versions @@ -199,14 +199,14 @@ class Storage { * expire old versions of a file. */ public static function expire($filename) { - if(\OC_Config::getValue('files_versions', Storage::DEFAULTENABLED)=='true') { + if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { - $versionsfoldername=\OC_Config::getValue('datadirectory').'/'. \OCP\USER::getUser() .'/'.\OC_Config::getValue('files_versionsfolder', Storage::DEFAULTFOLDER); + $versionsfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. \OCP\USER::getUser() .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); // check for old versions $matches=glob($versionsfoldername.$filename.'.v*'); - if(count($matches)>\OC_Config::getValue('files_versionmaxversions', Storage::DEFAULTMAXVERSIONS)){ - $numbertodelete=count($matches-\OC_Config::getValue('files_versionmaxversions', Storage::DEFAULTMAXVERSIONS)); + if(count($matches)>\OCP\Config::getSystemValue('files_versionmaxversions', Storage::DEFAULTMAXVERSIONS)){ + $numbertodelete=count($matches-\OCP\Config::getSystemValue('files_versionmaxversions', Storage::DEFAULTMAXVERSIONS)); // delete old versions of a file $deleteitems=array_slice($matches,0,$numbertodelete); diff --git a/apps/gallery/ajax/sharing.php b/apps/gallery/ajax/sharing.php old mode 100644 new mode 100755 index ce56d652c6..04de57eb17 --- a/apps/gallery/ajax/sharing.php +++ b/apps/gallery/ajax/sharing.php @@ -80,7 +80,7 @@ function handleGetThumbnail($token, $imgpath) { function handleGetAlbumThumbnail($token, $albumname) { $owner = OC_Gallery_Sharing::getTokenOwner($token); - $file = OC_Config::getValue("datadirectory").'/'. $owner .'/gallery/'.$albumname.'.png'; + $file = OCP\Config::getSystemValue("datadirectory").'/'. $owner .'/gallery/'.$albumname.'.png'; $image = new OC_Image($file); if ($image->valid()) { $image->centerCrop(); @@ -93,7 +93,7 @@ function handleGetAlbumThumbnail($token, $albumname) function handleGetPhoto($token, $photo) { $owner = OC_Gallery_Sharing::getTokenOwner($token); - $file = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ).'/'.$owner.'/files'.urldecode($photo); + $file = OCP\Config::getSystemValue( "datadirectory", OC::$SERVERROOT."/data" ).'/'.$owner.'/files'.urldecode($photo); header('Content-Type: '.OC_Image::getMimeTypeForFile($file)); OC_Response::sendFile($file); } diff --git a/apps/gallery/index.php b/apps/gallery/index.php index 0ae6b15d76..4d49e3212e 100755 --- a/apps/gallery/index.php +++ b/apps/gallery/index.php @@ -27,8 +27,8 @@ OCP\User::checkLoggedIn(); OC_Util::checkAppEnabled('gallery'); OCP\App::setActiveNavigationEntry( 'gallery_index' ); -if (!file_exists(OC_Config::getValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery')) { - mkdir(OC_Config::getValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery'); +if (!file_exists(OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery')) { + mkdir(OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery'); } if (!isset($_GET['view'])) { diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php index 455ac5036d..7885ce2bf5 100755 --- a/apps/gallery/lib/photo.php +++ b/apps/gallery/lib/photo.php @@ -68,7 +68,7 @@ class OC_Gallery_Photo { public static function getThumbnail($image_name, $owner = null) { if (!$owner) $owner = OCP\USER::getUser(); - $save_dir = OC_Config::getValue("datadirectory").'/'. $owner .'/gallery/'; + $save_dir = OCP\Config::getSystemValue("datadirectory").'/'. $owner .'/gallery/'; $save_dir .= dirname($image_name). '/'; $image_path = $image_name; $thumb_file = $save_dir . basename($image_name); diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php index 9cf8c113d1..11c7541a75 100755 --- a/apps/gallery/lib/scanner.php +++ b/apps/gallery/lib/scanner.php @@ -81,7 +81,7 @@ class OC_Gallery_Scanner { $image->destroy(); } } - imagepng($thumbnail, OC_Config::getValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery/' . $albumName.'.png'); + imagepng($thumbnail, OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery/' . $albumName.'.png'); imagedestroy($thumbnail); } diff --git a/apps/user_migrate/admin.php b/apps/user_migrate/admin.php index 028433939c..518e4f43f6 100755 --- a/apps/user_migrate/admin.php +++ b/apps/user_migrate/admin.php @@ -30,7 +30,7 @@ if (isset($_POST['user_import'])) { $importname = "owncloud_import_" . date("y-m-d_H-i-s"); // Save data dir for later - $datadir = OC_Config::getValue( 'datadirectory' ); + $datadir = OCP\Config::getSystemValue( 'datadirectory' ); // Copy the uploaded file $from = $_FILES['owncloud_import']['tmp_name']; diff --git a/apps/user_openid/phpmyid.php b/apps/user_openid/phpmyid.php index a86e8070fc..21d1c0a454 100755 --- a/apps/user_openid/phpmyid.php +++ b/apps/user_openid/phpmyid.php @@ -1067,7 +1067,7 @@ function destroy_assoc_handle ( $id ) { session_write_close(); session_id($id); - if (OC_Config::getValue( "forcessl", false )) { + if (OCP\Config::getSystemValue( "forcessl", false )) { ini_set("session.cookie_secure", "on"); } session_start(); @@ -1195,7 +1195,7 @@ function new_assoc ( $expiration ) { session_write_close(); } - if (OC_Config::getValue( "forcessl", false )) { + if (OCP\Config::getSystemValue( "forcessl", false )) { ini_set("session.cookie_secure", "on"); } session_start(); @@ -1269,7 +1269,7 @@ function secret ( $handle ) { } session_id($handle); - if (OC_Config::getValue( "forcessl", false )) { + if (OCP\Config::getSystemValue( "forcessl", false )) { ini_set("session.cookie_secure", "on"); } session_start(); @@ -1447,7 +1447,7 @@ function user_session () { global $proto, $profile; session_name('phpMyID_Server'); - if (OC_Config::getValue( "forcessl", false )) { + if (OCP\Config::getSystemValue( "forcessl", false )) { ini_set("session.cookie_secure", "on"); } @session_start(); diff --git a/lib/public/config.php b/lib/public/config.php new file mode 100644 index 0000000000..de9d163624 --- /dev/null +++ b/lib/public/config.php @@ -0,0 +1,70 @@ +. +* +*/ + +/** + * Public interface of ownCloud for apps to use. + * Config Class + * + */ + +// use OCP namespace for all classes that are considered public. +// This means that they should be used by apps instead of the internal ownCloud classes +namespace OCP; + +class Config { + + + + + /** + * @brief Gets a value from config.php + * @param $key key + * @param $default = null default value + * @returns the value or $default + * + * This function gets the value from config.php. If it does not exist, + * $default will be returned. + */ + public static function getSystemValue( $key, $default = null ){ + return(\OC_Config::getValue( $key, $default )); + } + + + /** + * @brief Sets a value + * @param $key key + * @param $value value + * @returns true/false + * + * This function sets the value and writes the config.php. If the file can + * not be written, false will be returned. + */ + public static function setSystemValue( $key, $value ){ + return(\OC_Config::setValue( $key, $value )); + } + + + + +} + +?>