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';
36 class Document extends Error {
39 * Associative array of data from db.
41 * @var array $data_array.
58 * @internal param \The $object Group object to which this document is associated.
59 * @internal param \The $int docid.
60 * @internal param \The $array associative array of data.
63 function __construct(&$Group, $docid = false, $arr = false) {
65 if (!$Group || !is_object($Group)) {
66 $this->setError(_('No Valid Group Object'));
69 if ($Group->isError()) {
70 $this->setError('Document:: '. $Group->getErrorMessage());
73 $this->Group =& $Group;
76 if (!$arr || !is_array($arr)) {
77 if (!$this->fetchData($docid)) {
81 $this->data_array =& $arr;
82 if ($this->data_array['group_id'] != $this->Group->getID()) {
83 $this->setError('Document:: '. _('group_id in db result does not match Group Object'));
84 $this->data_array = null;
88 if (!$this->isPublic()) {
89 $perm =& $this->Group->getPermission();
91 if (!$perm || !is_object($perm) || !$perm->isDocEditor()) {
92 $this->setPermissionDeniedError();
93 $this->data_array = null;
101 * create - use this function to create a new entry in the database.
103 * @param string The filename of this document. Can be a URL.
104 * @param string The filetype of this document. If filename is URL, this should be 'URL';
105 * @param string The absolute path file itself.
106 * @param int The doc_group id of the doc_groups table.
107 * @param string The title of this document.
108 * @param string The description of this document.
109 * @param int The state id of the document. At creation, can not be deleted status.
110 * @return boolean success.
112 function create($filename, $filetype, $data, $doc_group, $title, $description, $stateid = 0) {
113 if (strlen($title) < 5) {
114 $this->setError(_('Title Must Be At Least 5 Characters'));
117 if (strlen($description) < 10) {
118 $this->setError(_('Document Description Must Be At Least 10 Characters'));
122 $user_id = ((session_loggedin()) ? user_getid() : 100);
124 $doc_initstatus = '3';
125 $perm =& $this->Group->getPermission();
126 if ($perm && is_object($perm) && $perm->isDocEditor()) {
127 if ($stateid && $stateid != 2) {
128 $doc_initstatus = $stateid;
130 $doc_initstatus = '1';
134 $result = db_query_params('SELECT filename, doc_group from docdata_vw
138 array($filename, $doc_group, $doc_initstatus));
140 if (!$result || db_numrows($result) > 0) {
141 $dg = new DocumentGroup($this->getGroup(), $doc_group);
142 $this->setError(_('Document already published in this folder').' '.$dg->getPath());
146 $result = db_query_params('SELECT title FROM docdata_vw where title = $1 AND doc_group = $2',
147 array($title, $doc_group));
148 if (!$result || db_numrows($result) > 0) {
149 $dg = new DocumentGroup($this->getGroup(), $doc_group);
150 $this->setError(_('Document already published in this folder').' '.$dg->getPath());
154 // If $filetype is "text/plain", $body convert UTF-8 encoding.
155 if (strcasecmp($filetype, "text/plain") === 0 &&
156 function_exists('mb_convert_encoding') &&
157 function_exists('mb_detect_encoding')) {
158 $data = mb_convert_encoding($data, 'UTF-8', mb_detect_encoding($data));
161 $filesize = filesize($data);
162 if (!$filesize) { $filesize = 0; }
164 // key words for in-document search
165 if ($this->Group->useDocmanSearch() && $filesize) {
166 $kw = new Parsedata();
167 $kwords = $kw->get_parse_data($data, htmlspecialchars($title), htmlspecialchars($description), $filetype, $filename);
173 $result = db_query_params('INSERT INTO doc_data (group_id, title, description, createdate, doc_group,
174 stateid, filename, filetype, filesize, data_words, created_by)
175 VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)',
176 array($this->Group->getId(),
177 htmlspecialchars($title),
178 htmlspecialchars($description),
189 $docid = db_insertid($result, 'doc_data', 'docid');
191 if (is_file($data)) {
192 if (!DocumentStorage::instance()->store($docid, $data)) {
193 DocumentStorage::instance()->rollback();
195 $this->setError(DocumentStorage::instance()->getErrorMessage());
199 $this->setError(_('Error Adding Document:').' '._('Not a file').' '.$filename);
205 if (!$result || !$docid) {
206 $this->setError(_('Error Adding Document:').' '.db_error().$result);
208 DocumentStorage::instance()->rollback();
214 if (!$this->fetchData($docid)) {
215 $this->setError(_('Error fetching Document'));
217 DocumentStorage::instance()->rollback();
223 if ($perm->isDocEditor()) {
224 $localDg = new DocumentGroup($this->Group, $doc_group);
225 if (!$localDg->update($localDg->getName(), $localDg->getParentID(), 1)) {
226 $this->setError(_('Error updating document group:').$localDg->getErrorMessage());
228 DocumentStorage::instance()->rollback();
234 $this->sendNotice(true);
235 $this->SendApprovalNotice();
238 DocumentStorage::instance()->commit();
244 * fetchData() - re-fetch the data for this document from the database.
246 * @param int The document id.
247 * @return boolean success
249 function fetchData($docid) {
250 $res = db_query_params('SELECT * FROM docdata_vw WHERE docid=$1 AND group_id=$2',
251 array($docid, $this->Group->getID()));
252 if (!$res || db_numrows($res) < 1) {
253 $this->setError(_('Document: Invalid docid'));
256 $this->data_array = db_fetch_array($res);
257 db_free_result($res);
262 * getGroup - get the Group object this Document is associated with.
264 * @return Object The Group object.
266 function &getGroup() {
271 * getID - get this docid.
273 * @return int The docid.
276 return $this->data_array['docid'];
280 * getName - get the name of this document.
282 * @return string The name of this document.
285 return $this->data_array['title'];
289 * getDescription - the description of this document.
291 * @return string The description.
293 function getDescription() {
294 return $this->data_array['description'];
298 * isURL - whether this document is a URL and not a local file.
300 * @return boolean is_url.
303 return ($this->data_array['filetype'] == 'URL');
307 * isText - whether this document is a text document and not a binary one.
309 * @return boolean is_text.
312 $doctype = $this->data_array['filetype'];
313 if (preg_match('|^text/|i', $doctype)) { // text plain, text html, text x-patch, etc
320 * isHtml - whether this document is a html document.
322 * @return boolean is_html.
325 $doctype = $this->data_array['filetype'];
326 if (preg_match('/html/i',$doctype)) {
333 * isPublic - whether this document is available to the general public.
335 * @return boolean is_public.
337 function isPublic() {
338 return (($this->data_array['stateid'] == 1) ? true : false);
342 * getStateID - get this stateid.
344 * @return int The stateid.
346 function getStateID() {
347 return $this->data_array['stateid'];
351 * getStateName - the statename of this document.
353 * @return string The statename.
355 function getStateName() {
356 return $this->data_array['state_name'];
360 * getDocGroupID - get this doc_group_id.
362 * @return int The doc_group_id.
364 function getDocGroupID() {
365 return $this->data_array['doc_group'];
369 * getDocGroupName - the doc_group_name of this document.
371 * @return string The docgroupname.
373 function getDocGroupName() {
374 return $this->data_array['group_name'];
378 * getCreatorID - get this creator's user_id.
380 * @return int The user_id.
382 function getCreatorID() {
383 return $this->data_array['created_by'];
387 * getCreatorUserName - the unix name of the person who created this document.
389 * @return string The unix name of the creator.
391 function getCreatorUserName() {
392 return $this->data_array['user_name'];
396 * getCreatorRealName - the real name of the person who created this document.
398 * @return string The real name of the creator.
400 function getCreatorRealName() {
401 return $this->data_array['realname'];
405 * getCreatorEmail - the email of the person who created this document.
407 * @return string The email of the creator.
409 function getCreatorEmail() {
410 return $this->data_array['email'];
414 * getFileName - the filename of this document.
416 * @return string The filename.
418 function getFileName() {
419 return $this->data_array['filename'];
423 * getFileType - the filetype of this document.
425 * @return string The filetype.
427 function getFileType() {
428 return $this->data_array['filetype'];
432 * getFileData - the filedata of this document.
434 * @param boolean update the download flag or not. default is true
435 * @return string The filedata.
437 function getFileData($download = true) {
441 return file_get_contents(DocumentStorage::instance()->get($this->getID()));
445 * getFileSize - Return the size of the document
447 * @return int The file size
449 function getFileSize() {
450 return $this->data_array['filesize'];
454 * getUpdated - get the time this document was updated.
456 * @return int The epoch date this document was updated.
458 function getUpdated() {
459 return $this->data_array['updatedate'];
463 * getDownload - get the number of views of this document.
465 * @return int the number of views
467 function getDownload() {
468 return $this->data_array['download'];
472 * getCreated - get the time this document was created.
474 * @return int The epoch date this document was created.
476 function getCreated() {
477 return $this->data_array['createdate'];
481 * getLocked - get the lock status of this document.
483 * @return int The lock status of this document.
485 function getLocked() {
486 return $this->data_array['locked'];
490 * getLockdate - get the lock time of this document.
492 * @return int The lock time of this document.
494 function getLockdate() {
495 return $this->data_array['lockdate'];
499 * getLockedBy - get the user id who set lock on this document.
501 * @return int The user id who set lock on this document.
503 function getLockedBy() {
504 return $this->data_array['locked_by'];
508 * getReservedBy - get the owner of the reversed status of this document.
510 * @return int The owner of the reversed status of this document.
512 function getReservedBy() {
513 return $this->data_array['reserved_by'];
517 * getReserved - get the reversed status of this document.
519 * @return int The reversed status of this document.
521 function getReserved() {
522 return $this->data_array['reserved'];
526 * getMonitoredUserEmailAddress - get the email addresses of users who monitor this file
528 * @return string The list of emails comma separated
530 function getMonitoredUserEmailAddress() {
531 $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()));
532 if (!$result || db_numrows($result) < 1) {
538 while ($arr = db_fetch_array($result)) {
542 $values .= $comma.$arr['email'];
550 * isMonitoredBy - get the monitored status of this document for a specific user id.
552 * @param string $userid
553 * @internal param \User $int ID
554 * @return boolean true if monitored by this user
556 function isMonitoredBy($userid = 'ALL') {
557 if ( $userid == 'ALL' ) {
560 $condition = 'user_id='.$userid.' AND';
562 $result = db_query_params('SELECT * FROM docdata_monitored_docman WHERE '.$condition.' doc_id=$1',
563 array($this->getID()));
565 if (!$result || db_numrows($result) < 1)
572 * removeMonitoredBy - remove this document for a specific user id for monitoring.
575 * @return boolean true if success
577 function removeMonitoredBy($userid) {
578 $result = db_query_params('DELETE FROM docdata_monitored_docman WHERE doc_id=$1 AND user_id=$2',
579 array($this->getID(), $userid));
582 $this->setError(_('Unable To Remove Monitor').' : '.db_error());
589 * addMonitoredBy - add this document for a specific user id for monitoring.
592 * @return boolean true if success
594 function addMonitoredBy($userid) {
595 $result = db_query_params('SELECT * FROM docdata_monitored_docman WHERE user_id=$1 AND doc_id=$2',
596 array($userid, $this->getID()));
598 if (!$result || db_numrows($result) < 1) {
599 $result = db_query_params('INSERT INTO docdata_monitored_docman (doc_id,user_id) VALUES ($1,$2)',
600 array($this->getID(), $userid));
603 $this->setError(_('Unable To Add Monitor').' : '.db_error());
611 * clearMonitor - remove all entries of monitoring for this document.
613 * @return boolean true if success.
615 function clearMonitor() {
616 $result = db_query_params('DELETE FROM docdata_monitored_docman WHERE doc_id = $1',
617 array($this->getID()));
619 $this->setError(_('Unable To Clear Monitor').' : '.db_error());
626 * setState - set the stateid of the document.
628 * @param int The state id of the doc_states table.
629 * @return boolean success or not.
631 function setState($stateid) {
632 return $this->setValueinDB('stateid', $stateid);
637 * setDocGroupID - set the doc_group of the document.
639 * @param int The group_id of this document.
640 * @return boolean success or not.
642 function setDocGroupID($newdocgroupid) {
643 return $this->setValueinDB('doc_group', $newdocgroupid);
647 * setLock - set the locking status of the document.
650 * @param time the epoch time.
651 * @param int $thistime
652 * @internal param \The $int status of the lock.
653 * @internal param \The $int userid who set the lock.
654 * @return boolean success or not.
656 function setLock($stateLock, $userid = NULL, $thistime = 0) {
657 $res = db_query_params('UPDATE doc_data SET
666 $this->Group->getID(),
669 if (!$res || db_affected_rows($res) < 1) {
670 $this->setOnUpdateError(_('Document lock failed').' '.db_error());
673 $this->data_array['locked'] = $stateLock;
674 $this->data_array['locked_by'] = $userid;
675 $this->data_array['lockdate'] = $thistime;
680 * setReservedBy - set the reserved status of the document and the owner
682 * @param int The status of the reserved
683 * @param int The ID of the owner : by default : noone
684 * @return boolean success
686 function setReservedBy($statusReserved, $idReserver = NULL) {
687 $res = db_query_params('UPDATE doc_data SET
692 array($statusReserved,
694 $this->Group->getID(),
697 if (!$res || db_affected_rows($res) < 1) {
698 $this->setOnUpdateError(_('Document reservation failed').' '.db_error());
701 $this->sendNotice(false);
706 * getFileTypeImage - return the file image for icon
708 * @return string the file image name
711 function getFileTypeImage() {
712 switch ($this->getFileType()) {
717 case "image/vnd.microsoft.icon":
718 case "image/svg+xml": {
719 $image = 'docman/file_type_image.png';
723 case "audio/x-vorbis+ogg":
725 case "audio/x-ms-wma":
726 case "audio/vnd.rn-realaudio": {
727 $image = "docman/file_type_sound.png";
730 case "application/pdf": {
731 $image = 'docman/file_type_pdf.png';
736 $image = 'docman/file_type_html.png';
741 case "application/xml":
744 case "text/x-shellscript": {
745 $image = 'docman/file_type_plain.png';
748 case "application/msword":
749 case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
750 case "application/vnd.oasis.opendocument.text": {
751 $image = 'docman/file_type_writer.png';
754 case "application/vnd.ms-excel":
755 case "application/vnd.oasis.opendocument.spreadsheet":
756 case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": {
757 $image = 'docman/file_type_spreadsheet.png';
760 case "application/vnd.oasis.opendocument.presentation":
761 case "application/vnd.ms-powerpoint":
762 case "application/vnd.ms-office":
763 case "application/vnd.openxmlformats-officedocument.presentationml.presentation": {
764 $image = 'docman/file_type_presentation.png';
767 case "application/zip":
768 case "application/x-tar":
769 case "application/x-rpm":
770 case "application/x-rar-compressed":
771 case "application/x-bzip2":
772 case "application/x-gzip":
773 case "application/x-lzip":
774 case "application/x-compress":
775 case "application/x-7z-compressed":
776 case "application/x-gtar":
777 case "application/x-stuffitx":
778 case "application/x-lzx":
779 case "application/x-lzh":
780 case "application/x-gca-compressed":
781 case "application/x-apple-diskimage":
782 case "application/x-dgc-compressed":
783 case "application/x-dar":
784 case "application/x-cfs-compressed":
785 case "application/vnd.ms-cab-compressed":
786 case "application/x-alz-compressed":
787 case "application/x-astrotite-afa":
788 case "application/x-ace-compressed":
789 case "application/x-cpio":
790 case "application/x-shar":
791 case "application/x-xz": {
792 $image = 'docman/file_type_archive.png';
796 $image = 'docman/file_type_unknown.png';
803 * update - use this function to update an existing entry in the database.
805 * @param string The filename of this document. Can be a URL.
806 * @param string The filetype of this document. If filename is URL, this should be 'URL';
807 * @param string The contents of this document.
808 * @param int The doc_group id of the doc_groups table.
809 * @param string The title of this document.
810 * @param string The description of this document.
811 * @param int The state id of the doc_states table.
812 * @return boolean success.
814 function update($filename, $filetype, $data, $doc_group, $title, $description, $stateid) {
816 $perm =& $this->Group->getPermission();
817 if (!$perm || !is_object($perm) || !$perm->isDocEditor()) {
818 $this->setPermissionDeniedError();
822 $user = session_get_user();
823 if ($this->getLocked() && ($this->getLockedBy() != $user->getID())) {
824 $this->setPermissionDeniedError();
828 if (strlen($title) < 5) {
829 $this->setError(_('Title Must Be At Least 5 Characters'));
833 if (strlen($description) < 10) {
834 $this->setError(_('Document Description Must Be At Least 10 Characters'));
838 /* TODO : NEED REAL CHECK */
840 $result = db_query_params('SELECT filename, doc_group FROM docdata_vw WHERE filename = $1 AND doc_group = $2 AND stateid = $3 AND docid != $4',
841 array($filename, $doc_group, $stateid, $this->getID()));
842 if (!$result || db_numrows($result) > 0) {
843 $this->setError(_('Document already published in this folder'));
849 $res = db_query_params('UPDATE doc_data SET
861 array(htmlspecialchars($title),
862 htmlspecialchars($description),
870 $this->Group->getID(),
874 if (!$res || db_affected_rows($res) < 1) {
875 $this->setOnUpdateError(db_error());
880 $localDg = new DocumentGroup($this->Group, $doc_group);
881 if (!$localDg->update($localDg->getName(), $localDg->getParentID(), 1)) {
882 $this->setOnUpdateError(_('Error updating document group:').$localDg->getErrorMessage());
887 if (filesize($data)) {
888 // key words for in-document search
889 if ($this->Group->useDocmanSearch()) {
890 $kw = new Parsedata();
891 $kwords = $kw->get_parse_data($data, htmlspecialchars($title), htmlspecialchars($description), $filetype, $filename);
896 $res = db_query_params('UPDATE doc_data SET filesize=$1, data_words=$2 WHERE group_id=$3 AND docid=$4',
897 array(filesize($data),
899 $this->Group->getID(),
903 if (!$res || db_affected_rows($res) < 1) {
904 $this->setOnUpdateError(db_error());
909 DocumentStorage::instance()->delete($this->getID())->commit();
910 DocumentStorage::instance()->store($this->getID(), $data);
913 $this->fetchData($this->getID());
914 $this->sendNotice(false);
919 * sendNotice - Notifies of document submissions
921 * @param boolean true = new document (default value)
924 function sendNotice($new = true) {
925 $BCC = $this->Group->getDocEmailAddress();
926 if ($this->isMonitoredBy('ALL')) {
927 $BCC .= $this->getMonitoredUserEmailAddress();
929 $dg = new DocumentGroup($this->Group, $this->getDocGroupID());
930 if ($dg->isMonitoredBy('ALL')) {
931 $BCC .= $dg->getMonitoredUserEmailAddress();
933 if (strlen($BCC) > 0) {
934 $session = session_get_user();
936 $status = _('New document');
938 $status = _('Updated document').' '._('by').' ' . $session->getRealName();
940 $subject = '['.$this->Group->getPublicName().'] '.$status.' - '.$this->getName();
941 $body = _('Project')._(': ').$this->Group->getPublicName()."\n";
942 $body .= _('Folder')._(': ').$this->getDocGroupName()."\n";
943 $body .= _('Document Title')._(': ').$this->getName()."\n";
944 $body .= _('Document description')._(': ').util_unconvert_htmlspecialchars($this->getDescription())."\n";
945 $body .= _('Submitter')._(': ').$this->getCreatorRealName()." (".$this->getCreatorUserName().") \n";
946 $body .= "\n\n-------------------------------------------------------\n".
947 _('For more info, visit:').
948 "\n\n" . util_make_url('/docman/?group_id='.$this->Group->getID().'&view=listfile&dirid='.$this->getDocGroupID());
950 $BCCarray = explode(',',$BCC);
951 foreach ($BCCarray as $dest_email) {
952 util_send_message($dest_email, $subject, $body, 'noreply@'.forge_get_config('web_host'), '', _('Docman'));
959 * SendApprovalNotice - send email to project admin for pending documents.
961 * @return boolean success.
963 function SendApprovalNotice() {
964 if ($this->getStateID() != 3)
967 $doc_name = $this->getName();
968 $desc = util_unconvert_htmlspecialchars( $this->getDescription() );
969 $group_id = $this->Group->getID();
970 $name = $this->getCreatorRealName()." (".$this->getCreatorUserName().")";
972 $subject="[" . forge_get_config('forge_name') ."] ".util_unconvert_htmlspecialchars($doc_name);
973 $body = "\nA new document has been uploaded and waiting to be approved by you:".
974 "\n".util_make_url('/docman/?group_id='.$group_id.'&view=admin').
975 "\nBy: " . $name . "\n";
977 $sanitizer = new TextSanitizer();
979 if (strstr($text,'<br/>') || strstr($text,'<br />')) {
980 $text = preg_replace('/[\n\r]/', '', $text);
982 $text = $sanitizer->convertNeededTagsForEmail($text);
983 $text = preg_replace('/\[.+\](.+)\[\/.+\]/','$1',$text);
984 $text = $sanitizer->convertExtendedCharsForEmail($text);
987 $extra_headers = "Return-Path: <noreply@".forge_get_config('web_host').">\n";
988 $extra_headers .= "Errors-To: <noreply@".forge_get_config('web_host').">\n";
989 $extra_headers .= "Sender: <noreply@".forge_get_config('web_host').">";
991 $sql = 'SELECT u.email FROM user_group ug INNER JOIN users u ON u.user_id=ug.user_id
992 WHERE ug.admin_flags = $1 AND ug.group_id = $2';
993 $res = db_query_params($sql, array('A', $group_id));
994 $bcc = implode(util_result_column_to_array($res),',');
995 if (strlen($bcc) > 0) {
996 util_send_message('',$subject,$body,"noreply@".forge_get_config('web_host'),
997 $bcc,'Docman',$extra_headers);
1003 * delete - Delete this file
1005 * @return boolean success
1008 $perm =& $this->Group->getPermission();
1009 if (!$perm || !is_object($perm) || !$perm->isDocEditor()) {
1010 $this->setPermissionDeniedError();
1014 $result = db_query_params('DELETE FROM doc_data WHERE docid=$1',
1015 array($this->getID()));
1017 $this->setError(_('Error Deleting Document:').' '.db_error());
1022 DocumentStorage::instance()->delete($this->getID())->commit();
1024 /** we should be able to send a notice that this doc has been deleted .... but we need to rewrite sendNotice
1025 * $this->sendNotice(false);
1026 * @TODO delete monitoring this file */
1031 * trash - move this file to trash
1033 * @return boolean success or not.
1036 $this->setState('2');
1037 $dm = new DocumentManager($this->Group);
1038 $this->setDocGroupID($dm->getTrashID());
1040 $this->setReservedBy(0);
1041 $this->sendNotice(false);
1042 $this->clearMonitor();
1048 * downloadUp - insert download stats
1051 private function downloadUp() {
1052 if (session_loggedin()) {
1053 $s =& session_get_user();
1059 $ip = getStringFromServer('REMOTE_ADDR');
1060 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));
1064 * setValueinDB - private function to update columns in db
1066 * @param string the column to update
1067 * @param int the value to store
1068 * @return boolean success or not
1071 private function setValueinDB($column, $value) {
1075 $qpa = db_construct_qpa();
1076 $qpa = db_construct_qpa($qpa, 'UPDATE doc_data SET ');
1077 $qpa = db_construct_qpa($qpa, $column);
1078 $qpa = db_construct_qpa($qpa, '=$1
1082 $this->Group->getID(),
1084 $res = db_query_qpa($qpa);
1085 if (!$res || db_affected_rows($res) < 1) {
1086 $this->setOnUpdateError(db_error().print_r($qpa));
1092 $this->setOnUpdateError(_('wrong column name'));
1095 $localDg = new DocumentGroup($this->Group, $this->getDocGroupID());
1096 if (!$localDg->update($localDg->getName(), $localDg->getParentID(), 1)) {
1097 $this->setError(_('Error updating document group:').$localDg->getErrorMessage());
1100 $this->sendNotice(false);
1104 function createVersion() {
1108 function deleteVersion() {
1115 // c-file-style: "bsd"