Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
47674cb4
Commit
47674cb4
authored
15 years ago
by
Aldo "xoen" Giambelluca
Browse files
Options
Downloads
Patches
Plain Diff
Improved OC_CONFIG::saveConfiguration()
* Support numeric types too * $WEBROOT variable was not necessary
parent
fa9deac8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
inc/lib_config.php
+6
-5
6 additions, 5 deletions
inc/lib_config.php
with
6 additions
and
5 deletions
inc/lib_config.php
+
6
−
5
View file @
47674cb4
...
@@ -113,23 +113,24 @@ class OC_CONFIG{
...
@@ -113,23 +113,24 @@ class OC_CONFIG{
/**
/**
* Write the configuration to the `config.php` file
* Write the configuration to the `config.php` file
*
*
* $configuration contains key/value
* $configuration contains key/value
pairs
* - the key is the option name without the 'CONFIG_' prefix
* - the key is the option name without the 'CONFIG_' prefix
* - the value is a string
or
a boolean
* - the value is a string
,
a boolean
or a number
*
*
* @param array $configuration is an associative array
* @param array $configuration is an associative array
*/
*/
protected
static
function
saveConfiguration
(
$configuration
)
{
protected
static
function
saveConfiguration
(
$configuration
)
{
global
$SERVERROOT
;
global
$SERVERROOT
;
global
$WEBROOT
;
$configContent
=
'<?php'
;
$configContent
=
'<?php'
;
foreach
(
$configuration
as
$key
=>
$value
)
{
foreach
(
$configuration
as
$key
=>
$value
)
{
if
(
is_string
(
$value
)
)
{
if
(
is_string
(
$value
)
)
{
$configContent
.
=
"
\n\$
CONFIG_
$key
= '
$value
';"
;
$configContent
.
=
"
\n\$
CONFIG_
$key
= '
$value
';"
;
// e.g. $CONFIG_DBTYPE = 'mysql';
}
else
if
(
is_bool
(
$value
)
)
{
}
else
if
(
is_bool
(
$value
)
)
{
$value
=
$value
?
'true'
:
'false'
;
$value
=
$value
?
'true'
:
'false'
;
$configContent
.
=
"
\n\$
CONFIG_
$key
=
$value
;"
;
$configContent
.
=
"
\n\$
CONFIG_
$key
=
$value
;"
;
// e.g. $CONFIG_INSTALLED = true;
}
else
if
(
is_numeric
(
$value
)
)
{
$configContent
.
=
"
\n\$
CONFIG_
$key
=
$value
;"
;
// e.g. $CONFIG_PI = 3.14;
}
}
}
}
$filename
=
"
$SERVERROOT
/config/config.php"
;
$filename
=
"
$SERVERROOT
/config/config.php"
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment