3 * FusionForge document manager
5 * Copyright 2000, Quentin Cregan/Sourceforge
6 * Copyright 2002-2003, Tim Perdue/GForge, LLC
7 * Copyright 2009, Roland Mas
8 * Copyright 2010-2011, Franck Villaume - Capgemini
9 * Copyright 2011-2013, Franck Villaume - TrivialDev
10 * Copyright (C) 2011-2012 Alain Peyrat - Alcatel-Lucent
11 * http://fusionforge.org
13 * This file is part of FusionForge. FusionForge is free software;
14 * you can redistribute it and/or modify it under the terms of the
15 * GNU General Public License as published by the Free Software
16 * Foundation; either version 2 of the Licence, or (at your option)
19 * FusionForge is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 require_once $gfcommon.'include/Error.class.php';
30 require_once $gfcommon.'docman/Parsedata.class.php';
31 require_once $gfcommon.'docman/DocumentManager.class.php';
32 require_once $gfcommon.'docman/DocumentGroup.class.php';
33 require_once $gfcommon.'docman/DocumentStorage.class.php';
35 class Document extends Error {
38 * Associative array of data from db.
40 * @var array $data_array.
57 * @internal param \The $object Group object to which this document is associated.
58 * @internal param \The $int docid.
59 * @internal param \The $array associative array of data.
62 function __construct(&$Group, $docid = false, $arr = false) {
64 if (!$Group || !is_object($Group)) {
65 $this->setError(_('No Valid Group Object'));
68 if ($Group->isError()) {
69 $this->setError('Document:: '. $Group->getErrorMessage());
72 $this->Group =& $Group;
75 if (!$arr || !is_array($arr)) {
76 if (!$this->fetchData($docid)) {
80 $this->data_array =& $arr;
81 if ($this->data_array['group_id'] != $this->Group->getID()) {
82 $this->setError('Document:: '. _('group_id in db result does not match Group Object'));
83 $this->data_array = null;
87 if (!$this->isPublic()) {
88 $perm =& $this->Group->getPermission();
90 if (!$perm || !is_object($perm) || !$perm->isDocEditor()) {
91 $this->setPermissionDeniedError();
92 $this->data_array = null;
100 * create - use this function to create a new entry in the database.
102 * @param string $filename The filename of this document. Can be a URL.
103 * @param string $filetype The filetype of this document. If filename is URL, this should be 'URL';
104 * @param string $data The absolute path file itself.
105 * @param int $doc_group The doc_group id of the doc_groups table.
106 * @param string $title The title of this document.
107 * @param string $description The description of this document.
108 * @param int $stateid The state id of the document. At creation, cannot be deleted status.
109 * @return bool success.
111 function create($filename, $filetype, $data, $doc_group, $title, $description, $stateid = 0) {
112 if (strlen($title) < 5) {
113 $this->setError(_('Title Must Be At Least 5 Characters'));
116 if (strlen($description) < 10) {
117 $this->setError(_('Document Description Must Be At Least 10 Characters'));
121 $user_id = ((session_loggedin()) ? user_getid() : 100);
123 $doc_initstatus = '3';
124 $perm =& $this->Group->getPermission();
125 if ($perm && is_object($perm) && $perm->isDocEditor()) {
126 if ($stateid && $stateid != 2) {
127 $doc_initstatus = $stateid;
129 $doc_initstatus = '1';
133 $result = db_query_params('SELECT filename, doc_group from docdata_vw
137 array($filename, $doc_group, $doc_initstatus));
139 if (!$result || db_numrows($result) > 0) {
140 $dg = new DocumentGroup($this->getGroup(), $doc_group);
141 $this->setError(_('Document already published in this folder').' '.$dg->getPath());
145 $result = db_query_params('SELECT title FROM docdata_vw where title = $1 AND doc_group = $2',
146 array($title, $doc_group));
147 if (!$result || db_numrows($result) > 0) {
148 $dg = new DocumentGroup($this->getGroup(), $doc_group);
149 $this->setError(_('Document already published in this folder').' '.$dg->getPath());
153 // If $filetype is "text/plain", $body convert UTF-8 encoding.
154 if (strcasecmp($filetype, "text/plain") === 0 &&
155 function_exists('mb_convert_encoding') &&
156 function_exists('mb_detect_encoding')) {
157 $data = mb_convert_encoding($data, 'UTF-8', mb_detect_encoding($data));
160 $filesize = filesize($data);
161 if (!$filesize) { $filesize = 0; }
163 // key words for in-document search
164 if ($this->Group->useDocmanSearch() && $filesize) {
165 $kw = new Parsedata();
166 $kwords = $kw->get_parse_data($data, htmlspecialchars($title), htmlspecialchars($description), $filetype, $filename);
172 $result = db_query_params('INSERT INTO doc_data (group_id, title, description, createdate, doc_group,
173 stateid, filename, filetype, filesize, data_words, created_by)
174 VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)',
175 array($this->Group->getId(),
176 htmlspecialchars($title),
177 htmlspecialchars($description),
188 $docid = db_insertid($result, 'doc_data', 'docid');
190 if (is_file($data)) {
191 if (!DocumentStorage::instance()->store($docid, $data)) {
192 DocumentStorage::instance()->rollback();
194 $this->setError(DocumentStorage::instance()->getErrorMessage());
198 $this->setError(_('Error Adding Document:').' '._('Not a file').' '.$filename);
204 if (!$result || !$docid) {
205 $this->setError(_('Error Adding Document:').' '.db_error().$result);
207 DocumentStorage::instance()->rollback();
213 if (!$this->fetchData($docid)) {
214 $this->setError(_('Error fetching Document'));
216 DocumentStorage::instance()->rollback();
222 if ($perm->isDocEditor()) {
223 $localDg = new DocumentGroup($this->Group, $doc_group);
224 if (!$localDg->update($localDg->getName(), $localDg->getParentID(), 1)) {
225 $this->setError(_('Error updating document group:').$localDg->getErrorMessage());
227 DocumentStorage::instance()->rollback();
233 $this->sendNotice(true);
234 $this->SendApprovalNotice();
237 DocumentStorage::instance()->commit();
243 * fetchData() - re-fetch the data for this document from the database.
245 * @param int $docid The document id.
246 * @return boolean success
248 function fetchData($docid) {
249 $res = db_query_params('SELECT * FROM docdata_vw WHERE docid=$1 AND group_id=$2',
250 array($docid, $this->Group->getID()));
251 if (!$res || db_numrows($res) < 1) {
252 $this->setError(_('Document: Invalid docid'));
255 $this->data_array = db_fetch_array($res);
256 db_free_result($res);
261 * getGroup - get the Group object this Document is associated with.
263 * @return Object The Group object.
265 function &getGroup() {
270 * getID - get this docid.
272 * @return int The docid.
275 return $this->data_array['docid'];
279 * getName - get the name of this document.
281 * @return string The name of this document.
284 return $this->data_array['title'];
288 * getDescription - the description of this document.
290 * @return string The description.
292 function getDescription() {
293 return $this->data_array['description'];
297 * isURL - whether this document is a URL and not a local file.
299 * @return boolean is_url.
302 return ($this->data_array['filetype'] == 'URL');
306 * isText - whether this document is a text document and not a binary one.
308 * @return boolean is_text.
311 $doctype = $this->data_array['filetype'];
312 if (preg_match('|^text/|i', $doctype)) { // text plain, text html, text x-patch, etc
319 * isHtml - whether this document is a html document.
321 * @return boolean is_html.
324 $doctype = $this->data_array['filetype'];
325 if (preg_match('/html/i',$doctype)) {
332 * isPublic - whether this document is available to the general public.
334 * @return boolean is_public.
336 function isPublic() {
337 return (($this->data_array['stateid'] == 1) ? true : false);
341 * getStateID - get this stateid.
343 * @return int The stateid.
345 function getStateID() {
346 return $this->data_array['stateid'];
350 * getStateName - the statename of this document.
352 * @return string The statename.
354 function getStateName() {
355 return $this->data_array['state_name'];
359 * getDocGroupID - get this doc_group_id.
361 * @return int The doc_group_id.
363 function getDocGroupID() {
364 return $this->data_array['doc_group'];
368 * getDocGroupName - the doc_group_name of this document.
370 * @return string The docgroupname.
372 function getDocGroupName() {
373 return $this->data_array['group_name'];
377 * getCreatorID - get this creator's user_id.
379 * @return int The user_id.
381 function getCreatorID() {
382 return $this->data_array['created_by'];
386 * getCreatorUserName - the unix name of the person who created this document.
388 * @return string The unix name of the creator.
390 function getCreatorUserName() {
391 return $this->data_array['user_name'];
395 * getCreatorRealName - the real name of the person who created this document.
397 * @return string The real name of the creator.
399 function getCreatorRealName() {
400 return $this->data_array['realname'];
404 * getCreatorEmail - the email of the person who created this document.
406 * @return string The email of the creator.
408 function getCreatorEmail() {
409 return $this->data_array['email'];
413 * getFileName - the filename of this document.
415 * @return string The filename.
417 function getFileName() {
418 return $this->data_array['filename'];
422 * getFileType - the filetype of this document.
424 * @return string The filetype.
426 function getFileType() {
427 return $this->data_array['filetype'];
431 * getFileData - the filedata of this document.
433 * @param boolean update the download flag or not. default is true
434 * @return string The filedata.
436 function getFileData($download = true) {
440 return file_get_contents($this->getFilePath());
444 * getFilePath - the filepath of this document.
446 * @return string The file where the file is stored.
448 function getFilePath() {
449 return DocumentStorage::instance()->get($this->getID());
453 * getFileSize - Return the size of the document
455 * @return int The file size
457 function getFileSize() {
458 return $this->data_array['filesize'];
462 * getUpdated - get the time this document was updated.
464 * @return int The epoch date this document was updated.
466 function getUpdated() {
467 return $this->data_array['updatedate'];
471 * getDownload - get the number of views of this document.
473 * @return int the number of views
475 function getDownload() {
476 return $this->data_array['download'];
480 * getCreated - get the time this document was created.
482 * @return int The epoch date this document was created.
484 function getCreated() {
485 return $this->data_array['createdate'];
489 * getLocked - get the lock status of this document.
491 * @return int The lock status of this document.
493 function getLocked() {
494 return $this->data_array['locked'];
498 * getLockdate - get the lock time of this document.
500 * @return int The lock time of this document.
502 function getLockdate() {
503 return $this->data_array['lockdate'];
507 * getLockedBy - get the user id who set lock on this document.
509 * @return int The user id who set lock on this document.
511 function getLockedBy() {
512 return $this->data_array['locked_by'];
516 * getReservedBy - get the owner of the reversed status of this document.
518 * @return int The owner of the reversed status of this document.
520 function getReservedBy() {
521 return $this->data_array['reserved_by'];
525 * getReserved - get the reversed status of this document.
527 * @return int The reversed status of this document.
529 function getReserved() {
530 return $this->data_array['reserved'];
534 * getMonitoredUserEmailAddress - get the email addresses of users who monitor this file
536 * @return string The list of emails comma separated
538 function getMonitoredUserEmailAddress() {
539 $result = db_query_params('select users.email from users,docdata_monitored_docman where users.user_id = docdata_monitored_docman.user_id and docdata_monitored_docman.doc_id = $1', array ($this->getID()));
540 if (!$result || db_numrows($result) < 1) {
546 while ($arr = db_fetch_array($result)) {
550 $values .= $comma.$arr['email'];
558 * isMonitoredBy - get the monitored status of this document for a specific user id.
560 * @param string $userid
561 * @internal param \User $int ID
562 * @return boolean true if monitored by this user
564 function isMonitoredBy($userid = 'ALL') {
565 if ( $userid == 'ALL' ) {
568 $condition = 'user_id='.$userid.' AND';
570 $result = db_query_params('SELECT * FROM docdata_monitored_docman WHERE '.$condition.' doc_id=$1',
571 array($this->getID()));
573 if (!$result || db_numrows($result) < 1)
580 * removeMonitoredBy - remove this document for a specific user id for monitoring.
583 * @return boolean true if success
585 function removeMonitoredBy($userid) {
586 $result = db_query_params('DELETE FROM docdata_monitored_docman WHERE doc_id=$1 AND user_id=$2',
587 array($this->getID(), $userid));
590 $this->setError(_('Unable To Remove Monitor').' : '.db_error());
597 * addMonitoredBy - add this document for a specific user id for monitoring.
600 * @return boolean true if success
602 function addMonitoredBy($userid) {
603 $result = db_query_params('SELECT * FROM docdata_monitored_docman WHERE user_id=$1 AND doc_id=$2',
604 array($userid, $this->getID()));
606 if (!$result || db_numrows($result) < 1) {
607 $result = db_query_params('INSERT INTO docdata_monitored_docman (doc_id,user_id) VALUES ($1,$2)',
608 array($this->getID(), $userid));
611 $this->setError(_('Unable To Add Monitor').' : '.db_error());
619 * clearMonitor - remove all entries of monitoring for this document.
621 * @return boolean true if success.
623 function clearMonitor() {
624 $result = db_query_params('DELETE FROM docdata_monitored_docman WHERE doc_id = $1',
625 array($this->getID()));
627 $this->setError(_('Unable To Clear Monitor').' : '.db_error());
634 * setState - set the stateid of the document.
636 * @param int The state id of the doc_states table.
637 * @return boolean success or not.
639 function setState($stateid) {
640 return $this->setValueinDB('stateid', $stateid);
645 * setDocGroupID - set the doc_group of the document.
647 * @param int The group_id of this document.
648 * @return boolean success or not.
650 function setDocGroupID($newdocgroupid) {
651 return $this->setValueinDB('doc_group', $newdocgroupid);
655 * setLock - set the locking status of the document.
658 * @param time the epoch time.
659 * @param int $thistime
660 * @internal param \The $int status of the lock.
661 * @internal param \The $int userid who set the lock.
662 * @return boolean success or not.
664 function setLock($stateLock, $userid = NULL, $thistime = 0) {
665 $res = db_query_params('UPDATE doc_data SET
674 $this->Group->getID(),
677 if (!$res || db_affected_rows($res) < 1) {
678 $this->setOnUpdateError(_('Document lock failed').' '.db_error());
681 $this->data_array['locked'] = $stateLock;
682 $this->data_array['locked_by'] = $userid;
683 $this->data_array['lockdate'] = $thistime;
688 * setReservedBy - set the reserved status of the document and the owner
690 * @param int $statusReserved The status of the reserved
691 * @param int $idReserver The ID of the owner : by default : noone
692 * @return boolean success
694 function setReservedBy($statusReserved, $idReserver = NULL) {
695 $res = db_query_params('UPDATE doc_data SET
700 array($statusReserved,
702 $this->Group->getID(),
705 if (!$res || db_affected_rows($res) < 1) {
706 $this->setOnUpdateError(_('Document reservation failed').' '.db_error());
709 $this->sendNotice(false);
714 * getFileTypeImage - return the file image for icon
716 * @return string the file image name
719 function getFileTypeImage() {
720 switch ($this->getFileType()) {
725 case "image/vnd.microsoft.icon":
726 case "image/svg+xml": {
727 $image = 'docman/file_type_image.png';
731 case "audio/x-vorbis+ogg":
733 case "audio/x-ms-wma":
734 case "audio/vnd.rn-realaudio": {
735 $image = "docman/file_type_sound.png";
738 case "application/pdf": {
739 $image = 'docman/file_type_pdf.png';
744 $image = 'docman/file_type_html.png';
749 case "application/xml":
752 case "text/x-shellscript": {
753 $image = 'docman/file_type_plain.png';
756 case "application/msword":
757 case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
758 case "application/vnd.oasis.opendocument.text": {
759 $image = 'docman/file_type_writer.png';
762 case "application/vnd.ms-excel":
763 case "application/vnd.oasis.opendocument.spreadsheet":
764 case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": {
765 $image = 'docman/file_type_spreadsheet.png';
768 case "application/vnd.oasis.opendocument.presentation":
769 case "application/vnd.ms-powerpoint":
770 case "application/vnd.ms-office":
771 case "application/vnd.openxmlformats-officedocument.presentationml.presentation": {
772 $image = 'docman/file_type_presentation.png';
775 case "application/zip":
776 case "application/x-tar":
777 case "application/x-rpm":
778 case "application/x-rar-compressed":
779 case "application/x-bzip2":
780 case "application/x-gzip":
781 case "application/x-lzip":
782 case "application/x-compress":
783 case "application/x-7z-compressed":
784 case "application/x-gtar":
785 case "application/x-stuffitx":
786 case "application/x-lzx":
787 case "application/x-lzh":
788 case "application/x-gca-compressed":
789 case "application/x-apple-diskimage":
790 case "application/x-dgc-compressed":
791 case "application/x-dar":
792 case "application/x-cfs-compressed":
793 case "application/vnd.ms-cab-compressed":
794 case "application/x-alz-compressed":
795 case "application/x-astrotite-afa":
796 case "application/x-ace-compressed":
797 case "application/x-cpio":
798 case "application/x-shar":
799 case "application/x-xz": {
800 $image = 'docman/file_type_archive.png';
804 $image = 'docman/file_type_unknown.png';
811 * update - use this function to update an existing entry in the database.
813 * @param string $filename The filename of this document. Can be a URL.
814 * @param string $filetype The filetype of this document. If filename is URL, this should be 'URL';
815 * @param string $data The contents of this document.
816 * @param int $doc_group The doc_group id of the doc_groups table.
817 * @param string $title The title of this document.
818 * @param string $description The description of this document.
819 * @param int $stateid The state id of the doc_states table.
820 * @return boolean success.
822 function update($filename, $filetype, $data, $doc_group, $title, $description, $stateid) {
824 $perm =& $this->Group->getPermission();
825 if (!$perm || !is_object($perm) || !$perm->isDocEditor()) {
826 $this->setPermissionDeniedError();
830 $user = session_get_user();
831 if ($this->getLocked() && ($this->getLockedBy() != $user->getID())) {
832 $this->setPermissionDeniedError();
836 if (strlen($title) < 5) {
837 $this->setError(_('Title Must Be At Least 5 Characters'));
841 if (strlen($description) < 10) {
842 $this->setError(_('Document Description Must Be At Least 10 Characters'));
846 /* TODO : NEED REAL CHECK */
848 $result = db_query_params('SELECT filename, doc_group FROM docdata_vw WHERE filename = $1 AND doc_group = $2 AND stateid = $3 AND docid != $4',
849 array($filename, $doc_group, $stateid, $this->getID()));
850 if (!$result || db_numrows($result) > 0) {
851 $this->setError(_('Document already published in this folder'));
857 $res = db_query_params('UPDATE doc_data SET
869 array(htmlspecialchars($title),
870 htmlspecialchars($description),
878 $this->Group->getID(),
882 if (!$res || db_affected_rows($res) < 1) {
883 $this->setOnUpdateError(db_error());
888 $localDg = new DocumentGroup($this->Group, $doc_group);
889 if (!$localDg->update($localDg->getName(), $localDg->getParentID(), 1)) {
890 $this->setOnUpdateError(_('Error updating document group:').$localDg->getErrorMessage());
895 if (filesize($data)) {
896 // key words for in-document search
897 if ($this->Group->useDocmanSearch()) {
898 $kw = new Parsedata();
899 $kwords = $kw->get_parse_data($data, htmlspecialchars($title), htmlspecialchars($description), $filetype, $filename);
904 $res = db_query_params('UPDATE doc_data SET filesize=$1, data_words=$2 WHERE group_id=$3 AND docid=$4',
905 array(filesize($data),
907 $this->Group->getID(),
911 if (!$res || db_affected_rows($res) < 1) {
912 $this->setOnUpdateError(db_error());
917 DocumentStorage::instance()->delete($this->getID())->commit();
918 DocumentStorage::instance()->store($this->getID(), $data);
921 $this->fetchData($this->getID());
922 $this->sendNotice(false);
927 * sendNotice - Notifies of document submissions
929 * @param boolean true = new document (default value)
932 function sendNotice($new = true) {
933 $BCC = $this->Group->getDocEmailAddress();
934 if ($this->isMonitoredBy('ALL')) {
935 $BCC .= $this->getMonitoredUserEmailAddress();
937 $dg = new DocumentGroup($this->Group, $this->getDocGroupID());
938 if ($dg->isMonitoredBy('ALL')) {
939 $BCC .= $dg->getMonitoredUserEmailAddress();
941 if (strlen($BCC) > 0) {
942 $session = session_get_user();
944 $status = _('New Document');
946 $status = _('Updated document').' '._('by').' ' . $session->getRealName();
948 $subject = '['.$this->Group->getPublicName().'] '.$status.' - '.$this->getName();
949 $body = _('Project')._(': ').$this->Group->getPublicName()."\n";
950 $body .= _('Folder')._(': ').$this->getDocGroupName()."\n";
951 $body .= _('Document Title')._(': ').$this->getName()."\n";
952 $body .= _('Document description')._(': ').util_unconvert_htmlspecialchars($this->getDescription())."\n";
953 $body .= _('Submitter')._(': ').$this->getCreatorRealName()." (".$this->getCreatorUserName().") \n";
954 $body .= "\n\n-------------------------------------------------------\n".
955 _('For more info, visit:').
956 "\n\n" . util_make_url('/docman/?group_id='.$this->Group->getID().'&view=listfile&dirid='.$this->getDocGroupID());
958 $BCCarray = explode(',',$BCC);
959 foreach ($BCCarray as $dest_email) {
960 util_send_message($dest_email, $subject, $body, 'noreply@'.forge_get_config('web_host'), '', _('Docman'));
967 * SendApprovalNotice - send email to project admin for pending documents.
969 * @return boolean success.
971 function SendApprovalNotice() {
972 if ($this->getStateID() != 3)
975 $doc_name = $this->getName();
976 $desc = util_unconvert_htmlspecialchars( $this->getDescription() );
977 $group_id = $this->Group->getID();
978 $name = $this->getCreatorRealName()." (".$this->getCreatorUserName().")";
980 $subject="[" . forge_get_config('forge_name') ."] ".util_unconvert_htmlspecialchars($doc_name);
981 $body = "\nA new document has been uploaded and waiting to be approved by you:".
982 "\n".util_make_url('/docman/?group_id='.$group_id.'&view=admin').
983 "\nBy: " . $name . "\n";
985 $sanitizer = new TextSanitizer();
987 if (strstr($text,'<br/>') || strstr($text,'<br />')) {
988 $text = preg_replace('/[\n\r]/', '', $text);
990 $text = $sanitizer->convertNeededTagsForEmail($text);
991 $text = preg_replace('/\[.+\](.+)\[\/.+\]/','$1',$text);
992 $text = $sanitizer->convertExtendedCharsForEmail($text);
995 $extra_headers = "Return-Path: <noreply@".forge_get_config('web_host').">\n";
996 $extra_headers .= "Errors-To: <noreply@".forge_get_config('web_host').">\n";
997 $extra_headers .= "Sender: <noreply@".forge_get_config('web_host').">";
999 $sql = 'SELECT u.email FROM user_group ug INNER JOIN users u ON u.user_id=ug.user_id
1000 WHERE ug.admin_flags = $1 AND ug.group_id = $2';
1001 $res = db_query_params($sql, array('A', $group_id));
1002 $bcc = implode(util_result_column_to_array($res),',');
1003 if (strlen($bcc) > 0) {
1004 util_send_message('',$subject,$body,"noreply@".forge_get_config('web_host'),
1005 $bcc,'Docman',$extra_headers);
1011 * delete - Delete this file
1013 * @return boolean success
1016 $perm =& $this->Group->getPermission();
1017 if (!$perm || !is_object($perm) || !$perm->isDocEditor()) {
1018 $this->setPermissionDeniedError();
1022 $result = db_query_params('DELETE FROM doc_data WHERE docid=$1',
1023 array($this->getID()));
1025 $this->setError(_('Error Deleting Document:').' '.db_error());
1030 DocumentStorage::instance()->delete($this->getID())->commit();
1032 /** we should be able to send a notice that this doc has been deleted .... but we need to rewrite sendNotice
1033 * $this->sendNotice(false);
1034 * @TODO delete monitoring this file */
1039 * trash - move this file to trash
1041 * @return boolean success or not.
1044 $this->setState('2');
1045 $dm = new DocumentManager($this->Group);
1046 $this->setDocGroupID($dm->getTrashID());
1048 $this->setReservedBy(0);
1049 $this->sendNotice(false);
1050 $this->clearMonitor();
1056 * downloadUp - insert download stats
1060 private function downloadUp() {
1061 if (session_loggedin()) {
1062 $s =& session_get_user();
1068 $ip = getStringFromServer('REMOTE_ADDR');
1069 db_query_params("INSERT INTO docman_dlstats_doc (ip_address, docid, month, day, user_id) VALUES ($1, $2, $3, $4, $5)", array($ip, $this->getID(), date('Ym'), date('d'), $us));
1073 * setValueinDB - private function to update columns in db
1075 * @param string $column the column to update
1076 * @param int $value the value to store
1077 * @return boolean success or not
1080 private function setValueinDB($column, $value) {
1084 $qpa = db_construct_qpa();
1085 $qpa = db_construct_qpa($qpa, 'UPDATE doc_data SET ');
1086 $qpa = db_construct_qpa($qpa, $column);
1087 $qpa = db_construct_qpa($qpa, '=$1
1091 $this->Group->getID(),
1093 $res = db_query_qpa($qpa);
1094 if (!$res || db_affected_rows($res) < 1) {
1095 $this->setOnUpdateError(db_error().print_r($qpa));
1101 $this->setOnUpdateError(_('wrong column name'));
1104 $localDg = new DocumentGroup($this->Group, $this->getDocGroupID());
1105 if (!$localDg->update($localDg->getName(), $localDg->getParentID(), 1)) {
1106 $this->setError(_('Error updating document group:').$localDg->getErrorMessage());
1109 $this->sendNotice(false);
1113 function createVersion() {
1117 function deleteVersion() {
1124 // c-file-style: "bsd"