• 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 $tpl->setVariable("BTN_TARGET","target=\"bottom\"");
00064 $tpl->parseCurrentBlock();
00065 
00066 // catch stored message
00067 sendInfo();
00068 // display infopanel if something happened
00069 infoPanel();
00070 
00071 // get all forums
00072 $frm_obj = ilUtil::getObjectsByOperations('frm','visible');
00073 $frmNum = count($frm_obj);
00074 
00075 $pageHits = $frm->getPageHits();
00076 
00077 // start: form operations
00078 if (isset($_POST["cmd"]["submit"]))
00079 {       
00080         if(is_array($_POST["forum_id"]))
00081         {
00082                 $startTbl = "frm_data";
00083                 
00084                 require_once "forums_export.php";       
00085                 
00086                 unset($topicData);      
00087                 
00088         }
00089         
00090 }
00091 // end: form operations
00092 
00093 if ($frmNum > 0)
00094 {
00095         $z = 0; 
00096         
00097         // navigation to browse
00098         if ($frmNum > $pageHits)
00099         {
00100                 $params = array(
00101                         "ref_id"                => $_GET["ref_id"]
00102                 );
00103                 
00104                 if (!$_GET["offset"])
00105                 {
00106                         $Start = 0;
00107                 }
00108                 else
00109                 {
00110                         $Start = $_GET["offset"];
00111                 }
00112                 
00113                 $linkbar = ilUtil::Linkbar(basename($_SERVER["PHP_SELF"]),$frmNum,$pageHits,$Start,$params);
00114                 
00115                 if ($linkbar != "")
00116                 {
00117                         $tpl->setVariable("LINKBAR", $linkbar);
00118                 }
00119         }       
00120 
00121         // get forums dates
00122         foreach($frm_obj as $data)
00123         {               
00124                 if ($frmNum > $pageHits && $z >= ($Start+$pageHits))
00125                 {
00126                         break;
00127                 }
00128                 
00129                 if (($frmNum > $pageHits && $z >= $Start) || $frmNum <= $pageHits)
00130                 {
00131                 
00132                         unset($topicData);
00133                         
00134                         $frm->setWhereCondition("top_frm_fk = ".$data["obj_id"]);
00135                         $topicData = $frm->getOneTopic();               
00136                         
00137                         if ($topicData["top_num_threads"] > 0)
00138                         {
00139                                 $thr_page = "liste";
00140                         }
00141                         else
00142                         {
00143                                 $thr_page = "new";
00144                         }
00145 
00146                         $tpl->setCurrentBlock("forum_row");
00147                         $tpl->setVariable("TXT_FORUMPATH", $lng->txt("context"));
00148                 
00149                         $rowCol = ilUtil::switchColor($z,"tblrow2","tblrow1");
00150                         $tpl->setVariable("ROWCOL", $rowCol);           
00151 
00152                         $moderators = "";               
00153                         $lpCont = "";
00154                         $lastPost = "";
00155                         
00156                         // get last-post data
00157                         if ($topicData["top_last_post"] != "")
00158                         {
00159                                 $lastPost = $frm->getLastPost($topicData["top_last_post"]);
00160                                 $lastPost["pos_message"] = $frm->prepareText($lastPost["pos_message"]);
00161                         }
00162                         // read-access
00163                         // TODO: this will not work :-(
00164                         // We have no ref_id at this point
00165                         if ($rbacsystem->checkAccess("read", $data["ref_id"])) 
00166                         {                       
00167                                 // forum title
00168                                 if (($topicData["top_num_threads"] < 1)  && (!$rbacsystem->checkAccess("edit_post", $data["ref_id"])))
00169                                 {
00170                                         $tpl->setVariable("TITLE","<b>".$topicData["top_name"]."</b>");
00171                                 }
00172                                 else
00173                                 {
00174                                         $tpl->setVariable("TITLE","<a href=\"forums_threads_".$thr_page.".php?ref_id=".$data["ref_id"]."&backurl=forums\">".$topicData["top_name"]."</a>");
00175                                 }
00176                                 // add to desktop link
00177                                 if (!$ilias->account->isDesktopItem($data["ref_id"], "frm"))
00178                                 {
00179                                         $tpl->setVariable("TO_DESK_LINK", "forums.php?cmd=addToDesk&item_id=".$data["ref_id"]);
00180                                         $tpl->setVariable("TXT_TO_DESK", "(".$lng->txt("to_desktop").")");
00181                                 }
00182                                 // create-dates of forum
00183                                 if ($topicData["top_usr_id"] > 0)
00184                                 {
00185                                         $moderator = $frm->getUser($topicData["top_usr_id"]);
00186 
00187                                         $tpl->setVariable("START_DATE_TXT1", $lng->txt("launch"));
00188                                         $tpl->setVariable("START_DATE_TXT2", strtolower($lng->txt("by")));
00189                                         $tpl->setVariable("START_DATE", $frm->convertDate($topicData["top_date"]));
00190                                         $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>");                                                                           
00191                                 }
00192                                 
00193                                 // when forum was changed ...
00194                                 if ($topicData["update_user"] > 0)
00195                                 {                       
00196                                         $moderator = $frm->getUser($topicData["update_user"]);  
00197                                         
00198                                         $tpl->setVariable("LAST_UPDATE_TXT1", $lng->txt("last_change"));
00199                                         $tpl->setVariable("LAST_UPDATE_TXT2", strtolower($lng->txt("by")));
00200                                         $tpl->setVariable("LAST_UPDATE", $frm->convertDate($topicData["top_update"]));
00201                                         $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>");                                                                                 
00202                                 }
00203                                 
00204                                 // show content of last-post
00205                                 if (is_array($lastPost))
00206                                 {                                       
00207                                         $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;";                      
00208                                         $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/>";
00209                                         $lpCont .= $lastPost["pos_date"];                                                       
00210                                 }
00211         
00212                                 $tpl->setVariable("LAST_POST", $lpCont);
00213                                 
00214                                 // get dates of moderators
00215                                 $MODS = $frm->getModerators();
00216                                                                                         
00217                                 for ($i = 0; $i < count($MODS); $i++)
00218                                 {
00219                                         unset($moderator);                                              
00220                                         $moderator = $frm->getUser($MODS[$i]);
00221                                         
00222                                         if ($moderators != "")
00223                                         {
00224                                                 $moderators .= ", ";
00225                                         }
00226 
00227                                         $moderators .= "<a href=\"forums_user_view.php?ref_id=".$data["ref_id"]."&user=".$MODS[$i]."&backurl=forums&offset=".$Start."\">".$moderator->getLogin()."</a>";
00228                                 }
00229                                         
00230                                 $tpl->setVariable("MODS",$moderators); 
00231                                 
00232                                 $tpl->setVariable("FORUM_ID", $topicData["top_pk"]);                            
00233                                 
00234                 
00235                         } // if ($rbacsystem->checkAccess("read", $data["ref_id"])) 
00236                         else 
00237                         {
00238                                 // only visible-access  
00239                                 $tpl->setVariable("TITLE","<b>".$topicData["top_name"]."</b>");
00240                                 
00241                                 if (is_array($lastPost))
00242                                 {
00243                                         $lpCont = $lastPost["pos_message"]."<br/>".$lng->txt("from")." ".$lastPost["lastname"]."<br/>".$lastPost["pos_date"];                           
00244                                 }
00245 
00246                                 $tpl->setVariable("LAST_POST", $lpCont);
00247                                 
00248                                 if ($topicData["top_mods"] > 0)
00249                                 {                       
00250                                         $MODS = $rbacreview->assignedUsers($topicData["top_mods"]);
00251                                                                                 
00252                                         for ($i = 0; $i < count($MODS); $i++)
00253                                         {
00254                                                 unset($moderator);
00255                                                 $moderator = $frm->getUser($MODS[$i]);
00256                                                 
00257                                                 if ($moderators != "")
00258                                                 {
00259                                                         $moderators .= ", ";
00260                                                 }
00261                                                 
00262                                                 $moderators .= $moderator->getLogin();
00263                                         }
00264                                 }
00265                                 $tpl->setVariable("MODS",$moderators); 
00266                         } // else       
00267                         
00268                         // get context of forum                 
00269                         $PATH = $frm->getForumPath($data["ref_id"]);
00270                         $tpl->setVariable("FORUMPATH",$PATH);
00271                         
00272                         $tpl->setVariable("DESCRIPTION",$topicData["top_description"]);
00273                         $tpl->setVariable("NUM_THREADS",$topicData["top_num_threads"]);
00274                         $tpl->setVariable("NUM_POSTS",$topicData["top_num_posts"]);             
00275                         $tpl->setVariable("NUM_VISITS",$topicData["visits"]);           
00276                 
00277                         $tpl->parseCurrentBlock();      
00278                                         
00279                 } // if (($frmNum > $pageHits && $z >= $Start) || $frmNum <= $pageHits)
00280                 
00281                 $z ++;          
00282                 
00283         } // foreach($frm_obj as $data)
00284 
00285         $tpl->setCurrentBlock("forum_options"); 
00286         $tpl->setVariable("TXT_SELECT_ALL", $lng->txt("select_all"));
00287         $tpl->setVariable("IMGPATH",$tpl->tplPath);
00288         $tpl->setVariable("FORMACTION", basename($_SERVER["PHP_SELF"])."?ref_id=".$_GET["ref_id"]);
00289         $tpl->setVariable("TXT_OK",$lng->txt("ok"));    
00290         //$tpl->setVariable("TXT_PRINT", $lng->txt("print"));
00291         $tpl->setVariable("TXT_EXPORT_HTML", $lng->txt("export_html"));
00292         $tpl->setVariable("TXT_EXPORT_XML", $lng->txt("export_xml"));
00293         $tpl->parseCurrentBlock();
00294         
00295 } // if ($frmNum > 0)
00296 else
00297 {
00298         $tpl->setCurrentBlock("forum_no");
00299         $tpl->setVariable("TXT_MSG_NO_FORUMS_AVAILABLE",$lng->txt("forums_not_available"));
00300         $tpl->parseCurrentBlock();
00301 }
00302 
00303 $tpl->setCurrentBlock("forum");
00304 
00305 $tpl->setVariable("COUNT_FORUM", $lng->txt("forums_count").": ".$frmNum);
00306 $tpl->setVariable("TXT_PAGEHEADLINE", $lng->txt("forums_overview"));
00307 $tpl->setVariable("TXT_FORUM", $lng->txt("forum"));
00308 $tpl->setVariable("TXT_TITLE", $lng->txt("title"));
00309 $tpl->setVariable("TXT_DESCRIPTION", $lng->txt("description"));
00310 $tpl->setVariable("TXT_NUM_THREADS", $lng->txt("forums_threads"));
00311 $tpl->setVariable("TXT_NUM_POSTS", $lng->txt("forums_articles"));
00312 $tpl->setVariable("TXT_NUM_VISITS", $lng->txt("visits"));
00313 $tpl->setVariable("TXT_LAST_POST", $lng->txt("forums_last_post"));
00314 $tpl->setVariable("TXT_MODS", $lng->txt("forums_moderators"));
00315 $tpl->parseCurrentBlock();
00316 
00317 $tpl->setVariable("TPLPATH", $tpl->vars["TPLPATH"]);
00318 
00319 $tpl->show();
00320 ?>

Generated on Fri Dec 13 2013 08:00:17 for ILIAS Release_3_3_x_branch .rev 46803 by  doxygen 1.7.1