discussThread.php

Go to the documentation of this file.
00001 <?PHP
00006 class discussThread extends lockableClass
00007 {
00008         var $sectionID;             
00009         var $forumID;               
00010         var $threadID;              
00011         var $globalID;              
00012         
00013         var $title;                 
00014         var $content;               
00015         var $replies;               
00016         var $lastReplyBy;           
00017         var $repliesCount;          
00018         
00019         var $created;               
00020         var $lastChanged;           
00021         var $lastChangedBy;         
00022         var $isSticky;              
00023         
00024         var $owner;                 
00025         var $viewLevel;             
00026         var $replyLevel;            
00027         var $editLevel;             
00028         
00029         var $filename;              
00030         var $thisThreadURL;         
00031         var $isChanged = false;     
00032         var $changeIsReply = false; 
00033         var $newThread = false;     
00034         var $parentForum = 0;       
00035         
00045         function discussThread($sectionID, $forumID, $threadID = 0, $parentForum = null)
00046         {
00047                 global $globalID, $discussContentDirectory;
00048                 
00049                 $this->sectionID = $sectionID;
00050                 $this->forumID = $forumID;
00051                 $this->threadID = $threadID;
00052                 
00053                 if( $parentForum != null )
00054                         $this->parentForum = &$parentForum;
00055                 
00056                 $this->makeFilename();
00057                 if( ! $this->lock() )
00058                         die( renderInformationBox( i18n("Timeout!"), i18n("Too many users are attempting to access this thread. Please try again.") ) );
00059                 $this->load();
00060                 
00061                 if( $this->userCanEdit() && $_POST["discussEdit"]["threadID"] == $this->threadID ) // Are we editing this thread?
00062                 {
00063                         $this->title = stripslashes($_POST["discussEdit"]["title"]);
00064                         $this->description = stripslashes($_POST["discussEdit"]["description"]);
00065                         $this->content = stripslashes($_POST["discussEdit"]["content"]);
00066                         $this->isSticky = $_POST["discussEdit"]["isSticky"] ? 1 : 0;
00067                         $this->owner = $_POST["discussEdit"]["owner"];
00068                         $this->viewLevel = $_POST["discussEdit"]["viewLevel"];
00069                         $this->replyLevel = $_POST["discussEdit"]["replyLevel"];
00070                         $this->editLevel = $_POST["discussEdit"]["editLevel"];
00071                         $this->lastChanged = time();
00072                         $this->lastChangedBy = currentUser();
00073                         
00074                         if( $_POST["discuss_saveThread"] )
00075                                 $this->isChanged = true;
00076                 }
00077                 if( $threadID != 0 )
00078                         $this->save();
00079                 $this->unlock();
00080                 
00081                 $this->globalID = "discuss/$sectionID/$forumID/$threadID";
00082                 $this->thisThreadURL = globalIDtoURL($this->globalID);
00083                 
00084                 if( $this->userCanEdit() && $_REQUEST["discuss_deleteThreadConfirm"] == "true" && $globalID == $this->globalID )
00085                 {
00086                         $errorHandler = new errorHandler( $this->thisThreadURL );
00087                         $errorHandler->handle( i18n("Attempting to delete the thread"), $this->delete() );
00088                         if( $errorHandler->handled == false )
00089                                 header( "Location: " . str_replace( "&amp;", "&", globalIDtoURL( "discuss/$sectionID/$forumID", array( "discuss_deleteSuccess" => "true" ) ) ) );
00090                         else
00091                                 $this->content = $errorHandler->render() . $this->content;
00092                 }
00093                 else if( $this->parentForum != null && $this->parentForum->isModerator() && $_POST["move_thread"] && $this->parentForum->globalID != $_POST["moveto"] )
00094                 {
00095                         list( $top, $otherSectionID, $otherForumID ) = explode("/", $_POST["moveto"]);
00096                         $otherForum = new discussForum($otherSectionID, $otherForumID);
00097                         // You can't move a post to a forum you are not moderator of... Just for checking, really, but still applies!
00098                         if( $otherForum->isModerator() )
00099                         {
00100                                 $movefrom = "$discussContentDirectory/{$this->sectionID}/forums/{$this->forumID}/threads/{$this->threadID}.php";
00101                                 $moveto = "$discussContentDirectory/{$otherForum->sectionID}/forums/{$otherForum->forumID}/threads/{$this->threadID}.php";
00102                                 
00103                                 RecursiveMkdir("$discussContentDirectory/{$otherForum->sectionID}/forums/{$otherForum->forumID}/threads");
00104                                 
00105                                 if( rename( $movefrom, $moveto ) )
00106                                 {
00107                                         if( $this->parentForum->lock() )
00108                                         {
00109                                                 if( $otherForum->lock() )
00110                                                 {
00111                                                         $this->parentForum->threadsCount--;
00112                                                         $this->parentForum->lastChanged = time();
00113                                                         $this->parentForum->lastChangedBy = currentUser();
00114                                                         $this->parentForum->save();
00115                                                         if( $this->parentForum->threadsCount == 0 )
00116                                                                 rmdir("$discussContentDirectory/{$this->sectionID}/forums/{$this->forumID}/threads");
00117                                                         
00118                                                         $otherForum->threadsCount++;
00119                                                         $otherForum->lastChanged = time();
00120                                                         $otherForum->lastChangedBy = currentUser();
00121                                                         $otherForum->save();
00122                                                         $otherForum->unlock();
00123                                                 }
00124                                                 else
00125                                                         die( renderInformationBox( i18n("Timeout error!"), i18n("Too many people are attempting to access the forum. Please try again.") ) );
00126                                                 
00127                                                 $this->parentForum->unlock();
00128                                         }
00129                                         else
00130                                                 die( renderInformationBox( i18n("Timeout error!"), i18n("Too many people are attempting to access the forum. Please try again.") ) );
00131                                         header("Location: " . $otherForum->thisForumURL . "&discuss_moveSuccess=true");
00132                                 }
00133                         }
00134                 }
00135         }
00136         
00142         function load()
00143         {
00144                 if( file_exists( $this->filename ) )
00145                 {
00146                         include( $this->filename );
00147                         $this->title = $thread_data["title"];
00148                         $this->description = $thread_data["description"];
00149                         $this->content = $thread_data["content"];
00150                         $this->replies = $thread_data["replies"];
00151                         $this->lastReplyBy = $thread_data["lastReplyBy"];
00152                         $this->repliesCount = $thread_data["repliesCount"];
00153                         $this->isSticky = $thread_data["isSticky"];
00154                         $this->owner = $thread_data["owner"];
00155                         $this->viewLevel = $thread_data["viewLevel"];
00156                         $this->replyLevel = $thread_data["replyLevel"];
00157                         $this->editLevel = $thread_data["editLevel"];
00158                         $this->created = $thread_data["created"];
00159                         $this->lastChanged = $thread_data["lastChanged"];
00160                         $this->lastChangedBy = $thread_data["lastChangedBy"];
00161                         return true;
00162                 }
00163                 else
00164                 {
00165                         return false;
00166                 }
00167         }
00168         
00169         
00175         function save( $parentLocked = false )
00176         {
00177                 global $subscriptions;
00178                 if( $this->isChanged )
00179                 {
00180                         if( $parentLocked || $this->parentForum->lock() )
00181                         {
00182                                 $thread_data["title"] = $this->title;
00183                                 $thread_data["description"] = $this->description;
00184                                 $thread_data["content"] = $this->content;
00185                                 $thread_data["replies"] = $this->replies;
00186                                 $thread_data["lastReplyBy"] = $this->lastReplyBy;
00187                                 $thread_data["repliesCount"] = $this->repliesCount;
00188                                 $thread_data["isSticky"] = $this->isSticky;
00189                                 $thread_data["owner"] = $this->owner;
00190                                 $thread_data["viewLevel"] = $this->viewLevel;
00191                                 $thread_data["replyLevel"] = $this->replyLevel;
00192                                 $thread_data["editLevel"] = $this->editLevel;
00193                                 $thread_data["created"] = $this->created;
00194                                 $thread_data["lastChanged"] = $this->lastChanged;
00195                                 $thread_data["lastChangedBy"] = $this->lastChangedBy;
00196                                 
00197                                 if( file_exists( $this->filename ) )
00198                                         if( !unlink( $this->filename ) )
00199                                                 return false;
00200                                 
00201                                 $postdata = array(
00202                                         "title" => $thread_data["title"],
00203                                         "viewLevel" => $thread_data["viewLevel"],
00204                                         "timestamp" => $thread_data["lastChanged"],
00205                                         "sectionID" => $this->sectionID,
00206                                         "forumID" => $this->forumID,
00207                                         "threadID" => $this->threadID
00208                                 );
00209                                 
00210                                 if( $this->newThread )
00211                                 {
00212                                         $subject = i18n( "The thread ##0## was created (in ##1##)", array( $this->title, $this->parentForum->title ) );
00213                                         $message = i18n( "The text in ##0## is as follows:", array( $this->title ) ) . "\n" . $this->content . "\n---\n" . globalIDtoURL($this->globalID);
00214                                 }
00215                                 else if( $this->changeIsReply )
00216                                 {
00217                                         $subject = i18n( "The thread ##0## has a new comment by ##1## (in ##2##)", array( $this->title, getUserInfo( $this->lastReplyBy, "name" ), $this->parentForum->title ) );
00218                                         $message = i18n( "The comment text is as follows:" ) . "\n" . $this->lastReply . "\n---\n" . globalIDtoURL($this->globalID . "#" . $_REQUEST["newcommentid"]);
00219                                         $postdata["title"] = i18n("[Commented] ##0##", array( $postdata["title"] ) );
00220                                         $postdata["commentID"] = $_REQUEST["newcommentid"];
00221                                 }
00222                                 else
00223                                 {
00224                                         $subject = i18n( "The thread ##0## was edited (in ##1##)", array( $this->title, $this->parentForum->title ) );
00225                                         $message = i18n( "The new text in ##0## is as follows:", array( $this->title ) ) . "\n" . $this->content . "\n---\n" . globalIDtoURL($this->globalID);
00226                                         $postdata["title"] = i18n("[Edited] ##0##", array( $postdata["title"] ) );
00227                                 }
00228                                 $subscriptions->handle( $this->globalID, $this->owner, $this->viewLevel, $subject, $message );
00229                                 
00230                                 if( isAuth() )
00231                                 {
00232                                         $userposts = new discuss_userPosts( $this->owner );
00233                                         $userposts->rotate( $postdata );
00234                                         unset( $userposts );
00235                                 }
00236                                 
00237                                 $this->parentForum->load();
00238                                 $this->parentForum->lastChanged = $this->lastChanged;
00239                                 $this->parentForum->lastChangedBy = $this->lastChangedBy;
00240                                 $this->parentForum->save();
00241                                 // We really should not be unlocking te parent forum if the caller locked the forum... could cause some horrible stuff :)
00242                                 if( $parentLocked == false )
00243                                         $this->parentForum->unlock();
00244                         }
00245                         else
00246                                 die( renderInformationBox( i18n("Timeout error!"), i18n("Too many people are attempting to access the forum. Please try again.") ) );
00247                         
00248                         return file_put_contents( $this->filename, array_export( $thread_data, "thread_data" ) );
00249                 }
00250         }
00251         
00259         function delete()
00260         {
00261                 global $subscriptions;
00262                 $subscriptions->removeGlobalID( $this->globalID );
00263                 
00264                 if( file_exists( $this->filename ) )
00265                         return unlink( $this->filename );
00266         }
00267         
00275         function move($whereto)
00276         {
00277                 if( $this->delete() )
00278                 {
00279                         $this->forumID = $whereto;
00280                         $this->isChanged = true;
00281                         $this->makeFilename();
00282                         return $this->save();
00283                 }
00284                 return false;
00285         }
00286         
00290         function userCanEdit()
00291         {
00292                 if( $this->owner == currentUser() )
00293                         return true;
00294                 
00295                 if( userAllows($this->owner, $this->editLevel ) )
00296                         return true;
00297                 
00298                 if( $this->parentForum != 0 && $this->parentForum->isModerator() )
00299                         return true;
00300                 
00301                 // Admin can always edit
00302                 if( isAllowed( "global_admin" ) )
00303                         return true;
00304                 
00305                 // Nothing was caught, the user is not allowed to edit...
00306                 return false;
00307         }
00308         
00312         function userCanView()
00313         {
00314                 if( $this->owner == currentUser() )
00315                         return true;
00316                 
00317                 if( userAllows($this->owner, $this->viewLevel ) )
00318                         return true;
00319                 
00320                 if( $this->parentForum != 0 && $this->parentForum->isModerator() )
00321                         return true;
00322                 
00323                 // Admin can always edit
00324                 if( isAllowed( "global_admin" ) )
00325                         return true;
00326                 
00327                 // Nothing was caught, the user is not allowed to edit...
00328                 return false;
00329         }
00330         
00334         function makeFilename()
00335         {
00336                 global $discussContentDirectory;
00337                 if( ! is_dir( "$discussContentDirectory/{$this->sectionID}/forums/{$this->forumID}/threads" ) )
00338                         RecursiveMkdir( "$discussContentDirectory/{$this->sectionID}/forums/{$this->forumID}/threads" );
00339                 
00340                 $this->filename = "$discussContentDirectory/{$this->sectionID}/forums/{$this->forumID}/threads/{$this->threadID}.php";
00341                 $this->lockfile = "$discussContentDirectory/{$this->sectionID}/forums/{$this->forumID}/threads/{$this->threadID}.lock";
00342                 $this->globalID = "discuss/{$this->sectionID}/{$this->forumID}/{$this->threadID}";
00343         }
00344         
00348         function renderThreadEditor($thread_data = "", $parentForum = "") {
00349                 global $formatting_toolbar, $permissionlevels_array;
00350                 
00351                 // If the thread data is "", then we're called from $this, so use $this' data
00352                 if( $thread_data == "" )
00353                 {
00354                         $title = i18n("Editing existing thread");
00355                         $commandTitle = i18n("Save thread");
00356                         $isModerator = $this->parentForum->isModerator();
00357                         $thread_data["title"] = $this->title;
00358                         $thread_data["description"] = $this->description; // This is optional
00359                         $thread_data["content"] = $this->content;
00360                         $thread_data["isSticky"] = $this->isSticky;
00361                         $thread_data["owner"] = $this->owner;
00362                         $thread_data["viewLevel"] = $this->viewLevel;
00363                         $thread_data["replyLevel"] = $this->replyLevel;
00364                         $thread_data["editLevel"] = $this->editLevel;
00365                         $thread_info = "<input type=\"hidden\" name=\"discussEdit[threadID]\" value=\"{$this->threadID}\" />";
00366                 }
00367                 else
00368                 {
00369                         $isModerator = $parentForum->isModerator();
00370                         $title = i18n("Creating a new thread");
00371                         $commandTitle = i18n("Create thread");
00372                         $thread_info = "<input type=\"hidden\" name=\"discuss_newThread\" value=\"true\" />";
00373                         
00374                 }
00375                 
00376                 foreach( $permissionlevels_array as $level => $description )
00377                 {
00378                         $viewlevel_selected = ( $level == $thread_data["viewLevel"] ) ? " selected" : "";
00379                         $temp_viewLevel .= "<option value=\"$level\"$viewlevel_selected>$description</option>";
00380                         
00381                         $replylevel_selected = ( $level == $thread_data["replyLevel"] ) ? " selected" : "";
00382                         $temp_replyLevel .= "<option value=\"$level\"$replylevel_selected>$description</option>";
00383                         
00384                         $editlevel_selected = ( $level == $thread_data["editLevel"] ) ? " selected" : "";
00385                         $temp_editLevel .= "<option value=\"$level\"$editlevel_selected>$description</option>";
00386                 }
00387                 
00388                 // Render the editor...
00389                 $editor = "
00390                         <form name=\"discuss_editor\" method=\"post\" action=\"" . $this->thisThreadURL . "\">
00391                         <input type=\"hidden\" name=\"discuss_sectionID\" value=\"{$_REQUEST['discuss_sectionID']}\" />
00392                         <input type=\"hidden\" name=\"discuss_forumID\" value=\"{$_REQUEST['discuss_forumID']}\" />
00393                         $thread_info
00394                         <table class=\"setup\">
00395                         <tr class=\"setup\"><th colspan=\"2\"><a class=\"namedanchor\" name=\"thread_editor\"> </a>" . $title . "</th></tr>
00396                         <tr class=\"setup\">
00397                                 <td class=\"setup\" width=\"50%\">" . i18n("Title") . ":</td>
00398                                 <td class=\"setup\"><input style=\"width: 100%\" type=\"text\" name=\"discussEdit[title]\" value=\"{$thread_data['title']}\" /></td>
00399                         </tr>
00400                         <tr class=\"setup\">
00401                                 <td class=\"setup\" width=\"50%\">" . i18n("Description (optional)") . ":</td>
00402                                 <td class=\"setup\"><input style=\"width: 100%\" type=\"text\" name=\"discussEdit[description]\" value=\"{$thread_data['description']}\" /></td>
00403                         </tr>
00404                         <tr class=\"setup\">
00405                                 <td class=\"setup\" width=\"50%\">" . i18n("Owner") . ":</td>
00406                                 <td class=\"setup\"><input style=\"width: 100%\" type=\"text\" name=\"discussEdit[owner]\" value=\"{$thread_data['owner']}\" /></td>
00407                         </tr>
00408                         <tr class=\"setup\">
00409                                 <td class=\"setup\" width=\"50%\">" . i18n("The following users can view the thread") . ":</td>
00410                                 <td class=\"setup\"><select style=\"width: 100%\" name=\"discussEdit[viewLevel]\">$temp_viewLevel</select></td>
00411                         </tr>
00412                         <tr class=\"setup\">
00413                                 <td class=\"setup\" width=\"50%\">" . i18n("The following users can reply to the thread") . ":</td>
00414                                 <td class=\"setup\"><select style=\"width: 100%\" name=\"discussEdit[replyLevel]\">$temp_replyLevel</select></td>
00415                         </tr>
00416                         <tr class=\"setup\">
00417                                 <td class=\"setup\" width=\"50%\">" . i18n("The following users can edit this post") . ":</td>
00418                                 <td class=\"setup\"><select style=\"width: 100%\" name=\"discussEdit[editLevel]\">$temp_editLevel</select></td>
00419                         </tr>";
00420                 if( $isModerator )
00421                         $editor .= "
00422                         <tr class=\"setup\">
00423                                 <td class=\"setup\" width=\"50%\">" . i18n("The post is sticky") . ":</td>
00424                                 <td class=\"setup\"><label><input type=\"checkbox\" name=\"discussEdit[isSticky]\"$temp_isSticky />" . i18n("Keep the thread first in the forum (sticky)") . "</label></td>
00425                         </tr>";
00426                 $editor .= "
00427                         <tr class=\"setup\">
00428                                 <td class=\"setup\" colspan=\"2\">" . i18n("Your post") . ":
00429                         </tr>
00430                         $formatting_toolbar
00431                         <tr class=\"setup\">
00432                                 <td class=\"setup\" colspan=\"2\">
00433                                 <textarea rows=\"15\" cols=\"70\" style=\"width: 100%;\" id=\"edit\" name=\"discussEdit[content]\">{$thread_data['content']}</textarea>
00434                                 </td>
00435                         </tr>
00436                         <tr class=\"setup\">
00437                                 <td class=\"setup\"><input type=\"submit\" name=\"discuss_saveThread\" value=\"$commandTitle\" /> <input type=\"submit\" name=\"discuss_preview\" value=\"" . i18n("Preview thread") . "\" /></td>
00438                                 <td class=\"setup wikirightalign\"><input type=\"reset\" value=\"" . i18n("Reset") . "\" /></td>
00439                         </tr>
00440                         </table>
00441                         </form>";
00442                         
00443                 return $editor;
00444         }
00445         
00451         function renderBlock()
00452         {
00453                 $data = "<div class=\"discuss_threadHeader\"><a
00454                                 href=\"{$this->thisThreadURL}\" class=\"discuss_threadHeader\"><span
00455                                 class=\"discuss_threadLink\">" . i18n("Go") . " &raquo;</span><span
00456                                 class=\"discuss_threadTitle\">{$this->title}</span><span
00457                                 class=\"discuss_threadDescription\">{$this->description}</span></a>";
00458                 
00459                 // Check wether the user wants to show the details or not...
00460                 if( getUserInfo( currentUser(), "discuss_verboseListings" ) != 1 )
00461                 {
00462                         $data .= "<span
00463                                 class=\"discuss_threadAuthor\">" . i18n("Posted by") . ": " . parse_profilelinks( "%%{$this->owner}%%" ) . "</span><span
00464                                 class=\"discuss_threadNumberOfReplies\">" . i18n("Replies") . ": {$this->repliesCount}</span><span
00465                                 class=\"discuss_threadLastChangedBy\">" . i18n("Last change by") . " " . parse_profilelinks( "%%{$this->lastChangedBy}%%" ) . " </span><span
00466                                 class=\"discuss_threadLastChanged\">" . i18n("Last updated") . ": " . formatTime( $this->lastChanged ) . "</span>";
00467                 }
00468                 else
00469                 {
00470                         $data .= "<span class=\"discuss_threadUnverbose\">" . i18n("Last change by ##0## on ##1##", array( parse_profilelinks( "%%{$this->lastChangedBy}%%" ), formatTime( $this->lastChanged ) ) ) . " </span>";
00471                 }
00472                 
00473                 $data .= "</div>";
00474                 
00475                 // Render title, owner, number of replies, created date, last change date, last comment by
00476                 return $data;
00477         }
00478         
00484         function render()
00485         {
00486                 global $subscriptions, $discuss_options;
00487                 if( $this->parentForum->isModerator() && $_REQUEST["discuss_moveThread"] == "true" )
00488                 {
00489                         $commandModerator = "<span class=\"discuss_threadModeratorLink\">" .
00490                                 drawCommand( i18n("Abort move"), i18n("Abort move"), $this->thisThreadURL, " discuss_threadModeratorMove" ) .
00491                                 "</span>";
00492                         
00493                         foreach( $discuss_options["sectionPositions"] as $position => $sectionID )
00494                         {
00495                                 $currentSection = "";
00496                                 
00497                                 $theSection = new discussSection($sectionID);
00498                                 
00499                                 foreach( $theSection->forums as $key => $theForum )
00500                                 {
00501                                         if( $theForum->isModerator() )
00502                                         {
00503                                                 if( $theForum->globalID == $this->parentForum->globalID )
00504                                                         $default = " default";
00505                                                 else
00506                                                         $default = "";
00507                                                 $currentSection .= "
00508                                                         <option$default value=\"" . $theForum->globalID . "\">" . $theForum->title . "</option>";
00509                                         }
00510                                 }
00511                                 
00512                                 
00513                                 if( $currentSection != "" )
00514                                         $panel .= "<optgroup label=\"" . $theSection->title . "\">$currentSection</optgroup>";
00515                         }
00516                         $panel = "
00517                                 <form action=\"" . $this->thisThreadURL . "\" method=\"post\">
00518                 <table class=\"options\">
00519                 <tr class=\"option\">
00520                         <td class=\"option\">" . i18n("Where do you want to move this thread?") . "<small class=\"comment\">" . i18n("Select the forum where you wish to move this thread. Note that only forums where you are moderator are shown") . "</small></td>
00521                         <td class=\"option\"><select style=\"width: 100%;\" class=\"option_select\" name=\"moveto\">" . $panel . "</select></td>
00522                 </tr>
00523                 <tr class=\"options\">
00524                         <td width=\"50%\" class=\"options-bottomleft\"><input type=\"submit\" class=\"options_save\" name=\"move_thread\" value=\"" .i18n("Move thread") . "\" /></td>
00525                         <td width=\"50%\" class=\"options-bottomright\"><input type=\"reset\" class=\"options_reset\" value=\"" . i18n("Reset") . "\" /></td>
00526                 </tr>
00527                 </table>
00528                                 </form>";
00529                         
00530                         $renderedModerator = renderInformationBox( i18n("Move thread?"), $panel, false );
00531                 }
00532                 else if( $this->parentForum->isModerator() )
00533                 {
00534                         $commandModerator = "<span class=\"discuss_threadModeratorLink\">" .
00535                                 drawCommand( i18n("Move"), i18n("Move"), $this->thisThreadURL . "&amp;discuss_moveThread=true", " discuss_threadModeratorMove" ) .
00536                                 "</span>";
00537                 }
00538                 
00539                 if( $this->userCanEdit() && $_REQUEST["discuss_editThread"] == "true" )
00540                 {
00541                         $commandEdit = "<span class=\"discuss_threadEditLink\">
00542                                         " . drawCommand( i18n("Delete"), i18n("Delete"), $this->thisThreadURL . "&amp;discuss_deleteThread=true", " discuss_threadDeleteThread" ) . "
00543                                         " . drawCommand( i18n("Abort edit"), i18n("Abort edit"), $this->thisThreadURL . "&amp;discuss_editThread=false", " discuss_threadEditThread" ) . "
00544                                 </span>";
00545                         $rendered_thread = $this->renderThreadEditor();
00546                 }
00547                 else if ( $this->userCanEdit() && $_REQUEST["discuss_deleteThread"] == "true" )
00548                 {
00549                         $commandEdit = "<span class=\"discuss_threadEditLink\">
00550                                         " . drawCommand( i18n("Abort delete"), i18n("Abort delete"), $this->thisThreadURL . "&amp;discuss_deleteThread=false", " discuss_threadDeleteThread" ) . "
00551                                         " . drawCommand( i18n("Edit"), i18n("Edit"), $this->thisThreadURL . "&amp;discuss_editThread=true", " discuss_threadEditThread" ) . "
00552                                 </span>";
00553                         $rendered_thread = 
00554                                 renderInformationBox(
00555                                         i18n("Delete this thread?"),
00556                                         i18n("Are you sure you wish to delete this thread? Please note - It will delete all replies, and CANNOT be undone.##0####1## ##2####3##",
00557                                                 array(
00558                                                         "<div class=\"wikicenteralign\">",
00559                                                         drawCommand(
00560                                                                 i18n("Delete"),
00561                                                                 i18n("Accept deletion of this thread and all replies"),
00562                                                                 $this->thisThreadURL . "&amp;discuss_deleteThreadConfirm=true"
00563                                                         ),
00564                                                         drawCommand(
00565                                                                 i18n("Abort delete"),
00566                                                                 i18n("Click here to accept deleting the thread"),
00567                                                                 $this->thisThreadURL . "&amp;discuss_deleteThread=false"
00568                                                         ),
00569                                                         "</div>"
00570                                                 )
00571                                         )
00572                                 ) . "<div class=\"discuss_threadContent\">" . parse_page_data( $this->content ) . "</div>";
00573                 }
00574                 else if ( $this->userCanEdit() )
00575                 {
00576                         $commandEdit = "<span class=\"discuss_threadEditLink\">
00577                                         " . drawCommand( i18n("Delete"), i18n("Delete"), $this->thisThreadURL . "&amp;discuss_deleteThread=true", " discuss_threadDeleteThread" ) . "
00578                                         " . drawCommand( i18n("Edit"), i18n("Edit"), $this->thisThreadURL . "&amp;discuss_editThread=true", " discuss_threadEditThread" ) . "
00579                                 </span>";
00580                         $rendered_thread = "<div class=\"discuss_threadContent\">" . parse_page_data( $this->content ) . "</div>";
00581                 }
00582                 else if( $this->userCanView() )
00583                         $rendered_thread = "<div class=\"discuss_threadContent\">" . parse_page_data( $this->content ) . "</div>";
00584                 else
00585                 {
00586                         // If we've gotten to here... The user isn't allowed to view the thread! Tell them they've been bad
00587                         $rendered_thread = renderInformationBox( i18n("Viewing disallowed"), i18n("You are not allowed to view this thread!") );
00588                 }
00589                 
00590                 // Render header (breadcrumbs trail returns to whatever page we were on in pagination, if applicable)
00591                 $rendered_content = "<span
00592                                 class=\"discuss_Breadcrumbs\">
00593                                         " . i18n("You are here:") . "
00594                                         <a href=\"" . globalIDtoURL("discuss") . "\" class=\"discuss_forumBreadcrumbsToTop\">" . i18n("Forum home") . "</a> &raquo;
00595                                         <a href=\"" . globalIDtoURL("discuss/" . $this->sectionID . "/" . $this->forumID ) . "\" class=\"discuss_forumBreadcrumbsForum\">{$this->parentForum->title}</a> &raquo;
00596                                         {$this->title}
00597                                         </span><span
00598                                 class=\"discuss_Navigator\">&nbsp;
00599                                 $rendered_navigator
00600                         </span>
00601                         <div class=\"discuss_threadCommands\">
00602                                 $commandModerator
00603                                 $commandEdit
00604                                 " . $subscriptions->renderSubscribeControl( $this->globalID, false, " discussSubscribeControl" ) . "
00605                                 <span class=\"discuss_threadAddReply\"><a class=\"command\" href=\"#commentshandler\">[" . i18n("Reply") . "]</a></span>
00606                         </div>";
00607                 
00608                 $avatar = getAvatarThumbnail( $this->owner );
00609                 list( $avatarx, $avatary ) = getimagesize( $avatar );
00610                 $avatar = siteURL(true) . $avatar;
00611                 
00612                 // Render the header
00613                 $rendered_content .= "<div class=\"discuss_threadHeader\"><a href=\"" . globalIDtoURL("user/" . $this->owner) . "\" title=\"" . i18n("##0##'s avatar", array( getUserInfo( $this->owner, "name" ) ) ) . "\"><img
00614                                 class=\"comment-avatar\" alt=\"" . i18n("##0##'s avatar", array( getUserInfo( $this->owner, "name" ) ) ) . "\" src=\"$avatar\" width=\"$avatarx\" height=\"$avatary\" /></a><span
00615                                 class=\"discuss_threadTitle\">{$this->title}</span><span
00616                                 class=\"discuss_threadDescription\">{$this->description}</span></div>";
00617                 
00618                 // Render post (edit or not)
00619                 $rendered_content .= "$renderedModerator<div
00620                         class=\"discuss_threadcontents\">$rendered_thread</div>";
00621                 
00622                 if( $_REQUEST["discuss_editThread"] != "true" && userAllows($this->owner, $this->viewLevel) )
00623                 {
00624                         // Render replies (commentshandler)
00625                         $replies = new commentHandler( $this->replies, $this->owner, $this->replyLevel, $this->editLevel );
00626                         $replies->thisPageURL = $this->thisThreadURL;
00627                         $rendered_content .= $replies->renderComments() . $replies->renderCommentsAdder();
00628                         if( $replies->commentsChanged )
00629                         {
00630                                 if( $this->lock() )
00631                                 {
00632                                         $this->load();
00633                                         $this->replies = $replies->comments;
00634                                         $this->repliesCount = $replies->numberOfComments();
00635                                         $this->lastChangedBy = $this->lastReplyBy = str_replace( "%", "", $replies->lastCommenter ); // Last change is both editing and replying...
00636                                         $this->lastReply = $replies->lastComment;
00637                                         $this->isChanged = true;
00638                                         $this->changeIsReply = true;
00639                                         $this->save();
00640                                         $this->unlock();
00641                                         header( "Location: " . str_replace("&amp;", "&", $this->thisThreadURL ) );
00642                                 }
00643                                 else
00644                                         die( renderInformationBox( i18n("Timeout error!"), i18n("Too many people are attempting to access the forum. Please try again.") ) );
00645                         }
00646                 }
00647                 
00648                 return $rendered_content;
00649         }
00650 }
00651 ?>

Generated on Sun Oct 26 20:33:13 2008 for The Travelsized Content Management System by  doxygen 1.5.5