summaryrefslogtreecommitdiff
path: root/lib/RHRD
diff options
context:
space:
mode:
Diffstat (limited to 'lib/RHRD')
-rwxr-xr-xlib/RHRD/rddb.pm48
1 files changed, 29 insertions, 19 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index 9155d8e..df9f25b 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -36,12 +36,7 @@ use constant {
RD_MIN_CUT => 1,
RD_MAX_CUT => 999,
- RHRD_DROPBOX_PSEUDO_STATION_NAME => 'import-dropbox',
- RHRD_SYSTEM_MACROS_GROUP => 'SYSTEM',
- RHRD_SHOW_MACROS_GROUP => 'SHOWS',
- RHRD_ALLSHOWS_GROUP => 'ALL_SHOWS',
- RHRD_ALLMUSICPOOLS_GROUP => 'ALL_POOLS',
- RHRD_ALLJINGLES_GROUP => 'ALL_JINGLE',
+ RHRD_CONFIG_FILE => '/etc/rhrd.conf',
};
########################### context handling ###########################
@@ -50,6 +45,22 @@ sub init
{
my %ctx;
+ my $cfg = Config::IniFiles->new(-file => RD_CONFIG_FILE)
+ or return (undef , 'ERROR', "RHRD Config File Error: " . join("\n", @Config::IniFiles::errors));
+
+ $ctx{'config'}{'specialgroups'}{'system'} = $cfg->val('specialgroups', 'system', 'SYSTEM');
+ $ctx{'config'}{'specialgroups'}{'shows'} = $cfg->val('specialgroups', 'shows', 'SHOWS');
+ $ctx{'config'}{'specialgroups'}{'allshows'} = $cfg->val('specialgroups', 'allshows', 'ALL_SHOWS');
+ $ctx{'config'}{'specialgroups'}{'allpools'} = $cfg->val('specialgroups', 'allpools', 'ALL_POOLS');
+ $ctx{'config'}{'specialgroups'}{'allingles'} = $cfg->val('specialgroups', 'alljingles', 'ALL_JINGLE');
+
+ $ctx{'config'}{'specialusers'}{'no-update-token'} = $cfg->val('specialusers', 'no-update-token', 'admin');
+ $ctx{'config'}{'specialusers'}{'admins'} = $cfg->val('specialusers', 'no-update-token', 'admin');
+ $ctx{'config'}{'specialusers'}{'allshows'} = $cfg->val('specialusers', 'no-update-token', '');
+ $ctx{'config'}{'specialusers'}{'allpools'} = $cfg->val('specialusers', 'no-update-token', '');
+
+ $ctx{'config'}{'dropboxes'}{'dropbox-pseudo-station'} = $cfg->val('dropboxes', 'dropbox-pseudo-station', 'import-dropbox');
+
my ($dbh, $status, $errorstring) = opendb();
unless(defined $dbh) {
return ($dbh, $status, $errorstring);
@@ -68,9 +79,8 @@ sub destroy
sub opendb
{
- my $RD_CONF = RD_CONFIG_FILE;
- my $cfg = Config::IniFiles->new(-file => $RD_CONF)
- or return (undef , 'ERROR', "Config File Error: " . join("\n", @Config::IniFiles::errors));
+ my $cfg = Config::IniFiles->new(-file => RD_CONFIG_FILE)
+ or return (undef , 'ERROR', "RD Config File Error: " . join("\n", @Config::IniFiles::errors));
my $dbhost = $cfg->val('mySQL', 'Hostname');
my $dbname = $cfg->val('mySQL', 'Database');
@@ -674,10 +684,10 @@ sub get_dropboxes
or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
if(defined $groupname) {
- $sth->execute($username, RHRD_DROPBOX_PSEUDO_STATION_NAME, $groupname)
+ $sth->execute($username, $ctx->{'config'}{'dropboxes'}{'dropbox-pseudo-station'}, $groupname)
or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
} else {
- $sth->execute($username, RHRD_DROPBOX_PSEUDO_STATION_NAME)
+ $sth->execute($username, $ctx->{'config'}{'dropboxes'}{'dropbox-pseudo-station'})
or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
}
@@ -731,13 +741,13 @@ sub get_dropboxes
sub get_shows_cart_range
{
my ($ctx) = @_;
- return get_cart_range($ctx, RHRD_ALLSHOWS_GROUP)
+ return get_cart_range($ctx, $ctx->{'config'}{'specialgroups'}{'allshows'})
}
sub get_shows_next_free_slot
{
my ($ctx) = @_;
- return get_next_free_slot($ctx, RHRD_ALLSHOWS_GROUP)
+ return get_next_free_slot($ctx, $ctx->{'config'}{'specialgroups'}{'allshows'})
}
sub list_shows
@@ -749,7 +759,7 @@ sub list_shows
my $sth = $ctx->{'dbh'}->prepare($sql)
or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
- $sth->execute(RHRD_DROPBOX_PSEUDO_STATION_NAME)
+ $sth->execute($ctx->{'config'}{'dropboxes'}{'dropbox-pseudo-station'})
or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
my @show_dbs;
@@ -787,7 +797,7 @@ sub get_show_group_carts
my $sth = $ctx->{'dbh'}->prepare($sql)
or return (undef, undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
- $sth->execute($showid, RHRD_DROPBOX_PSEUDO_STATION_NAME)
+ $sth->execute($showid, $ctx->{'config'}{'dropboxes'}{'dropbox-pseudo-station'})
or return (undef, undef, 'ERROR', "Database Error: " . $sth->errstr);
my ($group_low_cart, $group_high_cart) = $sth->fetchrow_array();
@@ -880,13 +890,13 @@ sub get_show_carts
sub get_musicpools_cart_range
{
my ($ctx) = @_;
- return get_cart_range($ctx, RHRD_ALLMUSICPOOLS_GROUP)
+ return get_cart_range($ctx, $ctx->{'config'}{'specialgroups'}{'allpools'})
}
sub get_musicpools_next_free_slot
{
my ($ctx) = @_;
- return get_next_free_slot($ctx, RHRD_ALLMUSICPOOLS_GROUP)
+ return get_next_free_slot($ctx, $ctx->{'config'}{'specialgroups'}{'allpools'})
}
########################### JINGLES handling ###########################
@@ -894,13 +904,13 @@ sub get_musicpools_next_free_slot
sub get_jingles_cart_range
{
my ($ctx) = @_;
- return get_cart_range($ctx, RHRD_ALLJINGLES_GROUP)
+ return get_cart_range($ctx, $ctx->{'config'}{'specialgroups'}{'alljingles'})
}
sub get_jingles_next_free_slot
{
my ($ctx) = @_;
- return get_next_free_slot($ctx, RHRD_ALLJINGLES_GROUP)
+ return get_next_free_slot($ctx, $ctx->{'config'}{'specialgroups'}{'alljingles'})
}
################################# END ####################################