function getNotificationObjects($course_id, $since, $user_id) { $items = array(); $type = get_object_type($course_id, array('sem', 'inst', 'fak')); if ($type == 'sem') { $query = 'SELECT wiki.*, seminare.Name, ' . $GLOBALS['_fullname_sql']['full'] . ' as fullname FROM wiki JOIN auth_user_md5 USING (user_id) JOIN user_info USING (user_id) JOIN seminar_user ON (range_id = Seminar_id) JOIN seminare USING (Seminar_id) WHERE seminar_user.user_id = ? AND Seminar_id = ? AND wiki.chdate > ?'; } else { $query = 'SELECT wiki.*, Institute.Name, ' . $GLOBALS['_fullname_sql']['full'] . ' as fullname FROM wiki JOIN auth_user_md5 USING (user_id) JOIN user_info USING (user_id) JOIN user_inst ON (range_id = Institut_id) JOIN Institute USING (Institut_id) WHERE user_inst.user_id = ? AND Institut_id = ? AND wiki.chdate > ?'; } $wikipage_stmt = DBManager::get()->prepare("SELECT * FROM wiki\n WHERE keyword = ? AND range_id = ?\n AND version = ?"); $stmt = DBManager::get()->prepare($query); $stmt->execute(array($user_id, $course_id, $since)); while ($row = $stmt->fetch()) { // use correct text depending on type of object if ($type == 'sem') { if ($row['version'] > 1) { $summary = sprintf('%s hat im Wiki der Veranstaltung "%s" die Seite "%s" geändert.', $row['fullname'], $row['Name'], $row['keyword']); } else { $summary = sprintf('%s hat im Wiki der Veranstaltung "%s" die Seite "%s" erstellt.', $row['fullname'], $row['Name'], $row['keyword']); } } else { if ($row['version'] > 1) { $summary = sprintf('%s hat im Wiki der Einreichtung "%s" die Seite "%s" geändert.', $row['fullname'], $row['Name'], $row['keyword']); } else { $summary = sprintf('%s hat im Wiki der Einreichtung "%s" die Seite "%s" erstellt.', $row['fullname'], $row['Name'], $row['keyword']); } } $content = ''; if ($row['version'] > 1) { $wikipage_stmt->execute(array($row['keyword'], $row['range_id'], $row['version'] - 1)); $old_page = $wikipage_stmt->fetch(PDO::FETCH_ASSOC); $content = '<table>' . do_diff($old_page['body'], $row['body']) . '</table>'; } else { $content = wikiReady($row['body']); } $items[] = new ContentElement('Wiki: ' . $row['keyword'], $summary, $content, $row['user_id'], $row['fullname'], URLHelper::getLink('wiki.php', array('cid' => $row['range_id'], 'keyword' => $row['keyword'])), $row['chdate']); } return $items; }
function extWikiReady ($text, $show_comments = 'all') { if ($this->is_raw_output) { return $text; } return wikiReady($text, TRUE, TRUE, $show_comments); }
private function wikiPageToJson($page, $without = array()) { $json = $page->toArray(words("range_id keyword chdate version")); // (pre-rendered) content if (!in_array("content", $without)) { $json['content'] = $page->body; $json['content_html'] = wikiReady($page->body); } if (!in_array("user", $without)) { $json['user'] = User::getMiniUser($this, $page->author); } foreach ($without as $key) { if (isset($json[$key])) { unset($json[$key]); } } // string to int conversions as SORM does not know about ints foreach (words("chdate mkdate filesize downloads") as $key) { if (isset($result[$key])) { $result[$key] = intval($result[$key]); } } return $json; }
function str_compare($str1, $str2, $show_equal=FALSE) { $this->set_str('diff',$str1,$str2); $this->compare(); $str = ''; $lastdiff = ""; $textaccu = ""; $template = "<tr>%s<td width=\"10\"> </td><td><font size=-1>%s</font> </td></tr>"; foreach ($this->toArray() as $obj) { if ($show_equal || $obj->get('diff') != $this->equal) { if ($lastdiff && $obj->get("diff") != $lastdiff) { $str .= sprintf($template, $lastdiff, wikiReady($textaccu)); $textaccu=""; } $textaccu .= $obj->text(); $lastdiff = $obj->get("diff"); } } if ($textaccu) { $str .= sprintf($template, $lastdiff, wikiReady($textaccu)); } return $str; }