tiki-notepad_list.php 3.19 KB
Newer Older
awcolley's avatar
awcolley committed
1
<?php
2
// (c) Copyright 2002-2016 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
$section = 'mytiki';
9 10 11
require_once ('tiki-setup.php');
include_once ('lib/notepad/notepadlib.php');
include_once ('lib/userfiles/userfileslib.php');
12 13 14
$access->check_feature('feature_notepad');
$access->check_user($user);
$access->check_permission('tiki_p_notepad');
awcolley's avatar
awcolley committed
15
// Process upload here
16
if (isset($_FILES['userfile1']) && is_uploaded_file($_FILES['userfile1']['tmp_name'])) {
17
	check_ticket('notepad-list');
18 19 20
	$fp = fopen($_FILES['userfile1']['tmp_name'], "rb");
	$data = '';
	while (!feof($fp)) {
changi67's avatar
changi67 committed
21
		$data.= fread($fp, 8192 * 16);
22
	}
changi67's avatar
changi67 committed
23
	fclose($fp);
24
	if (strlen($data) > 1000000) {
25
		$smarty->assign('msg', tra("The file is too large"));
26
		$smarty->display("error.tpl");
27 28 29 30 31 32
		die;
	}
	$size = $_FILES['userfile1']['size'];
	$name = $_FILES['userfile1']['name'];
	$type = $_FILES['userfile1']['type'];
	$notepadlib->replace_note($user, 0, $name, $data);
awcolley's avatar
awcolley committed
33
}
34
if (isset($_REQUEST["merge"])) {
35
	check_ticket('notepad-list');
36 37
	$merge = '';
	$first = true;
38 39 40 41 42
	if (!isset($_REQUEST["note"])) {
		$smarty->assign('msg', tra("No item indicated"));
		$smarty->display("error.tpl");
		die;
	}
43
	foreach (array_keys($_REQUEST["note"]) as $note) {
44 45 46 47
		$data_c = $notepadlib->get_note($user, $note);
		$data = $data_c['data'];
		if ($first) {
			$first = false;
changi67's avatar
changi67 committed
48 49
			$merge.= "---------" . tra('merged note:') . $data_c['name'] . "----" . "\n";
			$merge.= $data;
50
		} else {
changi67's avatar
changi67 committed
51 52
			$merge.= "\n---------" . tra('merged note:') . $data_c['name'] . "----" . "\n";
			$merge.= $data;
53 54 55 56
		}
	}
	// Now create the merged note
	$tikilib->replace_note($user, 0, $_REQUEST['merge_name'], $merge);
awcolley's avatar
awcolley committed
57
}
58
if (isset($_REQUEST["delete"]) && isset($_REQUEST["note"])) {
59
	foreach (array_keys($_REQUEST["note"]) as $note) {
60 61 62
		$notepadlib->remove_note($user, $note);
	}
}
awcolley's avatar
awcolley committed
63
$quota = $userfileslib->userfiles_quota($user);
64
$limit = $prefs['userfiles_quota'] * 1024 * 1000;
changi67's avatar
changi67 committed
65
if ($limit == 0) $limit = 999999999;
66 67
$percentage = ($quota / $limit) * 100;
$cellsize = round($percentage / 100 * 200);
changi67's avatar
changi67 committed
68
if ($cellsize == 0) $cellsize = 1;
69 70 71 72 73
$percentage = round($percentage);
$smarty->assign('cellsize', $cellsize);
$smarty->assign('percentage', $percentage);
if (!isset($_REQUEST["sort_mode"])) {
	$sort_mode = 'lastModif_desc';
awcolley's avatar
awcolley committed
74
} else {
75 76 77 78
	$sort_mode = $_REQUEST["sort_mode"];
}
if (!isset($_REQUEST["offset"])) {
	$offset = 0;
awcolley's avatar
awcolley committed
79
} else {
80
	$offset = $_REQUEST["offset"];
awcolley's avatar
awcolley committed
81
}
82 83 84
$smarty->assign_by_ref('offset', $offset);
if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
awcolley's avatar
awcolley committed
85
} else {
86
	$find = '';
awcolley's avatar
awcolley committed
87
}
88 89 90 91
$smarty->assign('find', $find);
$smarty->assign_by_ref('sort_mode', $sort_mode);
if (isset($_SESSION['thedate'])) {
	$pdate = $_SESSION['thedate'];
awcolley's avatar
awcolley committed
92
} else {
mose's avatar
mose committed
93
	$pdate = $tikilib->now;
awcolley's avatar
awcolley committed
94
}
95
$channels = $notepadlib->list_notes($user, $offset, $maxRecords, $sort_mode, $find);
96
$smarty->assign_by_ref('cant_pages', $channels["cant"]);
97
$smarty->assign_by_ref('channels', $channels["data"]);
98
include_once ('tiki-section_options.php');
99
include_once ('tiki-mytiki_shared.php');
100
ask_ticket('notepad-list');
101
$smarty->assign('mid', 'tiki-notepad_list.tpl');
102
$smarty->display("tiki.tpl");