[Iamb-dev] CVS: iamb index.cgi,1.29,1.30
Status: Beta
Brought to you by:
rbowen
From: Rich B. <rb...@us...> - 2002-03-28 16:03:18
|
Update of /cvsroot/iamb/iamb In directory usw-pr-cvs1:/tmp/cvs-serv2053 Modified Files: index.cgi Log Message: Code tidying. No functional change. Index: index.cgi =================================================================== RCS file: /cvsroot/iamb/iamb/index.cgi,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -r1.29 -r1.30 *** index.cgi 28 Jan 2001 22:30:14 -0000 1.29 --- index.cgi 28 Mar 2002 16:03:15 -0000 1.30 *************** *** 446,477 **** =cut ! sub Edit { ! # Form to edit an existing article ! my ($iamb) = @_; ! my ($template, $details, $sth, $user, ! $article, %articles, %children, ! ); ! my $form = $iamb->form; ! $user = $iamb->WhoAmI; ! $sth =$iamb->dbh->prepare("select * from ". $iamb->articles ." ! where ID=$form->{article} ! "); ! $sth->execute; ! $details = $sth->fetchrow_hashref; ! $details->{title} =~ s/"/"/g; ! # Only the author can edit the article ! if ($user->{ID} && $user->{ID}==$details->{authorID}) { ! $template = 'edit'; ! } ! else { ! # Without access, edit becomes the same as view article ! ($template, $details) = Article($iamb); ! $template = 'notauthor'; } ! return ($template, $details); ! } # End Edit =head2 Update --- 446,476 ---- =cut ! sub Edit { ! # Form to edit an existing article ! my ($iamb) = @_; ! my ( $template, $details, $sth, $user, $article, %articles, %children, ); ! my $form = $iamb->form; ! $user = $iamb->WhoAmI; ! $sth = $iamb->dbh->prepare( "select * from " . $iamb->articles . " ! where ID=$form->{article} ! " ); ! $sth->execute; ! $details = $sth->fetchrow_hashref; ! $details->{title} =~ s/"/"/g; ! ! # Only the author can edit the article ! if ( $user->{ID} && $user->{ID} == $details->{authorID} ) { ! $template = 'edit'; ! } else { ! ! # Without access, edit becomes the same as view article ! ( $template, $details ) = Article($iamb); ! $template = 'notauthor'; } ! return ( $template, $details ); ! } # End Edit =head2 Update *************** *** 485,518 **** =cut ! sub Update { ! # Update an existing article in the database ! my ($iamb) = @_; ! my ($template, $details, $sth, $time, $id, ! $html, $user, $sth2, $parent, ! $now, ! ); ! my $form = $iamb->form; ! $user = $iamb->WhoAmI; ! $sth = $iamb->dbh->prepare("select * from " . $iamb->articles . " where ID=$form->{ID} ! "); ! $sth->execute; ! $details = $sth->fetchrow_hashref; ! ! if ($user->{ID} && $user->{ID} == $details->{authorID}) ! { ! $time = time; # Update the time ! ! # Remove script amd comments ! $form->{body} =~ s/<!--?|<script//ig; ! $form->{body} =~ s/-->//g; ! $form->{image}="" if ($form->{image} eq "http://"); ! $form->{title} ||= 'Untitled'; ! ! for (qw(title body author email link image)) { ! $form->{$_} = $iamb->dbh->quote($form->{$_}); ! } ! $sth = $iamb->dbh->prepare("update ". $iamb->articles . " set title = $form->{title}, body = $form->{body}, --- 484,515 ---- =cut ! sub Update { ! # Update an existing article in the database ! my ($iamb) = @_; ! my ( $template, $details, $sth, $time, $id, $html, $user, $sth2, $parent, ! $now, ); ! ! my $form = $iamb->form; ! $user = $iamb->WhoAmI; ! $sth = $iamb->dbh->prepare( "select * from " . $iamb->articles . " where ID=$form->{ID} ! " ); ! $sth->execute; ! $details = $sth->fetchrow_hashref; ! ! if ( $user->{ID} && $user->{ID} == $details->{authorID} ) { ! $time = time; # Update the time ! ! # Remove script amd comments ! $form->{body} =~ s/<!--?|<script//ig; ! $form->{body} =~ s/-->//g; ! $form->{image} = "" if ( $form->{image} eq "http://" ); ! $form->{title} ||= 'Untitled'; ! ! for (qw(title body author email link image)) { ! $form->{$_} = $iamb->dbh->quote( $form->{$_} ); ! } ! $sth = $iamb->dbh->prepare( "update " . $iamb->articles . " set title = $form->{title}, body = $form->{body}, *************** *** 520,553 **** image = $form->{image} where ID = $form->{ID} ! "); ! # Users cannot move a thread/article from one forum to another ! # at this time. ! # Forum is not specified because articleID is always unique. ! $sth->execute; ! $now = time; ! $sth = $iamb->dbh->prepare("update ". $iamb->threads ." set updated = $now where ID = $form->{threadID} ! "); ! $sth->execute; ! } ! # Get the unread marks right ! $iamb->UpdateUnread($form->{forum}, $user->{ID}); ! $sth = $iamb->dbh->prepare("delete from ". $iamb->unread . " where userID = $user->{ID} and articleID = $form->{ID} and marktype = 1 ! "); ! $sth->execute; ! $sth->finish; ! ! $form->{article} = $form->{ID}; ! ($template, $details) = Article($iamb); ! return ($template, $details); ! } # End sub Update =head2 MarkUnread --- 517,551 ---- image = $form->{image} where ID = $form->{ID} ! " ); ! # Users cannot move a thread/article from one forum to another ! # at this time. ! # Forum is not specified because articleID is always unique. ! $sth->execute; ! ! $now = time; ! $sth = $iamb->dbh->prepare( "update " . $iamb->threads . " set updated = $now where ID = $form->{threadID} ! " ); ! $sth->execute; ! } ! # Get the unread marks right ! $iamb->UpdateUnread( $form->{forum}, $user->{ID} ); ! $sth = $iamb->dbh->prepare( "delete from " . $iamb->unread . " where userID = $user->{ID} and articleID = $form->{ID} and marktype = 1 ! " ); ! $sth->execute; ! $sth->finish; ! $form->{article} = $form->{ID}; ! ( $template, $details ) = Article($iamb); ! ! return ( $template, $details ); ! } # End sub Update =head2 MarkUnread *************** *** 903,906 **** --- 901,907 ---- Current version: $Revision$ $Log$ + Revision 1.30 2002/03/28 16:03:15 rbowen + Code tidying. No functional change. + Revision 1.29 2001/01/28 22:30:14 rbowen Date/Time field name change. |