Changeset 4331
- Timestamp:
- 06/17/06 16:32:58 (3 years ago)
- Files:
-
- animanga/trunk/lib/Animanga.pm (modified) (1 diff)
- animanga/trunk/lib/Animanga/Data.pm (modified) (7 diffs)
- animanga/trunk/lib/Animanga/Data/MySQL.pm (modified) (2 diffs)
- animanga/trunk/lib/Animanga/Display.pm (modified) (3 diffs)
- animanga/trunk/lib/Animanga/Utility.pm (modified) (1 diff)
- animanga/trunk/scripts/www/comments.pl (modified) (2 diffs)
- animanga/trunk/scripts/www/users.pl (modified) (1 diff)
- animanga/trunk/templates/sensei/users-edit (modified) (1 diff)
- animanga/trunk/templates/www/box-list (modified) (1 diff)
- animanga/trunk/templates/www/comments (modified) (1 diff)
- animanga/trunk/templates/www/faq (modified) (1 diff)
- animanga/trunk/templates/www/thread-list (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
animanga/trunk/lib/Animanga.pm
r4329 r4331 338 338 my $now = $self->time(); 339 339 340 if($self->user(" time")) {340 if($self->user("currenttime")) { 341 341 # update session 342 342 $self->update("sessions", { animanga/trunk/lib/Animanga/Data.pm
r4329 r4331 138 138 pid => -1 139 139 }); 140 } 141 142 143 sub updateSequenceInThreadWithCid { 144 my($self, $cid) = @_; 145 146 $self->recursivelyUpdateSequenceInThreadWithCid($cid, $cid, 1, 0, 0, 0, $self->var("commentsperpage"), $self->constant("statusposted")); 147 } 148 149 150 sub recursivelyUpdateSequenceInThreadWithCid { 151 my($self, $cid, $tid, $page, $level, $count, $postedcount, $perpage, $writestatus) = @_; 152 153 if($postedcount > 0 && $postedcount % $perpage == 0) { 154 $page++; 155 } 156 157 $count++; 158 $postedcount++ if $writestatus == $self->constant("statusposted"); 159 160 $self->update("comments", { 161 tid => $tid, 162 page => $page, 163 level => $level, 164 sequence => $count 165 }, { 166 cid => $cid 167 }); 168 169 my $data = $self->selectAll("cid, writestatus", "comments", { pid => $cid }); 170 171 $level++; 172 173 foreach (@$data) { 174 ($page, $count, $postedcount) = $self->recursivelyUpdateSequenceInThreadWithCid($_->{"cid"}, $tid, $page, $level, $count, $postedcount, $perpage, $_->{"writestatus"}); 175 } 176 177 $level--; 178 179 return ($page, $count, $postedcount); 140 180 } 141 181 … … 481 521 482 522 523 sub firstNewCommentReplyInThreadWithTid { 524 my($self, $tid) = @_; 525 526 $tid = $self->quote($tid); 527 my $lasttime = $self->quote($self->user("lasttime")); 528 529 return $self->selectHashref("comments.cid, comments.time, users.uid, users.nick", "comments LEFT JOIN users ON comments.uid = users.uid", "comments.tid = $tid AND comments.time > $lasttime ORDER BY comments.time LIMIT 1"); 530 } 531 532 483 533 sub sendMessageToUser { 484 534 my($self, $from_uid, $to_uid, $subject, $message, $no_receipt) = @_; … … 556 606 my $now = $self->time(); 557 607 my $ip = $self->remoteHost(); 558 my $level; 559 my $sequence; 608 my $level = 0; 609 my $sequence = 1; 610 my $page = 1; 560 611 561 612 if($pid == -1) { … … 564 615 $writestatus = $self->constant("statusposted"); 565 616 $replycount = 0; 566 $sequence = 1;567 $level = 0;568 617 } else { 569 618 my $parent_subject; 570 619 571 ($aid, $type, $writestatus, $locked, $parent_subject, $level, $sequence) = $self->select("aid, type, writestatus, locked, subject, level, sequence", "comments", { cid => $pid }); 572 573 if($tid) { 574 $sequence = $self->select("MAX(sequence)", "comments", { tid => $tid }); 575 } else { 576 $sequence = 0; 577 } 620 ($aid, $type, $writestatus, $locked, $parent_subject) = $self->select("aid, type, writestatus, locked, subject", "comments", { cid => $pid }); 578 621 579 622 unless($subject) { … … 587 630 $tid ||= -1; 588 631 $replycount = -1; 589 $level++;590 $sequence++;591 632 } 592 633 … … 607 648 ip => $ip, 608 649 writestatus => $writestatus, 650 latest => $now, 609 651 locked => $locked, 610 652 replycount => $replycount, 611 653 level => $level, 612 654 sequence => $sequence, 655 page => $page, 613 656 }); 614 657 … … 626 669 627 670 # update user commentcount 628 my $commentcount = $self->user("commentcount"); 629 $commentcount++; 630 631 $self->update("users", { 632 commentcount => $commentcount, 633 commenttime => $now, 634 }, { 635 uid => $uid 636 }); 671 if($writestatus == $self->constant("statusposted")) { 672 my $commentcount = $self->user("commentcount"); 673 $commentcount++; 674 675 $self->update("users", { 676 commentcount => $commentcount, 677 commenttime => $now, 678 }, { 679 uid => $uid 680 }); 681 } 637 682 638 683 # update attached comment/thread count 639 684 if($type == $self->constant("typeforum")) { 640 if($pid == -1 ) { 641 $self->update("forums", { 642 -threadcount => "threadcount + 1", 643 -commentcount => "commentcount + 1", 644 commenttime => $now, 645 }, { 646 fid => $aid 647 }); 648 } else { 649 $self->update("forums", { 650 -commentcount => "commentcount + 1", 651 commenttime => $now, 652 }, { 653 fid => $aid 654 }); 655 } 656 657 if($tid == -1) { 658 $self->update("comments", { 659 tid => $cid, 660 }, { 661 cid => $cid 662 }); 685 if($writestatus == $self->constant("statusposted")) { 686 if($pid == -1 ) { 687 $self->update("forums", { 688 -threadcount => "threadcount + 1", 689 -commentcount => "commentcount + 1", 690 commenttime => $now, 691 }, { 692 fid => $aid 693 }); 694 } else { 695 $self->update("forums", { 696 -commentcount => "commentcount + 1", 697 commenttime => $now, 698 }, { 699 fid => $aid 700 }); 701 } 702 } 703 704 if($tid > 0) { 705 if($writestatus == $self->constant("statusposted")) { 706 $self->update("comments", { 707 lid => $cid, 708 latest => $now, 709 -replycount => "replycount + 1", 710 }, { 711 cid => $tid 712 }); 713 } 714 } 715 716 if($tid > 0) { 717 $self->updateSequenceInThreadWithCid($tid); 663 718 } else { 664 719 $self->update("comments", { 665 lid => $cid, 666 latest => $now, 667 -replycount => "replycount + 1", 720 tid => $cid 668 721 }, { 669 cid => $tid722 cid => $cid 670 723 }); 671 672 $self->update("comments", {673 -sequence => "sequence + 1",674 }, "tid = '$tid' AND sequence >= '$sequence' AND cid != '$cid'");675 724 } 676 725 } 677 726 elsif($type == $self->constant("typestory")) { 678 $self->update("stories", { 679 -storycommentcount => "storycommentcount + 1", 680 storycommenttime => $now, 681 }, { 682 fid => $aid 683 }); 727 if($writestatus == $self->constant("statusposted")) { 728 $self->update("stories", { 729 -storycommentcount => "storycommentcount + 1", 730 storycommenttime => $now, 731 }, { 732 fid => $aid 733 }); 734 } 684 735 } 685 736 686 737 $self->endTransaction(); 738 739 return $cid; 687 740 } 688 741 animanga/trunk/lib/Animanga/Data/MySQL.pm
r4329 r4331 286 286 287 287 288 sub commentReplyWithCid { 289 my($self, $cid) = @_; 290 291 my $writestatus; 292 293 if($self->user("designation") == $self->constant("usernormal")) { 294 $writestatus = "AND comments.writestatus = '" . $self->constant("statusposted") . "'"; 295 } 296 297 $cid = $self->quote($cid); 298 299 return $self->selectHashref(<<SELECT, <<FROM, <<WHERE); 300 comments.cid, comments.time, users.uid, users.nick 301 SELECT 302 303 comments 304 LEFT JOIN users ON comments.uid = users.uid 305 FROM 306 307 comments.cid = $cid 308 $writestatus 309 WHERE 310 } 311 312 288 313 sub commentsWithPid { 289 314 my($self, $pid, $text) = @_; … … 445 470 WHERE 446 471 447 ORDER BY comments.sticky DESC,comments.latest DESC 472 ORDER BY comments.sticky DESC,comments.latest DESC,comments.time DESC 448 473 LIMIT $offset,$count 449 474 OTHER animanga/trunk/lib/Animanga/Display.pm
r4329 r4331 172 172 } 173 173 174 if($_->{"style"} == $commentnested) { 175 $_->{"comment"} = $self->parseAnimangaTags($_->{"comment"}, $_->{"uid"}) if $_->{"comment"}; 176 $_->{"signature"} = $self->parseAnimangaTags($_->{"signature"}, $_->{"uid"}) if $_->{"signature"}; 177 } 174 $_->{"comment"} = $self->parseAnimangaTags($_->{"comment"}, $_->{"uid"}) if $_->{"comment"}; 175 $_->{"signature"} = $self->parseAnimangaTags($_->{"signature"}, $_->{"uid"}) if $_->{"signature"}; 178 176 179 177 $comments[0] = $_; … … 227 225 } 228 226 229 if($_->{"style"} == $commentnested) { 230 $_->{"comment"} = $self->parseAnimangaTags($_->{"comment"}, $_->{"uid"}) if $_->{"comment"}; 231 $_->{"signature"} = $self->parseAnimangaTags($_->{"signature"}, $_->{"uid"}) if $_->{"signature"}; 232 } 227 $_->{"comment"} = $self->parseAnimangaTags($_->{"comment"}, $_->{"uid"}) if $_->{"comment"}; 228 $_->{"signature"} = $self->parseAnimangaTags($_->{"signature"}, $_->{"uid"}) if $_->{"signature"}; 233 229 234 230 $comments[0] = $_; … … 252 248 253 249 foreach (@$data) { 254 $_->{"reply"} = $self->commentWithCid($_->{"lid"}) unless $_->{"lid"} == $_->{"cid"}; 250 $_->{"latest"} = $self->commentReplyWithCid($_->{"lid"}) unless $_->{"lid"} == $_->{"cid"}; 251 $_->{"new"} = $self->firstNewCommentReplyInThreadWithTid($_->{"tid"}); 255 252 $_->{"pages"} = POSIX::ceil(($_->{"replycount"} + 1) / $self->var("commentsperpage")); 256 253 } animanga/trunk/lib/Animanga/Utility.pm
r4061 r4331 290 290 $text =~ s|\[CODE\](.+?)\[/CODE\]|Animanga::Filters::code($1)|ieg; 291 291 292 # [I], [B], [U] 292 # [I], [B], [U], [S] 293 293 $text =~ s|\[I\](.+?)\[/I\]|<i>$1</i>|ig; 294 294 $text =~ s|\[B\](.+?)\[/B\]|<b>$1</b>|ig; 295 295 $text =~ s|\[U\](.+?)\[/U\]|<u>$1</u>|ig; 296 $text =~ s|\[S\](.+?)\[/S\]|<del>$1</del>|ig; 296 297 297 298 return $text; animanga/trunk/scripts/www/comments.pl
r4329 r4331 310 310 311 311 # submit comment 312 $a->postComment($pid, $aid, $type, $subject, $comment, $tid) unless $diff && $diff < 10;312 my $cid = $a->postComment($pid, $aid, $type, $subject, $comment, $tid) unless $diff && $diff < 10; 313 313 314 314 # redirect to results 315 315 if($type == $a->constant("typeforum") && $supercid != -1) { 316 $a->redirect("comments.pl?cid=$supercid ");316 $a->redirect("comments.pl?cid=$supercid;reply=$cid#$cid"); 317 317 } else { 318 318 $a->redirect($a->attachedLink($aid, $type)); … … 354 354 # redirect to results 355 355 if($type == $a->constant("typeforum")) { 356 $a->redirect("comments.pl?cid=$supercid ");356 $a->redirect("comments.pl?cid=$supercid;reply=$cid#$cid"); 357 357 } else { 358 358 $a->redirect($a->attachedLink($aid, $type)); animanga/trunk/scripts/www/users.pl
r4329 r4331 558 558 my $now = $a->time(); 559 559 560 $a->update("sessions", { last => $now }, { uid => $uid });560 $a->update("sessions", { lasttime => $now }, { uid => $uid }); 561 561 $a->update("messages", { new => 0 }, { touid => $uid }); 562 562 animanga/trunk/templates/sensei/users-edit
r3941 r4331 25 25 <tr> 26 26 <td class="left">Senast</td> 27 <td><? page.user. time filter formattedtime ?></td>27 <td><? page.user.currenttime filter formattedtime ?></td> 28 28 </tr> 29 29 animanga/trunk/templates/www/box-list
r4329 r4331 14 14 <? include new time = item.unixtime ?> <a href="articles.pl?sid=<? item.sid ?>"><? item.title ?></a> 15 15 <? elsif item.type == constants.boxcomment ?> 16 <? include new time = item.unixtime ?> <a href="comments.pl? <? if item.cid == item.tid ?>tid<? else ?>cid<? end ?>=<? item.cid ?>"><? item.subject ?></a>16 <? include new time = item.unixtime ?> <a href="comments.pl?cid=<? item.cid ?>"><? item.subject ?></a> 17 17 <? elsif item.type == constants.boxforum ?> 18 18 <? include new time = item.unixcommenttime ?> <a href="forum.pl?fid=<? item.fid ?>"><? item.forum ?></a> animanga/trunk/templates/www/comments
r4329 r4331 37 37 <input type="hidden" name="aid" value="<? page.comment.aid ?>" /> 38 38 <input type="hidden" name="pid" value="<? page.comment.cid ?>" /> 39 <? if page.comment.pid == -1 ?>40 39 <input type="hidden" name="tid" value="<? page.comment.tid ?>" /> 41 <? end ?>42 40 <input type="hidden" name="type" value="<? page.comment.type ?>" /> 43 41 animanga/trunk/templates/www/faq
r2773 r4331 34 34 35 35 <li><b>[U]</b>understruken stil<b>[/U]</b></li> 36 Blir <U>understruken stil</U>. 36 Blir <u>understruken stil</u>. 37 38 <br /> 39 <br /> 40 41 <li><b>[S]</b>genomstruken stil<b>[/S]</b></li> 42 Blir <del>genomstruken stil</del>. 37 43 38 44 <br /> animanga/trunk/templates/www/thread-list
r4329 r4331 6 6 <? end ?> 7 7 8 <? if comment.reply.uid == 1 ?> 9 <? replybyline = comment.reply.nick ?> 10 <? else ?> 11 <? replybyline = "<a href=\"users.pl?uid=$comment.reply.uid\">$comment.reply.nick</a>" ?> 8 <? if comment.latest ?> 9 <? if comment.latest.uid == 1 ?> 10 <? latestbyline = comment.latest.nick ?> 11 <? else ?> 12 <? latestbyline = "<a href=\"users.pl?uid=$comment.latest.uid\">$comment.latest.nick</a>" ?> 13 <? end ?> 14 <? end ?> 15 16 <? if comment.new ?> 17 <? if comment.new.uid == 1 ?> 18 <? newbyline = comment.new.nick ?> 19 <? else ?> 20 <? newbyline = "<a href=\"$urls.www/users.pl?uid=$comment.new.uid\">$comment.new.nick</a>" ?> 21 <? end ?> 12 22 <? end ?> 13 23 14 24 <div class="thread"> 15 25 <? include new time = comment.unixlatest ?> <? if comment.locked ?><b>[låst]</b><? end ?><? if comment.sticky ?><b>[klistrad]</b><? end ?> <a href="comments.pl?cid=<? comment.cid ?>"><? comment.subject ?></a> 16 17 <? pages = undef ?>18 26 19 27 <? if comment.pages > 1 ?> … … 34 42 <? end ?> 35 43 <? end ?> 44 45 (<? pages ?>) 36 46 <? end ?> 37 47 38 <? if pages ?> 39 (<? pages ?>) 40 <? end ?> 48 (<a href="<? urls.www ?>/comments.pl?cid=<? comment.cid ?>;overview=1">Översikt</a>) 49 41 50 <br /> 42 51 43 <? comment.replycount ?> <? comment.replycount filter answerstring ?>, av <? byline ?><? if comment.replycount == 0 || !comment.reply ?>, <? comment.time filter formattedtime ?><? else ?>, <a href="comments.pl?cid=<? comment.cid ?>;reply=<? comment.reply.cid ?>#<? comment.reply.cid ?>">senaste</a> av <? replybyline ?>, <? comment.reply.time filter formattedtime ?><? end ?> 52 <? comment.replycount ?> <? comment.replycount filter answerstring ?>, av <? byline ?>, skapad <? comment.time filter formattedtime ?><br /> 53 <? if comment.latest ?><a href="comments.pl?cid=<? comment.cid ?>;reply=<? comment.latest.cid ?>#<? comment.latest.cid ?>">Senaste</a> av <? latestbyline ?>, postad <? comment.latest.time filter formattedtime ?><? if comment.new ?>, <a href="<? urls.www ?>/comments.pl?cid=<? comment.cid ?>;reply=<? comment.new.cid ?>#<? comment.new.cid ?>">första olästa</a> av <? newbyline ?><? end ?><? end ?> 44 54 </div> 45 55 <? end ?>
