summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/RHRD/rddb.pm121
1 files changed, 121 insertions, 0 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index 5df0b6c..65866fc 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -347,6 +347,95 @@ sub drop_log_table
return (1, 'OK', 'success');
}
+sub get_logevent_table_name
+{
+ my ($shortname, $pre) = @_;
+
+ $shortname=~s/ /_/g;
+ return $shortname . ($pre ? '_PRE' : '_POST');
+}
+
+sub get_logevent_table_name_escaped
+{
+ my ($ctx, $shortname, $pre) = @_;
+ return $ctx->{'dbh'}->quote_identifier(get_logevent_table_name($shortname, $pre));
+}
+
+sub create_logevent_table
+{
+ my ($ctx, $shortname, $pre) = @_;
+
+ my $tabname = get_logevent_table_name_escaped($ctx, $shortname, $pre);
+ my $sql = qq{
+ create table if not exists $tabname
+ (ID INT NOT NULL PRIMARY KEY,
+ COUNT INT NOT NULL,
+ TYPE INT DEFAULT 0,
+ SOURCE INT NOT NULL,
+ START_TIME int,
+ GRACE_TIME int default 0,
+ CART_NUMBER INT UNSIGNED NOT NULL,
+ TIME_TYPE INT NOT NULL,
+ POST_POINT enum('N','Y') default 'N',
+ TRANS_TYPE INT NOT NULL,
+ START_POINT INT NOT NULL DEFAULT -1,
+ END_POINT INT NOT NULL DEFAULT -1,
+ FADEUP_POINT int default -1,
+ FADEUP_GAIN int default ?,
+ FADEDOWN_POINT int default -1,
+ FADEDOWN_GAIN int default ?,
+ SEGUE_START_POINT INT NOT NULL DEFAULT -1,
+ SEGUE_END_POINT INT NOT NULL DEFAULT -1,
+ SEGUE_GAIN int default ?,
+ DUCK_UP_GAIN int default 0,
+ DUCK_DOWN_GAIN int default 0,
+ COMMENT CHAR(255),
+ LABEL CHAR(64),
+ ORIGIN_USER char(255),
+ ORIGIN_DATETIME datetime,
+ EVENT_LENGTH int default -1,
+ LINK_EVENT_NAME char(64),
+ LINK_START_TIME int,
+ LINK_LENGTH int default 0,
+ LINK_START_SLOP int default 0,
+ LINK_END_SLOP int default 0,
+ LINK_ID int default -1,
+ LINK_EMBEDDED enum('N','Y') default 'N',
+ EXT_START_TIME time,
+ EXT_LENGTH int,
+ EXT_CART_NAME char(32),
+ EXT_DATA char(32),
+ EXT_EVENT_ID char(32),
+ EXT_ANNC_TYPE char(8),
+ index COUNT_IDX (COUNT),
+ index CART_NUMBER_IDX (CART_NUMBER),
+ index LABEL_IDX (LABEL));
+ };
+
+ my $sth = $ctx->{'dbh'}->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
+
+ $sth->execute(RD_FADE_DEPTH, RD_FADE_DEPTH, RD_FADE_DEPTH)
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ $sth->finish();
+
+ return (1, 'OK', 'success');
+}
+
+sub drop_logevent_table
+{
+ my ($ctx, $shortname, $pre) = @_;
+
+ my $tabname = get_logevent_table_name_escaped($ctx, $shortname, $pre);
+ my $sql = qq{drop table $tabname;};
+
+ $ctx->{'dbh'}->do($sql)
+ or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
+
+ return (1, 'OK', 'success');
+}
+
########################### TOKEN handling ###########################
sub get_token
@@ -1882,6 +1971,38 @@ sub create_musicpool_group
return ($num, 'OK', 'success');
}
+sub create_musicpool_event
+{
+ my ($ctx, $shortname, $groupname, $color) = @_;
+
+ my $sql = qq{insert into EVENTS (NAME, PROPERTIES, IMPORT_SOURCE, FIRST_TRANS_TYPE, DEFAULT_TRANS_TYPE, COLOR, SCHED_GROUP, TITLE_SEP) values (?, ?, ?, ?, ?, ?, ?, ?);};
+ my $sth = $ctx->{'dbh'}->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
+
+ $sth->execute($shortname, 'SEGUE, Scheduler', 3, 1, 1, '#' . $color, $groupname, 25) # TODO: make title seperartion configurable !?!?
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+ $sth->finish();
+
+ $sql = qq{insert into EVENT_PERMS (EVENT_NAME, SERVICE_NAME) values (?, ?);};
+ $sth = $ctx->{'dbh'}->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $ctx->{'dbh'}->errstr);
+
+ $sth->execute($shortname, $ctx->{'config'}{'shows'}{'service'})
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+ $sth->finish();
+
+ my ($cnt, $status, $errorstring) = create_logevent_table($ctx, $shortname, 1);
+ unless(defined $cnt) {
+ return (undef, $status, $errorstring);
+ }
+
+ ($cnt, $status, $errorstring) = create_logevent_table($ctx, $shortname, 0);
+ unless(defined $cnt) {
+ return (undef, $status, $errorstring);
+ }
+
+ return (1, 'OK', 'success');
+}
sub is_musicpools_user
{