2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-13 05:06:35 +00:00

configDB - added interface functions for use with:

01_FHEMWEB.pm - Editing files stored in database
fhem.pl - enable loading modules from database

git-svn-id: https://svn.fhem.de/fhem/trunk@5591 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
betateilchen 2014-04-21 11:32:49 +00:00
parent 5b5754fe7d
commit 8fbe9d6070

View File

@ -55,10 +55,14 @@
# 2014-04-03 - fixed global attributes not read from version 0
#
# 2014-04-18 - added commands fileimport, fileexport
# 2014 04-19 - added commands filelist, filedelete
# 2014-04-19 - added commands filelist, filedelete
# interface cfgDB_Readfile for interaction
# with other modules
#
# 2014-04-21 - added interface functions for FHEMWEB and fhem.pl
# to show files in "Edit files" and use them
# with CommandReload() mechanism
#
##############################################################################
#
@ -739,51 +743,20 @@ sub _cfgDB_Writefile($$) {
return;
}
# read 99ers from database
sub cfgDB_Read99($) {
my $counter = 0;
# read filelist containing 99_ files in database
sub cfgDB_Read99() {
my $ret;
my $fhem_dbh = _cfgDB_Connect;
my $sth = $fhem_dbh->prepare( "SELECT filename FROM fhemfilesave WHERE filename like '%/99_%.pm' group by filename" );
my $sth2 = $fhem_dbh->prepare( "SELECT line FROM fhemfilesave WHERE filename = ( ? )");
$sth->execute();
while (my $file = $sth->fetchrow_array()) {
Log3 undef, 5, "Loading $file from database";
$sth2->execute($file);
no strict "refs";
eval {
while (my @line = $sth2->fetchrow_array()) {
$ret = eval $line[0];
if($@) {
Log3 undef, 1, "reload: Error:Modul $file deactivated:\n $@";
last;
}
last if($line[0] eq '1;');
}
};
$sth2->finish();
if($ret) {
my $m = $file;
$m =~ s,.*([0-9][0-9])_,,;
$m =~ s,.pm,,;
use strict "refs";
my ($defptr, $ldata);
if($modules{$m}) {
$defptr = $modules{$m}{defptr};
$ldata = $modules{$m}{ldata};
}
$modules{$m} = \%hash;
$modules{$m}{ORDER} = 99;
$modules{$m}{LOADED} = 1;
$modules{$m}{defptr} = $defptr if($defptr);
$modules{$m}{ldata} = $ldata if($ldata);
$counter++;
}
while (my $line = $sth->fetchrow_array()) {
$line =~ m,^(.*)/([^/]*)$,; # Split into dir and file
$ret .= "$2,"; #
}
$sth->finish();
$fhem_dbh->disconnect();
return $counter;
$ret =~ s/,$//;
return $ret;
}
1;