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

forums_threads_new.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.ilObjForum.php";
00035 
00036 $lng->loadLanguageModule("forum");
00037 
00038 $forumObj = new ilObjForum($_GET["ref_id"]);
00039 $frm =& $forumObj->Forum;
00040 
00041 $frm->setForumId($forumObj->getId());
00042 $frm->setForumRefId($forumObj->getRefId());
00043 
00044 $frm->setWhereCondition("top_frm_fk = ".$frm->getForumId());
00045 $topicData = $frm->getOneTopic();
00046 
00047 $tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00048 $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.forums_threads_new.html");
00049 $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00050 $tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00051 
00052 $tpl->setCurrentBlock("header_image");
00053 $tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_frm_b.gif"));
00054 $tpl->parseCurrentBlock();
00055 $tpl->setVariable("HEADER", $lng->txt("frm")." \"".$forumObj->getTitle()."\"");
00056 
00057 // display infopanel if something happened
00058 infoPanel();
00059 
00060 if (!$rbacsystem->checkAccess("edit_post",$forumObj->getRefId()))
00061 {
00062         $ilias->raiseError($lng->txt("permission_denied"),$ilias->error_obj->MESSAGE);
00063 }
00064 
00065 require_once("classes/class.ilForumLocatorGUI.php");
00066 $frm_loc =& new ilForumLocatorGUI();
00067 $frm_loc->setRefId($_GET["ref_id"]);
00068 $frm_loc->setForum($frm);
00069 $frm_loc->display();
00070 
00071 
00072 
00073 // ********************************************************************************
00074 
00075 // form processing
00076 if ($_GET["cmd"] == "newthread")
00077 {
00078         $formData = $_POST["formData"];
00079 
00080         // check form-dates
00081         $checkEmptyFields = array(
00082                 $lng->txt("subject")   => $formData["subject"],
00083                 $lng->txt("message")   => $formData["message"]
00084         );
00085 
00086         $errors = ilUtil::checkFormEmpty($checkEmptyFields);
00087         if ($errors != "")
00088         {
00089                 sendInfo($lng->txt("form_empty_fields")." ".$errors);
00090         }
00091         else
00092         {       
00093                 
00094                 // build new thread
00095                 $newPost = $frm->generateThread($topicData["top_pk"], $_SESSION["AccountId"], 
00096                         ilUtil::stripSlashes($formData["subject"]), ilUtil::stripSlashes($formData["message"]),$formData["notify"],$formData["notify_posts"],$formData["anonymize"]);
00097                 
00098                 // file upload
00099                 if(isset($_FILES["userfile"]))
00100                 {
00101                         $tmp_file_obj =& new ilFileDataForum($forumObj->getId(),$newPost);
00102                         $tmp_file_obj->storeUploadedFile($_FILES["userfile"]);
00103                 }
00104                 // end file upload              
00105                 
00106                 // Visit-Counter
00107                 $frm->setDbTable("frm_data");
00108                 $frm->setWhereCondition("top_pk = ".$topicData["top_pk"]);
00109                 $frm->updateVisits($topicData["top_pk"]);
00110                 // on success: change location
00111                 $frm->setWhereCondition("thr_top_fk = '".$topicData["top_pk"]."' AND thr_subject = ".
00112                                                                 $ilDB->quote($formData["subject"])." AND thr_num_posts = 1");           
00113 
00114                 if (is_array($thrData = $frm->getOneThread()))
00115                 {
00116                         #sendInfo($lng->txt("forums_thread_new_entry"),true);
00117                         #header("location: forums_threads_liste.php?thr_pk=".$thrData["thr_pk"]."&ref_id=".$forumObj->getRefId());
00118                         ilUtil::redirect('repository.php?ref_id='.$forumObj->getRefId());
00119                 } 
00120         }
00121 }
00122 
00123 $tpl->setCurrentBlock("new_thread");
00124 $tpl->setVariable("TXT_REQUIRED_FIELDS", $lng->txt("required_field"));
00125 $tpl->setVariable("TXT_SUBJECT", $lng->txt("forums_thread"));
00126 $tpl->setVariable("TXT_MESSAGE", $lng->txt("forums_the_post"));
00127 
00128 
00129 include_once 'classes/class.ilMail.php';
00130 $umail = new ilMail($_SESSION["AccountId"]);
00131 // catch hack attempts
00132 if ($rbacsystem->checkAccess("mail_visible",$umail->getMailObjectReferenceId()))
00133 {
00134         $tpl->setCurrentBlock("notify");
00135         $tpl->setVariable("TXT_NOTIFY",$lng->txt("forum_direct_notification"));
00136         $tpl->setVariable("NOTIFY",$lng->txt("forum_notify_me_directly"));
00137         $tpl->parseCurrentBlock();
00138         if ($ilias->getSetting("forum_notification") != 0)
00139         {
00140                 $tpl->setCurrentBlock("notify_posts");
00141                 $tpl->setVariable("TXT_NOTIFY_POSTS",$lng->txt("forum_general_notification"));
00142                 $tpl->setVariable("NOTIFY_POSTS",$lng->txt("forum_notify_me_generally"));
00143                 $tpl->parseCurrentBlock();
00144         }
00145 }
00146 /*if ($frm->isAnonymized())
00147 {
00148         $tpl->setCurrentBlock("anonymize");
00149         $tpl->setVariable("TXT_ANONYMIZE",$lng->txt("forum_anonymize"));
00150         $tpl->setVariable("ANONYMIZE",$lng->txt("forum_anonymize_desc"));
00151         $tpl->parseCurrentBlock();
00152 }*/
00153 $tpl->setVariable("SUBMIT", $lng->txt("submit"));
00154 $tpl->setVariable("RESET", $lng->txt("reset"));
00155 $tpl->setVariable("FORMACTION", basename($_SERVER["PHP_SELF"])."?cmd=newthread&ref_id=".$forumObj->getRefId()."&backurl=".$_GET["backurl"]);
00156 $tpl->setVariable("TXT_NEW_TOPIC", $lng->txt("forums_new_thread"));
00157 
00158 $tpl->setCurrentBlock("attachment");
00159 $tpl->setVariable("TXT_ATTACHMENTS_ADD",$lng->txt("forums_attachments_add"));
00160 $tpl->setVariable("BUTTON_UPLOAD",$lng->txt("upload"));
00161 $tpl->parseCurrentBlock("attachment");
00162 
00163 $tpl->parseCurrentBlock("new_thread");
00164 
00165 $tpl->setVariable("TPLPATH", $tpl->vars["TPLPATH"]);
00166 
00167 $tpl->show();
00168 ?>

Generated on Fri Dec 13 2013 13:52:10 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1