public static function mention($markup, $matches) { $mention = $matches[0]; $thread_id = self::$mention_thread_id; $username = stripslashes(substr($mention, 1)); if ($username[0] !== '"') { $user_id = get_userid($username); } else { $name = substr($username, 1, strlen($username) - 2); $db = DBManager::get(); $user_id = $db->query("SELECT user_id FROM auth_user_md5 WHERE CONCAT(Vorname, ' ', Nachname) = " . $db->quote($name) . " " . "")->fetch(PDO::FETCH_COLUMN, 0); } $thread = new ForumPosting($thread_id); if (!$thread->isNew() && $user_id && $user_id !== $GLOBALS['user']->id) { $user = new User($user_id); $messaging = new messaging(); $url = $GLOBALS['ABSOLUTE_URI_STUDIP'] . "plugins.php/blubber/forum/thread/" . $thread_id . ($thread['context_type'] === "course" ? '?cid=' . $thread['Seminar_id'] : ""); $messaging->insert_message(sprintf(_("%s hat Sie in einem Blubber erwähnt. Zum Beantworten klicken auf Sie auf folgenen Link:\n\n%s\n"), get_fullname(), $url), get_username($user_id), $GLOBALS['user']->id, null, null, null, null, _("Sie wurden erwähnt.")); DBManager::get()->exec("INSERT IGNORE INTO blubber_mentions " . "SET user_id = " . DBManager::get()->quote($user_id) . ", " . "topic_id = " . DBManager::get()->quote($thread_id) . ", " . "mkdate = UNIX_TIMESTAMP() " . ""); return '[' . $user['Vorname'] . " " . $user['Nachname'] . ']' . $GLOBALS['ABSOLUTE_URI_STUDIP'] . "about.php?username=" . $user['username'] . ' '; } else { return stripslashes($mention); } }
public function new_posting_action() { $context = Request::option("context"); $context_type = Request::option("context_type"); if ($context_type === "course") { $seminar = new Seminar($context); if ($seminar->write_level > 0 && !$GLOBALS['perm']->have_studip_perm("autor", $context)) { throw new AccessDeniedException("Kein Zugriff"); } } ForumPosting::$course_hashes = $context_type === "course" ? $context : false; $output = array(); $thread = new ForumPosting(Request::option("thread")); $thread['seminar_id'] = $context_type === "course" ? $context : $GLOBALS['user']->id; $thread['context_type'] = $context_type; $thread['parent_id'] = 0; if ($thread->isNew() && !$thread->getId()) { $thread->store(); } ForumPosting::$mention_thread_id = $thread->getId(); StudipTransformFormat::addStudipMarkup("mention1", '@\\"[^\\n\\"]*\\"', "", "ForumPosting::mention"); StudipTransformFormat::addStudipMarkup("mention2", '@[^\\s]*[\\d\\w_]+', "", "ForumPosting::mention"); $content = transformBeforeSave(studip_utf8decode(Request::get("content"))); if (strpos($content, "\n") !== false) { $thread['name'] = substr($content, 0, strpos($content, "\n")); $thread['description'] = $content; } else { if (strlen($content) > 255) { $thread['name'] = ""; } else { $thread['name'] = $content; } $thread['description'] = $content; } if ($GLOBALS['user']->id !== "nobody") { $thread['user_id'] = $GLOBALS['user']->id; $thread['author'] = get_fullname(); } else { if (Request::get("anonymous_security") === $_SESSION['blubber_anonymous_security']) { $contact_user = BlubberExternalContact::findByEmail(Request::get("anonymous_email")); $_SESSION['anonymous_email'] = Request::get("anonymous_email"); $_SESSION['anonymous_name'] = $contact_user['name'] = Request::get("anonymous_name"); $contact_user->store(); $thread['user_id'] = $contact_user->getId(); $thread['external_contact'] = 1; $thread['author'] = Request::get("anonymous_name"); } else { throw new AccessDeniedException("No permission to write posting."); } } $thread['author_host'] = $_SERVER['REMOTE_ADDR']; $thread['root_id'] = $thread->getId(); if ($thread->store()) { if ($context_type === "private") { $statement = DBManager::get()->prepare("INSERT IGNORE INTO blubber_mentions " . "SET user_id = :user_id, " . "topic_id = :thread_id, " . "mkdate = UNIX_TIMESTAMP() " . ""); $statement->execute(array('user_id' => $GLOBALS['user']->id, 'thread_id' => $thread->getId())); $contact_groups = Request::getArray("contact_groups"); foreach ($contact_groups as $gruppe_id) { $users = DBManager::get()->query("SELECT user_id " . "FROM statusgruppe_user " . "INNER JOIN statusgruppen ON (statusgruppe_user.statusgruppe_id = statusgruppen.statusgruppe_id) " . "WHERE statusgruppen.range_id = " . DBManager::get()->quote($GLOBALS['user']->id) . " " . "AND statusgruppe_user.statusgruppe_id = " . DBManager::get()->quote($gruppe_id) . " " . "")->fetchAll(PDO::FETCH_COLUMN, 0); foreach ($users as $user_id) { $statement->execute(array('user_id' => $user_id, 'thread_id' => $thread->getId())); //Meldung oder nicht Meldung, das ist hier die Frage. } } } $factory = new Flexi_TemplateFactory($this->plugin->getPluginPath() . "/views"); $template = $factory->open("forum/thread.php"); $template->set_attribute('thread', $thread); $template->set_attribute('controller', $this); $output['content'] = studip_utf8encode($template->render()); $output['mkdate'] = time(); $output['posting_id'] = $thread->getId(); } $this->render_json($output); }