Source for file api.forum.php

Documentation is available at api.forum.php

  1. <?php
  2. ////////////////////////////////////////////////////////////////////////////////
  3. // Copyright (C) ReloadCMS Development Team //
  4. // http://reloadcms.sf.net //
  5. // //
  6. // This program is distributed in the hope that it will be useful, //
  7. // but WITHOUT ANY WARRANTY, without even the implied warranty of //
  8. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
  9. // //
  10. // This product released under GNU General Public License v2 //
  11. ////////////////////////////////////////////////////////////////////////////////
  12.  
  13.  
  14.  
  15. class forum{
  16. var $topics = array();
  17. var $error = '';
  18. var $sort_all = array();
  19. function forum(){
  20. if(!$this->loadTopicsData()){
  21. return false;
  22. }
  23. }
  24. function loadTopicsData(){
  25. if(!is_readable(FORUM_PATH . 'topic_index.dat')){
  26. $this->error = __('Cannot load topics data');
  27. return false;
  28. }
  29. $content = file_get_contents(FORUM_PATH . 'topic_index.dat');
  30. if(($topics = @unserialize($content)) == false){
  31. $this->error = __('Topics data corrupted');
  32. return false;
  33. }
  34. $this->topics = $topics;
  35. return true;
  36. }
  37. function getTopicData($topic_id){
  38. return $this->topics[$topic_id];
  39. }
  40. function getFreshTopics($number){
  41. $this->sortTopics($this->sort_all);
  42. return array_slice($this->sort_all, 0, $number);
  43. }
  44. function sortTopics(&$output, $method = 'all'){
  45. switch ($method){
  46. case 'all' :
  47. $output = array();
  48. foreach ($this->topics as $topic_id => $topic) {
  49. if(!empty($topic)){
  50. $output[$topic['last_reply']] = $topic_id;
  51. }
  52. }
  53. krsort($output);
  54. return true;
  55. break;
  56. }
  57. }
  58. }
  59.  
  60. ?>

Documentation generated on Fri, 08 Jun 2007 12:21:17 +0300 by phpDocumentor 1.3.0RC3