first part of the config stuff

This commit is contained in:
Frank Karlitschek 2012-05-02 13:28:56 +02:00
parent 8c7f854671
commit 8e99475886
15 changed files with 112 additions and 42 deletions

2
apps/bookmarks/ajax/editBookmark.php Normal file → Executable file
View File

@ -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') {

View File

@ -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') {

View File

@ -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());

View File

@ -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" );

View File

@ -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();
?>

6
apps/files_versions/ajax/togglesettings.php Normal file → Executable file
View File

@ -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');
}
?>

2
apps/files_versions/templates/settings.php Normal file → Executable file
View File

@ -1,5 +1,5 @@
<form id="versions">
<fieldset class="personalblock">
<input type="checkbox" name="versions" id="versions" value="1" <?php if (OC_Config::getValue('versions', 'true')=='true') echo ' checked="checked"'; ?> /> <label for="versions"><?php echo $l->t('Enable Files Versioning'); ?></label> <br/>
<input type="checkbox" name="versions" id="versions" value="1" <?php if (OCP\Config::getSystemValue('versions', 'true')=='true') echo ' checked="checked"'; ?> /> <label for="versions"><?php echo $l->t('Enable Files Versioning'); ?></label> <br/>
</fieldset>
</form>

View File

@ -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);

4
apps/gallery/ajax/sharing.php Normal file → Executable file
View File

@ -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);
}

View File

@ -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'])) {

View File

@ -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);

View File

@ -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);
}

View File

@ -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'];

View File

@ -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();

70
lib/public/config.php Normal file
View File

@ -0,0 +1,70 @@
<?php
/**
* ownCloud
*
* @author Frank Karlitschek
* @copyright 2010 Frank Karlitschek karlitschek@kde.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* 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 ));
}
}
?>