1 | <?php |
---|
2 | include("../inc/inc.Settings.php"); |
---|
3 | include("../inc/inc.AccessUtils.php"); |
---|
4 | include("../inc/inc.ClassAccess.php"); |
---|
5 | include("../inc/inc.ClassDocument.php"); |
---|
6 | include("../inc/inc.ClassFolder.php"); |
---|
7 | include("../inc/inc.ClassGroup.php"); |
---|
8 | include("../inc/inc.ClassUser.php"); |
---|
9 | include("../inc/inc.DBAccess.php"); |
---|
10 | include("../inc/inc.FileUtils.php"); |
---|
11 | include("../inc/inc.Language.php"); |
---|
12 | include("../inc/inc.OutUtils.php"); |
---|
13 | include("../inc/inc.Authentication.php"); |
---|
14 | |
---|
15 | $comment = $_POST['comment']; |
---|
16 | $documentid = (isset($_GET['documentid'])) ? (int) $_GET['documentid'] : NULL; |
---|
17 | $expires = $_POST['expires']; |
---|
18 | $expday = (int)$_POST['expday']; |
---|
19 | $expmonth = (int)$_POST['expmonth']; |
---|
20 | $expyear = (int)$_POST['expyear']; |
---|
21 | $userfile = $_FILES['userfile']['tmp_name']; |
---|
22 | |
---|
23 | |
---|
24 | $document = getDocument($documentid); |
---|
25 | |
---|
26 | |
---|
27 | |
---|
28 | printHTMLHead( getMLText("document_title", array("documentname" => $document->getName()) ) ); |
---|
29 | printTitleBar($document->getFolder()); |
---|
30 | printCenterStart(); |
---|
31 | |
---|
32 | printStartBox(getMLText("update_document")); |
---|
33 | |
---|
34 | print "<div class=\"standardText\">"; |
---|
35 | |
---|
36 | |
---|
37 | if ($document->getAccessMode($user) < M_READWRITE) |
---|
38 | { |
---|
39 | printMLText("operation_not_allowed"); |
---|
40 | printGoBack(); |
---|
41 | } |
---|
42 | else |
---|
43 | { |
---|
44 | if ($document->isLocked()) |
---|
45 | { |
---|
46 | $lockingUser = $document->getLockingUser(); |
---|
47 | |
---|
48 | if (($lockingUser->getID() != $user->getID()) && ($document->getAccessMode($user) != M_ALL)) |
---|
49 | { |
---|
50 | printMLText("update_locked_msg", array("username" => $lockingUser->getFullName(), "email" => $lockingUser->getEmail())); |
---|
51 | printMLText("no_update_cause_locked"); |
---|
52 | printGoBack(); |
---|
53 | |
---|
54 | print "</div>"; |
---|
55 | printEndBox(); |
---|
56 | printCenterEnd(); |
---|
57 | printHTMLFoot(); |
---|
58 | exit; |
---|
59 | } |
---|
60 | else |
---|
61 | $document->setLocked(false); |
---|
62 | } |
---|
63 | |
---|
64 | if (!isset($userfile) || ($userfile == "none") || ($userfile == "")) |
---|
65 | { |
---|
66 | printMLText("uploading_failed"); |
---|
67 | printGoBack(); |
---|
68 | } |
---|
69 | else |
---|
70 | { |
---|
71 | printMLText("updating_document"); |
---|
72 | |
---|
73 | $comment = sanitizeString($comment); |
---|
74 | $userfile_type = sanitizeString($userfile_type); |
---|
75 | $userfile_name = sanitizeString($userfile_name); |
---|
76 | |
---|
77 | $lastDotIndex = strrpos(basename($userfile_name), "."); |
---|
78 | if (is_bool($lastDotIndex) && !$lastDotIndex) |
---|
79 | $fileType = "."; |
---|
80 | else |
---|
81 | $fileType = substr($userfile_name, $lastDotIndex); |
---|
82 | |
---|
83 | if (!$document->addContent($comment, $user, $userfile, basename($userfile_name), $fileType, $userfile_type)) |
---|
84 | { |
---|
85 | printMLText("error_occured"); |
---|
86 | printGoBack(); |
---|
87 | } |
---|
88 | else |
---|
89 | { |
---|
90 | $expires = ($expires == "true") ? mktime(0,0,0, $expmonth, $expday, $expyear) : false; |
---|
91 | |
---|
92 | if (!$document->setExpires($expires)) |
---|
93 | { |
---|
94 | printMLText("error_occured"); |
---|
95 | printGoBack(); |
---|
96 | } |
---|
97 | else |
---|
98 | { |
---|
99 | printMLText("op_finished"); |
---|
100 | printGoto(array(array($document->getName(), "../out/out.ViewDocument.php?documentid=".$document->getID()))); |
---|
101 | } |
---|
102 | } |
---|
103 | } |
---|
104 | } |
---|
105 | |
---|
106 | print "</div>"; |
---|
107 | printEndBox(); |
---|
108 | printCenterEnd(); |
---|
109 | printHTMLFoot(); |
---|
110 | ?> |
---|