tiki-list_articles.php 5.63 KB
Newer Older
1
<?php
2
// (c) Copyright 2002-2009 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
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;
	}
22 23
	$access->check_authenticity();
	$artlib->remove_article($_REQUEST["remove"]);
24
}
25 26 27 28
// 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
29 30
if (!isset($_REQUEST["sort_mode"])) {
	$sort_mode = 'publishDate_desc';
31
} else {
32 33 34
	$sort_mode = $_REQUEST["sort_mode"];
}
$smarty->assign_by_ref('sort_mode', $sort_mode);
35 36 37
// 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
38 39
if (!isset($_REQUEST["offset"])) {
	$offset = 0;
40
} else {
41
	$offset = $_REQUEST["offset"];
42
}
43
$smarty->assign_by_ref('offset', $offset);
sylvieg's avatar
sylvieg committed
44 45
if (!empty($_REQUEST['maxRecords'])) {
	$maxRecords = $_REQUEST['maxRecords'];
46
} else {
47
	$maxRecords = $maxRecords;
sylvieg's avatar
sylvieg committed
48
}
sylvieg's avatar
typo  
sylvieg committed
49
$smarty->assign_by_ref('maxRecords', $maxRecords);
50 51

$visible_only = 'y';
changi67's avatar
changi67 committed
52 53
if (($tiki_p_admin == 'y') || ($tiki_p_admin_cms == 'y')) {
	$date_max = '';
54
	$visible_only = "n";
changi67's avatar
changi67 committed
55 56 57 58 59 60 61 62
} 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"];
	}
63
} else {
64
	$date_max = $tikilib->now;
65
}
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
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);
81 82
if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
83
} else {
84
	$find = '';
85
}
86 87 88
$smarty->assign('find', $find);
if (!isset($_REQUEST["type"])) {
	$_REQUEST["type"] = '';
lrargerich's avatar
lrargerich committed
89
}
90 91
if (!isset($_REQUEST["topic"])) {
	$_REQUEST["topic"] = '';
lrargerich's avatar
lrargerich committed
92
}
93 94 95 96 97 98 99 100 101

$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];
102
		unset($_REQUEST['cat_categories']);
103 104 105 106 107 108 109
	}
} else {
		$_REQUEST['cat_categories'] = array();
}
if ($prefs['feature_categories'] == 'y' && !empty($_REQUEST['categId'])) {
	$filter['categId'] = $_REQUEST['categId'];
	$smarty->assign('find_categId', $_REQUEST['categId']);
110
}
111 112 113
if (!isset($_REQUEST['lang'])) {
	$_REQUEST['lang'] = '';
}
114 115
$smarty->assign('find_topic', $_REQUEST["topic"]);
$smarty->assign('find_type', $_REQUEST["type"]);
116
$smarty->assign('find_lang', $_REQUEST['lang']);
117
// Get a list of last changes to the Wiki database
118
$listpages = $artlib->list_articles($offset, $maxRecords, $sort_mode, $find, $date_min, $date_max, $user, $_REQUEST["type"], $_REQUEST["topic"], $visible_only, '', $filter["categId"], '', '', $_REQUEST['lang']);
119
// If there're more records then assign next_offset
120
$smarty->assign_by_ref('cant', $listpages['cant']);
121
$smarty->assign_by_ref('listpages', $listpages["data"]);
122

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