2 # DBStubs.pl: DB independent (I hope, heh) factoid support
4 # Version: v0.6d (20000223)
8 if (&IsParam("useStrict")) { use strict; }
11 # Usage: &setFactInfo($faqtoid, $type, $what, ?, ?);
13 &dbSet("factoids", "factoid_key", $_[0], $_[1], $_[2]);
17 # Usage: &IsLocked($faqtoid);
20 my $thisnuh = &getFactInfo($faqtoid, "locked_by");
22 if (defined $thisnuh and $thisnuh ne "") {
23 if (!&IsHostMatch($thisnuh) and &IsFlag("o") ne "o") {
24 &performReply("cannot alter locked factoids");
33 # Usage: &AddModified($faqtoid,$nuh);
35 my ($faqtoid,$nuh) = @_;
36 my $modified_by = &getFactInfo($faqtoid, "modified_by");
37 my (@modifiedlist, @modified, %modified);
39 if (defined $modified_by) {
40 push(@modifiedlist, split(/\,/, $modified_by));
42 push(@modifiedlist,$nuh);
44 foreach (reverse @modifiedlist) {
45 /^(\S+)!(\S+)@(\S+)$/;
47 next if (exists $modified{$nick});
49 $modified{$nick} = $_;
50 push(@modified,$nick);
55 foreach (reverse @modified) {
56 push(@modifiedlist, $modified{$_});
58 shift(@modifiedlist) while (scalar @modifiedlist > 3);
60 &setFactInfo($faqtoid,"modified_by", join(",",@modifiedlist));
61 &setFactInfo($faqtoid,"modified_time", time());
67 ### Commands which use the fundamental functions... Helpers?
71 # Usage: &CmdLock($function,$faqtoid);
75 my $thisnuh = &getFactInfo($faqtoid,"locked_by");
77 if (defined $thisnuh and $thisnuh ne "") {
78 my $locked_by = (split(/\!/,$thisnuh))[0];
79 &msg($who,"factoid \002$faqtoid\002 has already been locked by $locked_by.");
83 $thisnuh ||= &getFactInfo($faqtoid,"created_by");
85 # fixes bug found on 19991103.
86 # code needs to be reorganised though.
88 if (!&IsHostMatch($thisnuh) && IsFlag("o") ne "o") {
89 &msg($who, "sorry, you are not allowed to lock '$faqtoid'.");
94 &performReply("locking factoid \002$faqtoid\002");
95 &setFactInfo($faqtoid,"locked_by",$nuh);
96 &setFactInfo($faqtoid,"locked_time", time());
102 # Usage: &CmdUnLock($faqtoid);
106 my $thisnuh = &getFactInfo($faqtoid,"locked_by");
108 if (!defined $thisnuh) {
109 &msg($who, "factoid \002$faqtoid\002 is not locked.");
113 if ($thisnuh ne "" and !&IsHostMatch($thisnuh) and &IsFlag("o") ne "o") {
114 &msg($who, "sorry, you are not allowed to unlock factoid '$faqtoid'.");
118 &performReply("unlocking factoid \002$faqtoid\002");
119 &setFactInfo($faqtoid,"locked_by", "");
120 &setFactInfo($faqtoid,"locked_time", "");