-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfiles.class.php
96 lines (80 loc) · 2.13 KB
/
files.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php /* FILES $Id: files.class.php,v 1.8 2004/03/10 08:46:21 kiryl Exp $ */
require_once( $AppUI->getSystemClass( 'libmail' ) );
require_once( $AppUI->getSystemClass( 'dp' ) );
require_once( $AppUI->getModuleClass( 'tasks' ) );
require_once( $AppUI->getModuleClass( 'projects' ) );
/**
* File Class
*/
class CFile extends CDpObject {
var $SGD_id = NULL;
var $SGD_name = NULL;
var $SGD_description = NULL;
var $SGD_type = NULL;
var $SGD_date = NULL;
var $SGD_parent = NULL;
var $SGD_state = NULL;
function CFile() {
$this->CDpObject( 'mngdocument', 'file_id' );
}
function check() {
// ensure the integrity of some variables
$this->SGD_id = intval( $this->SGD_id );
$this->SGD_parent = intval( $this->SGD_parent );
return NULL; // object is ok
}
function deletefile() {
global $AppUI;
$this->_message = "deleted";
// remove the file from the file system
@unlink( dPgetConfig('root_dir')."/SGD/$this->SGD_name" );
// delete the main table reference
$sql = "DELETE FROM SGD WHERE SGD_id = $this->SGD_id";
if (!db_exec( $sql )) {
return db_error();
}
return NULL;
}
function deletedirectory() {
global $AppUI;
$this->_message = "deleted";
// delete the main table reference
$sql = "DELETE FROM SGD WHERE SGD_id = $this->SGD_id";
if (!db_exec( $sql )) {
return db_error();
}
return NULL;
}
// move a file from a temporary (uploaded) location to the file system
function moveTemp( $upload ) {
global $AppUI;
// check that directories are created
if (!is_dir(dPgetConfig('root_dir')."/SGD")) {
$res = mkdir( dPgetConfig('root_dir')."/SGD", 0777 );
if (!$res) {
return false;
}
}
$this->_filepath = dPgetConfig('root_dir')."/SGD/$this->SGD_name";
// move it
$res = move_uploaded_file( $upload['tmp_name'], $this->_filepath );
if (!$res) {
return false;
}
return true;
}
}
/**
* CFileLog Class
*/
class CFileLog extends CDpObject {
var $SGD_Log_id = NULL;
var $SGD_Log_document_name = NULL;
var $SGD_Log_user = NULL;
var $SGD_Log_date = NULL;
var $SGD_Log_action = NULL;
function CFileLog() {
$this->CDpObject( 'CFile_Log', 'SGD_Log_id' );
}
}
?>