tiki-list_articles.php 4.81 KB
Newer Older
1
<?php
2

3
// $Id: /cvsroot/tikiwiki/tiki/tiki-list_articles.php,v 1.38.2.2 2008-03-21 23:06:51 sylvieg Exp $
4

5
// Copyright (c) 2002-2007, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
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.

9
// Initialization
mose's avatar
mose committed
10
$section = 'cms';
11
require_once ('tiki-setup.php');
12

13 14
include_once ('lib/articles/artlib.php');

15 16
$smarty->assign('headtitle',tra('List Articles'));

17
if ($prefs['feature_articles'] != 'y') {
18
	$smarty->assign('msg', tra("This feature is disabled").": feature_articles");
lrargerich's avatar
lrargerich committed
19

20
	$smarty->display("error.tpl");
21 22
	die;
}
lrargerich's avatar
lrargerich committed
23

24
// Now check permissions to access this page
sylvieg's avatar
sylvieg committed
25
if($tiki_p_read_article != 'y') {
26 27 28 29
	$smarty->assign('errortype', 401);
	$smarty->assign('msg',tra("Permission denied you cannot view pages"));
	$smarty->display("error.tpl");
	die;  
30
}
sylvieg's avatar
sylvieg committed
31

32
if (isset($_REQUEST["remove"])) {
33

34
	if ($tiki_p_remove_article != 'y') {
35
		$smarty->assign('errortype', 401);
36
		$smarty->assign('msg', tra("Permission denied you cannot remove articles"));
37

38
		$smarty->display("error.tpl");
39 40
		die;
	}
mose's avatar
mose committed
41
  $area = 'delarticle';
42
  if ($prefs['feature_ticketlib2'] != 'y' or (isset($_POST['daconfirm']) and isset($_SESSION["ticket_$area"]))) {
mose's avatar
mose committed
43 44 45 46 47
    key_check($area);
		$artlib->remove_article($_REQUEST["remove"]);
  } else {
    key_get($area);
  }
48
}
49 50 51 52 53

// 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
54 55
if (!isset($_REQUEST["sort_mode"])) {
	$sort_mode = 'publishDate_desc';
56
} else {
57 58
	$sort_mode = $_REQUEST["sort_mode"];
}
59

60
$smarty->assign_by_ref('sort_mode', $sort_mode);
61 62 63 64

// 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
65 66
if (!isset($_REQUEST["offset"])) {
	$offset = 0;
67
} else {
68
	$offset = $_REQUEST["offset"];
69
}
70
$smarty->assign_by_ref('offset', $offset);
sylvieg's avatar
sylvieg committed
71 72
if (!empty($_REQUEST['maxRecords'])) {
	$maxRecords = $_REQUEST['maxRecords'];
73
} else {
74
	$maxRecords = $maxRecords;
sylvieg's avatar
sylvieg committed
75
}
sylvieg's avatar
typo  
sylvieg committed
76
$smarty->assign_by_ref('maxRecords', $maxRecords);
77

redflo's avatar
redflo committed
78
if( ($tiki_p_admin == 'y') || ($tiki_p_admin_cms == 'y') ) {
79
  $date_max = '';
redflo's avatar
redflo committed
80
} elseif(isset($_SESSION["thedate"])) {
mose's avatar
mose committed
81
  if($_SESSION["thedate"]<$tikilib->now) {
redflo's avatar
redflo committed
82 83
    // If the session is older then set it to today
    // so you can list articles
84
    $date_max = $tikilib->now; 
redflo's avatar
redflo committed
85
  } else {
86
      $date_max = $_SESSION["thedate"]; 
redflo's avatar
redflo committed
87
  }
88
} else {
89
	$date_max = $tikilib->now;
90 91
}

92 93
if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
94
} else {
95
	$find = '';
96 97
}

98 99 100 101
$smarty->assign('find', $find);

if (!isset($_REQUEST["type"])) {
	$_REQUEST["type"] = '';
lrargerich's avatar
lrargerich committed
102
}
103 104 105

if (!isset($_REQUEST["topic"])) {
	$_REQUEST["topic"] = '';
lrargerich's avatar
lrargerich committed
106 107
}

108 109 110
if (!isset($_REQUEST["categId"])) {
	$_REQUEST["categId"] = '';
}
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_categId', $_REQUEST["categId"]);
117
$smarty->assign('find_lang', $_REQUEST['lang']);
118 119


lrargerich's avatar
lrargerich committed
120

121 122 123
$visible_only='y';
if( ($tiki_p_admin == 'y') || ($tiki_p_admin_cms == 'y') ) { $visible_only="n"; }

124
// Get a list of last changes to the Wiki database
125
$listpages = $tikilib->list_articles($offset, $maxRecords, $sort_mode, $find, 0, $date_max, $user, $_REQUEST["type"], $_REQUEST["topic"], $visible_only, '', $_REQUEST["categId"], '', '', $_REQUEST['lang']);
126
// If there're more records then assign next_offset
127
$smarty->assign_by_ref('cant', $listpages['cant']);
128

129
$smarty->assign_by_ref('listpages', $listpages["data"]);
130
//print_r($listpages["data"]);
131
$topics = $artlib->list_topics();
132
$smarty->assign_by_ref('topics', $topics);
lrargerich's avatar
lrargerich committed
133

134 135 136
$types = $artlib->list_types();
$smarty->assign_by_ref('types', $types);

137
if ($prefs['feature_categories'] == 'y') {
138 139 140 141
	global $categlib; include_once ('lib/categories/categlib.php');
	$categories = $categlib->get_all_categories_ext();
	$smarty->assign_by_ref('categories', $categories);
}
142
if ($prefs['feature_multilingual'] == 'y') {
sylvieg's avatar
sylvieg committed
143 144 145 146
	$languages = array();
	$languages = $tikilib->list_languages(false, 'y');
	$smarty->assign_by_ref('languages', $languages);
}
147

148 149 150 151 152 153 154 155 156
if ($tiki_p_edit_article != 'y' && $tiki_p_remove_article != 'y') { //check one editable
	foreach ($listpages['data'] as $page) {
		if ($page['author'] == $user && $page['creator_edit'] == 'y') {
			$smarty->assign('oneEditPage', 'y');
			break;
		}
	}
}

157
include_once ('tiki-section_options.php');
lrargerich's avatar
lrargerich committed
158

159
if ($prefs['feature_mobile'] =='y' && isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'mobile') {
nhuffschmid's avatar
nhuffschmid committed
160 161 162 163
	include_once ("lib/hawhaw/hawtikilib.php");

	HAWTIKI_list_articles($listpages, $tiki_p_read_article, $offset, $maxRecords, $listpages["cant"]);
}
164
ask_ticket('list-articles');
nhuffschmid's avatar
nhuffschmid committed
165

166
// Display the template
167
$smarty->assign('mid', 'tiki-list_articles.tpl');
168
$smarty->display("tiki.tpl");