extend_thread_debate.php
4.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: extend_thread_debate.php 30673 2012-06-11 07:51:54Z svn_project_zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class extend_thread_debate extends extend_thread_base {
public $affirmpoint;
public $negapoint;
public $endtime;
public $stand;
public function before_newthread($parameters) {
if(empty($_GET['affirmpoint']) || empty($_GET['negapoint'])) {
showmessage('debate_position_nofound');
} elseif(!empty($_GET['endtime']) && (!($this->endtime = @strtotime($_GET['endtime'])) || $this->endtime < TIMESTAMP)) {
showmessage('debate_endtime_invalid');
} elseif(!empty($_GET['umpire'])) {
if(!C::t('common_member')->fetch_uid_by_username($_GET['umpire'])) {
$_GET['umpire'] = dhtmlspecialchars($_GET['umpire']);
showmessage('debate_umpire_invalid', '', array('umpire' => $_GET['umpire']));
}
}
$this->affirmpoint = censor(dhtmlspecialchars($_GET['affirmpoint']));
$this->negapoint = censor(dhtmlspecialchars($_GET['negapoint']));
$this->stand = intval($_GET['stand']);
$this->param['extramessage'] = "\t".$_GET['affirmpoint']."\t".$_GET['negapoint'];
}
public function after_newthread() {
if($this->group['allowpostdebate']) {
C::t('forum_debate')->insert(array(
'tid' => $this->tid,
'uid' => $this->member['uid'],
'starttime' => $this->param['publishdate'],
'endtime' => $this->endtime,
'affirmdebaters' => 0,
'negadebaters' => 0,
'affirmvotes' => 0,
'negavotes' => 0,
'umpire' => $_GET['umpire'],
'winner' => '',
'bestdebater' => '',
'affirmpoint' => $this->affirmpoint,
'negapoint' => $this->negapoint,
'umpirepoint' => ''
));
}
}
public function before_feed() {
$message = !$this->param['price'] && !$this->param['readperm'] ? $this->param['message'] : '';
$this->feed['icon'] = 'debate';
$this->feed['title_template'] = 'feed_thread_debate_title';
$this->feed['body_template'] = 'feed_thread_debate_message';
$this->feed['body_data'] = array(
'subject' => "<a href=\"forum.php?mod=viewthread&tid={$this->tid}\">{$this->param['subject']}</a>",
'message' => messagecutstr($message, 150),
'affirmpoint'=> messagecutstr($this->affirmpoint, 150),
'negapoint'=> messagecutstr($this->negapoint, 150)
);
}
public function after_newreply() {
global $firststand, $stand;
if($this->param['special'] == 5) {
if(!$firststand) {
C::t('forum_debate')->update_debaters($this->thread['tid'], $stand);
} else {
$stand = $firststand;
}
C::t('forum_debate')->update_replies($this->thread['tid'], $stand);
C::t('forum_debatepost')->insert(array(
'tid' => $this->thread['tid'],
'pid' => $this->pid,
'uid' => $this->member['uid'],
'dateline' => getglobal('timestamp'),
'stand' => $stand,
'voters' => 0,
'voterids' => '',
));
}
}
public function before_replyfeed() {
global $stand;
if($this->forum['allowfeed'] && !$this->param['isanonymous']) {
if($this->param['special'] == 5 && $this->thread['authorid'] != $this->member['uid']) {
$this->feed['icon'] = 'debate';
if($stand == 1) {
$this->feed['title_template'] = 'feed_thread_debatevote_title_1';
} elseif($stand == 2) {
$this->feed['title_template'] = 'feed_thread_debatevote_title_2';
} else {
$this->feed['title_template'] = 'feed_thread_debatevote_title_3';
}
$this->feed['title_data'] = array(
'subject' => "<a href=\"forum.php?mod=viewthread&tid=".$this->thread['tid']."\">".$this->thread['subject']."</a>",
'author' => "<a href=\"home.php?mod=space&uid=".$this->thread['authorid']."\">".$this->thread['author']."</a>"
);
}
}
}
public function before_editpost($parameters) {
$isfirstpost = $this->post['first'] ? 1 : 0;
if($isfirstpost) {
if($this->thread['special'] == 5 && $this->group['allowpostdebate']) {
if(empty($_GET['affirmpoint']) || empty($_GET['negapoint'])) {
showmessage('debate_position_nofound');
} elseif(!empty($_GET['endtime']) && (!($endtime = @strtotime($_GET['endtime'])) || $endtime < TIMESTAMP)) {
showmessage('debate_endtime_invalid');
} elseif(!empty($_GET['umpire'])) {
if(!C::t('common_member')->fetch_uid_by_username($_GET['umpire'])) {
$_GET['umpire'] = dhtmlspecialchars($_GET['umpire']);
showmessage('debate_umpire_invalid');
}
}
$affirmpoint = censor(dhtmlspecialchars($_GET['affirmpoint']));
$negapoint = censor(dhtmlspecialchars($_GET['negapoint']));
C::t('forum_debate')->update($this->thread['tid'], array('affirmpoint' => $affirmpoint, 'negapoint' => $negapoint, 'endtime' => $endtime, 'umpire' => $_GET['umpire']));
}
}
}
}
?>