コード例 #1
0
ファイル: forum.php プロジェクト: noackorama/blubberforum
 public function get_source_action()
 {
     $posting = new ForumPosting(Request::get("topic_id"));
     $thread = new ForumPosting($posting['root_id']);
     if ($thread['context_type'] === "course" && !$GLOBALS['perm']->have_studip_perm("autor", $posting['Seminar_id']) or $thread['context_type'] === "private" && !$thread->isRelated()) {
         throw new AccessDeniedException("Kein Zugriff");
     }
     echo studip_utf8encode(forum_kill_edit($posting['description']));
     $this->render_nothing();
 }
コード例 #2
0
 /**
  * Get all activities for this user as an array.
  */
 private function get_activities($user_id, $range, $days)
 {
     $db = \DBManager::get();
     $now = time();
     $chdate = $now - 24 * 60 * 60 * $days;
     $items = array();
     if ($range === 'user') {
         $sem_filter = "seminar_user.user_id = '{$user_id}' AND auth_user_md5.user_id = '{$user_id}'";
         $inst_filter = "user_inst.user_id = '{$user_id}' AND auth_user_md5.user_id = '{$user_id}'";
     } else {
         if (isset($range)) {
             $sem_filter = "seminar_user.user_id = '{$user_id}' AND Seminar_id = '{$range}'";
             $inst_filter = "user_inst.user_id = '{$user_id}' AND Institut_id = '{$range}'";
         } else {
             $sem_filter = "seminar_user.user_id = '{$user_id}'";
             $inst_filter = "user_inst.user_id = '{$user_id}'";
         }
     }
     $sem_fields = 'auth_user_md5.user_id AS author_id, auth_user_md5.Vorname, auth_user_md5.Nachname, seminare.Name';
     $inst_fields = 'auth_user_md5.user_id AS author_id, auth_user_md5.Vorname, auth_user_md5.Nachname, Institute.Name';
     $user_fields = 'auth_user_md5.user_id AS author_id, auth_user_md5.Vorname, auth_user_md5.Nachname, auth_user_md5.username';
     // forum
     $sql = "SELECT px_topics.*, {$sem_fields}\n                FROM px_topics\n                JOIN auth_user_md5 USING (user_id)\n                JOIN seminar_user USING (Seminar_id)\n                JOIN seminare USING (Seminar_id)\n                WHERE {$sem_filter} AND px_topics.chdate > {$chdate}";
     $result = $db->query($sql);
     foreach ($result as $row) {
         $items[] = array('id' => $row['topic_id'], 'title' => $row['name'], 'author' => $row['Vorname'] . ' ' . $row['Nachname'], 'author_id' => $row['author_id'], 'link' => \URLHelper::getLink('forum.php#anker', array('cid' => $row['Seminar_id'], 'view' => 'tree', 'open' => $row['topic_id'])), 'updated' => $row['chdate'], 'summary' => sprintf('%s %s hat im Forum der Veranstaltung "%s" den Beitrag "%s" geschrieben.', $row['Vorname'], $row['Nachname'], $row['Name'], $row['name']), 'content' => forum_kill_edit($row['description']), 'category' => 'forum');
     }
     $sql = "SELECT px_topics.*, {$inst_fields}\n                FROM px_topics\n                JOIN auth_user_md5 USING (user_id)\n                JOIN user_inst ON (Seminar_id = Institut_id)\n                JOIN Institute USING (Institut_id)\n                WHERE {$inst_filter} AND px_topics.chdate > {$chdate}";
     $result = $db->query($sql);
     foreach ($result as $row) {
         $items[] = array('id' => $row['topic_id'], 'title' => $row['name'], 'author' => $row['Vorname'] . ' ' . $row['Nachname'], 'author_id' => $row['author_id'], 'link' => \URLHelper::getLink('forum.php#anker', array('cid' => $row['Institut_id'], 'view' => 'tree', 'open' => $row['topic_id'])), 'updated' => $row['chdate'], 'summary' => sprintf('%s %s hat im Forum der Einrichtung "%s" den Beitrag "%s" geschrieben.', $row['Vorname'], $row['Nachname'], $row['Name'], $row['name']), 'content' => forum_kill_edit($row['description']), 'category' => 'forum');
     }
     // files
     $sql = "SELECT dokumente.*, {$sem_fields}\n                FROM dokumente\n                JOIN auth_user_md5 USING (user_id)\n                JOIN seminar_user USING (Seminar_id)\n                JOIN seminare USING (Seminar_id)\n                WHERE {$sem_filter} AND dokumente.chdate > {$chdate}";
     $result = $db->query($sql);
     foreach ($result as $row) {
         $folder_tree = \TreeAbstract::GetInstance('StudipDocumentTree', array('range_id' => $row['seminar_id']));
         if ($folder_tree->isDownloadFolder($row['range_id'], $user_id)) {
             $items[] = array('id' => $row['dokument_id'], 'title' => $row['name'], 'author' => $row['Vorname'] . ' ' . $row['Nachname'], 'author_id' => $row['author_id'], 'link' => \URLHelper::getLink('folder.php#anker', array('cid' => $row['seminar_id'], 'cmd' => 'tree', 'open' => $row['dokument_id'])), 'updated' => $row['chdate'], 'summary' => sprintf('%s %s hat im Dateibereich der Veranstaltung "%s" die Datei "%s" hochgeladen.', $row['Vorname'], $row['Nachname'], $row['Name'], $row['name']), 'content' => $row['description'] . " (" . $row['filename'] . ")", 'category' => 'files');
         }
     }
     $sql = "SELECT dokumente.*, {$inst_fields}\n                FROM dokumente\n                JOIN auth_user_md5 USING (user_id)\n                JOIN user_inst ON (seminar_id = Institut_id)\n                JOIN Institute USING (Institut_id)\n                WHERE {$inst_filter} AND dokumente.chdate > {$chdate}";
     $result = $db->query($sql);
     foreach ($result as $row) {
         $folder_tree = \TreeAbstract::GetInstance('StudipDocumentTree', array('range_id' => $row['seminar_id']));
         if ($folder_tree->isDownloadFolder($row['range_id'], $user_id)) {
             $items[] = array('id' => $row['dokument_id'], 'title' => $row['name'], 'author' => $row['Vorname'] . ' ' . $row['Nachname'], 'author_id' => $row['author_id'], 'link' => \URLHelper::getLink('folder.php#anker', array('cid' => $row['Institut_id'], 'cmd' => 'tree', 'open' => $row['dokument_id'])), 'updated' => $row['chdate'], 'summary' => sprintf('%s %s hat im Dateibereich der Einrichtung "%s" die Datei "%s" hochgeladen.', $row['Vorname'], $row['Nachname'], $row['Name'], $row['name']), 'content' => $row['description'], 'category' => 'files');
         }
     }
     // wiki
     $sql = "SELECT wiki.*, {$sem_fields}\n                FROM wiki\n                JOIN auth_user_md5 USING (user_id)\n                JOIN seminar_user ON (range_id = Seminar_id)\n                JOIN seminare USING (Seminar_id)\n                WHERE {$sem_filter} AND wiki.chdate > {$chdate}";
     $result = $db->query($sql);
     foreach ($result as $row) {
         $items[] = array('id' => md5($row['range_id'] . ':' . $row['keyword'] . ':' . $row['version']), 'title' => $row['keyword'], 'author' => $row['Vorname'] . ' ' . $row['Nachname'], 'author_id' => $row['author_id'], 'link' => \URLHelper::getLink('wiki.php', array('cid' => $row['range_id'], 'keyword' => $row['keyword'])), 'updated' => $row['chdate'], 'summary' => sprintf('%s %s hat im Wiki der Veranstaltung "%s" die Seite "%s" geändert.', $row['Vorname'], $row['Nachname'], $row['Name'], $row['keyword']), 'content' => $row['body'], 'category' => 'wiki');
     }
     $sql = "SELECT wiki.*, {$inst_fields}\n                FROM wiki\n                JOIN auth_user_md5 USING (user_id)\n                JOIN user_inst ON (range_id = Institut_id)\n                JOIN Institute USING (Institut_id)\n                WHERE {$inst_filter} AND wiki.chdate > {$chdate}";
     $result = $db->query($sql);
     foreach ($result as $row) {
         $items[] = array('id' => md5($row['range_id'] . ':' . $row['keyword'] . ':' . $row['version']), 'title' => $row['keyword'], 'author' => $row['Vorname'] . ' ' . $row['Nachname'], 'author_id' => $row['author_id'], 'link' => \URLHelper::getLink('wiki.php', array('cid' => $row['range_id'], 'keyword' => $row['keyword'])), 'updated' => $row['chdate'], 'summary' => sprintf('%s %s hat im Wiki der Einrichtung "%s" die Seite "%s" geändert.', $row['Vorname'], $row['Nachname'], $row['Name'], $row['keyword']), 'content' => $row['body'], 'category' => 'wiki');
     }
     // info
     $sql = "SELECT scm.*, {$sem_fields}\n                FROM scm\n                JOIN auth_user_md5 USING (user_id)\n                JOIN seminar_user ON (range_id = Seminar_id)\n                JOIN seminare USING (Seminar_id)\n                WHERE {$sem_filter} AND scm.chdate > {$chdate}";
     $result = $db->query($sql);
     foreach ($result as $row) {
         $items[] = array('id' => $row['scm_id'], 'title' => $row['tab_name'], 'author' => $row['Vorname'] . ' ' . $row['Nachname'], 'author_id' => $row['author_id'], 'link' => \URLHelper::getLink('scm.php', array('cid' => $row['range_id'], 'show_scm' => $row['scm_id'])), 'updated' => $row['chdate'], 'summary' => sprintf('%s %s hat in der Veranstaltung "%s" die Informationsseite "%s" geändert.', $row['Vorname'], $row['Nachname'], $row['Name'], $row['tab_name']), 'content' => $row['content'], 'category' => 'info');
     }
     $sql = "SELECT scm.*, {$inst_fields}\n                FROM scm\n                JOIN auth_user_md5 USING (user_id)\n                JOIN user_inst ON (range_id = Institut_id)\n                JOIN Institute USING (Institut_id)\n                WHERE {$inst_filter} AND scm.chdate > {$chdate}";
     $result = $db->query($sql);
     foreach ($result as $row) {
         $items[] = array('id' => $row['scm_id'], 'title' => $row['tab_name'], 'author' => $row['Vorname'] . ' ' . $row['Nachname'], 'author_id' => $row['author_id'], 'link' => \URLHelper::getLink('scm.php', array('cid' => $row['range_id'], 'show_scm' => $row['scm_id'])), 'updated' => $row['chdate'], 'summary' => sprintf('%s %s hat in der Einrichtung "%s" die Informationsseite "%s" geändert.', $row['Vorname'], $row['Nachname'], $row['Name'], $row['tab_name']), 'content' => $row['content'], 'category' => 'info');
     }
     // news
     if ($range === 'user') {
         $sql = "SELECT news.*, news_range.range_id, {$user_fields}\n                    FROM news\n                    JOIN news_range USING (news_id)\n                    JOIN auth_user_md5 USING (user_id)\n                    WHERE range_id = '{$user_id}' AND news.date BETWEEN {$chdate} AND {$now}";
         $result = $db->query($sql);
         foreach ($result as $row) {
             $items[] = array('id' => $row['news_id'], 'title' => $row['topic'], 'author' => $row['Vorname'] . ' ' . $row['Nachname'], 'author_id' => $row['author_id'], 'link' => \URLHelper::getLink('about.php#anker', array('username' => $row['username'], 'nopen' => $row['news_id'])), 'updated' => max($row['date'], $row['chdate']), 'summary' => sprintf('%s %s hat die persönliche Ankündigung "%s" eingestellt.', $row['Vorname'], $row['Nachname'], $row['topic']), 'content' => $row['body'], 'category' => 'news');
         }
     }
     $sql = "SELECT news.*, news_range.range_id, {$sem_fields}\n                FROM news\n                JOIN news_range USING (news_id)\n                JOIN auth_user_md5 USING (user_id)\n                JOIN seminar_user ON (range_id = Seminar_id)\n                JOIN seminare USING (Seminar_id)\n                WHERE {$sem_filter} AND news.date BETWEEN {$chdate} AND {$now}";
     $result = $db->query($sql);
     foreach ($result as $row) {
         $items[] = array('id' => $row['news_id'], 'title' => $row['topic'], 'author' => $row['Vorname'] . ' ' . $row['Nachname'], 'author_id' => $row['author_id'], 'link' => \URLHelper::getLink('seminar_main.php#anker', array('cid' => $row['range_id'], 'nopen' => $row['news_id'])), 'updated' => max($row['date'], $row['chdate']), 'summary' => sprintf('%s %s hat in der Veranstaltung "%s" die Ankündigung "%s" eingestellt.', $row['Vorname'], $row['Nachname'], $row['Name'], $row['topic']), 'content' => $row['body'], 'category' => 'news');
     }
     $sql = "SELECT news.*, news_range.range_id, {$inst_fields}\n                FROM news\n                JOIN news_range USING (news_id)\n                JOIN auth_user_md5 USING (user_id)\n                JOIN user_inst ON (range_id = Institut_id)\n                JOIN Institute USING (Institut_id)\n                WHERE {$inst_filter} AND news.date BETWEEN {$chdate} AND {$now}";
     $result = $db->query($sql);
     foreach ($result as $row) {
         $items[] = array('id' => $row['news_id'], 'title' => $row['topic'], 'author' => $row['Vorname'] . ' ' . $row['Nachname'], 'author_id' => $row['author_id'], 'link' => \URLHelper::getLink('institut_main.php#anker', array('cid' => $row['range_id'], 'nopen' => $row['news_id'])), 'updated' => max($row['date'], $row['chdate']), 'summary' => sprintf('%s %s hat in der Einrichtung "%s" die Ankündigung "%s" eingestellt.', $row['Vorname'], $row['Nachname'], $row['Name'], $row['topic']), 'content' => $row['body'], 'category' => 'news');
     }
     // votings
     if ($range === 'user') {
         $sql = "SELECT vote.*, {$user_fields}\n                    FROM vote\n                    JOIN auth_user_md5 ON (author_id = user_id)\n                    WHERE range_id = '{$user_id}' AND vote.startdate BETWEEN {$chdate} AND {$now}";
         $result = $db->query($sql);
         foreach ($result as $row) {
             $items[] = array('id' => $row['vote_id'], 'title' => $row['title'], 'author' => $row['Vorname'] . ' ' . $row['Nachname'], 'author_id' => $row['author_id'], 'link' => \URLHelper::getLink('about.php#openvote', array('username' => $row['username'], 'voteopenID' => $row['vote_id'])), 'updated' => max($row['startdate'], $row['chdate']), 'summary' => sprintf('%s %s hat die persönliche Umfrage "%s" gestartet.', $row['Vorname'], $row['Nachname'], $row['title']), 'content' => $row['question'], 'category' => 'votings');
         }
     }
     $sql = "SELECT vote.*, {$sem_fields}\n                FROM vote\n                JOIN auth_user_md5 ON (author_id = user_id)\n                JOIN seminar_user ON (range_id = Seminar_id)\n                JOIN seminare USING (Seminar_id)\n                WHERE {$sem_filter} AND vote.startdate BETWEEN {$chdate} AND {$now}";
     $result = $db->query($sql);
     foreach ($result as $row) {
         $items[] = array('id' => $row['vote_id'], 'title' => $row['title'], 'author' => $row['Vorname'] . ' ' . $row['Nachname'], 'author_id' => $row['author_id'], 'link' => \URLHelper::getLink('seminar_main.php#openvote', array('cid' => $row['range_id'], 'voteopenID' => $row['vote_id'])), 'updated' => max($row['startdate'], $row['chdate']), 'summary' => sprintf('%s %s hat in der Veranstaltung "%s" die Umfrage "%s" gestartet.', $row['Vorname'], $row['Nachname'], $row['Name'], $row['title']), 'content' => $row['question'], 'category' => 'votings');
     }
     $sql = "SELECT vote.*, {$inst_fields}\n                FROM vote\n                JOIN auth_user_md5 ON (author_id = user_id)\n                JOIN user_inst ON (range_id = Institut_id)\n                JOIN Institute USING (Institut_id)\n                WHERE {$inst_filter} AND vote.startdate BETWEEN {$chdate} AND {$now}";
     $result = $db->query($sql);
     foreach ($result as $row) {
         $items[] = array('id' => $row['vote_id'], 'title' => $row['title'], 'author' => $row['Vorname'] . ' ' . $row['Nachname'], 'author_id' => $row['author_id'], 'link' => \URLHelper::getLink('institut_main.php#openvote', array('cid' => $row['range_id'], 'voteopenID' => $row['vote_id'])), 'updated' => max($row['startdate'], $row['chdate']), 'summary' => sprintf('%s %s hat in der Einrichtung "%s" die Umfrage "%s" gestartet.', $row['Vorname'], $row['Nachname'], $row['Name'], $row['title']), 'content' => $row['question'], 'category' => 'votings');
     }
     // surveys
     if ($range === 'user') {
         $sql = "SELECT eval.*, {$user_fields}\n                    FROM eval\n                    JOIN eval_range USING (eval_id)\n                    JOIN auth_user_md5 ON (author_id = user_id)\n                    WHERE range_id = '{$user_id}' AND eval.startdate BETWEEN {$chdate} AND {$now}";
         $result = $db->query($sql);
         foreach ($result as $row) {
             $items[] = array('id' => $row['eval_id'], 'title' => $row['title'], 'author' => $row['Vorname'] . ' ' . $row['Nachname'], 'author_id' => $row['author_id'], 'link' => \URLHelper::getLink('about.php#openvote', array('username' => $row['username'], 'voteopenID' => $row['eval_id'])), 'updated' => max($row['startdate'], $row['chdate']), 'summary' => sprintf('%s %s hat die persönliche Evaluation "%s" gestartet.', $row['Vorname'], $row['Nachname'], $row['title']), 'content' => $row['text'], 'category' => 'surveys');
         }
     }
     $sql = "SELECT eval.*, {$sem_fields}\n                FROM eval\n                JOIN eval_range USING (eval_id)\n                JOIN auth_user_md5 ON (author_id = user_id)\n                JOIN seminar_user ON (range_id = Seminar_id)\n                JOIN seminare USING (Seminar_id)\n                WHERE {$sem_filter} AND eval.startdate BETWEEN {$chdate} AND {$now}";
     $result = $db->query($sql);
     foreach ($result as $row) {
         $items[] = array('id' => $row['eval_id'], 'title' => $row['title'], 'author' => $row['Vorname'] . ' ' . $row['Nachname'], 'author_id' => $row['author_id'], 'link' => \URLHelper::getLink('seminar_main.php#openvote', array('cid' => $row['range_id'], 'voteopenID' => $row['eval_id'])), 'updated' => max($row['startdate'], $row['chdate']), 'summary' => sprintf('%s %s hat in der Veranstaltung "%s" die Evaluation "%s" gestartet.', $row['Vorname'], $row['Nachname'], $row['Name'], $row['title']), 'content' => $row['text'], 'category' => 'surveys');
     }
     $sql = "SELECT eval.*, {$inst_fields}\n                FROM eval\n                JOIN eval_range USING (eval_id)\n                JOIN auth_user_md5 ON (author_id = user_id)\n                JOIN user_inst ON (range_id = Institut_id)\n                JOIN Institute USING (Institut_id)\n                WHERE {$inst_filter} AND eval.startdate BETWEEN {$chdate} AND {$now}";
     $result = $db->query($sql);
     foreach ($result as $row) {
         $items[] = array('id' => $row['eval_id'], 'title' => $row['title'], 'author' => $row['Vorname'] . ' ' . $row['Nachname'], 'author_id' => $row['author_id'], 'link' => \URLHelper::getLink('institut_main.php#openvote', array('cid' => $row['range_id'], 'voteopenID' => $row['eval_id'])), 'updated' => max($row['startdate'], $row['chdate']), 'summary' => sprintf('%s %s hat in der Einrichtung "%s" die Evaluation "%s" gestartet.', $row['Vorname'], $row['Nachname'], $row['Name'], $row['title']), 'content' => $row['text'], 'category' => 'surveys');
     }
     // sort everything
     usort($items, create_function('$a, $b', 'return $b["updated"] - $a["updated"];'));
     $items = array_slice($items, 0, 100);
     return $items;
 }