Пример #1
0
 /**
  * Create/Update the linked posting for the passed issue_id
  * 
  * @param string $seminar_id
  * @param string $issue_id    issue id to link to
  * @param string $title       (new) title of the posting
  * @param string $content     (new) content of the posting
  */
 static function setThreadForIssue($seminar_id, $issue_id, $title, $content)
 {
     if ($topic_id = self::getThreadIdForIssue($issue_id)) {
         // update
         ForumEntry::update($topic_id, $title ?: _('Ohne Titel'), $content);
     } else {
         // create
         // make sure the forum is set up properly
         ForumEntry::checkRootEntry($seminar_id);
         $topic_id = md5(uniqid(rand()));
         ForumEntry::insert(array('topic_id' => $topic_id, 'seminar_id' => $seminar_id, 'user_id' => $GLOBALS['user']->id, 'name' => $title ?: _('Ohne Titel'), 'content' => $content, 'author' => get_fullname($GLOBALS['user']->id), 'author_host' => getenv('REMOTE_ADDR')), $seminar_id);
         $stmt = DBManager::get()->prepare("INSERT INTO forum_entries_issues\n                (issue_id, topic_id) VALUES (?, ?)");
         $stmt->execute(array($issue_id, $topic_id));
     }
 }
Пример #2
0
 function add_action($category_id)
 {
     ForumPerm::check('add_area', $this->getId());
     $new_id = md5(uniqid(rand()));
     if (Request::isXhr()) {
         $name = studip_utf8decode(Request::get('name', _('Kein Titel')));
         $content = studip_utf8decode(Request::get('content'));
     } else {
         $name = Request::get('name', _('Kein Titel'));
         $content = Request::get('content');
     }
     ForumEntry::insert(array('topic_id' => $new_id, 'seminar_id' => $this->getId(), 'user_id' => $GLOBALS['user']->id, 'name' => $name, 'content' => $content, 'author' => get_fullname($GLOBALS['user']->id), 'author_host' => getenv('REMOTE_ADDR')), $this->getId());
     ForumCat::addArea($category_id, $new_id);
     if (Request::isXhr()) {
         $this->set_layout(null);
         $this->entry = array_pop(ForumEntry::parseEntries(array(ForumEntry::getEntry($new_id))));
         $this->visitdate = ForumVisit::getLastVisit($this->getId());
     } else {
         $this->redirect(PluginEngine::getLink('coreforum/index/index/'));
     }
 }
Пример #3
0
 private function createEntry($parent_id, $course_id, $subject, $content, $anonymous)
 {
     $topic_id = self::generateID();
     $data = array('topic_id' => $topic_id, 'seminar_id' => $course_id, 'user_id' => $GLOBALS['user']->id, 'name' => $subject, 'content' => $content, 'author' => $GLOBALS['user']->getFullName(), 'author_host' => $_SERVER['REMOTE_ADDR'], 'anonymous' => (int) $anonymous);
     \ForumEntry::insert($data, $parent_id);
     return $topic_id;
 }
Пример #4
0
 /**
  * check, if the default root-node for this seminar exists and make sure
  * the default category exists as well
  *
  * @param type $seminar_id
  *
  * @return void
  */
 function checkRootEntry($seminar_id)
 {
     setTempLanguage($GLOBALS['DEFAULT_LANGUAGE']);
     // check, if the root entry in the topic tree exists
     $stmt = DBManager::get()->prepare("SELECT COUNT(*) FROM forum_entries\n            WHERE topic_id = ? AND seminar_id = ?");
     $stmt->execute(array($seminar_id, $seminar_id));
     if ($stmt->fetchColumn() == 0) {
         $stmt = DBManager::get()->prepare("INSERT INTO forum_entries\n                (topic_id, seminar_id, name, mkdate, chdate, lft, rgt, depth)\n                VALUES (?, ?, 'Übersicht', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), 0, 1, 0)");
         $stmt->execute(array($seminar_id, $seminar_id));
     }
     // make sure, that the category "Allgemein" exists
     $stmt = DBManager::get()->prepare("INSERT IGNORE INTO forum_categories\n            (category_id, seminar_id, entry_name) VALUES (?, ?, ?)");
     $stmt->execute(array($seminar_id, $seminar_id, _('Allgemein')));
     // make sure that the default area "Allgemeine Diskussionen" exists, if there is nothing else present
     $stmt = DBManager::get()->prepare("SELECT COUNT(*) FROM forum_entries\n            WHERE seminar_id = ? AND depth = 1");
     $stmt->execute(array($seminar_id));
     // add default area
     if ($stmt->fetchColumn() == 0) {
         $data = array('topic_id' => md5(uniqid()), 'seminar_id' => $seminar_id, 'user_id' => '', 'name' => _('Allgemeine Diskussion'), 'content' => _('Hier ist Raum für allgemeine Diskussionen'), 'author' => '', 'author_host' => '');
         ForumEntry::insert($data, $seminar_id);
     }
     restoreLanguage();
 }
Пример #5
0
 /**
  * Add a new entry. Has a simple spambot protection and checks 
  * the parent_id to add the entry to, throwing an exception if missing.
  * 
  * @throws Exception
  */
 function add_entry_action()
 {
     // Schutz vor Spambots - diese füllen meistens alle Felder aus, auch "versteckte".
     // Ist dieses Feld gefüllt, war das vermutlich kein Mensch
     if (Request::get('nixda')) {
         throw new Exception('Access denied!');
     }
     if (!($parent_id = Request::option('parent'))) {
         throw new Exception('missing seminar_id/topic_id while adding a new entry!');
     }
     ForumPerm::check('add_entry', $this->getId(), $parent_id);
     $constraints = ForumEntry::getConstraints($parent_id);
     // if we are answering/citing a posting, we want to add it to the thread
     // (which is the parent of passed posting id)
     if ($constraints['depth'] == 3) {
         $parent_id = ForumEntry::getParentTopicId($parent_id);
     }
     $new_id = md5(uniqid(rand()));
     if ($GLOBALS['user']->id == 'nobody') {
         $fullname = Request::get('author', 'unbekannt');
     } else {
         $fullname = get_fullname($GLOBALS['user']->id);
     }
     ForumEntry::insert(array('topic_id' => $new_id, 'seminar_id' => $this->getId(), 'user_id' => $GLOBALS['user']->id, 'name' => Request::get('name') ?: '', 'content' => Studip\Markup::purifyHtml(Request::get('content')), 'author' => $fullname, 'author_host' => getenv('REMOTE_ADDR'), 'anonymous' => Config::get()->FORUM_ANONYMOUS_POSTINGS ? Request::get('anonymous') ?: 0 : 0), $parent_id);
     $this->flash['notify'] = $new_id;
     $this->redirect(PluginEngine::getLink('coreforum/index/index/' . $new_id . '#' . $new_id));
 }