model_forum_post.php
25.9 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: model_forum_post.php 34819 2014-08-11 06:46:20Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class model_forum_post extends discuz_model {
public $forum;
public $thread;
public $post;
public $pid = 0;
public $feed = array();
public function __construct($tid = null, $pid = null) {
parent::__construct();
require_once libfile('function/post');
require_once libfile('function/forumlist');
if($tid) {
include_once libfile('function/forum');
loadforum(null, $tid);
if($pid) {
$this->post = get_post_by_tid_pid($tid, $pid);
}
}
$this->forum = &$this->app->var['forum'];
$this->thread = &$this->app->var['thread'];
$this->group = &$this->app->var['group'];
}
protected function _init_parameters($parameters) {
$varname = array(
'member', 'group', 'forum', 'thread', 'extramessage', 'special',//'nauthorid' 'modnewreplies' 'tid'
'message','clientip', 'invisible', 'isanonymous', 'usesig',
'htmlon', 'bbcodeoff', 'smileyoff', 'parseurloff', 'pstatus',
'noticetrimstr', 'noticeauthor', 'from', 'sechash', 'geoloc',
'subject', 'special', 'sortid', 'typeid', 'isanonymous', 'cronpublish', 'cronpublishdate', 'save',
'readperm', 'price', 'ordertype', 'hiddenreplies', 'allownoticeauthor', 'audit', 'tags', 'bbcodeoff', 'imgcontent', 'imgcontentwidth',
'smileyoff', 'parseurloff', 'usesig', 'htmlon', 'extramessage',
);
foreach($varname as $name) {
if(!isset($this->param[$name]) && isset($parameters[$name])) {
$this->param[$name] = $parameters[$name];
}
}
}
public function newreply($parameters) {
$this->_init_parameters($parameters);
if($this->thread['closed'] && !$this->forum['ismoderator'] && !$this->thread['isgroup']) {
return $this->showmessage('post_thread_closed');
} elseif(!$this->thread['isgroup'] && $post_autoclose = checkautoclose($this->thread)) {
return $this->showmessage($post_autoclose, '', array('autoclose' => $this->forum['autoclose']));
} if(trim($this->param['subject']) == '' && trim($this->param['message']) == '' && $this->thread['special'] != 2) {
return $this->showmessage('post_sm_isnull');
} elseif($post_invalid = checkpost($this->param['subject'], $this->param['message'], $this->param['special'] == 2 && $this->group['allowposttrade'])) {
return $this->showmessage($post_invalid, '', array('minpostsize' => $this->setting['minpostsize'], 'maxpostsize' => $this->setting['maxpostsize']));
} elseif(checkflood()) {
return $this->showmessage('post_flood_ctrl', '', array('floodctrl' => $this->setting['floodctrl']));
} elseif(checkmaxperhour('pid')) {
return $this->showmessage('post_flood_ctrl_posts_per_hour', '', array('posts_per_hour' => $this->group['maxpostsperhour']));
}
$heatthreadset = update_threadpartake($this->thread['tid'], true);
$bbcodeoff = checkbbcodes($this->param['message'], !empty($this->param['bbcodeoff']));
$smileyoff = checksmilies($this->param['message'], !empty($this->param['smileyoff']));
$parseurloff = !empty($this->param['parseurloff']);
$htmlon = $this->group['allowhtml'] && !empty($this->param['htmlon']) ? 1 : 0;
$usesig = !empty($this->param['usesig']) && $this->group['maxsigsize'] ? 1 : 0;
$this->param['isanonymous'] = $this->group['allowanonymous'] && !empty($this->param['isanonymous'])? 1 : 0;
$author = empty($this->param['isanonymous']) ? $this->member['username'] : '';
list(, $this->param['modnewreplies']) = threadmodstatus($this->param['subject']."\t".$this->param['message'].$this->param['extramessage']);
if($this->thread['displayorder'] == -4) {
$this->param['modnewreplies'] = 0;
}
$pinvisible = $this->param['modnewreplies'] ? -2 : ($this->thread['displayorder'] == -4 ? -3 : 0);
$this->param['message'] = preg_replace('/\[attachimg\](\d+)\[\/attachimg\]/is', '[attach]\1[/attach]', $this->param['message']);
if(!empty($this->param['noticetrimstr'])) {
$this->param['message'] = $this->param['noticetrimstr']."\n\n".$this->param['message'];
$bbcodeoff = false;
}
$status = (defined('IN_MOBILE') ? 8 : 0);
if($this->param['modstatus']) {
foreach($this->param['modstatus'] as $modbit => $modvalue) {
$status = setstatus($modbit, $modvalue, $status);
}
}
$this->pid = insertpost(array(
'fid' => $this->forum['fid'],
'tid' => $this->thread['tid'],
'first' => '0',
'author' => $this->member['username'],
'authorid' => $this->member['uid'],
'subject' => $this->param['subject'],
'dateline' => $this->param['timestamp'] ? $this->param['timestamp'] : getglobal('timestamp'),
'message' => $this->param['message'],
'useip' => $this->param['clientip'] ? $this->param['clientip'] : getglobal('clientip'),
'port' => $this->param['remoteport'] ? $this->param['remoteport'] : getglobal('remoteport'),
'invisible' => $pinvisible,
'anonymous' => $this->param['isanonymous'],
'usesig' => $usesig,
'htmlon' => $htmlon,
'bbcodeoff' => $bbcodeoff,
'smileyoff' => $smileyoff,
'parseurloff' => $parseurloff,
'attachment' => '0',
'status' => $status,
));
$this->param['updatethreaddata'] = $heatthreadset ? $heatthreadset : array();
$this->param['maxposition'] = C::t('forum_post')->fetch_maxposition_by_tid($this->thread['posttableid'], $this->thread['tid']);
$this->param['updatethreaddata'][] = DB::field('maxposition', $this->param['maxposition']);
useractionlog($this->member['uid'], 'pid');
if($this->param['geoloc'] && IN_MOBILE == 2) {
list($mapx, $mapy, $location) = explode('|', $this->param['geoloc']);
if($mapx && $mapy && $location) {
C::t('forum_post_location')->insert(array(
'pid' => $this->pid,
'tid' => $this->thread['tid'],
'uid' => $this->member['uid'],
'mapx' => $mapx,
'mapy' => $mapy,
'location' => $location,
));
}
}
$nauthorid = 0;
if(!empty($this->param['noticeauthor']) && !$this->param['isanonymous'] && !$this->param['modnewreplies']) {
list($ac, $nauthorid) = explode('|', authcode($this->param['noticeauthor'], 'DECODE'));
if($nauthorid != $this->member['uid']) {
if($ac == 'q') {
notification_add($nauthorid, 'post', 'reppost_noticeauthor', array(
'tid' => $this->thread['tid'],
'subject' => $this->thread['subject'],
'fid' => $this->forum['fid'],
'pid' => $this->pid,
'from_id' => $this->pid,
'from_idtype' => 'quote',
));
} elseif($ac == 'r') {
notification_add($nauthorid, 'post', 'reppost_noticeauthor', array(
'tid' => $this->thread['tid'],
'subject' => $this->thread['subject'],
'fid' => $this->forum['fid'],
'pid' => $this->pid,
'from_id' => $this->thread['tid'],
'from_idtype' => 'post',
));
}
}
}
if($this->thread['authorid'] != $this->member['uid'] && getstatus($this->thread['status'], 6) && empty($this->param['noticeauthor']) && !$this->param['isanonymous'] && !$this->param['modnewreplies']) {
$thapost = C::t('forum_post')->fetch_threadpost_by_tid_invisible($this->thread['tid'], 0);
notification_add($thapost['authorid'], 'post', 'reppost_noticeauthor', array(
'tid' => $this->thread['tid'],
'subject' => $this->thread['subject'],
'fid' => $this->forum['fid'],
'pid' => $this->pid,
'from_id' => $this->thread['tid'],
'from_idtype' => 'post',
));
}
$this->forum['threadcaches'] && deletethreadcaches($this->thread['tid']);
include_once libfile('function/stat');
updatestat($this->thread['isgroup'] ? 'grouppost' : 'post');
$this->param['showmsgparam']['fid'] = $this->forum['fid'];
$this->param['showmsgparam']['tid'] = $this->thread['tid'];
$this->param['showmsgparam']['pid'] = $this->pid;
$this->param['showmsgparam']['from'] = $this->param['from'];
$this->param['showmsgparam']['sechash'] = !empty($this->param['sechash']) ? $this->param['sechash'] : '';
dsetcookie('clearUserdata', 'forum');
if($this->thread['replies'] <= 0) {
C::t('forum_sofa')->delete($this->thread['tid']);
}
if($this->param['modnewreplies']) {
updatemoderate('pid', $this->pid);
unset($this->param['showmsgparam']['pid']);
if($this->param['updatethreaddata']) {
C::t('forum_thread')->update($this->thread['tid'], $this->param['updatethreaddata'], false, false, 0, true);
}
C::t('forum_forum')->update_forum_counter($this->forum['fid'], 0, 0, 1, 1);
manage_addnotify('verifypost');
return 'post_reply_mod_succeed';
} else {
$fieldarr = array(
'lastposter' => array($author),
'replies' => 1
);
if($this->thread['lastpost'] < getglobal('timestamp')) {
$fieldarr['lastpost'] = array(getglobal('timestamp'));
}
$row = C::t('forum_threadaddviews')->fetch($this->thread['tid']);
if(!empty($row)) {
C::t('forum_threadaddviews')->update($this->thread['tid'], array('addviews' => 0));
$fieldarr['views'] = $row['addviews'];
}
$this->param['updatethreaddata'] = array_merge($this->param['updatethreaddata'], C::t('forum_thread')->increase($this->thread['tid'], $fieldarr, false, 0, true));
if($this->thread['displayorder'] != -4) {
updatepostcredits('+', $this->member['uid'], 'reply', $this->forum['fid']);
if($this->forum['status'] == 3) {
if($this->forum['closed'] > 1) {
C::t('forum_thread')->increase($this->forum['closed'], $fieldarr, true);
}
C::t('forum_groupuser')->update_counter_for_user($this->member['uid'], $this->forum['fid'], 0, 1);
C::t('forum_forumfield')->update($this->forum['fid'], array('lastupdate' => TIMESTAMP));
require_once libfile('function/grouplog');
updategroupcreditlog($this->forum['fid'], $this->member['uid']);
}
$lastpost = $this->thread['tid']."\t".$this->thread['subject']."\t".getglobal('timestamp')."\t".$author;
C::t('forum_forum')->update($this->forum['fid'], array('lastpost' => $lastpost));
C::t('forum_forum')->update_forum_counter($this->forum['fid'], 0, 1, 1);
if($this->forum['type'] == 'sub') {
C::t('forum_forum')->update($this->forum['fup'], array('lastpost' => $lastpost));
}
}
$this->param['page'] = getstatus($this->thread['status'], 4) ? 1 : @ceil(($this->thread['special'] ? $this->thread['replies'] + 1 : $this->thread['replies'] + 2) / getglobal('ppp'));
if($this->param['updatethreaddata']) {
C::t('forum_thread')->update($this->thread['tid'], $this->param['updatethreaddata'], false, false, 0, true);
}
return 'post_reply_succeed';
}
}
public function replyfeed() {
if(!$this->feed) {
if($this->forum['allowfeed'] && !$this->param['isanonymous']) {
if($this->thread['authorid'] != $this->member['uid']) {
$post_url = "forum.php?mod=redirect&goto=findpost&pid=".$this->pid."&ptid=".$this->thread['tid'];
$this->feed['icon'] = 'post';
$this->feed['title_template'] = !empty($this->thread['author']) ? 'feed_reply_title' : 'feed_reply_title_anonymous';
$this->feed['title_data'] = array(
'subject' => "<a href=\"$post_url\">".$this->thread['subject']."</a>",
'author' => "<a href=\"home.php?mod=space&uid=".$this->thread['authorid']."\">".$this->thread['author']."</a>"
);
$forum_attachexist = getglobal('forum_attachexist');
if(!empty($forum_attachexist)) {
$imgattach = C::t('forum_attachment_n')->fetch_max_image('tid:'.$this->thread['tid'], 'pid', $this->pid);
$firstaid = $imgattach['aid'];
unset($imgattach);
if($firstaid) {
$this->feed['images'] = array(getforumimg($firstaid));
$this->feed['image_links'] = array($post_url);
}
}
}
}
}
$this->feed['title_data']['hash_data'] = "tid".$this->thread['tid'];
$this->feed['id'] = $this->pid;
$this->feed['idtype'] = 'pid';
if($this->feed['icon']) {
postfeed($this->feed);
}
}
public function thread($name = null, $val = null) {
if(isset($val)) {
return $this->setvar($this->thread, $name, $val);
} else {
return $this->getvar($this->thread, $name);
}
}
public function forum($name = null, $val = null) {
if(isset($val)) {
return $this->setvar($this->forum, $name, $val);
} else {
return $this->getvar($this->forum, $name);
}
}
public function editpost($parameters) {
$this->_init_parameters($parameters);
$isfirstpost = $this->post['first'] ? 1 : 0;
$isorigauthor = $this->member['uid'] && $this->member['uid'] == $this->post['authorid'];
$this->param['audit'] = $this->post['invisible'] == -2 || $this->thread['displayorder'] == -2 ? $this->param['audit'] : 0;
list($this->param['modnewthreads'], $this->param['modnewreplies']) = threadmodstatus($this->param['subject']."\t".$this->param['message'].$this->param['extramessage']);
if($post_invalid = checkpost($this->param['subject'], $this->param['message'], $isfirstpost && ($this->param['special'] || $this->param['sortid']))) {
showmessage($post_invalid, '', array('minpostsize' => $this->setting['minpostsize'], 'maxpostsize' => $this->setting['maxpostsize']));
}
if(!$isorigauthor && !$this->group['allowanonymous']) {
if($this->post['anonymous'] && !$this->param['isanonymous']) {
$this->param['isanonymous'] = 0;
$this->param['threadupdatearr']['author'] = $this->post['author'];
$anonymousadd = 0;
} else {
$this->param['isanonymous'] = $this->post['anonymous'];
$anonymousadd = '';
}
} else {
$this->param['threadupdatearr']['author'] = $this->param['isanonymous'] ? '' : $this->post['author'];
$anonymousadd = $this->param['isanonymous'];
}
if($isfirstpost) {
if(trim($this->param['subject']) == '' && $this->thread['special'] != 2) {
showmessage('post_sm_isnull');
}
if(!$this->param['sortid'] && !$this->thread['special'] && trim($this->param['message']) == '') {
showmessage('post_sm_isnull');
}
$publishdate = null;
if ($this->group['allowsetpublishdate'] && $this->thread['displayorder'] == -4) {
$cron_publish_ids = dunserialize($this->cache('cronpublish'));
if (!$this->param['cronpublish'] && in_array($this->thread['tid'], $cron_publish_ids) || $this->param['modnewthreads']) {
$this->param['threadupdatearr']['dateline'] = $publishdate = TIMESTAMP;
unset($cron_publish_ids[$this->thread['tid']]);
$cron_publish_ids = serialize($cron_publish_ids);
savecache('cronpublish', $cron_publish_ids);
} elseif ($this->param['cronpublish'] && $this->param['cronpublishdate']) {
$this->param['threadupdatearr']['dateline'] = $publishdate = strtotime($this->param['cronpublishdate']);
$this->param['save'] = 1;
if (!in_array($this->thread['tid'], $cron_publish_ids)) {
$cron_publish_ids[$this->thread['tid']] = $this->thread['tid'];
$cron_publish_ids = serialize($cron_publish_ids);
savecache('cronpublish', $cron_publish_ids);
}
}
}
$this->param['readperm'] = $this->group['allowsetreadperm'] ? intval($this->param['readperm']) : ($isorigauthor ? 0 : 'ignore');
if($this->thread['special'] != 3) {
$this->param['price'] = intval($this->param['price']);
$this->param['price'] = $this->thread['price'] < 0 && !$this->thread['special']
?($isorigauthor || !$this->param['price'] ? -1 : $this->param['price'])
:($this->group['maxprice'] ? ($this->param['price'] <= $this->group['maxprice'] ? ($this->param['price'] > 0 ? $this->param['price'] : 0) : $this->group['maxprice']) : ($isorigauthor ? $this->param['price'] : $this->thread['price']));
if($this->param['price'] > 0 && floor($this->param['price'] * (1 - $this->setting['creditstax'])) == 0) {
return $this->showmessage('post_net_price_iszero');
}
}
$this->thread['status'] = setstatus(4, $this->param['ordertype'], $this->thread['status']);
$this->thread['status'] = setstatus(15, $this->param['imgcontent'], $this->thread['status']);
if($this->param['imgcontent']) {
stringtopic($this->param['message'], $this->post['tid'], true, $this->param['imgcontentwidth']);
}
$this->thread['status'] = setstatus(2, $this->param['hiddenreplies'], $this->thread['status']);
$this->thread['status'] = setstatus(6, $this->param['allownoticeauthor'] ? 1 : 0, $this->thread['status']);
$displayorder = (empty($this->param['save']) || $this->thread['displayorder'] != -4 ) ? ($this->thread['displayorder'] == -4 ? -4 : $this->thread['displayorder']) : -4;
$this->param['threadupdatearr']['typeid'] = $this->param['typeid'];
$this->param['threadupdatearr']['sortid'] = $this->param['sortid'];
$this->param['threadupdatearr']['subject'] = $this->param['subject'];
if($this->param['readperm'] !== 'ignore') {
$this->param['threadupdatearr']['readperm'] = $this->param['readperm'];
}
$this->param['threadupdatearr']['price'] = $this->param['price'];
$this->param['threadupdatearr']['status'] = $this->thread['status'];
if(getglobal('forum_auditstatuson') && $this->param['audit'] == 1) {
$this->param['threadupdatearr']['displayorder'] = 0;
$this->param['threadupdatearr']['moderated'] = 1;
} else {
$this->param['threadupdatearr']['displayorder'] = $displayorder;
}
C::t('forum_thread')->update($this->thread['tid'], $this->param['threadupdatearr'], true);
if($this->thread['tid'] > 1) {
if($this->thread['closed'] > 1) {
C::t('forum_thread')->update($this->thread['closed'], array('subject' => $this->param['subject']), true);
} elseif(empty($this->thread['isgroup'])) {
$threadclosed = C::t('forum_threadclosed')->fetch($thread['tid']);
if($threadclosed['redirect']) {
C::t('forum_thread')->update($threadclosed['redirect'], array('subject' => $this->param['subject']), true);
}
}
}
$class_tag = new tag();
$tagstr = $class_tag->update_field($this->param['tags'], $this->thread['tid'], 'tid', $this->thread);
} else {
if($this->param['subject'] == '' && $this->param['message'] == '' && $this->thread['special'] != 2) {
showmessage('post_sm_isnull');
}
}
$this->param['htmlon'] = $this->group['allowhtml'] && !empty($this->param['htmlon']) ? 1 : 0;
if($this->setting['editedby'] && (TIMESTAMP - $this->post['dateline']) > 60 && $this->member['adminid'] != 1) {
$editor = $this->param['isanonymous'] && $isorigauthor ? lang('forum/misc', 'anonymous') : $this->member['username'];
$edittime = dgmdate(TIMESTAMP);
$this->param['message'] = lang('forum/misc', $this->param['htmlon'] ? 'post_edithtml' : (!$this->forum['allowbbcode'] || $this->param['bbcodeoff'] ? 'post_editnobbcode' : 'post_edit'), array('editor' => $editor, 'edittime' => $edittime)) . $this->param['message'];
}
$this->param['bbcodeoff'] = checkbbcodes($this->param['message'], !empty($this->param['bbcodeoff']));
$this->param['smileyoff'] = checksmilies($this->param['message'], !empty($this->param['smileyoff']));
$tagoff = $isfirstpost ? !empty($tagoff) : 0;
if(getglobal('forum_auditstatuson') && $this->param['audit'] == 1) {
C::t('forum_post')->update($this->thread['posttableid'], $this->post['pid'], array('status' => 4), false, false, null, -2, null, 0);
updatepostcredits('+', $this->post['authorid'], ($isfirstpost ? 'post' : 'reply'), $this->forum['fid']);
updatemodworks('MOD', 1);
updatemodlog($this->thread['tid'], 'MOD');
}
$displayorder = $pinvisible = 0;
if($isfirstpost) {
$displayorder = $this->param['modnewthreads'] ? -2 : $this->thread['displayorder'];
$pinvisible = $this->param['modnewthreads'] ? -2 : (empty($this->param['save']) ? 0 : -3);
} else {
$pinvisible = $this->param['modnewreplies'] ? -2 : ($this->thread['displayorder'] == -4 ? -3 : 0);
}
$this->param['message'] = preg_replace('/\[attachimg\](\d+)\[\/attachimg\]/is', '[attach]\1[/attach]', $this->param['message']);
$this->param['parseurloff'] = !empty($this->param['parseurloff']);
$setarr = array(
'message' => $this->param['message'],
'usesig' => $this->param['usesig'],
'htmlon' => $this->param['htmlon'],
'bbcodeoff' => $this->param['bbcodeoff'],
'parseurloff' => $this->param['parseurloff'],
'smileyoff' => $this->param['smileyoff'],
'subject' => $this->param['subject'],
'tags' => $tagstr,
'port'=>getglobal('remoteport')
);
$setarr['status'] = $this->post['status'];
if($this->param['modstatus']) {
foreach($this->param['modstatus'] as $modbit => $modvalue) {
$setarr['status'] = setstatus($modbit, $modvalue, $setarr['status']);
}
}
if($anonymousadd !== '') {
$setarr['anonymous'] = $anonymousadd;
}
if($publishdate) {
$setarr['dateline'] = $publishdate;
}
if(getglobal('forum_auditstatuson') && $this->param['audit'] == 1) {
$setarr['invisible'] = 0;
} else {
$setarr['invisible'] = $pinvisible;
}
C::t('forum_post')->update('tid:'.$this->thread['tid'], $this->post['pid'], $setarr);
$this->forum['lastpost'] = explode("\t", $this->forum['lastpost']);
if($this->post['dateline'] == $this->forum['lastpost'][2] && ($this->post['author'] == $this->forum['lastpost'][3] || ($this->forum['lastpost'][3] == '' && $this->post['anonymous']))) {
$lastpost = $this->thread['tid']."\t".($isfirstpost ? $this->param['subject'] : $this->thread['subject'])."\t".$this->post['dateline']."\t".($this->param['isanonymous'] ? '' : $this->post['author']);
C::t('forum_forum')->update($this->forum['fid'], array('lastpost' => $lastpost));
}
if(!getglobal('forum_auditstatuson') || $this->param['audit'] != 1) {
if($isfirstpost && $this->param['modnewthreads']) {
C::t('forum_thread')->update($this->thread['tid'], array('displayorder' => -2));
manage_addnotify('verifythread');
} elseif(!$isfirstpost && $this->param['modnewreplies']) {
C::t('forum_thread')->increase($this->thread['tid'], array('replies' => -1));
manage_addnotify('verifypost');
}
if($this->param['modnewreplies'] || $this->param['modnewthreads']) {
C::t('forum_forum')->update($this->forum['fid'], array('modworks' => '1'));
}
}
if($this->thread['lastpost'] == $this->post['dateline'] && ((!$this->post['anonymous'] && $this->thread['lastposter'] == $this->post['author']) || ($this->post['anonymous'] && $this->thread['lastposter'] == '')) && $this->post['anonymous'] != $this->param['isanonymous']) {
C::t('forum_thread')->update($this->thread['tid'], array('lastposter' => $this->param['isanonymous'] ? '' : $this->post['author']), true);
}
if(!$isorigauthor) {
updatemodworks('EDT', 1);
require_once libfile('function/misc');
modlog($this->thread, 'EDT');
}
if($isfirstpost && $this->thread['displayorder'] == -4 && empty($this->param['save'])) {
threadpubsave($this->thread['tid']);
}
}
public function deletepost($parameters) {
$this->_init_parameters($parameters);
if(!$this->setting['editperdel']) {
return $this->showmessage('post_edit_thread_ban_del', NULL);
}
$isfirstpost = $this->post['first'] ? 1 : 0;
if($isfirstpost && $this->thread['replies'] > 0) {
return $this->showmessage(($this->thread['special'] == 3 ? 'post_edit_reward_already_reply' : 'post_edit_thread_already_reply'), NULL);
}
if($this->thread['displayorder'] >= 0) {
updatepostcredits('-', $this->post['authorid'], ($isfirstpost ? 'post' : 'reply'), $this->forum['fid']);
}
if(!$this->param['handlereplycredit']) {
if(!$isfirstpost && !$this->param['isanonymous']) {
$postreplycredit = C::t('forum_post')->fetch('tid:'.$this->thread['tid'], $this->post['pid']);
$postreplycredit = $postreplycredit['replycredit'];
if($postreplycredit) {
C::t('forum_post')->update('tid:'.$this->thread['tid'], $this->post['pid'], array('replycredit' => 0));
updatemembercount($this->post['authorid'], array($replycredit_rule['extcreditstype'] => '-'.$postreplycredit));
}
}
}
C::t('forum_post')->delete('tid:'.$this->thread['tid'], $this->post['pid']);
$forumcounter = array();
if($isfirstpost) {
$forumcounter['threads'] = $forumcounter['posts'] = -1;
$tablearray = array('forum_relatedthread', 'forum_debate', 'forum_debatepost', 'forum_polloption', 'forum_poll');
foreach ($tablearray as $table) {
C::t($table)->delete_by_tid($this->thread['tid']);
}
C::t('forum_thread')->delete_by_tid($this->thread['tid']);
C::t('common_moderate')->delete($this->thread['tid'], 'tid');
C::t('forum_threadmod')->delete_by_tid($this->thread['tid']);
if($this->setting['globalstick'] && in_array($this->thread['displayorder'], array(2, 3))) {
require_once libfile('function/cache');
updatecache('globalstick');
}
} else {
$forumcounter['posts'] = -1;
$lastpost = C::t('forum_post')->fetch_visiblepost_by_tid('tid:'.$this->thread['tid'], $this->thread['tid'], 0, 1);
$lastpost['author'] = !$lastpost['anonymous'] ? addslashes($lastpost['author']) : '';
$this->param['updatefieldarr']['replies'] = -1;
$this->param['updatefieldarr']['lastposter'] = array($lastpost['author']);
$this->param['updatefieldarr']['lastpost'] = array($lastpost['dateline']);
C::t('forum_thread')->increase($this->thread['tid'], $this->param['updatefieldarr']);
}
$this->forum['lastpost'] = explode("\t", $this->forum['lastpost']);
if($this->post['dateline'] == $this->forum['lastpost'][2] && ($this->post['author'] == $this->forum['lastpost'][3] || ($this->forum['lastpost'][3] == '' && $this->post['anonymous']))) {
$lastthread = C::t('forum_thread')->fetch_by_fid_displayorder($this->forum['fid']);
C::t('forum_forum')->update($this->forum['fid'], array('lastpost' => "$lastthread[tid]\t$lastthread[subject]\t$lastthread[lastpost]\t$lastthread[lastposter]"));
}
C::t('forum_forum')->update_forum_counter($this->forum['fid'], $forumcounter['threads'], $forumcounter['posts']);
}
}
?>