source: contrib/Dms/op/op.UpdateDocument.php @ 3526

Revision 3526, 2.7 KB checked in by afernandes, 13 years ago (diff)

Ticket #1416 - Disponibilizado modulos Timesheet e DMS para a comunidade.

  • Property svn:executable set to *
Line 
1<?php
2include("../inc/inc.Settings.php");
3include("../inc/inc.AccessUtils.php");
4include("../inc/inc.ClassAccess.php");
5include("../inc/inc.ClassDocument.php");
6include("../inc/inc.ClassFolder.php");
7include("../inc/inc.ClassGroup.php");
8include("../inc/inc.ClassUser.php");
9include("../inc/inc.DBAccess.php");
10include("../inc/inc.FileUtils.php");
11include("../inc/inc.Language.php");
12include("../inc/inc.OutUtils.php");
13include("../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
28printHTMLHead( getMLText("document_title", array("documentname" => $document->getName()) ) );
29printTitleBar($document->getFolder());
30printCenterStart();
31
32printStartBox(getMLText("update_document"));
33
34print "<div class=\"standardText\">";
35
36
37if ($document->getAccessMode($user) < M_READWRITE)
38{
39        printMLText("operation_not_allowed");
40        printGoBack();
41}
42else
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
106print "</div>";
107printEndBox();
108printCenterEnd();
109printHTMLFoot();
110?>
Note: See TracBrowser for help on using the repository browser.