2015-08-03 11:35:01 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Modl;
|
|
|
|
|
|
|
|
class ConfigDAO extends SQL {
|
|
|
|
function set(Config $c) {
|
|
|
|
$this->_sql = '
|
|
|
|
update config
|
2015-08-10 23:42:45 +02:00
|
|
|
set description = :description,
|
2015-08-03 11:35:01 +02:00
|
|
|
theme = :theme,
|
|
|
|
locale = :locale,
|
|
|
|
maxusers = :maxusers,
|
|
|
|
loglevel = :loglevel,
|
|
|
|
timezone = :timezone,
|
|
|
|
xmppwhitelist = :xmppwhitelist,
|
|
|
|
info = :info,
|
|
|
|
unregister = :unregister,
|
|
|
|
username = :username,
|
|
|
|
password = :password,
|
|
|
|
rewrite = :rewrite,
|
|
|
|
sizelimit = :sizelimit';
|
2015-08-10 23:42:45 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
$this->prepare(
|
2015-08-10 23:42:45 +02:00
|
|
|
'Config',
|
|
|
|
array(
|
2015-08-03 11:35:01 +02:00
|
|
|
'description' => $c->description,
|
|
|
|
'theme' => $c->theme,
|
|
|
|
'locale' => $c->locale,
|
|
|
|
'maxusers' => $c->maxusers,
|
|
|
|
'loglevel' => $c->loglevel,
|
|
|
|
'timezone' => $c->timezone,
|
|
|
|
'xmppwhitelist'=> $c->xmppwhitelist,
|
|
|
|
'info' => $c->info,
|
|
|
|
'unregister' => $c->unregister,
|
|
|
|
'username' => $c->username,
|
|
|
|
'password' => $c->password,
|
|
|
|
'rewrite' => $c->rewrite,
|
|
|
|
'sizelimit' => $c->sizelimit
|
|
|
|
)
|
|
|
|
);
|
2015-08-10 23:42:45 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
$this->run('Config');
|
2015-08-10 23:42:45 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
if(!$this->_effective) {
|
|
|
|
$this->_sql = '
|
|
|
|
truncate table config;';
|
|
|
|
|
|
|
|
$this->prepare(
|
2015-08-10 23:42:45 +02:00
|
|
|
'Config',
|
2015-08-03 11:35:01 +02:00
|
|
|
array(
|
|
|
|
)
|
|
|
|
);
|
2015-08-10 23:42:45 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
$this->run('Config');
|
2015-08-10 23:42:45 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
$this->_sql = '
|
|
|
|
insert into config
|
|
|
|
(
|
|
|
|
description,
|
|
|
|
theme,
|
|
|
|
locale,
|
|
|
|
maxusers,
|
|
|
|
loglevel,
|
|
|
|
timezone,
|
|
|
|
xmppwhitelist,
|
|
|
|
info,
|
|
|
|
unregister,
|
|
|
|
username,
|
|
|
|
password,
|
|
|
|
rewrite,
|
|
|
|
sizelimit
|
|
|
|
)
|
|
|
|
values
|
|
|
|
(
|
|
|
|
:description,
|
|
|
|
:theme,
|
|
|
|
:locale,
|
|
|
|
:maxusers,
|
|
|
|
:loglevel,
|
|
|
|
:timezone,
|
|
|
|
:xmppwhitelist,
|
|
|
|
:info,
|
|
|
|
:unregister,
|
|
|
|
:username,
|
|
|
|
:password,
|
|
|
|
:rewrite,
|
|
|
|
:sizelimit
|
|
|
|
)
|
|
|
|
';
|
2015-08-10 23:42:45 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
$this->prepare(
|
2015-08-10 23:42:45 +02:00
|
|
|
'Config',
|
2015-08-03 11:35:01 +02:00
|
|
|
array(
|
|
|
|
'description' => $c->description,
|
|
|
|
'theme' => $c->theme,
|
|
|
|
'locale' => $c->locale,
|
|
|
|
'maxusers' => $c->maxusers,
|
|
|
|
'loglevel' => $c->loglevel,
|
|
|
|
'timezone' => $c->timezone,
|
|
|
|
'xmppwhitelist'=> $c->xmppwhitelist,
|
|
|
|
'info' => $c->info,
|
|
|
|
'unregister' => $c->unregister,
|
|
|
|
'username' => $c->username,
|
|
|
|
'password' => $c->password,
|
|
|
|
'rewrite' => $c->rewrite,
|
|
|
|
'sizelimit' => $c->sizelimit
|
|
|
|
)
|
|
|
|
);
|
2015-08-10 23:42:45 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
$this->run('Config');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function get() {
|
|
|
|
$this->_sql = '
|
|
|
|
select * from config';
|
|
|
|
|
|
|
|
$this->prepare('Config', array());
|
2015-08-10 23:42:45 +02:00
|
|
|
|
2015-08-03 11:35:01 +02:00
|
|
|
$conf = $this->run('Config', 'item');
|
|
|
|
|
|
|
|
if(!isset($conf))
|
|
|
|
return new Config;
|
|
|
|
|
|
|
|
return $conf;
|
|
|
|
}
|
|
|
|
}
|