1<?php 2/** 3 * @package tikiwiki 4 */ 5// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 6// 7// All Rights Reserved. See copyright.txt for details and a complete list of authors. 8// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 9// $Id$ 10 11$section = 'blogs'; 12require_once('tiki-setup.php'); 13$bloglib = TikiLib::lib('blog'); 14 15$access->check_feature('feature_blogs'); 16$access->check_permission('tiki_p_create_blogs'); 17 18if (isset($_REQUEST["blogId"])) { 19 $blogId = $_REQUEST["blogId"]; 20} else { 21 $blogId = 0; 22} 23 24$smarty->assign('individual', 'n'); 25 26$tikilib->get_perm_object($blogId, 'blog'); 27 28$smarty->assign('blogId', $blogId); 29$smarty->assign('title', ''); 30$smarty->assign('description', ''); 31$smarty->assign('public', 'y'); 32$smarty->assign('use_find', 'n'); 33$smarty->assign('add_date', 'y'); 34$smarty->assign('use_title', 'y'); 35$smarty->assign('use_title_in_post', 'y'); 36$smarty->assign('use_description', 'y'); 37$smarty->assign('use_breadcrumbs', 'n'); 38$smarty->assign('use_author', 'y'); 39$smarty->assign('allow_comments', 'y'); 40$smarty->assign('show_avatar', 'n'); 41$smarty->assign('show_related', 'n'); 42$smarty->assign('related_max', 5); 43$smarty->assign('maxPosts', 25); 44$smarty->assign('use_excerpt', 'n'); 45$smarty->assign('creator', $user); 46 47 48if (! isset($created)) { 49 $created = time(); 50 $smarty->assign('created', $created); 51} 52 53if (! isset($lastModif)) { 54 $lastModif = time(); 55 $smarty->assign('lastModif', $lastModif); 56} 57 58if (isset($_REQUEST["blogId"]) && $_REQUEST["blogId"] > 0) { 59 // Check permission 60 $data = $bloglib->get_blog($_REQUEST["blogId"]); 61 62 if ($data["user"] != $user || ! $user) { 63 if ($tiki_p_blog_admin != 'y') { 64 $smarty->assign('errortype', 401); 65 $smarty->assign('msg', tra("You do not have permission to edit this blog")); 66 67 $smarty->display("error.tpl"); 68 die; 69 } 70 } 71 72 $smarty->assign('title', $data["title"]); 73 $smarty->assign('description', $data["description"]); 74 $smarty->assign('public', $data["public"]); 75 $smarty->assign('add_date', $data["add_date"]); 76 $smarty->assign('use_title', $data["use_title"]); 77 $smarty->assign('use_title_in_post', $data["use_title_in_post"]); 78 $smarty->assign('use_description', $data["use_description"]); 79 $smarty->assign('use_breadcrumbs', $data["use_breadcrumbs"]); 80 $smarty->assign('use_author', $data["use_author"]); 81 $smarty->assign('allow_comments', $data["allow_comments"]); 82 $smarty->assign('show_avatar', $data["show_avatar"]); 83 $smarty->assign('show_related', $data["show_related"]); 84 $smarty->assign('related_max', $data["related_max"]); 85 $smarty->assign('use_find', $data["use_find"]); 86 $smarty->assign('maxPosts', $data["maxPosts"]); 87 $smarty->assign('use_excerpt', $data["use_excerpt"]); 88 $smarty->assign('creator', $data["user"]); 89 $smarty->assign('alwaysOwner', $data["always_owner"]); 90} 91 92if (isset($_REQUEST["heading"]) and $tiki_p_edit_templates == 'y') { 93 // Sanitization cleanup 94 $heading = preg_replace('/st<x>yle="[^"]*"/', 'style_dangerous', $_REQUEST["heading"]); 95} elseif (! isset($data["heading"])) { 96 $heading = file_get_contents($smarty->get_filename('blog_heading.tpl')); 97 if (! $heading) { 98 $heading = ''; 99 } 100} else { 101 $heading = $data["heading"]; 102} 103 104if (isset($_REQUEST["post_heading"]) and $tiki_p_edit_templates == 'y') { 105 // Sanitization cleanup 106 $post_heading = preg_replace('/st<x>yle="[^"]*"/', 'style_dangerous', $_REQUEST["post_heading"]); 107} elseif (! isset($data["post_heading"])) { 108 $post_heading = file_get_contents($smarty->get_filename('blog_post_heading.tpl')); 109 if (! $post_heading) { 110 $post_heading = ''; 111 } 112} else { 113 $post_heading = $data["post_heading"]; 114} 115 116$smarty->assign_by_ref('heading', $heading); 117$smarty->assign_by_ref('post_heading', $post_heading); 118$users = $userlib->list_all_users(); 119$smarty->assign_by_ref('users', $users); 120 121$category_needed = false; 122if (isset($_REQUEST["save"]) && $prefs['feature_categories'] == 'y' && $prefs['feature_blog_mandatory_category'] >= 0 && (empty($_REQUEST['cat_categories']) || count($_REQUEST['cat_categories']) <= 0)) { 123 $category_needed = true; 124 $smarty->assign('category_needed', 'y'); 125} elseif (isset($_REQUEST["save"]) || isset($_REQUEST['preview'])) { 126 check_ticket('edit-blog'); 127 if (isset($_REQUEST["public"]) && $_REQUEST["public"] == 'on') { 128 $public = 'y'; 129 } else { 130 $public = 'n'; 131 } 132 133 $allow_comments = isset($_REQUEST["allow_comments"]) ? 'y' : 'n'; 134 $show_avatar = isset($_REQUEST['show_avatar']) ? 'y' : 'n'; 135 $show_related = isset($_REQUEST['show_related']) ? 'y' : 'n'; 136 $related_max = isset($_REQUEST['related_max']) ? $_REQUEST['related_max'] : 5; 137 $use_excerpt = isset($_REQUEST['use_excerpt']) ? 'y' : 'n'; 138 $use_find = isset($_REQUEST['use_find']) ? 'y' : 'n'; 139 $use_title = isset($_REQUEST['use_title']) ? 'y' : 'n'; 140 $use_title_in_post = isset($_REQUEST['use_title_in_post']) ? 'y' : 'n'; 141 $use_description = isset($_REQUEST['use_description']) ? 'y' : 'n'; 142 $use_breadcrumbs = isset($_REQUEST['use_breadcrumbs']) ? 'y' : 'n'; 143 $use_author = isset($_REQUEST['use_author']) ? 'y' : 'n'; 144 $add_date = isset($_REQUEST['add_date']) ? 'y' : 'n'; 145 $alwaysOwner = isset($_REQUEST['alwaysOwner']) ? 'y' : 'n'; 146 147 if (isset($_REQUEST["save"])) { 148 $bid = $bloglib->replace_blog( 149 $_REQUEST["title"], 150 $_REQUEST["description"], 151 $_REQUEST["creator"], 152 $public, 153 $_REQUEST["maxPosts"], 154 $_REQUEST["blogId"], 155 $heading, 156 $use_title, 157 $use_title_in_post, 158 $use_description, 159 $use_breadcrumbs, 160 $use_author, 161 $add_date, 162 $use_find, 163 $allow_comments, 164 $show_avatar, 165 $alwaysOwner, 166 $post_heading, 167 $show_related, 168 $related_max, 169 $use_excerpt 170 ); 171 172 $cat_type = 'blog'; 173 $cat_objid = $bid; 174 $cat_desc = substr($_REQUEST["description"], 0, 200); 175 $cat_name = $_REQUEST["title"]; 176 $cat_href = "tiki-view_blog.php?blogId=" . $cat_objid; 177 include_once("categorize.php"); 178 179 header("location: tiki-list_blogs.php?blogId=$bid"); 180 die; 181 } 182} 183 184if (isset($_REQUEST['preview']) || $category_needed) { 185 $smarty->assign('title', $_REQUEST["title"]); 186 187 $smarty->assign('description', $_REQUEST["description"]); 188 $smarty->assign('public', isset($_REQUEST["public"]) ? 'y' : 'n'); 189 $smarty->assign('use_find', isset($_REQUEST["use_find"]) ? 'y' : 'n'); 190 $smarty->assign('use_title', isset($_REQUEST["use_title"]) ? 'y' : 'n'); 191 $smarty->assign('use_title_in_post', isset($_REQUEST["use_title_in_post"]) ? 'y' : 'n'); 192 $smarty->assign('use_description', isset($_REQUEST["use_description"]) ? 'y' : 'n'); 193 $smarty->assign('use_breadcrumbs', isset($_REQUEST["use_breadcrumbs"]) ? 'y' : 'n'); 194 $smarty->assign('use_author', isset($_REQUEST["use_author"]) ? 'y' : 'n'); 195 $smarty->assign('show_avatar', isset($_REQUEST["show_avatar"]) ? 'y' : 'n'); 196 $smarty->assign('show_related', isset($_REQUEST["show_related"]) ? 'y' : 'n'); 197 $smarty->assign('related_max', isset($_REQUEST['related_max']) ? $_REQUEST['related_max'] : 5); 198 $smarty->assign('use_excerpt', isset($_REQUEST['use_excerpt']) ? 'y' : 'n'); 199 $smarty->assign('add_date', isset($_REQUEST["add_date"]) ? 'y' : 'n'); 200 $smarty->assign('allow_comments', isset($_REQUEST["allow_comments"]) ? 'y' : 'n'); 201 $smarty->assign('maxPosts', $_REQUEST["maxPosts"]); 202 $smarty->assign('heading', $heading); 203 $smarty->assign('creator', $_REQUEST["creator"]); 204 205 $smarty->assign( 206 'blog_data', 207 [ 208 'title' => $_REQUEST["title"], 209 'description' => $_REQUEST["description"], 210 'creator' => $_REQUEST["creator"], 211 'public' => $public, 212 'maxPosts' => $_REQUEST["maxPosts"], 213 'blogId' => $_REQUEST["blogId"], 214 'heading' => $heading, 215 'use_title' => $use_title, 216 'use_title_in_post' => $use_title_in_post, 217 'use_description' => $use_description, 218 'use_breadcrumbs' => $use_breadcrumbs, 219 'use_author' => $use_author, 220 'add_date' => $add_date, 221 'use_find' => $use_find, 222 'allow_comments' => $allow_comments, 223 'show_avatar' => $show_avatar, 224 'always_owner' => $alwaysOwner, 225 'post_heading' => $post_heading, 226 'show_related' => $show_related, 227 'related_max' => $related_max, 228 'use_excerpt' => $use_excerpt 229 ] 230 ); 231 232 // display heading preview 233 $smarty->assign('show_blog_heading_preview', 'y'); 234 $cookietab = 2; 235} else { 236 $smarty->assign('show_blog_heading_preview', 'n'); 237} 238 239 240$cat_type = 'blog'; 241$cat_objid = $blogId; 242include_once("categorize_list.php"); 243 244$defaultRows = 5; 245 246ask_ticket('edit-blog'); 247 248include_once('tiki-section_options.php'); 249 250// disallow robots to index page: 251$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW'); 252 253// Display the Index Template 254$smarty->assign('mid', 'tiki-edit_blog.tpl'); 255$smarty->display("tiki.tpl"); 256