tiki-article_types.php 4.51 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright 2002-2015 by authors of the Tiki Wiki CMS Groupware Project
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.
changi67's avatar
changi67 committed
9 10
// $Id$

11 12
$section = 'cms';
require_once ('tiki-setup.php');
lphuberdeau's avatar
lphuberdeau committed
13
$artlib = TikiLib::lib('art');
14
$access->check_feature('feature_articles');
15

16
// PERMISSIONS: NEEDS p_admin or tiki_p_articles_admin_types
17
$access->check_permission(array('tiki_p_articles_admin_types'));
18

19
if (isset($_REQUEST["add_type"])) {
20
	$artlib->add_type($_REQUEST["new_type"]);
21
} elseif (isset($_REQUEST["remove_type"])) {
22 23
	$access->check_authenticity();
	$artlib->remove_type($_REQUEST["remove_type"]);
24
} elseif (isset($_REQUEST["update_type"])) {
25
	foreach (array_keys($_REQUEST["type_array"]) as $this_type) {
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
		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["creator_edit"][$this_type]))							$_REQUEST["creator_edit"][$this_type] = 'n';

		$artlib->edit_type(
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
			$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["creator_edit"][$this_type]
65
		);
66

67
		// Add custom attributes
68
		if ($prefs["article_custom_attributes"] == 'y' && !empty($_REQUEST["new_attribute"][$this_type])) {
69 70 71 72 73 74 75
			$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;
			}
		}
76 77 78 79
	}
}

$types = $artlib->list_types();
80 81 82 83 84

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"]);
	}
85
	foreach ($types as &$t) {
86
		$t["attributes"] = $artlib->get_article_type_attributes($t["type"], 'relationId ASC');
87
	}
88 89
}

90 91 92 93
$smarty->assign('types', $types);

include_once ('tiki-section_options.php');

94 95
// the strings below are used to localize the article types in the template file
//get_strings tr('Article') tr('Review') tr('Event') tr('Classified')
96 97
$smarty->assign('mid', 'tiki-article_types.tpl');
$smarty->display("tiki.tpl");