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
00037 require_once "class.ilObjectGUI.php";
00038
00039 class ilObjForumGUI extends ilObjectGUI
00040 {
00045 function ilObjForumGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
00046 {
00047 global $ilCtrl;
00048
00049
00050 $this->ctrl =& $ilCtrl;
00051 $this->ctrl->saveParameter($this,array("ref_id","cmdClass"));
00052
00053 $this->type = "frm";
00054 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
00055
00056 $this->lng->loadLanguageModule('forum');
00057 }
00058
00059 function &executeCommand()
00060 {
00061 $next_class = $this->ctrl->getNextClass($this);
00062 $cmd = $this->ctrl->getCmd();
00063 $this->prepareOutput();
00064
00065 switch($next_class)
00066 {
00067 case 'ilpermissiongui':
00068 include_once("./classes/class.ilPermissionGUI.php");
00069 $perm_gui =& new ilPermissionGUI($this);
00070 $ret =& $this->ctrl->forwardCommand($perm_gui);
00071 break;
00072
00073 default:
00074 if(!$cmd)
00075 {
00076 $cmd = "showThreads";
00077 }
00078 $cmd .= "Object";
00079
00080 $this->$cmd();
00081
00082 break;
00083 }
00084
00085 return true;
00086 }
00087
00088 function markAllReadObject()
00089 {
00090 global $ilUser;
00091
00092 $this->object->markAllThreadsRead($ilUser->getId());
00093
00094 sendInfo($this->lng->txt('forums_all_threads_marked_read'));
00095
00096 $this->showThreadsObject();
00097 return true;
00098 }
00099
00103 function showThreadsObject()
00104 {
00105 global $rbacsystem,$ilUser;
00106
00107 $frm =& $this->object->Forum;
00108 $frm->setForumId($this->object->getId());
00109 $frm->setForumRefId($this->object->getRefId());
00110 $frm->setWhereCondition("top_frm_fk = ".$frm->getForumId());
00111
00112 $topicData = $frm->getOneTopic();
00113 if(!$topicData['top_num_threads'])
00114 {
00115 ilUtil::redirect("forums_threads_new.php?ref_id=".$this->object->getRefId());
00116 }
00117
00118 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.forums_threads_liste.html");
00119 if($rbacsystem->checkAccess('edit_post',$this->object->getRefId()))
00120 {
00121 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00122
00123
00124 $this->tpl->setCurrentBlock("btn_cell");
00125 $this->tpl->setVariable("BTN_LINK",'forums_threads_new.php?ref_id='.$this->object->getRefId());
00126 $this->tpl->setVariable("BTN_TXT",$this->lng->txt('forums_new_thread'));
00127 $this->tpl->parseCurrentBlock();
00128 }
00129
00130
00131 $this->tpl->setCurrentBlock("btn_cell");
00132 $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this,'markAllRead'));
00133 $this->tpl->setVariable("BTN_TXT",$this->lng->txt('forums_mark_read'));
00134 $this->tpl->parseCurrentBlock();
00135
00136
00137 if($topicData)
00138 {
00139
00140 $frm->setDbTable("frm_data");
00141 $frm->setWhereCondition("top_pk = ".$topicData["top_pk"]);
00142 $frm->updateVisits($topicData["top_pk"]);
00143
00144
00145 $frm->setOrderField("thr_date DESC");
00146 $resThreads = $frm->getThreadList($topicData["top_pk"]);
00147 $thrNum = $resThreads->numRows();
00148
00149
00150 if ($thrNum != $topicData['top_num_threads'])
00151 {
00152 $frm->fixThreadNumber($topicData['top_pk'], $thrNum);
00153 }
00154
00155 $pageHits = $frm->getPageHits();
00156 $pageHits = $ilUser->getPref('hits_per_page');
00157
00158 if ($thrNum > 0)
00159 {
00160 $z = 0;
00161
00162
00163 if ($thrNum > $pageHits)
00164 {
00165 $params = array(
00166 "ref_id" => $_GET["ref_id"]
00167 );
00168
00169 if (!$_GET["offset"])
00170 {
00171 $Start = 0;
00172 }
00173 else
00174 {
00175 $Start = $_GET["offset"];
00176 }
00177
00178 $linkbar = ilUtil::Linkbar(basename($_SERVER["PHP_SELF"]),$thrNum,$pageHits,$Start,$params);
00179
00180 if ($linkbar != "")
00181 {
00182 $this->tpl->setVariable("LINKBAR", $linkbar);
00183 }
00184 }
00185
00186
00187 while ($thrData = $resThreads->fetchRow(DB_FETCHMODE_ASSOC))
00188 {
00189 $rowCol = ilUtil::switchColor($z,"tblrow1","tblrow2");
00190
00191 if ($thrNum > $pageHits && $z >= ($Start+$pageHits))
00192 {
00193 break;
00194 }
00195
00196 if (($thrNum > $pageHits && $z >= $Start) || $thrNum <= $pageHits)
00197 {
00198
00199 $usr_data = $frm->getUserData($thrData["thr_usr_id"],$thrData["import_name"]);
00200
00201
00202 $this->tpl->setCurrentBlock("threads_row");
00203 $this->tpl->setVariable("ROWCOL", $rowCol);
00204
00205 $thrData["thr_date"] = $frm->convertDate($thrData["thr_date"]);
00206 $this->tpl->setVariable("DATE",$thrData["thr_date"]);
00207 $this->tpl->setVariable("TITLE","<a href=\"forums_frameset.php?thr_pk=".
00208 $thrData["thr_pk"]."&ref_id=".$this->object->getRefId()."\">".
00209 $thrData["thr_subject"]."</a>");
00210 if ($this->ilias->getSetting("forum_notification") != 0 &&
00211 $frm->isNotificationEnabled($ilUser->getId(), $thrData["thr_pk"]))
00212 {
00213 $this->tpl->setVariable("NOTIFICATION_ENABLED", $this->lng->txt("forums_notification_enabled"));
00214 }
00215
00216 $num_unread = $this->object->getCountUnread($ilUser->getId(),$thrData['thr_pk']);
00217 $this->tpl->setVariable("NUM_POSTS",$thrData["thr_num_posts"].' ('.$num_unread.')');
00218 $this->tpl->setVariable("NEW_POSTS",$this->object->getCountNew($ilUser->getId(),$thrData['thr_pk']));
00219 $this->tpl->setVariable("NUM_VISITS",$thrData["visits"]);
00220
00221
00222
00223 if($thrData["thr_usr_id"] && $usr_data["usr_id"] != 0)
00224 {
00225 $backurl = urlencode("repository.php?ref_id=".$_GET["ref_id"]."&offset=".$Start);
00226 $this->tpl->setVariable("AUTHOR","<a href=\"forums_user_view.php?ref_id=".$this->object->getRefId().
00227 "&user=".$usr_data["usr_id"]."&backurl=".$backurl.
00228 "\">".$usr_data["login"]."</a>");
00229 }
00230 else
00231 {
00232 $this->tpl->setVariable("AUTHOR",$usr_data["login"]);
00233 }
00234
00235
00236
00237 $lpCont = "";
00238 if ($thrData["thr_last_post"] != "")
00239 {
00240 $lastPost = $frm->getLastPost($thrData["thr_last_post"]);
00241 }
00242
00243 $last_usr_data = $frm->getUserData($lastPost["pos_usr_id"],$lastPost["import_name"]);
00244 if (is_array($lastPost))
00245 {
00246 $lastPost["pos_message"] = $frm->prepareText($lastPost["pos_message"]);
00247 $lpCont = $lastPost["pos_date"]."<br/>".strtolower($this->lng->txt("from"))." ";
00248 $lpCont .= "<a href=\"forums_frameset.php?pos_pk=".
00249 $lastPost["pos_pk"]."&thr_pk=".$lastPost["pos_thr_fk"]."&ref_id=".
00250 $this->object->getRefId()."#".$lastPost["pos_pk"]."\">".$last_usr_data["login"]."</a>";
00251 }
00252
00253 $this->tpl->setVariable("LAST_POST", $lpCont);
00254
00255 $this->tpl->setVariable("FORUM_ID", $thrData["thr_pk"]);
00256 $this->tpl->setVariable("THR_TOP_FK", $thrData["thr_top_fk"]);
00257
00258 $this->tpl->setVariable("TXT_PRINT", $this->lng->txt("print"));
00259
00260 $this->tpl->setVariable("THR_IMGPATH",$this->tpl->tplPath);
00261
00262 $this->tpl->parseCurrentBlock("threads_row");
00263
00264 }
00265
00266 $z ++;
00267
00268 }
00269
00270 $this->tpl->setVariable("TXT_SELECT_ALL", $this->lng->txt("select_all"));
00271 $this->tpl->setVariable("FORMACTION",'forums_threads_liste.php?ref_id='.$this->object->getRefId());
00272 $this->tpl->setVariable("TXT_OK",$this->lng->txt("ok"));
00273 $this->tpl->setVariable("TXT_EXPORT_HTML", $this->lng->txt("export_html"));
00274 $this->tpl->setVariable("TXT_EXPORT_XML", $this->lng->txt("export_xml"));
00275 if ($this->ilias->getSetting("forum_notification") != 0)
00276 {
00277 $this->tpl->setVariable("TXT_DISABLE_NOTIFICATION", $this->lng->txt("forums_disable_notification"));
00278 $this->tpl->setVariable("TXT_ENABLE_NOTIFICATION", $this->lng->txt("forums_enable_notification"));
00279 }
00280 $this->tpl->setVariable("IMGPATH",$this->tpl->tplPath);
00281
00282 }
00283
00284 }
00285
00286 $this->tpl->setCurrentBlock("threadtable");
00287 $this->tpl->setVariable("COUNT_THREAD", $this->lng->txt("forums_count_thr").": ".$thrNum);
00288 $this->tpl->setVariable("TXT_DATE", $this->lng->txt("date"));
00289 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00290 $this->tpl->setVariable("TXT_TOPIC", $this->lng->txt("forums_thread"));
00291 $this->tpl->setVariable("TXT_AUTHOR", $this->lng->txt("forums_created_by"));
00292 $this->tpl->setVariable("TXT_NUM_POSTS", $this->lng->txt("forums_articles").' ('.$this->lng->txt('unread').')');
00293 $this->tpl->setVariable("TXT_NEW_POSTS",$this->lng->txt('forums_new_articles'));
00294 $this->tpl->setVariable("TXT_NUM_VISITS", $this->lng->txt("visits"));
00295 $this->tpl->setVariable("TXT_LAST_POST", $this->lng->txt("forums_last_post"));
00296 $this->tpl->parseCurrentBlock("threadtable");
00297
00298 $this->tpl->setCurrentBlock("perma_link");
00299 $this->tpl->setVariable("PERMA_LINK", ILIAS_HTTP_PATH.
00300 "/goto.php?target=".
00301 $this->object->getType().
00302 "_".$this->object->getRefId()."&client_id=".CLIENT_ID);
00303 $this->tpl->setVariable("TXT_PERMA_LINK", $this->lng->txt("perma_link"));
00304 $this->tpl->setVariable("PERMA_TARGET", "_top");
00305 $this->tpl->parseCurrentBlock();
00306 }
00307
00311 function createObject()
00312 {
00313 global $rbacsystem;
00314
00315 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
00316
00317 if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
00318 {
00319 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00320 }
00321
00322 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.frm_create.html");
00323
00324 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_frm.gif'));
00325 $this->tpl->setVariable("ALT_IMG", $this->lng->txt('edit_properties'));
00326
00327 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00328 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("desc"));
00329 $this->tpl->setVariable("TITLE",$_POST['title']);
00330 $this->tpl->setVariable("DESC",$_POST['description']);
00331
00332 $this->ctrl->setParameter($this, "new_type", $new_type);
00333 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00334
00335 $this->tpl->setVariable("TARGET", ' target="'.
00336 ilFrameTargetInfo::_getFrame("MainContent").'" ');
00337
00338 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt('frm_new'));
00339 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00340 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
00341 $this->tpl->setVariable("CMD_SUBMIT", "save");
00342 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00343
00344
00345 $this->tpl->setVariable("TXT_VIEW",$this->lng->txt('frm_default_view'));
00346 $this->tpl->setVariable("TXT_ANSWER",$this->lng->txt('order_by').' '.$this->lng->txt('answers'));
00347 $this->tpl->setVariable("TXT_DATE",$this->lng->txt('order_by').' '.$this->lng->txt('date'));
00348
00349 $default_sort = $_POST['sort'] ? $_POST['sort'] : 1;
00350
00351 $this->tpl->setVariable("CHECK_ANSWER",ilUtil::formRadioButton($default_sort == 1 ? 1 : 0,'sort',1));
00352 $this->tpl->setVariable("CHECK_DATE",ilUtil::formRadioButton($default_sort == 2 ? 1 : 0,'sort',2));
00353
00354
00355 # $this->tpl->setVariable("TXT_ANONYMIZED",$this->lng->txt('frm_anonymous_posting'));
00356 # $this->tpl->setVariable("TXT_ANONYMIZED_DESC",$this->lng->txt('frm_anonymous_posting_desc'));
00357
00358 # $anonymized = $_POST['anonymized'] ? $_POST['anonymized'] : 0;
00359
00360 # $this->tpl->setVariable("CHECK_ANONYMIZED",ilUtil::formCheckbox($anonymized == 1 ? 1 : 0,'anonymized',1));
00361
00362
00363
00364 $statisticsEnabled = $_POST['statistics_enabled'] ? $_POST['statistics_enabled'] : 1;
00365
00366 $this->tpl->setVariable("TXT_STATISTICS_ENABLED", $this->lng->txt("frm_statistics_enabled"));
00367 $this->tpl->setVariable("TXT_STATISTICS_ENABLED_DESC", $this->lng->txt("frm_statistics_enabled_desc"));
00368
00369
00370 $this->tpl->setVariable("CHECK_STATISTICS_ENABLED",
00371 ilUtil::formCheckbox(
00372 $statisticsEnabled == 1 && $this->ilias->getSetting("enable_fora_statistics", true)? 1 : 0,
00373 'statistics_enabled', 1,
00374 $this->ilias->getSetting("enable_fora_statistics", true)?false:true));
00375
00376
00377 include_once("classes/class.ilMainMenuGUI.php");
00378 if(ilMainMenuGUI::_checkAdministrationPermission())
00379 {
00380 $this->tpl->setCurrentBlock("forum_import");
00381 $this->tpl->setVariable("FORMACTION_IMPORT",
00382 $this->ctrl->getFormAction($this));
00383 $this->tpl->setVariable("TXT_IMPORT_FORUM", $this->lng->txt("forum_import")." (ILIAS 2)");
00384 $this->tpl->setVariable("TXT_IMPORT_FILE", $this->lng->txt("forum_import_file"));
00385 $this->tpl->setVariable("BTN2_CANCEL", $this->lng->txt("cancel"));
00386 $this->tpl->setVariable("BTN_IMPORT", $this->lng->txt("import"));
00387 $this->tpl->setVariable("TYPE_IMG2",ilUtil::getImagePath('icon_frm.gif'));
00388 $this->tpl->setVariable("ALT_IMG2", $this->lng->txt("forum_import"));
00389 $this->tpl->parseCurrentBlock();
00390 }
00391 return true;
00392 }
00393
00399 function cancelObject($in_rep = false)
00400 {
00401 sendInfo($this->lng->txt("msg_cancel"),true);
00402
00403
00404 ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
00405
00406 }
00407
00408 function updateObject()
00409 {
00410 if(strlen($_POST['title']))
00411 {
00412 $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
00413 $this->object->setDescription(ilUtil::stripSlashes($_POST["desc"]));
00414 $this->object->setDefaultView((int) $_POST['sort']);
00415 # $this->object->setAnonymized((int) $_POST['anonymized']);
00416 $this->object->setStatisticsEnabled((int) $_POST['statistics_enabled']);
00417 $this->object->update();
00418
00419 sendInfo($this->lng->txt("msg_obj_modified"),true);
00420
00421
00422 $this->ctrl->redirect($this,'edit');
00423 }
00424
00425 sendInfo($this->lng->txt('frm_title_required'));
00426
00427 return $this->editObject();
00428 }
00429
00436 function editObject()
00437 {
00438 global $rbacsystem;
00439
00440 if (!$rbacsystem->checkAccess("write", $_GET["ref_id"],"frm"))
00441 {
00442 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00443 }
00444
00445 $default_sort = $_POST['sort']
00446 ? $_POST['sort']
00447 : $this->object->getDefaultView();
00448 # $anonymized = $_POST['anonymized']
00449 # ? $_POST['anonymized']
00450 # : $this->object->isAnonymized();
00451
00452 $statisticsEnabled = $_POST['statistics_enabled'] ?
00453 $_POST['statistics_enabled']
00454 : $this->object->isStatisticsEnabled();
00455
00456
00457
00458 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.forum_properties.html");
00459
00460 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_frm.gif'));
00461 $this->tpl->setVariable("ALT_IMG",$this->lng->txt('edit_properties'));
00462
00463
00464 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
00465 $this->tpl->setVariable("TXT_DESC", $this->lng->txt("desc"));
00466 $this->tpl->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
00467 $this->tpl->setVariable("DESC", ilUtil::stripSlashes($this->object->getDescription()));
00468
00469
00470 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00471 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt('edit_properties'));
00472 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00473 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
00474 $this->tpl->setVariable("CMD_SUBMIT", "update");
00475 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00476
00477
00478 $this->tpl->setVariable("TXT_VIEW",$this->lng->txt('frm_default_view'));
00479 $this->tpl->setVariable("TXT_ANSWER",$this->lng->txt('order_by').' '.$this->lng->txt('answers'));
00480 $this->tpl->setVariable("TXT_DATE",$this->lng->txt('order_by').' '.$this->lng->txt('date'));
00481
00482 $this->tpl->setVariable("CHECK_ANSWER",ilUtil::formRadioButton($default_sort == 1 ? 1 : 0,'sort',1));
00483 $this->tpl->setVariable("CHECK_DATE",ilUtil::formRadioButton($default_sort == 2 ? 1 : 0,'sort',2));
00484
00485
00486 # $this->tpl->setVariable("TXT_ANONYMIZED",$this->lng->txt('frm_anonymous_posting'));
00487 # $this->tpl->setVariable("TXT_ANONYMIZED_DESC",$this->lng->txt('frm_anonymous_posting_desc'));
00488
00489 # $this->tpl->setVariable("CHECK_ANONYMIZED",ilUtil::formCheckbox($anonymized == 1 ? 1 : 0,'anonymized',1));
00490
00491
00492 $this->tpl->setVariable("TXT_STATISTICS_ENABLED", $this->lng->txt("frm_statistics_enabled"));
00493 $this->tpl->setVariable("TXT_STATISTICS_ENABLED_DESC", $this->lng->txt("frm_statistics_enabled_desc"));
00494
00495 $this->tpl->setVariable("CHECK_STATISTICS_ENABLED",
00496 ilUtil::formCheckbox(
00497 $statisticsEnabled == 1 && $this->ilias->getSetting("enable_fora_statistics", true)? 1 : 0,
00498 'statistics_enabled', 1,
00499 $this->ilias->getSetting("enable_fora_statistics", true)?false:true));
00500
00501
00502 }
00503
00504
00505 function performImportObject()
00506 {
00507
00508 $this->__initFileObject();
00509
00510 if(!$this->file_obj->storeUploadedFile($_FILES["importFile"]))
00511 {
00512 $this->message = $this->lng->txt("import_file_not_valid");
00513 $this->file_obj->unlinkLast();
00514 }
00515 else if(!$this->file_obj->unzip())
00516 {
00517 $this->message = $this->lng->txt("cannot_unzip_file");
00518 $this->file_obj->unlinkLast();
00519 }
00520 else if(!$this->file_obj->findXMLFile())
00521 {
00522 $this->message = $this->lng->txt("cannot_find_xml");
00523 $this->file_obj->unlinkLast();
00524 }
00525 else if(!$this->__initParserObject($this->file_obj->getXMLFile()) or !$this->parser_obj->startParsing())
00526 {
00527 $this->message = $this->lng->txt("import_parse_error").":<br/>";
00528 }
00529
00530
00531 if(!$this->message)
00532 {
00533 sendInfo($this->lng->txt("import_forum_finished"),true);
00534 $ref_id = $this->parser_obj->getRefId();
00535 if ($ref_id > 0)
00536 {
00537 $this->ctrl->setParameter($this, "ref_id", $ref_id);
00538 ilUtil::redirect($this->getReturnLocation("save",
00539 $this->ctrl->getLinkTarget($this, "showThreads")));
00540 }
00541 else
00542 {
00543 ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
00544 }
00545 }
00546 else
00547 {
00548 sendInfo($this->message);
00549 $this->createObject();
00550 }
00551 }
00552
00553
00558 function saveObject()
00559 {
00560 global $rbacadmin;
00561
00562
00563 $_POST['Fobject']['title'] = $_POST['title'];
00564 $_POST['Fobject']['desc'] = $_POST['desc'];
00565
00566
00567 $forumObj = parent::saveObject();
00568
00569
00570 $forumObj->setDefaultView((int) $_POST['sort']);
00571 # $forumObj->setAnonymized((int) $_POST['anonymized']);
00572 $forumObj->setStatisticsEnabled((int) $_POST['statistics_enabled']);
00573 $forumObj->createSettings();
00574
00575
00576 $roles = $forumObj->initDefaultRoles();
00577
00578
00579 $rbacadmin->assignUser($roles[0], $forumObj->getOwner(), "n");
00580 ilObjUser::updateActiveRoles($forumObj->getOwner());
00581
00582
00583 $top_data = array(
00584 "top_frm_fk" => $forumObj->getId(),
00585 "top_name" => addslashes($forumObj->getTitle()),
00586 "top_description" => addslashes($forumObj->getDescription()),
00587 "top_num_posts" => 0,
00588 "top_num_threads" => 0,
00589 "top_last_post" => "",
00590 "top_mods" => $roles[0],
00591 "top_usr_id" => $_SESSION["AccountId"],
00592 "top_date" => date("Y-m-d H:i:s")
00593 );
00594
00595 $q = "INSERT INTO frm_data ";
00596 $q .= "(top_frm_fk,top_name,top_description,top_num_posts,top_num_threads,top_last_post,top_mods,top_date,top_usr_id) ";
00597 $q .= "VALUES ";
00598 $q .= "('".$top_data["top_frm_fk"]."','".$top_data["top_name"]."','".$top_data["top_description"]."','".
00599 $top_data["top_num_posts"]."','".$top_data["top_num_threads"]."','".$top_data["top_last_post"]."','".
00600 $top_data["top_mods"]."','".$top_data["top_date"]."','".$top_data["top_usr_id"]."')";
00601 $this->ilias->db->query($q);
00602
00603
00604 sendInfo($this->lng->txt("frm_added"),true);
00605
00606 $this->ctrl->setParameter($this, "ref_id", $forumObj->getRefId());
00607
00608 ilUtil::redirect($this->ctrl->getLinkTarget($this,'showThreads'));
00609 }
00610
00611 function getTabs(&$tabs_gui)
00612 {
00613 global $rbacsystem;
00614
00615 $this->ctrl->setParameter($this,"ref_id",$this->ref_id);
00616
00617 if($rbacsystem->checkAccess('write',$this->ref_id))
00618 {
00619 include_once './classes/class.ilRepositoryExplorer.php';
00620
00621 $tabs_gui->addTarget("forums_threads",ilRepositoryExplorer::buildLinkTarget($this->ref_id,'frm'),
00622 array("", "showThreads", "view", "markAllRead"), "");
00623 }
00624 if ($rbacsystem->checkAccess('write',$this->ref_id))
00625 {
00626 $force_active = ($_GET["cmd"] == "edit")
00627 ? true
00628 : false;
00629 $tabs_gui->addTarget("edit_properties",
00630 $this->ctrl->getLinkTarget($this, "edit"), "edit", get_class($this),
00631 "", $force_active);
00632 }
00633
00634 if ($this->ilias->getSetting("enable_fora_statistics", true) &&
00635 ($this->object->isStatisticsEnabled() || $rbacsystem->checkAccess('write',$this->ref_id)))
00636 {
00637 $tabs_gui->addTarget("statistic",
00638 $this->ctrl->getLinkTarget($this, "showStatistics"), "showStatistics", get_class($this),"",false);
00639
00640 }
00641
00642 if ($rbacsystem->checkAccess('edit_permission',$this->ref_id))
00643 {
00644 $tabs_gui->addTarget("perm_settings",
00645 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
00646 }
00647
00648 return true;
00649 }
00650
00654 function showStatisticsObject()
00655 {
00656 global $rbacsystem, $ilUser, $ilAccess;
00657
00659 if (!$this->ilias->getSetting("enable_fora_statistics", true))
00660 {
00661 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00662 }
00663
00664
00665 if (!$rbacsystem->checkAccess("read", $_GET["ref_id"],"frm"))
00666 {
00667 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00668 }
00669
00670
00671 if (!$rbacsystem->checkAccess("read", $_GET["ref_id"],"frm") && !$this->object->isStatisticsEnabled())
00672 {
00673 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00674 }
00675
00676
00677
00678 $tbl = new ilTableGUI();
00679 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.forums_statistics_view.html");
00680 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.table.html");
00681
00682
00683
00684
00685 if ($rbacsystem->checkAccess("write", $_GET["ref_id"],"frm") && !$this->object->isStatisticsEnabled())
00686 {
00687
00688 $this->tpl->setVariable ("STATUSLINE",$this->lng->txt("frm_statistics_disabled_for_participants"));
00689 }
00690
00691
00692 $sort_order = isset($_GET['sort_order']) ? $_GET['sort_order']:"DESC";
00693 $sort_by = isset($_GET['sort_by']) ? $_GET['sort_by'] : 'ranking';
00694
00695 if ($sort_by == "title")
00696 $sort_by = "ranking";
00697
00698
00699
00700 $query = "SELECT COUNT(f.pos_usr_id) as ranking, u.login, u.lastname, u.firstname
00701 FROM frm_posts f, frm_posts_tree t, frm_threads th, usr_data u, frm_data d
00702 WHERE f.pos_pk = t.pos_fk AND t.thr_fk = th.thr_pk AND u.usr_id = f.pos_usr_id AND d.top_pk = f.pos_top_fk AND d.top_frm_fk=".$this->object->getId()."
00703 GROUP BY pos_usr_id ORDER BY $sort_by $sort_order";
00704
00705
00706 $resultset = $this->ilias->db->query ($query);
00707
00708 while ($row = $resultset->fetchRow(DB_FETCHMODE_ASSOC)) {
00709 $data [] = $row;
00710 }
00711
00712
00713
00714 $tbl->setTitle($this->lng->txt("statistic"),"icon_usr_b.gif",$this->lng->txt("obj_".$this->object->getType()));
00715
00716 $header_names = array ($this->lng->txt("frm_statistics_ranking"),$this->lng->txt("login"), $this->lng->txt("lastname"),$this->lng->txt("firstname"));
00717
00718 $tbl->setHeaderNames($header_names);
00719
00720 $header_params = array("ref_id" => $this->ref_id, "cmd" => "statistic" );
00721 $header_fields = array("ranking","login","lastname", "firstname");
00722
00723 $tbl->setHeaderVars($header_fields,$header_params);
00724 $tbl->setColumnWidth(array("","25%","25%","25%"));
00725
00726
00727 $tbl->enable("hits");
00728 $tbl->disable("sort");
00729 $tbl->setOrderColumn($sort_by);
00730 $tbl->setOrderDirection($sort_order);
00731 $tbl->setLimit(0);
00732 $tbl->setOffset(0);
00733 $tbl->setData($data);
00734
00735 $tbl->render();
00736
00737 $this->tpl->parseCurrentBlock();
00738
00739 }
00740
00741
00742
00743
00744 function __initFileObject()
00745 {
00746 include_once "classes/class.ilFileDataImportForum.php";
00747
00748 $this->file_obj =& new ilFileDataImportForum();
00749
00750 return true;
00751 }
00752
00753 function __initParserObject($a_xml_file)
00754 {
00755 include_once "classes/class.ilForumImportParser.php";
00756
00757 $this->parser_obj =& new ilForumImportParser($a_xml_file,$this->ref_id);
00758
00759 return true;
00760 }
00761
00767 function _goto($a_target, $a_thread = 0)
00768 {
00769 global $ilAccess, $ilErr, $lng;
00770
00771 if ($ilAccess->checkAccess("read", "", $a_target))
00772 {
00773 if ($a_thread != 0)
00774 {
00775 $_GET["thr_pk"] = $a_thread;
00776 $_GET["ref_id"] = $a_target;
00777 include_once("forums_frameset.php");
00778 exit;
00779 }
00780 else
00781 {
00782 $_GET["ref_id"] = $a_target;
00783 include_once("repository.php");
00784 exit;
00785 }
00786 }
00787 else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
00788 {
00789 $_GET["cmd"] = "frameset";
00790 $_GET["target"] = "";
00791 $_GET["ref_id"] = ROOT_FOLDER_ID;
00792 sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
00793 ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
00794 include("repository.php");
00795 exit;
00796 }
00797
00798 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
00799
00800 }
00801
00802
00803 }
00804 ?>