tiki-list_articles.php 6.63 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.
6
// $Id$
mose's avatar
mose committed
7
$section = 'cms';
8 9
require_once ('tiki-setup.php');
include_once ('lib/articles/artlib.php');
changi67's avatar
changi67 committed
10
$smarty->assign('headtitle', tra('List Articles'));
11 12
$access->check_feature('feature_articles');
$access->check_permission('tiki_p_read_article');
13
$auto_query_args = array('sort_mode', 'category', 'offset', 'maxRecords', 'find', 'find_from_Month', 'find_from_Day', 'find_from_Year', 'find_to_Month', 'find_to_Day', 'find_to_Year', 'type', 'topic', 'cat_categories', 'categId', 'lang', 'mode', 'mapview', 'searchmap', 'searchlist');
14 15 16 17 18 19 20 21 22 23 24
if ($prefs["gmap_article_list"] == 'y') {
	$smarty->assign('gmapbuttons', true);
} else {
	$smarty->assign('gmapbuttons', false);
}
if (isset($_REQUEST["mapview"]) && $_REQUEST["mapview"] == 'y' && !isset($_REQUEST["searchmap"]) && !isset($_REQUEST["searchlist"]) || isset($_REQUEST["searchmap"]) && !isset($_REQUEST["searchlist"])) {
	$smarty->assign('mapview', true);
}
if (isset($_REQUEST["mapview"]) && $_REQUEST["mapview"] == 'n' && !isset($_REQUEST["searchmap"]) && !isset($_REQUEST["searchlist"]) || isset($_REQUEST["searchlist"]) && !isset($_REQUEST["searchmap"]) ) {
	$smarty->assign('mapview', false);
}
25
if (isset($_REQUEST["remove"])) {
26 27 28
	$artperms = Perms::get( array( 'type' => 'article', 'object' => $_REQUEST['remove'] ) );

	if ($artperms->remove_article != 'y') {
29
		$smarty->assign('errortype', 401);
30
		$smarty->assign('msg', tra("You do not have permission to remove articles"));
31
		$smarty->display("error.tpl");
32 33
		die;
	}
34 35
	$access->check_authenticity();
	$artlib->remove_article($_REQUEST["remove"]);
36
}
37 38 39 40
// This script can receive the thresold
// for the information as the number of
// days to get in the log 1,3,4,etc
// it will default to 1 recovering information for today
41 42
if (!isset($_REQUEST["sort_mode"])) {
	$sort_mode = 'publishDate_desc';
43
} else {
44 45 46
	$sort_mode = $_REQUEST["sort_mode"];
}
$smarty->assign_by_ref('sort_mode', $sort_mode);
47 48 49
// If offset is set use it if not then use offset =0
// use the maxRecords php variable to set the limit
// if sortMode is not set then use lastModif_desc
50 51
if (!isset($_REQUEST["offset"])) {
	$offset = 0;
52
} else {
53
	$offset = $_REQUEST["offset"];
54
}
55
$smarty->assign_by_ref('offset', $offset);
sylvieg's avatar
sylvieg committed
56 57
if (!empty($_REQUEST['maxRecords'])) {
	$maxRecords = $_REQUEST['maxRecords'];
58
} else {
59
	$maxRecords = $maxRecords;
sylvieg's avatar
sylvieg committed
60
}
sylvieg's avatar
typo  
sylvieg committed
61
$smarty->assign_by_ref('maxRecords', $maxRecords);
62 63

$visible_only = 'y';
changi67's avatar
changi67 committed
64 65
if (($tiki_p_admin == 'y') || ($tiki_p_admin_cms == 'y')) {
	$date_max = '';
66
	$visible_only = "n";
changi67's avatar
changi67 committed
67 68 69 70 71 72 73 74
} elseif (isset($_SESSION["thedate"])) {
	if ($_SESSION["thedate"] < $tikilib->now) {
		// If the session is older then set it to today
		// so you can list articles
		$date_max = $tikilib->now;
	} else {
		$date_max = $_SESSION["thedate"];
	}
75
} else {
76
	$date_max = $tikilib->now;
77
}
78
if (!empty($_REQUEST["find_from_Month"]) && !empty($_REQUEST["find_from_Day"]) && !empty($_REQUEST["find_from_Year"])) {
79
	$date_min = $tikilib->make_time(0, 0, 0, $_REQUEST["find_from_Month"], $_REQUEST["find_from_Day"], $_REQUEST["find_from_Year"]);
80 81 82 83 84 85
	$smarty->assign('find_date_from', $date_min);
} else {
	$date_min = 0;
	$smarty->assign('find_date_from', $tikilib->now - 365*24*3600);
}
if (isset($_REQUEST["find_to_Month"]) && isset($_REQUEST["find_to_Day"]) && isset($_REQUEST["find_to_Year"])) {
86
	$t_date_max = $tikilib->make_time(23, 59, 59, $_REQUEST["find_to_Month"], $_REQUEST["find_to_Day"], $_REQUEST["find_to_Year"]);
87 88 89 90 91 92
	if ($t_date_max < $date_max || $date_max == '') {
		$date_max = $t_date_max;
		$visible_only = 'y';
	}
}
$smarty->assign('find_date_to', $date_max);
93 94
if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
95
} else {
96
	$find = '';
97
}
98 99 100
$smarty->assign('find', $find);
if (!isset($_REQUEST["type"])) {
	$_REQUEST["type"] = '';
lrargerich's avatar
lrargerich committed
101
}
102 103
if (!isset($_REQUEST["topic"])) {
	$_REQUEST["topic"] = '';
lrargerich's avatar
lrargerich committed
104
}
105 106 107 108 109 110 111 112 113

