1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8//this script may only be included - so its better to die if called directly. 9if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) { 10 header("location: index.php"); 11 exit; 12} 13 14/** 15 * @return array 16 */ 17function module_last_blog_posts_info() 18{ 19 return [ 20 'name' => tra('Newest Blog Posts'), 21 'description' => tra('Lists the specified number of blogs posts from newest to oldest.'), 22 'prefs' => ["feature_blogs"], 23 'params' => [ 24 'nodate' => [ 25 'name' => tra('No date'), 26 'description' => tra('If set to "y", the date of posts is not displayed in the module box.') . " " . tra('Default: "n".'), 27 ], 28 'blogid' => [ 29 'name' => tra('Blog identifier'), 30 'description' => tra('If set to a blog identifier, restricts the blog posts to those in the identified blog.') . " " . tra('Example value: 13.') . " " . tra('Not set by default.'), 31 'profile_reference' => 'blog', 32 ] 33 ], 34 'common_params' => ['nonums', 'rows'] 35 ]; 36} 37 38/** 39 * @param $mod_reference 40 * @param $module_params 41 */ 42function module_last_blog_posts($mod_reference, $module_params) 43{ 44 $smarty = TikiLib::lib('smarty'); 45 46 $blogId = isset($module_params["blogid"]) ? $module_params["blogid"] : 0; 47 $smarty->assign('blogid', $blogId); 48 49 $perms = Perms::get([ 'type' => 'blog', 'object' => $blogId ]); 50 TikiLib::lib('tiki')->get_perm_object($blogId, 'blog'); 51 52 $blog_posts = TikiLib::lib('blog')->list_blog_posts($blogId, $perms->blog_admin, 0, $mod_reference["rows"], 'created_desc', '', '', TikiLib::lib('tiki')->now); 53 $smarty->assign('modLastBlogPosts', $blog_posts["data"]); 54 $smarty->assign('nodate', isset($module_params["nodate"]) ? $module_params["nodate"] : 'n'); 55} 56