tiki-edit_blog.php 5.14 KB
Newer Older
1
<?php
2

3
// $Id: /cvsroot/tikiwiki/tiki/tiki-edit_blog.php,v 1.39.2.1 2007-11-08 21:38:33 ricks99 Exp $
4

5
// Copyright (c) 2002-2007, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
6 7 8
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.

9
// Initialization
10
$section = 'blogs';
11 12
require_once ('tiki-setup.php');
include_once ('lib/blogs/bloglib.php');
13

14 15
$smarty->assign('headtitle',tra('Create Blog'));

16
if ($prefs['feature_blogs'] != 'y') {
17
	$smarty->assign('msg', tra("This feature is disabled").": feature_blogs");
18

19
	$smarty->display("error.tpl");
20
	die;
lrargerich's avatar
lrargerich committed
21 22
}

23
// Now check permissions to access this page
24
if ($tiki_p_create_blogs != 'y') {
25
	$smarty->assign('errortype', 401);
26 27
	$smarty->assign('msg', tra("Permission denied you cannot create or edit blogs"));

28
	$smarty->display("error.tpl");
29
	die;
30 31
}

32 33
if (isset($_REQUEST["blogId"])) {
	$blogId = $_REQUEST["blogId"];
34
} else {
35
	$blogId = 0;
36 37
}

38
$smarty->assign('individual', 'n');
lrargerich's avatar
lrargerich committed
39

40
$tikilib->get_perm_object($blogId, 'blog');
lrargerich's avatar
lrargerich committed
41

42 43 44 45 46 47
$smarty->assign('blogId', $blogId);
$smarty->assign('title', '');
$smarty->assign('description', '');
$smarty->assign('public', 'n');
$smarty->assign('use_find', 'y');
$smarty->assign('use_title', 'y');
lrargerich's avatar
lrargerich committed
48
$smarty->assign('allow_comments', 'y');
49
$smarty->assign('show_avatar', 'n');
50
$smarty->assign('maxPosts', 10);
51
$smarty->assign('creator', $user);
52

53 54 55 56 57 58 59 60 61 62 63

if (!isset($created)) {
	$created=time();
	$smarty->assign('created', $created);
}

if (!isset($lastModif)) {
	$lastModif=time();
	$smarty->assign('lastModif', $lastModif);
}

64 65
if (isset($_REQUEST["blogId"]) && $_REQUEST["blogId"] > 0) {
	// Check permission
66
	$data = $tikilib->get_blog($_REQUEST["blogId"]);
67 68 69

	if ($data["user"] != $user || !$user) {
		if ($tiki_p_blog_admin != 'y') {
70
			$smarty->assign('errortype', 401);
71 72
			$smarty->assign('msg', tra("Permission denied you cannot edit this blog"));

73
			$smarty->display("error.tpl");
74 75 76 77 78 79 80 81 82
			die;
		}
	}

	$smarty->assign('title', $data["title"]);
	$smarty->assign('description', $data["description"]);
	$smarty->assign('public', $data["public"]);
	$smarty->assign('use_title', $data["use_title"]);
	$smarty->assign('allow_comments', $data["allow_comments"]);
83
	$smarty->assign('show_avatar',$data["show_avatar"]);
84 85
	$smarty->assign('use_find', $data["use_find"]);
	$smarty->assign('maxPosts', $data["maxPosts"]);
86
	$smarty->assign('creator', $data["user"]);
87 88 89

}

90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
if (isset($_REQUEST["heading"]) and $tiki_p_edit_templates == 'y') {
	// Sanatization cleanup
	$heading = preg_replace('/st<x>yle="[^"]*"/', 'style_dangerous', $_REQUEST["heading"]);
} elseif (!isset($data["heading"])) {
	$n = $smarty->get_filename('blog-heading.tpl', 'r');
	@$fp = fopen($n, 'r');
	if ($fp) {
		$heading = fread($fp, filesize($n));
		@fclose($fp);
	} else
		$heading = '';
} else {
	$heading = $data["heading"];
}

$smarty->assign_by_ref('heading', $heading);
$users = $userlib->list_all_users();
$smarty->assign_by_ref('users', $users);

109
$category_needed = false;
110
if (isset($_REQUEST["save"]) && $prefs['feature_categories'] == 'y' && $prefs['feature_blog_mandatory_category'] >=0 && (empty($_REQUEST['cat_categories']) || count($_REQUEST['cat_categories']) <= 0)) {
111 112 113
		$category_needed = true;
		$smarty->assign('category_needed', 'y');
} elseif (isset($_REQUEST["save"])) {
114
	check_ticket('edit-blog');
115 116 117 118 119 120 121
	if (isset($_REQUEST["public"]) && $_REQUEST["public"] == 'on') {
		$public = 'y';
	} else {
		$public = 'n';
	}

	$use_title = isset($_REQUEST['use_title']) ? 'y' : 'n';
122
	$allow_comments = isset($_REQUEST["allow_comments"]) ? 'y' : 'n';
123
	$show_avatar = isset($_REQUEST['show_avatar']) ? 'y' : 'n';	
124
	$use_find = isset($_REQUEST['use_find']) ? 'y' : 'n';
125 126

	$bid = $bloglib->replace_blog($_REQUEST["title"],
127
	    $_REQUEST["description"], $_REQUEST["creator"], $public,
128 129
	    $_REQUEST["maxPosts"], $_REQUEST["blogId"],
	    $heading, $use_title, $use_find,
130
	    $allow_comments, $show_avatar);
131

132 133 134 135 136 137 138
	$cat_type = 'blog';
	$cat_objid = $bid;
	$cat_desc = substr($_REQUEST["description"], 0, 200);
	$cat_name = $_REQUEST["title"];
	$cat_href = "tiki-view_blog.php?blogId=" . $cat_objid;
	include_once ("categorize.php");

139
	header ("location: tiki-list_blogs.php?blogId=$bid");
140
	die;
141 142
}

143 144 145 146 147 148 149 150 151 152
if (isset($_REQUEST['preview']) || $category_needed) {
	$smarty->assign('title', $_REQUEST["title"]);

	$smarty->assign('description', $_REQUEST["description"]);
	$smarty->assign('public', isset($_REQUEST["public"]) ? 'y' : 'n');
	$smarty->assign('use_find', isset($_REQUEST["use_find"]) ? 'y' : 'n');
	$smarty->assign('use_title', isset($_REQUEST["use_title"]) ? 'y' : 'n');
	$smarty->assign('allow_comments', isset($_REQUEST["allow_comments"]) ? 'y' : 'n');
	$smarty->assign('maxPosts', $_REQUEST["maxPosts"]);
	$smarty->assign('heading', $heading);
153
	$smarty->assign('creator', $_REQUEST["creator"]);
154 155 156
}


157
$cat_type = 'blog';
158
$cat_objid = $blogId;
159
include_once ("categorize_list.php");
160 161 162 163

$defaultRows = 5;
include_once("textareasize.php");

164
ask_ticket('edit-blog');
165

166 167
include_once ('tiki-section_options.php');

168 169 170
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');

171
// Display the Index Template
172
$smarty->assign('mid', 'tiki-edit_blog.tpl');
173
$smarty->display("tiki.tpl");