$filter['categId'] = 0;
if ($prefs['feature_categories'] == 'y' && !empty($_REQUEST['cat_categories'])) {
	$filter['categId'] = $_REQUEST['cat_categories'];
	if (count($_REQUEST['cat_categories']) > 1) {
		$smarty->assign('find_cat_categories', $_REQUEST['cat_categories']);
		unset($_REQUEST['categId']);
	} else {
		$_REQUEST['categId'] = $_REQUEST['cat_categories'][0];
114
		unset($_REQUEST['cat_categories']);
115 116 117 118 119 120 121
	}
} else {
		$_REQUEST['cat_categories'] = array();
}
if ($prefs['feature_categories'] == 'y' && !empty($_REQUEST['categId'])) {
	$filter['categId'] = $_REQUEST['categId'];
	$smarty->assign('find_categId', $_REQUEST['categId']);
122
}
123 124 125
if (!isset($_REQUEST['lang'])) {
	$_REQUEST['lang'] = '';
}
126 127
$smarty->assign('find_topic', $_REQUEST["topic"]);
$smarty->assign('find_type', $_REQUEST["type"]);
128
$smarty->assign('find_lang', $_REQUEST['lang']);
129
// Get a list of last changes to the Wiki database
130
$listpages = $artlib->list_articles($offset, $maxRecords, $sort_mode, $find, $date_min, $date_max, $user, $_REQUEST["type"], $_REQUEST["topic"], $visible_only, '', $filter["categId"], '', '', $_REQUEST['lang']);
131
// If there're more records then assign next_offset
132
$smarty->assign_by_ref('cant', $listpages['cant']);
133
$smarty->assign_by_ref('listpages', $listpages["data"]);
134

135 136 137 138 139 140 141 142 143 144 145 146 147
if ($prefs["gmap_article_list"] == 'y') {
	// Generate Google map plugin data
	global $gmapobjectarray;
	$gmapobjectarray = array();
	foreach ($listpages["data"] as $art) {
		$gmapobjectarray[] = array('type' => 'article',
			'id' => $art["articleId"],
			'title' => $art["title"],
			'href' => 'tiki-read_article.php?articleId=' . $art["articleId"],
		);
	}
}

148
$topics = $artlib->list_topics();
149
$smarty->assign_by_ref('topics', $topics);
150 151
$types = $artlib->list_types();
$smarty->assign_by_ref('types', $types);
152
if ($prefs['feature_categories'] == 'y') {
changi67's avatar
changi67 committed
153 154
	global $categlib;
	include_once ('lib/categories/categlib.php');
155
	$categories = $categlib->get_all_categories_respect_perms(null, 'view_category');
156
	$smarty->assign_by_ref('categories', $categories);
157
	$smarty->assign('cat_tree', $categlib->generate_cat_tree($categories, true, $_REQUEST['cat_categories']));	
158
}
159
if ($prefs['feature_multilingual'] == 'y') {
sylvieg's avatar
sylvieg committed
160 161 162 163
	$languages = array();
	$languages = $tikilib->list_languages(false, 'y');
	$smarty->assign_by_ref('languages', $languages);
}
164
if ($tiki_p_edit_article != 'y' && $tiki_p_remove_article != 'y') { //check one editable
changi67's avatar
changi67 committed
165
	foreach($listpages['data'] as $page) {
166 167 168 169 170 171
		if ($page['author'] == $user && $page['creator_edit'] == 'y') {
			$smarty->assign('oneEditPage', 'y');
			break;
		}
	}
}
172
include_once ('tiki-section_options.php');
173
ask_ticket('list-articles');
174
// Display the template
175
$smarty->assign('mid', 'tiki-list_articles.tpl');
176
$smarty->display("tiki.tpl");