/** * Generate sitemap(s) and an index * * @return bool */ public function generate() { // check that the sitemaps directory exists and create it if it doesn't check_dir_exists($this->directory, true); // this is used by PluginInteractionForum::get_active_topics $USER = new User(); // create a new sitemap $this->create_sitemap(); // get a list of public groups $publicgroups = get_records_select_array('group', 'public = 1 AND deleted = 0'); if (!empty($publicgroups)) { foreach ($publicgroups as $group) { if (isset($group->mtime) && $this->check_date($group->mtime)) { // each group gets a url entry $groupurl = group_homepage_url($group); $groupurl = utf8_encode(htmlspecialchars($groupurl, ENT_QUOTES, 'UTF-8')); $grouplastmod = format_date(strtotime($group->mtime), 'strftimew3cdate'); $this->add_url($groupurl, $grouplastmod); } // build a list of forums in each public group $forums = get_forum_list($group->id); $forumids = array(); foreach ($forums as $forum) { $forumids[] = $forum->id; } // active topics within the specified forums (public only) $activetopics = PluginInteractionForum::get_active_topics(0, 0, 0, $forumids); foreach ($activetopics['data'] as $topic) { if (isset($topic->mtime) && $this->check_date($topic->mtime) || isset($topic->ctime) && $this->check_date($topic->ctime)) { $forumurl = get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $topic->id; $forumurl = utf8_encode(htmlspecialchars($forumurl, ENT_QUOTES, 'UTF-8')); // mtime will be set if the last post has been edited if (isset($topic->mtime) && strtotime($topic->mtime) !== FALSE) { $forumlastmod = format_date(strtotime($topic->mtime), 'strftimew3cdate'); } else { $forumlastmod = format_date(strtotime($topic->ctime), 'strftimew3cdate'); } $this->add_url($forumurl, $forumlastmod); } } } } // views shared with the public // grouphomepage type views are handled above $types = array('portfolio'); $views = View::view_search(null, null, null, null, null, 0, true, null, $types); if (!empty($views->data)) { foreach ($views->data as $view) { if (isset($view['mtime']) && $this->check_date($view['mtime'])) { $viewurl = utf8_encode(htmlspecialchars($view['fullurl'], ENT_QUOTES, 'UTF-8')); $viewlastmod = format_date(strtotime($view['mtime']), 'strftimew3cdate'); $this->add_url($viewurl, $viewlastmod); } } } // add the urlset and print the xml out // only if the urlset has any children if ($this->currenturlset->hasChildNodes()) { $this->save_sitemap(true); } return true; }
/** * * @package mahara * @subpackage core * @author Catalyst IT Ltd * @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later * @copyright For copyright information on Mahara, please see the README file distributed with this software. * */ define('INTERNAL', 1); define('MENUITEM', 'groups/topics'); require dirname(dirname(__FILE__)) . '/init.php'; require_once 'pieforms/pieform.php'; safe_require('interaction', 'forum'); require_once 'group.php'; define('TITLE', get_string('Topics', 'interaction.forum')); if (!$USER->is_logged_in()) { throw new AccessDeniedException(get_string('accessdenied', 'error')); } $limit = param_integer('limit', 10); $offset = param_integer('offset', 0); $category = param_integer('category', 0); $data = PluginInteractionForum::get_active_topics($limit, $offset, $category); $pagination = build_pagination(array('id' => 'topics_pagination', 'url' => get_config('wwwroot') . 'group/topics.php' . ($category ? '?category=' . (int) $category : ''), 'jsonscript' => 'json/topics.php', 'datatable' => 'topiclist', 'count' => $data['count'], 'limit' => $limit, 'offset' => $offset)); $smarty = smarty(array('paginator')); $smarty->assign_by_ref('topics', $data['data']); $smarty->assign_by_ref('pagination', $pagination['html']); $smarty->assign('INLINEJAVASCRIPT', 'addLoadEvent(function() { p = ' . $pagination['javascript'] . '});'); $smarty->assign('PAGEHEADING', TITLE); $smarty->display('group/topics.tpl');