• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

forums.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00033 require_once "./include/inc.header.php";
00034 require_once "classes/class.ilForum.php";
00035 
00036 switch($_GET["cmd"])
00037 {
00038         case "addToDesk":
00039                 $ilias->account->addDesktopItem($_GET["item_id"], "frm");
00040                 break;
00041 }
00042 
00043 $frm = new ilForum();
00044 
00045 $lng->loadLanguageModule("forum");
00046 
00047 $tpl->addBlockFile("CONTENT", "content", "tpl.forums.html");
00048 $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00049 $tpl->addBlockFile("BUTTONS", "buttons", "tpl.buttons.html");
00050 $tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00051 
00052 // set locator
00053 $tpl->setVariable("TXT_LOCATOR",$lng->txt("locator"));
00054 $tpl->setCurrentBlock("locator_item");
00055 $tpl->setVariable("ITEM", $lng->txt("forums_overview"));
00056 $tpl->setVariable("LINK_ITEM", "forums.php");
00057 $tpl->parseCurrentBlock();
00058 
00059 // display buttons
00060 $tpl->setCurrentBlock("btn_cell");
00061 $tpl->setVariable("BTN_LINK","obj_location_new.php?new_type=frm&from=".basename($PATH_INFO));
00062 $tpl->setVariable("BTN_TXT",$lng->txt("frm_new"));
00063 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "frm");
00064 $tpl->setVariable("BTN_TARGET","target=\"$t_frame\"");
00065 $tpl->parseCurrentBlock();
00066 
00067 // catch stored message
00068 sendInfo();
00069 // display infopanel if something happened
00070 infoPanel();
00071 
00072 // get all forums
00073 $frm_obj = ilUtil::getObjectsByOperations('frm','visible');
00074 $frmNum = count($frm_obj);
00075 
00076 $pageHits = $frm->getPageHits();
00077 
00078 // start: form operations
00079 if (isset($_POST["cmd"]["submit"]))
00080 {       
00081         if(is_array($_POST["forum_id"]))
00082         {
00083                 $startTbl = "frm_data";
00084                 
00085                 require_once "forums_export.php";       
00086                 
00087                 unset($topicData);      
00088                 
00089         }
00090         
00091 }
00092 // end: form operations
00093 
00094 if ($frmNum > 0)
00095 {
00096         $z = 0; 
00097         
00098         // navigation to browse
00099         if ($frmNum > $pageHits)
00100         {
00101                 $params = array(
00102                         "ref_id"                => $_GET["ref_id"]
00103                 );
00104                 
00105                 if (!$_GET["offset"])
00106                 {
00107                         $Start = 0;
00108                 }
00109                 else
00110                 {
00111                         $Start = $_GET["offset"];
00112                 }
00113                 
00114                 $linkbar = ilUtil::Linkbar(basename($_SERVER["PHP_SELF"]),$frmNum,$pageHits,$Start,$params);
00115                 
00116                 if ($linkbar != "")
00117                 {
00118                         $tpl->setVariable("LINKBAR", $linkbar);
00119                 }
00120         }       
00121 
00122         // get forums dates
00123         foreach($frm_obj as $data)
00124         {               
00125                 if ($frmNum > $pageHits && $z >= ($Start+$pageHits))
00126                 {
00127                         break;
00128                 }
00129                 
00130                 if (($frmNum > $pageHits && $z >= $Start) || $frmNum <= $pageHits)
00131                 {
00132                 
00133                         unset($topicData);
00134                         
00135                         $frm->setWhereCondition("top_frm_fk = ".$data["obj_id"]);
00136                         $topicData = $frm->getOneTopic();               
00137                         
00138                         if ($topicData["top_num_threads"] > 0)
00139                         {
00140                                 $thr_page = "liste";
00141                         }
00142                         else
00143                         {
00144                                 $thr_page = "new";
00145                         }
00146 
00147                         $tpl->setCurrentBlock("forum_row");
00148                         $tpl->setVariable("TXT_FORUMPATH", $lng->txt("context"));
00149                 
00150                         $rowCol = ilUtil::switchColor($z,"tblrow2","tblrow1");
00151                         $tpl->setVariable("ROWCOL", $rowCol);           
00152 
00153                         $moderators = "";               
00154                         $lpCont = "";
00155                         $lastPost = "";
00156                         
00157                         // get last-post data
00158                         if ($topicData["top_last_post"] != "")
00159                         {
00160                                 $lastPost = $frm->getLastPost($topicData["top_last_post"]);
00161                                 $lastPost["pos_message"] = $frm->prepareText($lastPost["pos_message"]);
00162                         }
00163                         // read-access
00164                         // TODO: this will not work :-(
00165                         // We have no ref_id at this point
00166                         if ($rbacsystem->checkAccess("read", $data["ref_id"])) 
00167                         {                       
00168                                 // forum title
00169                                 if (($topicData["top_num_threads"] < 1)  && (!$rbacsystem->checkAccess("edit_post", $data["ref_id"])))
00170                                 {
00171                                         $tpl->setVariable("TITLE","<b>".$topicData["top_name"]."</b>");
00172                                 }
00173                                 else
00174                                 {
00175                                         $tpl->setVariable("TITLE","<a href=\"forums_threads_".$thr_page.".php?ref_id=".$data["ref_id"]."&backurl=forums\">".$topicData["top_name"]."</a>");
00176                                 }
00177                                 // add to desktop link
00178                                 if (!$ilias->account->isDesktopItem($data["ref_id"], "frm"))
00179                                 {
00180                                         $tpl->setVariable("TO_DESK_LINK", "forums.php?cmd=addToDesk&item_id=".$data["ref_id"]);
00181                                         $tpl->setVariable("TXT_TO_DESK", "(".$lng->txt("to_desktop").")");
00182                                 }
00183                                 // create-dates of forum
00184                                 if ($topicData["top_usr_id"] > 0)
00185                                 {
00186                                         $moderator = $frm->getUser($topicData["top_usr_id"]);
00187 
00188                                         $tpl->setVariable("START_DATE_TXT1", $lng->txt("launch"));
00189                                         $tpl->setVariable("START_DATE_TXT2", strtolower($lng->txt("by")));
00190                                         $tpl->setVariable("START_DATE", $frm->convertDate($topicData["top_date"]));
00191                                         $tpl->setVariable("START_DATE_USER","<a href=\"forums_user_view.php?ref_id=".$data["ref_id"]."&user=".$topicData["top_usr_id"]."&backurl=forums&offset=".$Start."\">".$moderator->getLogin()."</a>");                                                                           
00192                                 }
00193                                 
00194                                 // when forum was changed ...
00195                                 if ($topicData["update_user"] > 0)
00196                                 {                       
00197                                         $moderator = $frm->getUser($topicData["update_user"]);  
00198                                         
00199                                         $tpl->setVariable("LAST_UPDATE_TXT1", $lng->txt("last_change"));
00200                                         $tpl->setVariable("LAST_UPDATE_TXT2", strtolower($lng->txt("by")));
00201                                         $tpl->setVariable("LAST_UPDATE", $frm->convertDate($topicData["top_update"]));
00202                                         $tpl->setVariable("LAST_UPDATE_USER","<a href=\"forums_user_view.php?ref_id=".$data["ref_id"]."&user=".$topicData["update_user"]."&backurl=forums&offset=".$Start."\">".$moderator->getLogin()."</a>");                                                                                 
00203                                 }
00204                                 
00205                                 // show content of last-post
00206                                 if (is_array($lastPost))
00207                                 {                                       
00208                                         $lpCont = "<a href=\"forums_frameset.php?target=true&pos_pk=".$lastPost["pos_pk"]."&thr_pk=".$lastPost["pos_thr_fk"]."&ref_id=".$data["ref_id"]."#".$lastPost["pos_pk"]."\">".$lastPost["pos_message"]."</a><br/>".strtolower($lng->txt("from"))."&nbsp;";                      
00209                                         $lpCont .= "<a href=\"forums_user_view.php?ref_id=".$data["ref_id"]."&user=".$lastPost["pos_usr_id"]."&backurl=forums&offset=".$Start."\">".$lastPost["login"]."</a><br/>";
00210                                         $lpCont .= $lastPost["pos_date"];                                                       
00211                                 }
00212         
00213                                 $tpl->setVariable("LAST_POST", $lpCont);
00214                                 
00215                                 // get dates of moderators
00216                                 $MODS = $frm->getModerators();
00217                                                                                         
00218                                 for ($i = 0; $i < count($MODS); $i++)
00219                                 {
00220                                         unset($moderator);                                              
00221                                         $moderator = $frm->getUser($MODS[$i]);
00222                                         
00223                                         if ($moderators != "")
00224                                         {
00225                                                 $moderators .= ", ";
00226                                         }
00227 
00228                                         $moderators .= "<a href=\"forums_user_view.php?ref_id=".$data["ref_id"]."&user=".$MODS[$i]."&backurl=forums&offset=".$Start."\">".$moderator->getLogin()."</a>";
00229                                 }
00230                                         
00231                                 $tpl->setVariable("MODS",$moderators); 
00232                                 
00233                                 $tpl->setVariable("FORUM_ID", $topicData["top_pk"]);                            
00234                                 
00235                 
00236                         } // if ($rbacsystem->checkAccess("read", $data["ref_id"])) 
00237                         else 
00238                         {
00239                                 // only visible-access  
00240                                 $tpl->setVariable("TITLE","<b>".$topicData["top_name"]."</b>");
00241                                 
00242                                 if (is_array($lastPost))
00243                                 {
00244                                         $lpCont = $lastPost["pos_message"]."<br/>".$lng->txt("from")." ".$lastPost["lastname"]."<br/>".$lastPost["pos_date"];                           
00245                                 }
00246 
00247                                 $tpl->setVariable("LAST_POST", $lpCont);
00248                                 
00249                                 if ($topicData["top_mods"] > 0)
00250                                 {                       
00251                                         $MODS = $rbacreview->assignedUsers($topicData["top_mods"]);
00252                                                                                 
00253                                         for ($i = 0; $i < count($MODS); $i++)
00254                                         {
00255                                                 unset($moderator);
00256                                                 $moderator = $frm->getUser($MODS[$i]);
00257                                                 
00258                                                 if ($moderators != "")
00259                                                 {
00260                                                         $moderators .= ", ";
00261                                                 }
00262                                                 
00263                                                 $moderators .= $moderator->getLogin();
00264                                         }
00265                                 }
00266                                 $tpl->setVariable("MODS",$moderators); 
00267                         } // else       
00268                         
00269                         // get context of forum                 
00270                         $PATH = $frm->getForumPath($data["ref_id"]);
00271                         $tpl->setVariable("FORUMPATH",$PATH);
00272                         
00273                         $tpl->setVariable("DESCRIPTION",$topicData["top_description"]);
00274                         $tpl->setVariable("NUM_THREADS",$topicData["top_num_threads"]);
00275                         $tpl->setVariable("NUM_POSTS",$topicData["top_num_posts"]);             
00276                         $tpl->setVariable("NUM_VISITS",$topicData["visits"]);           
00277                 
00278                         $tpl->parseCurrentBlock();      
00279                                         
00280                 } // if (($frmNum > $pageHits && $z >= $Start) || $frmNum <= $pageHits)
00281                 
00282                 $z ++;          
00283                 
00284         } // foreach($frm_obj as $data)
00285 
00286         $tpl->setCurrentBlock("forum_options"); 
00287         $tpl->setVariable("TXT_SELECT_ALL", $lng->txt("select_all"));
00288         $tpl->setVariable("IMGPATH",$tpl->tplPath);
00289         $tpl->setVariable("FORMACTION", basename($_SERVER["PHP_SELF"])."?ref_id=".$_GET["ref_id"]);
00290         $tpl->setVariable("TXT_OK",$lng->txt("ok"));    
00291         //$tpl->setVariable("TXT_PRINT", $lng->txt("print"));
00292         $tpl->setVariable("TXT_EXPORT_HTML", $lng->txt("export_html"));
00293         $tpl->setVariable("TXT_EXPORT_XML", $lng->txt("export_xml"));
00294         $tpl->parseCurrentBlock();
00295         
00296 } // if ($frmNum > 0)
00297 else
00298 {
00299         $tpl->setCurrentBlock("forum_no");
00300         $tpl->setVariable("TXT_MSG_NO_FORUMS_AVAILABLE",$lng->txt("forums_not_available"));
00301         $tpl->parseCurrentBlock();
00302 }
00303 
00304 $tpl->setCurrentBlock("forum");
00305 
00306 $tpl->setVariable("COUNT_FORUM", $lng->txt("forums_count").": ".$frmNum);
00307 $tpl->setVariable("TXT_PAGEHEADLINE", $lng->txt("forums_overview"));
00308 $tpl->setVariable("TXT_FORUM", $lng->txt("forum"));
00309 $tpl->setVariable("TXT_TITLE", $lng->txt("title"));
00310 $tpl->setVariable("TXT_DESCRIPTION", $lng->txt("description"));
00311 $tpl->setVariable("TXT_NUM_THREADS", $lng->txt("forums_threads"));
00312 $tpl->setVariable("TXT_NUM_POSTS", $lng->txt("forums_articles"));
00313 $tpl->setVariable("TXT_NUM_VISITS", $lng->txt("visits"));
00314 $tpl->setVariable("TXT_LAST_POST", $lng->txt("forums_last_post"));
00315 $tpl->setVariable("TXT_MODS", $lng->txt("forums_moderators"));
00316 $tpl->parseCurrentBlock();
00317 
00318 $tpl->setVariable("TPLPATH", $tpl->vars["TPLPATH"]);
00319 
00320 $tpl->show();
00321 ?>

Generated on Fri Dec 13 2013 09:06:36 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1