$sql = "\n SELECT u.firstname, u.lastname, p.id, p.parent, p.topic, p.subject, p.body, p.ctime\n FROM {interaction_forum_post} p\n INNER JOIN {usr} u ON p.poster = u.id\n WHERE p.deleted = 0\n AND p.topic = ?"; $link = get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $id; $title = implode(' - ', array(get_field('group', 'name', 'id', $group->id), get_field('interaction_instance', 'title', 'id', $forumid), get_field_sql("\n SELECT p.subject\n FROM {interaction_forum_post} p\n WHERE p.topic = ?\n AND p.parent IS NULL", array($id)), get_string('allposts', 'interaction.forum'))); } if (!$group->public) { generate_feed(error_feed(), error_post(get_string('notpublic', 'group'))); exit; } $sql .= "\n ORDER BY p.ctime DESC\n LIMIT ?;"; $selflink = get_config('wwwroot') . 'interaction/forum/atom.php?type=' . $feedtype . '&id=' . $id; $postcount = 20; $postrecords = get_records_sql_array($sql, array($id, $postcount)); $image = get_config('wwwroot') . 'theme/raw/static/images/site-logo.png'; $updated = $postrecords ? atom_date($postrecords[0]->ctime) : ''; $generator = array('uri' => 'https://mahara.org', 'version' => get_config('series'), 'text' => 'Mahara'); $feed = array('title' => $title, 'link' => $link, 'selflink' => $selflink, 'id' => implode(',', array(get_config('wwwroot'), $feedtype, $id)), 'updated' => $updated, 'logo' => $image, 'icon' => get_config('wwwroot') . 'favicon.ico', 'generator' => $generator); $posts = array(); if ($postrecords) { foreach ($postrecords as &$post) { $parent = $post->parent; while (!$post->subject) { $post->subject = get_field('interaction_forum_post', 'subject', 'id', $parent); $parent = get_field('interaction_forum_post', 'parent', 'id', $parent); } if ($parent != $post->parent) { $post->subject = get_string('re', 'interaction.forum', $post->subject); } $posts[] = array('title' => $post->subject, 'link' => get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $post->topic . '&post=' . $post->id, 'id' => implode(',', array(get_config('wwwroot'), $post->topic, $post->id)), 'description' => $post->body, 'mtime' => atom_date($post->ctime), 'author' => implode(' ', array($post->firstname, $post->lastname))); } } generate_feed($feed, $posts);
$updated = $owner[0]->mtime; } $generator = array('uri' => 'https://mahara.org', 'version' => get_config('series'), 'text' => 'Mahara'); $rights = get_string('feedrights', 'artefact.blog', substr($updated, 0, 4) . ' ' . $author['name']); // is there a Creative Commons block in this view? // if so, set the feed rights accordingly $ccblock = get_records_sql_array("\n SELECT b.id\n FROM {block_instance} b\n WHERE b.view = ?\n AND b.blocktype = 'creativecommons'\n LIMIT 1;", array($viewid)); if ($ccblock) { require_once get_config('docroot') . 'blocktype/lib.php'; $ccblock_instance = new BlockInstance($ccblock[0]->id); $configdata = $ccblock_instance->get('configdata'); $licensetype = $configdata['license']; $licenseurl = "http://creativecommons.org/licenses/{$licensetype}/3.0/"; $licensename = get_string($licensetype, 'blocktype.creativecommons'); $rights .= ' ' . get_string('licensestatement', 'blocktype.creativecommons', $licenseurl, $licensename); } $feed = array('title' => $artefact->get('title'), 'link' => $link, 'selflink' => $selflink, 'id' => implode(',', array(get_config('wwwroot'), $artefactid, $viewid)), 'description' => $artefact->get('description'), 'author' => $author, 'updated' => atom_date($updated), 'logo' => $image, 'icon' => get_config('wwwroot') . 'favicon.ico', 'generator' => $generator, 'rights' => $rights); $posts = array(); if ($postids) { foreach ($postids as $postid) { $post = artefact_instance_from_id($postid->id); $attachments = $post->get_attachments(); $attachlinks = array(); foreach ($attachments as $attachment) { $attachlinks[] = array('link' => get_config('wwwroot') . 'artefact/file/download.php?file=' . $attachment->id . '&view=' . $viewid, 'title' => $attachment->title); } $posts[] = array('title' => $post->get('title'), 'link' => get_config('wwwroot') . 'artefact/artefact.php?artefact=' . $post->get('id') . '&view=' . $viewid, 'id' => implode(',', array(get_config('wwwroot'), $post->get('id'), $viewid)), 'description' => $post->get('description'), 'mtime' => atom_date($postid->mtime), 'attachments' => $attachlinks); } } generate_feed($feed, $posts); }
function blog_atom_entry($blog) { global $config; $summary = $blog['description']; if ($config['local_alternates']) { $blog['url'] = slinkto("blog_search.php", array(), array("blog_id" => $blog['blog_id'])); } $image = ""; $default_image_pattern = "/default\\.png/i"; if ($blog['image'] && !preg_match($default_image_pattern, $blog['image'])) { $image = sprintf("<link rel='related' title='portrait' type='%s' href='%s%s'/>", get_content_type($blog['image']), $config['base_url'], $blog['image']); } $summary = make_var_atom_safe($summary); $blog = make_array_atom_safe($blog); $return .= "\n<entry>\n\t<title><![CDATA[" . strip_tags($blog['title']) . "]]></title>\n\t<link rel='alternate' href=\"" . $blog['url'] . "\"/>\n\t{$image}\n\t<id>" . slinkto("blog_search.php", array(), array("blog_id" => $blog['blog_id'])) . "</id>\n\t<updated>" . atom_date($blog['added_on']) . "</updated>\n\t<summary><![CDATA[{$summary}]]></summary>\n\t<gd:rating value='" . $blog['incoming_bloglove'] . "' min='0' max='1000'/>\n</entry>\n"; return $return; }