00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00033 require_once "./include/inc.header.php";
00034 require_once "classes/class.ilObjForum.php";
00035
00036
00037
00038
00039 #ilUtil::redirect('repository.php?ref_id='.$_GET['ref_id']);
00040
00041
00042 function prepOutput($frm)
00043 {
00044 global $tpl, $lng;
00045
00046 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00047 $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00048 sendInfo();
00049 require_once("classes/class.ilForumTabsGUI.php");
00050 $frm_tab =& new ilForumTabsGUI();
00051 $frm_tab->setRefId($_GET["ref_id"]);
00052 $frm_tab->setForum($frm);
00053 $frm_tab->setTabs();
00054
00055 require_once("classes/class.ilForumLocatorGUI.php");
00056 $frm_loc =& new ilForumLocatorGUI();
00057 $frm_loc->setRefId($_GET["ref_id"]);
00058 $frm_loc->setForum($frm);
00059 $frm_loc->display();
00060
00061 }
00062
00063 $lng->loadLanguageModule("forum");
00064
00065 $forumObj = new ilObjForum($_GET["ref_id"]);
00066 $frm =& $forumObj->Forum;
00067
00068 $frm->setForumId($forumObj->getId());
00069 $frm->setForumRefId($forumObj->getRefId());
00070
00071 $frm->setWhereCondition("top_frm_fk = ".$forumObj->getId());
00072 $topicData = $frm->getOneTopic();
00073
00074
00075 if (!$topicData["top_num_threads"])
00076 {
00077 ilUtil::redirect("forums_threads_new.php?ref_id=".$forumObj->getRefId());
00078 }
00079
00080 $ilCtrl->getCallStructure(strtolower("ilObjForumGUI"));
00081
00082 if (!$rbacsystem->checkAccess("read,visible", $_GET["ref_id"]))
00083 {
00084 $ilias->raiseError($lng->txt("permission_denied"),$ilias->error_obj->MESSAGE);
00085 }
00086
00087
00088 if ($_GET["cmd"] != "")
00089 {
00090 $cmd = $_GET["cmd"];
00091 }
00092 else
00093 {
00094 if (is_array($_POST["cmd"]))
00095 {
00096 $cmd = key($_POST["cmd"]);
00097 }
00098 }
00099
00100 switch ($cmd)
00101 {
00102 case "properties":
00103 prepOutput($frm);
00104 $tpl->setVariable("HEADER", $lng->txt("frm")." \"".$forumObj->getTitle()."\"");
00105
00106
00107 include_once("classes/class.ilObjForumGUI.php");
00108 $forum_gui = new ilObjForumGUI("", $_GET["ref_id"], true, false);
00109 $forum_gui->properties();
00110 $tpl->show();
00111 exit;
00112 break;
00113
00114 case "saveProperties":
00115 if (!$rbacsystem->checkAccess("write", $_GET["ref_id"]))
00116 {
00117 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00118 }
00119
00120 include_once("classes/class.ilObjForumGUI.php");
00121 $forum_gui = new ilObjForumGUI("", $_GET["ref_id"], true, false);
00122 $forum_gui->saveProperties();
00123 break;
00124
00125 case "permissions":
00126 prepOutput($frm);
00127 $tpl->setVariable("HEADER", $lng->txt("frm")." \"".$forumObj->getTitle()."\"");
00128 include_once("classes/class.ilObjForumGUI.php");
00129 $forum_gui = new ilObjForumGUI("", $_GET["ref_id"], true, false);
00130 $forum_gui->setFormAction("permSave","forums_threads_liste.php?ref_id=".$_GET["ref_id"].
00131 "&cmd=permSave");
00132 $forum_gui->permObject();
00133 $tpl->show();
00134 exit;
00135 break;
00136
00137 case "permSave":
00138 include_once("classes/class.ilObjForumGUI.php");
00139 $forum_gui = new ilObjForumGUI("", $_GET["ref_id"], true, false);
00140 $forum_gui->setReturnLocation("permSave","forums_threads_liste.php?ref_id=".$_GET["ref_id"]);
00141 $forum_gui->permSaveObject();
00142 exit;
00143 break;
00144
00145 case "addRole":
00146 include_once("classes/class.ilObjForumGUI.php");
00147 $forum_gui = new ilObjForumGUI("", $_GET["ref_id"], true, false);
00148 $forum_gui->setReturnLocation("addRole","forums_threads_liste.php?ref_id=".$_GET["ref_id"]."&cmd=permissions");
00149 $forum_gui->addRoleObject();
00150 exit;
00151 break;
00152
00153 }
00154
00155 $tpl->setVariable("TXT_PAGEHEADLINE", $lng->txt("frm")." \"".$forumObj->getTitle()."\"");
00156 $tpl->addBlockFile("CONTENT", "content", "tpl.forums_threads_liste.html");
00157 $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00158 $tpl->addBlockFile("BUTTONS", "buttons", "tpl.buttons.html");
00159 $tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00160
00161 infoPanel();
00162
00163
00164 if (isset($_POST["cmd"]["submit"]))
00165 {
00166 if(is_array($_POST["forum_id"]))
00167 {
00168 if ($_POST["action"] == "enable_notifications")
00169 {
00170 for ($i = 0; $i < count($_POST["forum_id"]); $i++)
00171 {
00172 $frm->enableNotification($ilUser->getId(), $_POST["forum_id"][$i]);
00173 }
00174
00175 ilUtil::redirect("repository.php?cmd=showThreads&ref_id=".$_GET["ref_id"]);
00176 }
00177 else if ($_POST["action"] == "disable_notifications")
00178 {
00179 for ($i = 0; $i < count($_POST["forum_id"]); $i++)
00180 {
00181 $frm->disableNotification($ilUser->getId(), $_POST["forum_id"][$i]);
00182 }
00183
00184 ilUtil::redirect("repository.php?cmd=showThreads&ref_id=".$_GET["ref_id"]);
00185 }
00186 else
00187 {
00188 $startTbl = "frm_threads";
00189
00190 require_once "forums_export.php";
00191
00192 unset($topicData);
00193 }
00194 }
00195 else
00196 {
00197 ilUtil::redirect("repository.php?cmd=showThreads&ref_id=".$_GET["ref_id"]);
00198 }
00199
00200 }
00201
00202
00203
00204
00205
00206 require_once("classes/class.ilForumLocatorGUI.php");
00207 $frm_loc =& new ilForumLocatorGUI();
00208 $frm_loc->setRefId($_GET["ref_id"]);
00209 $frm_loc->setForum($frm);
00210 $frm_loc->display();
00211
00212 require_once("classes/class.ilForumTabsGUI.php");
00213 $frm_tab =& new ilForumTabsGUI();
00214 $frm_tab->setRefId($_GET["ref_id"]);
00215 $frm_tab->setForum($frm);
00216 $frm_tab->setTabs();
00217
00218 $frm->setWhereCondition("top_frm_fk = ".$frm->getForumId());
00219
00220 if (is_array($topicData = $frm->getOneTopic()))
00221 {
00222 if ($rbacsystem->checkAccess("edit_post", $_GET["ref_id"]))
00223 {
00224 $tpl->setCurrentBlock("btn_cell");
00225 $tpl->setVariable("BTN_LINK","forums_threads_new.php?ref_id=".$_GET["ref_id"]);
00226 $tpl->setVariable("BTN_TXT", $lng->txt("forums_new_thread"));
00227 $tpl->parseCurrentBlock();
00228 }
00229 else
00230 {
00231 $tpl->setVariable("NO_BTN", "<br/><br/>");
00232 }
00233
00234
00235
00236
00237 $frm->setDbTable("frm_data");
00238 $frm->setWhereCondition("top_pk = ".$topicData["top_pk"]);
00239 $frm->updateVisits($topicData["top_pk"]);
00240
00241
00242 $frm->setOrderField("thr_date DESC");
00243 $resThreads = $frm->getThreadList($topicData["top_pk"]);
00244 $thrNum = $resThreads->numRows();
00245 $pageHits = $frm->getPageHits();
00246
00247 if ($thrNum > 0)
00248 {
00249 $z = 0;
00250
00251
00252 if ($thrNum > $pageHits)
00253 {
00254 $params = array(
00255 "ref_id" => $_GET["ref_id"]
00256 );
00257
00258 if (!$_GET["offset"])
00259 {
00260 $Start = 0;
00261 }
00262 else
00263 {
00264 $Start = $_GET["offset"];
00265 }
00266
00267 $linkbar = ilUtil::Linkbar(basename($_SERVER["PHP_SELF"]),$thrNum,$pageHits,$Start,$params);
00268
00269 if ($linkbar != "")
00270 {
00271 $tpl->setVariable("LINKBAR", $linkbar);
00272 }
00273 }
00274
00275
00276 while ($thrData = $resThreads->fetchRow(DB_FETCHMODE_ASSOC))
00277 {
00278 if ($thrNum > $pageHits && $z >= ($Start+$pageHits))
00279 {
00280 break;
00281 }
00282
00283 if (($thrNum > $pageHits && $z >= $Start) || $thrNum <= $pageHits)
00284 {
00285
00286 $usr_data = $frm->getUserData($thrData["thr_usr_id"],$thrData["import_name"]);
00287
00288
00289 $tpl->setCurrentBlock("threads_row");
00290 $rowCol = ilUtil::switchColor($z,"tblrow2","tblrow1");
00291 $tpl->setVariable("ROWCOL", $rowCol);
00292
00293 $thrData["thr_date"] = $frm->convertDate($thrData["thr_date"]);
00294 $tpl->setVariable("DATE",$thrData["thr_date"]);
00295 $tpl->setVariable("TITLE","<a href=\"forums_frameset.php?thr_pk=".
00296 $thrData["thr_pk"]."&ref_id=".$_GET["ref_id"]."\">".
00297 $thrData["thr_subject"]."</a>");
00298
00299 $tpl->setVariable("NUM_POSTS",$thrData["thr_num_posts"]);
00300
00301 $tpl->setVariable("NUM_VISITS",$thrData["visits"]);
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311 if($thrData["thr_usr_id"] && $usr_data["usr_id"] != 0)
00312 {
00313 $tpl->setVariable("AUTHOR","<a href=\"forums_user_view.php?ref_id=".$_GET["ref_id"]."&user=".
00314 $usr_data["usr_id"]."&backurl=forums_threads_liste&offset=".
00315 $Start."\">".$usr_data["login"]."</a>");
00316 }
00317 else
00318 {
00319 $tpl->setVariable("AUTHOR",$usr_data["login"]);
00320 }
00321
00322
00323
00324 $lpCont = "";
00325 if ($thrData["thr_last_post"] != "")
00326 {
00327 $lastPost = $frm->getLastPost($thrData["thr_last_post"]);
00328 }
00329
00330 $last_usr_data = $frm->getUserData($lastPost["pos_usr_id"],$lastPost["import_name"]);
00331 if (is_array($lastPost))
00332 {
00333 $lastPost["pos_message"] = $frm->prepareText($lastPost["pos_message"]);
00334 $lpCont = $lastPost["pos_date"]."<br/>".strtolower($lng->txt("from"))." ";
00335 $lpCont .= "<a href=\"forums_frameset.php?pos_pk=".
00336 $lastPost["pos_pk"]."&thr_pk=".$lastPost["pos_thr_fk"]."&ref_id=".
00337 $_GET["ref_id"]."#".$lastPost["pos_pk"]."\">".$last_usr_data["login"]."</a>";
00338 }
00339
00340 $tpl->setVariable("LAST_POST", $lpCont);
00341
00342 $tpl->setVariable("FORUM_ID", $thrData["thr_pk"]);
00343 $tpl->setVariable("THR_TOP_FK", $thrData["thr_top_fk"]);
00344
00345 $tpl->setVariable("TXT_PRINT", $lng->txt("print"));
00346
00347 $tpl->setVariable("THR_IMGPATH",$tpl->tplPath);
00348
00349 if ($ilias->getSetting("forum_notification") != 0 &&
00350 $frm->isNotificationEnabled($ilUser->getId(), $thrData["thr_pk"]))
00351 {
00352 $tpl->setVariable("NOTIFICATION_ENABLED", $lng->txt("forums_notification_enabled"));
00353 }
00354
00355 $tpl->parseCurrentBlock("threads_row");
00356
00357 }
00358
00359 $z ++;
00360
00361 }
00362
00363 $tpl->setVariable("TXT_SELECT_ALL", $lng->txt("select_all"));
00364 $tpl->setVariable("FORMACTION", basename($_SERVER["PHP_SELF"])."?ref_id=".$_GET["ref_id"]);
00365 $tpl->setVariable("TXT_OK",$lng->txt("ok"));
00366 $tpl->setVariable("TXT_EXPORT_HTML", $lng->txt("export_html"));
00367 $tpl->setVariable("TXT_EXPORT_XML", $lng->txt("export_xml"));
00368 if ($ilias->getSetting("forum_notification") != 0)
00369 {
00370 $tpl->setVariable("TXT_DISABLE_NOTIFICATION", $lng->txt("forums_disable_notification"));
00371 $tpl->setVariable("TXT_ENABLE_NOTIFICATION", $lng->txt("forums_enable_notification"));
00372 }
00373 $tpl->setVariable("IMGPATH",$tpl->tplPath);
00374
00375 }
00376
00377 }
00378 else
00379 {
00380 $tpl->setCurrentBlock("threads_no");
00381 $tpl->setVariable("TXT_MSG_NO_THREADS_AVAILABLE",$lng->txt("forums_threads_not_available"));
00382 $tpl->parseCurrentBlock("threads_no");
00383 }
00384
00385 $tpl->setCurrentBlock("threadtable");
00386 $tpl->setVariable("COUNT_THREAD", $lng->txt("forums_count_thr").": ".$thrNum);
00387 $tpl->setVariable("TXT_DATE", $lng->txt("date"));
00388 $tpl->setVariable("TXT_TITLE", $lng->txt("title"));
00389 $tpl->setVariable("TXT_TOPIC", $lng->txt("forums_thread"));
00390 $tpl->setVariable("TXT_AUTHOR", $lng->txt("author"));
00391 $tpl->setVariable("TXT_NUM_POSTS", $lng->txt("forums_articles"));
00392 $tpl->setVariable("TXT_NUM_VISITS", $lng->txt("visits"));
00393 $tpl->setVariable("TXT_LAST_POST", $lng->txt("forums_last_post"));
00394 $tpl->parseCurrentBlock("threadtable");
00395
00396
00397
00398 if ($_GET["message"])
00399 {
00400 $tpl->addBlockFile("MESSAGE", "message2", "tpl.message.html");
00401 $tpl->setCurrentBlock("message2");
00402 $tpl->setVariable("MSG", urldecode( $_GET["message"]));
00403 $tpl->parseCurrentBlock();
00404 }
00405
00406 $tpl->setVariable("TPLPATH", $tpl->vars["TPLPATH"]);
00407
00408 $tpl->show();
00409 ?>