00001 <?PHP
00006 class discussSection
00007 {
00008 var $sectionID;
00009 var $globalID;
00010 var $title;
00011 var $description;
00012 var $viewLevel;
00013 var $forums;
00014 var $forumPositions;
00015
00016 var $forumKeys;
00017
00018 function discussSection($sectionID)
00019 {
00020 if( $_POST["discussSectionEdit"]["sectionID"] == $sectionID && $_POST["save_section"] && isAllowed("modules_discuss_admin") )
00021 {
00022 $this->sectionID = $_POST["discussSectionEdit"]["sectionID"];
00023 $this->load();
00024 $this->title = stripslashes($_POST["discussSectionEdit"]["title"]);
00025 $this->description = stripslashes($_POST["discussSectionEdit"]["description"]);
00026 if( $_POST["discussSectionEdit"]["viewLevel"] )
00027 $this->viewLevel = 1;
00028 else
00029 $this->viewLevel = 0;
00030
00031 $this->save();
00032 }
00033 else
00034 {
00035 $this->sectionID = $sectionID;
00036 $this->load();
00037 }
00038 $this->globalID = "discuss/$sectionID";
00039 }
00040
00041 function load()
00042 {
00043 global $discussContentDirectory;
00044
00045 if( file_exists( "$discussContentDirectory/{$this->sectionID}/options.php" ) )
00046 include( "$discussContentDirectory/{$this->sectionID}/options.php" );
00047
00048 $this->title = $section_options["title"];
00049 $this->description = $section_options["description"];
00050 $this->viewLevel = $section_options["viewLevel"];
00051 $this->forumPositions = $section_options["forumPositions"];
00052
00053 foreach( $this->forumPositions as $key => $value )
00054 {
00055 $this->forumKeys[$value] = $key;
00056 $this->forums[$key] = new discussForum( $this->sectionID, $value );
00057 $this->forums[$key]->parentSection =& $this;
00058 }
00059 }
00060
00061 function save()
00062 {
00063 global $discussContentDirectory;
00064
00065 if( file_exists( "$discussContentDirectory/{$this->sectionID}/options.php" ) )
00066 unlink( "$discussContentDirectory/{$this->sectionID}/options.php" );
00067
00068 $section_options["title"] = $this->title;
00069 $section_options["description"] = $this->description;
00070 $section_options["viewLevel"] = $this->viewLevel;
00071 $section_options["forumPositions"] = $this->forumPositions;
00072
00073 file_put_contents( "$discussContentDirectory/{$this->sectionID}/options.php", array_export( $section_options, "section_options" ) );
00074 }
00075
00079 function forumByID( $forumID )
00080 {
00081 return $this->forumKeys[$forumID];
00082 }
00083
00084 function userCanView()
00085 {
00086
00087 if( $this->viewLevel == 1 )
00088 return true;
00089
00090
00091 if( isAuth() )
00092 return true;
00093
00094
00095 return false;
00096 }
00097
00098 function render()
00099 {
00100 global $subscriptions;
00101
00102 if( $_REQUEST["discuss_moveSuccess"] == "true" )
00103 discuss_rebuildUserCache();
00104
00105 if( $this->userCanView() )
00106 {
00107 if( $_REQUEST["discuss_sectionID"] == $this->sectionID && isset( $_REQUEST["discuss_forumID"] ))
00108 {
00109 if( !isset( $_REQUEST["discuss_threadID"] ) )
00110 $this->forums[$this->forumByID($_REQUEST["discuss_forumID"])]->loadThreads();
00111 return $this->forums[$this->forumByID($_REQUEST["discuss_forumID"])]->render();
00112 }
00113 else if( ! isset( $_REQUEST["discuss_forumID"] ) )
00114 {
00115
00116 $rendered_content = "
00117 <div class=\"discuss_sectionContainer\">
00118 <div class=\"discuss_sectionHeader\">
00119 <span class=\"discuss_sectionSubscribe\">" . $subscriptions->renderSubscribeControl( $this->globalID, false, " discussSubscribeControl" ) . "</span>
00120 <span class=\"discuss_sectionTitle\">{$this->title}</span>
00121 <span class=\"discuss_sectionDescription\">{$this->description}</span>
00122 </div>";
00123
00124 foreach( $this->forumPositions as $position => $positionID )
00125 $rendered_forums .= $this->forums[$this->forumByID($positionID)]->renderBlock();
00126
00127
00128 $rendered_content .= "$rendered_forums
00129 </div>";
00130
00131
00132 if( $rendered_forums == "" )
00133 $rendered_content = "";
00134 }
00135 }
00136 return $rendered_content;
00137 }
00138 }
00139 ?>