tiki-list_articles.php 5.84 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
2 3
// (c) Copyright 2002-2009 by authors of the Tiki Wiki/CMS/Groupware Project
// 
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
// $Id: /cvsroot/tikiwiki/tiki/tiki-list_articles.php,v 1.38.2.2 2008-03-21 23:06:51 sylvieg Exp $
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
if (isset($_REQUEST["remove"])) {
14 15 16
	$artperms = Perms::get( array( 'type' => 'article', 'object' => $_REQUEST['remove'] ) );

	if ($artperms->remove_article != 'y') {
17
		$smarty->assign('errortype', 401);
18
		$smarty->assign('msg', tra("Permission denied you cannot remove articles"));
19
		$smarty->display("error.tpl");
20 21
		die;
	}
changi67's avatar
changi67 committed
22 23 24
	$area = 'delarticle';
	if ($prefs['feature_ticketlib2'] != 'y' or (isset($_POST['daconfirm']) and isset($_SESSION["ticket_$area"]))) {
		key_check($area);
mose's avatar
mose committed
25
		$artlib->remove_article($_REQUEST["remove"]);
changi67's avatar
changi67 committed
26 27 28
	} else {
		key_get($area);
	}
29
}
30 31 32 33
// 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
34 35
if (!isset($_REQUEST["sort_mode"])) {
	$sort_mode = 'publishDate_desc';
36
} else {
37 38 39
	$sort_mode = $_REQUEST["sort_mode"];
}
$smarty->assign_by_ref('sort_mode', $sort_mode);
40 41 42
// 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
43 44
if (!isset($_REQUEST["offset"])) {
	$offset = 0;
45
} else {
46
	$offset = $_REQUEST["offset"];
47
}
48
$smarty->assign_by_ref('offset', $offset);
sylvieg's avatar
sylvieg committed
49 50
if (!empty($_REQUEST['maxRecords'])) {
	$maxRecords = $_REQUEST['maxRecords'];
51
} else {
52
	$maxRecords = $maxRecords;
sylvieg's avatar
sylvieg committed
53
}
sylvieg's avatar
typo  
sylvieg committed
54
$smarty->assign_by_ref('maxRecords', $maxRecords);
55 56

$visible_only = 'y';
changi67's avatar
changi67 committed
57 58
if (($tiki_p_admin == 'y') || ($tiki_p_admin_cms == 'y')) {
	$date_max = '';
59
	$visible_only = "n";
changi67's avatar
changi67 committed
60 61 62 63 64 65 66 67
} 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"];
	}
68
} else {
69
	$date_max = $tikilib->now;
70
}
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
if (isset($_REQUEST["find_from_Month"]) && isset($_REQUEST["find_from_Day"]) && isset($_REQUEST["find_from_Year"])) {
	$date_min = $tikilib->make_time(0, 0, 0, $_REQUEST["find_from_Month"], $_REQUEST["find_from_Month"], $_REQUEST["find_from_Year"]);
	$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"])) {
	$t_date_max = $tikilib->make_time(0, 0, 0, $_REQUEST["find_to_Month"], $_REQUEST["find_to_Month"], $_REQUEST["find_to_Year"]);
	if ($t_date_max < $date_max || $date_max == '') {
		$date_max = $t_date_max;
		$visible_only = 'y';
	}
}
$smarty->assign('find_date_to', $date_max);
86 87
if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
88
} else {
89
	$find = '';
90
}
91 92 93
$smarty->assign('find', $find);
if (!isset($_REQUEST["type"])) {
	$_REQUEST["type"] = '';
lrargerich's avatar
lrargerich committed
94
}
95 96
if (!isset($_REQUEST["topic"])) {
	$_REQUEST["topic"] = '';
lrargerich's avatar
lrargerich committed
97
}
98 99 100 101 102 103 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];
	}
} else {
		$_REQUEST['cat_categories'] = array();
}
if ($prefs['feature_categories'] == 'y' && !empty($_REQUEST['categId'])) {
	$filter['categId'] = $_REQUEST['categId'];
	$smarty->assign('find_categId', $_REQUEST['categId']);
114
}
115 116 117
if (!isset($_REQUEST['lang'])) {
	$_REQUEST['lang'] = '';
}
118 119
$smarty->assign('find_topic', $_REQUEST["topic"]);
$smarty->assign('find_type', $_REQUEST["type"]);
120
$smarty->assign('find_lang', $_REQUEST['lang']);
121
// Get a list of last changes to the Wiki database
122
$listpages = $tikilib->list_articles($offset, $maxRecords, $sort_mode, $find, $date_min, $date_max, $user, $_REQUEST["type"], $_REQUEST["topic"], $visible_only, '', $filter["categId"], '', '', $_REQUEST['lang']);
123
// If there're more records then assign next_offset
124
$smarty->assign_by_ref('cant', $listpages['cant']);
125
$smarty->assign_by_ref('listpages', $listpages["data"]);
126

127
$topics = $artlib->list_topics();
128
$smarty->assign_by_ref('topics', $topics);
129 130
$types = $artlib->list_types();
$smarty->assign_by_ref('types', $types);
131
if ($prefs['feature_categories'] == 'y') {
changi67's avatar
changi67 committed
132 133
	global $categlib;
	include_once ('lib/categories/categlib.php');
134
	$categories = $categlib->get_all_categories_respect_perms(null, 'view_category');
135
	$smarty->assign_by_ref('categories', $categories);
136
	$smarty->assign('cat_tree', $categlib->generate_cat_tree($categories, true, $_REQUEST['cat_categories']));	
137
}
138
if ($prefs['feature_multilingual'] == 'y') {
sylvieg's avatar
sylvieg committed
139 140 141 142
	$languages = array();
	$languages = $tikilib->list_languages(false, 'y');
	$smarty->assign_by_ref('languages', $languages);
}
143
if ($tiki_p_edit_article != 'y' && $tiki_p_remove_article != 'y') { //check one editable
changi67's avatar
changi67 committed
144
	foreach($listpages['data'] as $page) {
145 146 147 148 149 150
		if ($page['author'] == $user && $page['creator_edit'] == 'y') {
			$smarty->assign('oneEditPage', 'y');
			break;
		}
	}
}
151
include_once ('tiki-section_options.php');
changi67's avatar
changi67 committed
152
if ($prefs['feature_mobile'] == 'y' && isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'mobile') {
nhuffschmid's avatar
nhuffschmid committed
153 154 155
	include_once ("lib/hawhaw/hawtikilib.php");
	HAWTIKI_list_articles($listpages, $tiki_p_read_article, $offset, $maxRecords, $listpages["cant"]);
}
156
ask_ticket('list-articles');
157
// Display the template
158
$smarty->assign('mid', 'tiki-list_articles.tpl');
159
$smarty->display("tiki.tpl");