discuss_userPosts.php

Go to the documentation of this file.
00001 <?PHP
00006 class discuss_userPosts
00007 {
00009         var $filename;                     
00010 
00011         var $posts;                        
00012         
00018         function discuss_userPosts( $username )
00019         {
00020                 global $userinfo_folder;
00021                 
00022                 $this->filename = "$userinfo_folder/$username/discuss_threads.php";
00023                 
00024                 $userposts = array();
00025                 if( file_exists( $this->filename ) )
00026                         include( $this->filename );
00027                 
00028                 $this->posts = $userposts;
00029         }
00030         
00038         function rotate( $postdata )
00039         {
00040                 // Create globalID from postdata
00041                 $globalID = "discuss/" . $postdata["sectionID"] . "/" . $postdata["forumID"] . "/" . $postdata["threadID"];
00042                 if( $postdata["commentID"] != "" )
00043                         $globalID .= "#" . $postdata["commentID"];
00044                 
00045                 // Check if globalID exists already, and remove the existing position if appropriate
00046                 if( array_key_exists( $globalID, $this->posts ) )
00047                         $this->postDeleted( $globalID );
00048                 
00049                 $tmp = array( $globalID => $postdata );
00050                 
00051                 // This only if it is actually a comment
00052                 if( $postdata["commentID"] != "" )
00053                         $tmp[$globalID]["commentID"] = $postdata["commentID"];
00054                 
00055                 $this->posts = $tmp + $this->posts;
00056                 
00057                 return $this->save();
00058         }
00059         
00067         function postDeleted( $globalID )
00068         {
00069                 // Remove from list
00070                 unset( $this->posts[$globalID] );
00071                 return $this->save();
00072         }
00073         
00079         function postcount()
00080         {
00081                 return count( $this->posts );
00082         }
00083         
00089         function save()
00090         {
00091                 if( file_exists( $this->filename ) )
00092                         unlink( $this->filename );
00093                 
00094                 return file_put_contents( $this->filename, array_export( $this->posts, "userposts" ) );
00095         }
00096 }
00097 ?>

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