tiki-received_pages.php 3.89 KB
Newer Older
lrargerich's avatar
lrargerich committed
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.
6
// $Id$
changi67's avatar
changi67 committed
7

8 9 10
require_once ('tiki-setup.php');
include_once ('lib/commcenter/commlib.php');
include_once ('lib/wiki/wikilib.php');
11
$auto_query_args = array('receivedPageId', 'sort_mode', 'offset', 'find', 'sort_modes');
12 13
$access->check_feature('feature_comm');
$access->check_permission('tiki_p_admin_received_pages');
14 15
if (!isset($_REQUEST["receivedPageId"])) {
	$_REQUEST["receivedPageId"] = 0;
lrargerich's avatar
lrargerich committed
16
}
17
$smarty->assign('receivedPageId', $_REQUEST["receivedPageId"]);
18
$errors = array();
19
if (isset($_REQUEST["accept"])) {
20
	check_ticket('received-pages');
21
	// CODE TO ACCEPT A PAGE HERE
22 23
	if (!$commlib->accept_page($_REQUEST["accept"])) {
		$info = $commlib->get_received_page($_REQUEST['accept']);
changi67's avatar
changi67 committed
24
		$errors[] = array('error' => 'Page already exists');
25
	}
lrargerich's avatar
lrargerich committed
26
}
27 28 29 30 31 32 33
if ($_REQUEST["receivedPageId"]) {
	$info = $commlib->get_received_page($_REQUEST["receivedPageId"]);
} else {
	$info = array();
	$info["pageName"] = '';
	$info["data"] = '';
	$info["comment"] = '';
lrargerich's avatar
lrargerich committed
34
}
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
$smarty->assign('view', 'n');
if (isset($_REQUEST["view"])) {
	$info = $commlib->get_received_page($_REQUEST["view"]);
	$smarty->assign('view', 'y');
}
if (isset($_REQUEST["preview"])) {
	$info["pageName"] = $_REQUEST["pageName"];
	$info["data"] = $_REQUEST["data"];
	$info["comment"] = $_REQUEST["comment"];
}
$smarty->assign('pageName', $info["pageName"]);
$smarty->assign('data', $info["data"]);
$smarty->assign('comment', $info["comment"]);
// Assign parsed
$smarty->assign('parsed', $tikilib->parse_data($info["data"]));
if (isset($_REQUEST["remove"])) {
51 52
	$access->check_authenticity();
	$commlib->remove_received_page($_REQUEST["remove"]);
lrargerich's avatar
lrargerich committed
53
}
54
if (isset($_REQUEST["save"])) {
55
	check_ticket('received-pages');
56 57 58 59
	$commlib->update_received_page($_REQUEST["receivedPageId"], $_REQUEST["pageName"], $_REQUEST["data"], $_REQUEST["comment"]);
	$smarty->assign('pageName', $_REQUEST["pageName"]);
	$smarty->assign('data', $_REQUEST["data"]);
	$smarty->assign('comment', $_REQUEST["comment"]);
sylvieg's avatar
sylvieg committed
60
	$smarty->assign('receivedPageId', 0);
61
	$smarty->assign('parsed', $tikilib->parse_data($_REQUEST["data"]));
lrargerich's avatar
lrargerich committed
62
}
63 64
if (!empty($_REQUEST['checked']) && (!empty($_REQUEST['prefix']) || !empty($_REQUEST['postfix']))) {
	check_ticket('received-pages');
changi67's avatar
changi67 committed
65 66
	foreach($_REQUEST['checked'] as $page) {
		$newpage = empty($_REQUEST['postfix']) ? $_REQUEST['prefix'] . $page : $page . $_REQUEST['postfix'];
67
		if ($tikilib->page_exists($newpage)) {
changi67's avatar
changi67 committed
68
			$errors[] = array('error' => 'Page already exists', 'param' => $page);
69 70 71
		}
	}
	if (empty($errors)) {
changi67's avatar
changi67 committed
72
		$commlib->rename_structure_pages($_REQUEST['checked'], isset($_REQUEST['prefix']) ? $_REQUEST['prefix'] : '', isset($_REQUEST['postfix']) ? $_REQUEST['postfix'] : '');
73 74
	}
}
75 76
if (!isset($_REQUEST["sort_mode"])) {
	$sort_mode = 'receivedDate_desc';
lrargerich's avatar
lrargerich committed
77
} else {
78 79 80 81
	$sort_mode = $_REQUEST["sort_mode"];
}
if (!isset($_REQUEST["offset"])) {
	$offset = 0;
lrargerich's avatar
lrargerich committed
82
} else {
83
	$offset = $_REQUEST["offset"];
lrargerich's avatar
lrargerich committed
84
}
85 86 87
$smarty->assign_by_ref('offset', $offset);
if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
lrargerich's avatar
lrargerich committed
88
} else {
89
	$find = '';
lrargerich's avatar
lrargerich committed
90
}
91 92
$smarty->assign('find', $find);
$smarty->assign_by_ref('sort_mode', $sort_mode);
sylvieg's avatar
sylvieg committed
93
$channels = $tikilib->list_received_pages($offset, $maxRecords, $sort_mode, $find, 'p');
94
$smarty->assign_by_ref('channels', $channels["data"]);
95
$smarty->assign_by_ref('cant', $channels['cant']);
sylvieg's avatar
sylvieg committed
96 97 98 99 100
if (!isset($_REQUEST['sort_modes'])) {
	$sort_modes = 'receivedDate_desc';
} else {
	$sort_modes = $_REQUEST['sort_modes'];
}
101
$structures = $tikilib->list_received_pages(0, -1, $sort_modes, $find, 's');
sylvieg's avatar
sylvieg committed
102
$smarty->assign_by_ref('structures', $structures['data']);
103 104 105
if (!empty($errors)) {
	$smarty->assign_by_ref('errors', $errors);
}
106
ask_ticket('received-pages');
lrargerich's avatar
lrargerich committed
107
// Display the template
108
$smarty->assign('mid', 'tiki-received_pages.tpl');
109
$smarty->display("tiki.tpl");