Pm/Flag.pm
Copying Source is Forbidden
125 lines of code
1
package Flag;
2
3
#/
4
# !this module is not complete
5
#/
6
7
use strict;
8
use warnings;
9
use CGI::Carp qw(fatalsToBrowser);
10
use Exporter;
11
use vars qw($VERSION @ISA @EXPORT_OK @EXPORT);
12
use CGI;
13
14
$VERSION = 1.00;
15
@ISA = qw(Exporter);
16
@EXPORT = qw(
17
get_flag
18
);
19
@EXPORT_OK = qw(
20
_tests
21
22
create_flag
23
delete_flag
24
get_flag
25
save_flag
26
27
get_flag_count
28
get_warning_count
29
);
30
31
# see subroutine descriptions to learn more
32
# create_flag(...); # see subroutine's description
33
# delete_flag(uid, content_id, status)
34
# get_flag(uid, content_id)
35
# save_flag(...); # see subroutine's description
36
# get_flag_count(uid)
37
# get_warning_count(uid)
38
39
my $TABLE_BORDER = 0;
40
my $DEBUG = 0;
41
42
########################
43
sub create_flag($$) {
44
#*
45
# creates a new record in the "flagged"
46
# table. this may also update the
47
# "flagged_counts_per_user" table
48
#
49
# the columns for each record are:
50
# ID (internal use, set as NULL, or exclude from insert statements)
51
# UID you should know this one by now
52
# content_ID (assign: UID (use $LOGGEDIN or other valid UID), image ID, msg ID)
53
# link (a specially crafted url to the flagged content)
54
# type (assign: 'd' for description, 'm' for message, 'i' for image (more may be added in the future)
55
# flagger_ID is the user who flagged the content in the first place
56
# flagger_reason is obvious
57
# DOF is the date the flag was created (date of flagging)
58
# moderator_ID is the ID of the moderator who last worked on this
59
# moderator_notes is a blob of notes (see code to see format of this blob)
60
# status: set this to 'pending', 'warning1', 'warning2', 'warning3', 'ignored', 'resolved'
61
# resolution: set this to 'deleted (whatever it was)', 'banned account', etc
62
#
63
# the return value of this function can be 1 or less!
64
# if it returns 0 or less, an error occured.
65
# see the code to know what the errors are, and what
66
# goes on. when debugging, it's okay to have clear
67
# error msgs (error_redir(url, msg)). when <b>not</b>
68
# debugging <b>ENSURE</b> error msgs returned to the
69
# client are as UN-informative as possible!
70
#
71
# this function will check if the flag already exists before inserting the flag
72
#*
73
my ($uid, $cid, $link, $type, $flagger_id, $flagger_reason, $dof, $mod_id, $mod_notes, $status) = @_; # a dbh && see desc && . && . && . && . && . && . && . && . && . && .
74
my $rv = 0;
75
76
return $rv; # 1 if successful, or <= 0
77
#usage: my $val = an_exported_sub($someval, $someotherval);
78
}
79
80
########################
81
sub delete_flag($$) {
82
#*
83
# to delete a flag id ($fid)
84
#*
85
my ($fid) = @_;
86
my $rv = 0;
87
88
return $rv; # 1 if deleted, or <= 0 if not
89
#usage: if (delete_flag('123abc')) { print "k, it's gone"; }
90
}
91
92
########################
93
sub _tests(;$) {
94
#*
95
# to test all <i>Pm::Flag</i> functions
96
#*
97
my ($extended) = @_; # show extended data (optional)
98
my $rv = "";
99
my $test = "";
100
my $test2 = "";
101
102
if ($Bc_sql::DB) {
103
$test = "loggedin";
104
$test2 = "1234567890";
105
$rv .= Html::display_debug_one("create_flag(\"$test\")", "$test2");
106
Bc_sql::sql_disconnect();
107
# end if ($DB)
108
} else {
109
$rv .= "DB connection error!<br>\n";
110
# end else of if ($DB)
111
}
112
113
return $rv; # 0 on failure, or a scalar
114
#usage: print _tests();
115
}
116
117
########################
118
########################
119
########################
120
########################
121
########################
122
########################
123
########################
124
125
1;