tiki-article_types.php 4.48 KB
Newer Older
1
<?php
2
// (c) Copyright 2002-2011 by authors of the Tiki Wiki CMS Groupware Project
changi67's avatar
changi67 committed
3
// 
4 5
// 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.
changi67's avatar
changi67 committed
6 7
// $Id$

8 9 10 11 12 13 14
$section = 'cms';
require_once ('tiki-setup.php');

include_once ('lib/articles/artlib.php');

$smarty->assign('headtitle',tra('Admin Article Types'));

15
$access->check_feature('feature_articles');
16

17
// PERMISSIONS: NEEDS p_admin or tiki_p_articles_admin_types
18
$access->check_permission(array('tiki_p_articles_admin_types'));
19 20 21 22 23

if(isset($_REQUEST["add_type"])) {
	$artlib->add_type($_REQUEST["new_type"]);
}
elseif(isset($_REQUEST["remove_type"])) {
24 25
	$access->check_authenticity();
	$artlib->remove_type($_REQUEST["remove_type"]);
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
}
elseif(isset($_REQUEST["update_type"])) {
	foreach(array_keys($_REQUEST["type_array"]) as $this_type) {
		if (!isset($_REQUEST["use_ratings"][$this_type])) {$_REQUEST["use_ratings"][$this_type] = 'n';}
		if (!isset($_REQUEST["show_pre_publ"][$this_type])) {$_REQUEST["show_pre_publ"][$this_type] = 'n';}
		if (!isset($_REQUEST["show_post_expire"][$this_type])) {$_REQUEST["show_post_expire"][$this_type] = 'n';}
		if (!isset($_REQUEST["heading_only"][$this_type])) {$_REQUEST["heading_only"][$this_type] = 'n';}
		if (!isset($_REQUEST["allow_comments"][$this_type])) {$_REQUEST["allow_comments"][$this_type] = 'n';}
		if (!isset($_REQUEST["comment_can_rate_article"][$this_type])) {$_REQUEST["comment_can_rate_article"][$this_type] = 'n';}
		if (!isset($_REQUEST["show_image"][$this_type])) {$_REQUEST["show_image"][$this_type] = 'n';}
		if (!isset($_REQUEST["show_avatar"][$this_type])) {$_REQUEST["show_avatar"][$this_type] = 'n';}
		if (!isset($_REQUEST["show_author"][$this_type])) {$_REQUEST["show_author"][$this_type] = 'n';}
		if (!isset($_REQUEST["show_pubdate"][$this_type])) {$_REQUEST["show_pubdate"][$this_type] = 'n';}
		if (!isset($_REQUEST["show_expdate"][$this_type])) {$_REQUEST["show_expdate"][$this_type] = 'n';}
		if (!isset($_REQUEST["show_reads"][$this_type])) {$_REQUEST["show_reads"][$this_type] = 'n';}
		if (!isset($_REQUEST["show_size"][$this_type])) {$_REQUEST["show_size"][$this_type] = 'n';}
		if (!isset($_REQUEST["show_topline"][$this_type])) {$_REQUEST["show_topline"][$this_type] = 'n';}
		if (!isset($_REQUEST["show_subtitle"][$this_type])) {$_REQUEST["show_subtitle"][$this_type] = 'n';}
		if (!isset($_REQUEST["show_image_caption"][$this_type])) {$_REQUEST["show_image_caption"][$this_type] = 'n';}
		if (!isset($_REQUEST["show_linkto"][$this_type])) {$_REQUEST["show_linkto"][$this_type] = 'n';}
		if (!isset($_REQUEST["show_lang"][$this_type])) {$_REQUEST["show_lang"][$this_type] = 'n';}
		if (!isset($_REQUEST["creator_edit"][$this_type])) {$_REQUEST["creator_edit"][$this_type] = 'n';}
		$artlib->edit_type($this_type, 
				$_REQUEST["use_ratings"][$this_type], 
				$_REQUEST["show_pre_publ"][$this_type], 
				$_REQUEST["show_post_expire"][$this_type], 
				$_REQUEST["heading_only"][$this_type], 
				$_REQUEST["allow_comments"][$this_type], 
				$_REQUEST["comment_can_rate_article"][$this_type], 
				$_REQUEST["show_image"][$this_type], 
				$_REQUEST["show_avatar"][$this_type], 
				$_REQUEST["show_author"][$this_type], 
				$_REQUEST["show_pubdate"][$this_type], 
				$_REQUEST["show_expdate"][$this_type], 
				$_REQUEST["show_reads"][$this_type], 
				$_REQUEST["show_size"][$this_type], 
				$_REQUEST["show_topline"][$this_type], 
				$_REQUEST["show_subtitle"][$this_type], 
				$_REQUEST["show_linkto"][$this_type], 
				$_REQUEST["show_image_caption"][$this_type], 
				$_REQUEST["show_lang"][$this_type], 
				$_REQUEST["creator_edit"][$this_type]);
68 69 70 71 72 73 74 75 76 77
				
		// Add custom attributes
		if ($prefs["article_custom_attributes"] == 'y' && !empty($_REQUEST["new_attribute"][$this_type])) {			
			$ok = $artlib->add_article_type_attribute($this_type, $_REQUEST["new_attribute"][$this_type]);
			if (!$ok) {
				$smarty->assign('msg', tra("Failed to add attribute"));
				$smarty->display("error.tpl");
				die;
			}
		}
78 79 80 81
	}
}

$types = $artlib->list_types();
82 83 84 85 86 87 88 89 90 91

if ($prefs["article_custom_attributes"] == 'y') {
	if (isset($_REQUEST["att_type"]) && isset($_REQUEST["att_remove"])) {
		$artlib->delete_article_type_attribute($_REQUEST["att_type"], $_REQUEST["att_remove"]);
	}
	foreach($types as &$t) {
		$t["attributes"] = $artlib->get_article_type_attributes($t["type"]);
	}	
}

92 93 94 95 96 97
$smarty->assign('types', $types);

include_once ('tiki-section_options.php');

$smarty->assign('mid', 'tiki-article_types.tpl');
$smarty->display("tiki.tpl");