This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".
The branch, master has been updated
via 56eb6c877652845cfde3f33b756876eb34700b1d (commit)
from 06787046969fdf5dcb203be63ae9e6838c9e3338 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=56eb6c877652845cfde3f33b756876eb34700b1d
commit 56eb6c877652845cfde3f33b756876eb34700b1d
Author: Franck Villaume <[email protected]>
Date: Fri Jun 3 11:59:42 2016 +0200
docman: introduce usage of timestamp to help import function
diff --git a/src/common/docman/Document.class.php
b/src/common/docman/Document.class.php
index 586376d..9e5fc9a 100644
--- a/src/common/docman/Document.class.php
+++ b/src/common/docman/Document.class.php
@@ -131,16 +131,17 @@ class Document extends FFError {
/**
* create - use this function to create a new entry in the database.
*
- * @param string $filename The filename of this document.
Can be a URL.
- * @param string $filetype The filetype of this document.
If filename is URL, this should be 'URL';
- * @param string $data The absolute path file itself.
- * @param int $doc_group The doc_group id of the
doc_groups table.
- * @param string $title The title of this document.
- * @param string $description The description of this
document.
- * @param int $stateid The state id of the document.
At creation, cannot be deleted status.
+ * @param string $filename The filename of this
document. Can be a URL.
+ * @param string $filetype The filetype of this
document. If filename is URL, this should be 'URL';
+ * @param string $data The absolute path file
itself.
+ * @param int $doc_group The doc_group id of the
doc_groups table.
+ * @param string $title The title of this
document.
+ * @param string $description The description of this
document.
+ * @param int $stateid The state id of the
document. At creation, cannot be deleted status.
+ * @param int $createtimestamp Timestamp of the
creation of this document
* @return bool success.
*/
- function create($filename, $filetype, $data, $doc_group, $title,
$description, $stateid = 0) {
+ function create($filename, $filetype, $data, $doc_group, $title,
$description, $stateid = 0, $createtimestamp = null) {
if (strlen($title) < 5) {
$this->setError(_('Title Must Be At Least 5
Characters'));
return false;
@@ -194,9 +195,10 @@ class Document extends FFError {
}
db_begin();
+ $createtimestamp = (($createtimestamp) ? $createtimestamp :
time());
$result = db_query_params('INSERT INTO doc_data (group_id,
createdate, doc_group, stateid)
VALUES ($1, $2, $3, $4)',
- array($this->Group->getID(),
time(), $doc_group, $doc_initstatus));
+ array($this->Group->getID(),
$createtimestamp, $doc_group, $doc_initstatus));
$docid = db_insertid($result, 'doc_data', 'docid');
if (!$result || !$docid) {
@@ -206,7 +208,7 @@ class Document extends FFError {
}
$dv = new DocumentVersion($this);
- $idversion = $dv->create($docid, $title, $description,
$user_id, $filetype, $filename, $filesize, $kwords);
+ $idversion = $dv->create($docid, $title, $description,
$user_id, $filetype, $filename, $filesize, $kwords, 1, 1, $createtimestamp);
if (!$idversion) {
$this->setError($dv->getErrorMessage());
db_rollback();
@@ -238,7 +240,7 @@ class Document extends FFError {
if ($perm->isDocEditor()) {
$localDg = documentgroup_get_object($doc_group,
$this->Group->getID());
- if (!$localDg->update($localDg->getName(),
$localDg->getParentID(), 1, $localDg->getState())) {
+ if (!$localDg->update($localDg->getName(),
$localDg->getParentID(), 1, $localDg->getState(), $createtimestamp)) {
$this->setError(_('Error updating document
group')._(': ').$localDg->getErrorMessage());
if ($filesize) {
DocumentStorage::instance()->rollback();
@@ -797,9 +799,10 @@ class Document extends FFError {
* @param int $version The version to update.
Default is 1.
* @param int $current_version Is the current version?
default is 1.
* @param int $new_version To create a new
version? default is 0. == No.
+ * @param int $updatetimestamp Timestamp of this
update.
* @return boolean success.
*/
- function update($filename, $filetype, $data, $doc_group, $title,
$description, $stateid, $version = 1, $current_version = 1, $new_version = 0) {
+ function update($filename, $filetype, $data, $doc_group, $title,
$description, $stateid, $version = 1, $current_version = 1, $new_version = 0,
$updatetimestamp = null) {
$perm =& $this->Group->getPermission();
if (!$perm || !is_object($perm) || !$perm->isDocEditor()) {
@@ -824,15 +827,16 @@ class Document extends FFError {
}
db_begin();
+ $updatetimestamp = (($updatetimestamp) ? $updatetimestamp :
time());
$colArr = array('stateid', 'doc_group', 'updatedate', 'locked',
'locked_by');
- $valArr = array($stateid, $doc_group, time(), 0, NULL);
+ $valArr = array($stateid, $doc_group, $updatetimestamp, 0,
NULL);
if (!$this->setValueinDB($colArr, $valArr)) {
db_rollback();
return false;
}
$localDg = new DocumentGroup($this->Group, $doc_group);
- if (!$localDg->update($localDg->getName(),
$localDg->getParentID(), 1, $localDg->getState())) {
+ if (!$localDg->update($localDg->getName(),
$localDg->getParentID(), 1, $localDg->getState(), $updatetimestamp)) {
$this->setOnUpdateError(_('Error updating document
group')._(': ').$localDg->getErrorMessage());
db_rollback();
return false;
@@ -875,14 +879,14 @@ class Document extends FFError {
if (isset($kwords)) {
$version_kwords = $kwords;
}
- $serial_id = $dv->create($this->getID(), $title,
$description, user_getid(), $filetype, $filename, $filesize, $version_kwords,
$version, $current_version);
+ $serial_id = $dv->create($this->getID(), $title,
$description, user_getid(), $filetype, $filename, $filesize, $version_kwords,
$version, $current_version, $updatetimestamp);
if (!$serial_id) {
$this->setOnUpdateError(_('Error updating
document version')._(': ').$dv->getErrorMessage());
db_rollback();
return false;
}
} else {
- if ($dv->isError() || !$dv->update($version, $title,
$description, $filetype, $filename, $filesize, $current_version)) {
+ if ($dv->isError() || !$dv->update($version, $title,
$description, $filetype, $filename, $filesize, $current_version,
$updatetimestamp)) {
$this->setOnUpdateError(_('Error updating
document version')._(': ').$dv->getErrorMessage());
db_rollback();
return false;
diff --git a/src/common/docman/DocumentGroup.class.php
b/src/common/docman/DocumentGroup.class.php
index b1f77a1..351ad53 100644
--- a/src/common/docman/DocumentGroup.class.php
+++ b/src/common/docman/DocumentGroup.class.php
@@ -124,11 +124,17 @@ class DocumentGroup extends FFError {
*
* @param string $name The name of the
directory to create
* @param int $parent_doc_group The ID of the parent
directory
+ * @param int $state The status of this
directory: default is 1 = public.
+ * Valid values are :
+ * 1 = public
+ * 2 = deleted
+ * 5 = private
+ * @param int $createtimestamp Timestamp of the
directory creation
* @internal param \Item $string name.
* @return boolean true on success / false on failure.
* @access public
*/
- function create($name, $parent_doc_group = 0, $state = 1) {
+ function create($name, $parent_doc_group = 0, $state = 1,
$createtimestamp = null) {
//
// data validation
//
@@ -167,13 +173,14 @@ class DocumentGroup extends FFError {
return false;
}
+ $createtimestamp = (($createtimestamp) ? $createtimestamp :
time());
$user_id = ((session_loggedin()) ? user_getid() : 100);
$result = db_query_params('INSERT INTO doc_groups (group_id,
groupname, parent_doc_group, stateid, createdate, created_by) VALUES ($1, $2,
$3, $4, $5, $6)',
array ($this->Group->getID(),
htmlspecialchars($name),
$parent_doc_group,
$state,
- time(),
+ $createtimestamp,
$user_id)
);
if ($result && db_affected_rows($result) > 0) {
@@ -473,10 +480,12 @@ class DocumentGroup extends FFError {
* @param string $name Name of the category.
* @param int $parent_doc_group the doc_group id of the
parent. default = 0
* @param int $metadata update only the
metadata : created_by, updatedate
+ * @param int $state state of the directory.
Default is 1 = public. See create function for valid values
+ * @param int $updatetimestamp Timestamp of the update
* @return boolean success or not
* @access public
*/
- function update($name, $parent_doc_group = 0, $metadata = 0, $state =
1) {
+ function update($name, $parent_doc_group = 0, $metadata = 0, $state =
1, $updatetimestamp = null) {
$perm =& $this->Group->getPermission();
if (!$perm || !$perm->isDocEditor()) {
$this->setPermissionDeniedError();
@@ -512,12 +521,13 @@ class DocumentGroup extends FFError {
}
$user_id = ((session_loggedin()) ? user_getid() : 100);
+ $updatetimestamp = (($updatetimestamp) ? $updatetimestamp :
time());
$colArr = array('groupname', 'parent_doc_group', 'updatedate',
'created_by', 'locked', 'locked_by', 'stateid');
- $valArr = array(htmlspecialchars($name), $parent_doc_group,
time(), $user_id, 0, NULL, $state);
+ $valArr = array(htmlspecialchars($name), $parent_doc_group,
$updatetimestamp, $user_id, 0, NULL, $state);
if ($this->setValueinDB($colArr, $valArr)) {
$parentDg = new DocumentGroup($this->Group,
$parent_doc_group);
if ($parentDg->getParentID())
- $parentDg->update($parentDg->getName(),
$parentDg->getParentID(), 1, $parentDg->getState());
+ $parentDg->update($parentDg->getName(),
$parentDg->getParentID(), 1, $parentDg->getState(), $updatetimestamp);
$this->fetchData($this->getID());
$this->sendNotice(false);
diff --git a/src/common/docman/DocumentVersion.class.php
b/src/common/docman/DocumentVersion.class.php
index 487f553..82db2e4 100644
--- a/src/common/docman/DocumentVersion.class.php
+++ b/src/common/docman/DocumentVersion.class.php
@@ -161,13 +161,14 @@ class DocumentVersion extends FFError {
* @param string $kwords The parsed words of the
file (content)
* @param int $version The version id to
create. Default is 1 (the first version)
* @param int $current_version Is it the current
version? Defaut is 1 (yes)
+ * @param int $createtimetamp timestamp of creation
of this version
* return bool true on success
*/
- function create($docid, $title, $description, $created_by, $filetype,
$filename, $filesize, $kwords, $version = 1, $current_version = 1) {
+ function create($docid, $title, $description, $created_by, $filetype,
$filename, $filesize, $kwords, $version = 1, $current_version = 1,
$createtimetamp) {
db_begin();
$res = db_query_params('INSERT INTO doc_data_version (docid,
title, description, created_by, filetype, filename, filesize, data_words,
version, current_version, createdate)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8,
$9, $10, $11)',
- array($docid, htmlspecialchars($title),
htmlspecialchars($description), $created_by, $filetype, $filename, $filesize,
$kwords, $version, $current_version, time()));
+ array($docid, htmlspecialchars($title),
htmlspecialchars($description), $created_by, $filetype, $filename, $filesize,
$kwords, $version, $current_version, $createtimetamp));
$serial_id = db_insertid($res, 'doc_data_version', 'serial_id');
if (!$res || !$serial_id) {
$this->setError(_('Document Version')._(': ')._('Cannot
create version.').' '.db_error());
@@ -283,12 +284,13 @@ class DocumentVersion extends FFError {
* @param string $filename The new filename
* @param int $filesize The new filesize
* @param int $current_version Is the current version
to set? Default is yes.
+ * @param int $updatetimestamp timestamp of this update
* @return bool true on success
*/
- function update($version, $title, $description, $filetype, $filename,
$filesize, $current_version = 1) {
+ function update($version, $title, $description, $filetype, $filename,
$filesize, $current_version = 1, $updatetimestamp) {
db_begin();
$colArr = array('title', 'description', 'filetype', 'filename',
'filesize', 'current_version', 'updatedate');
- $valArr = array(htmlspecialchars($title),
htmlspecialchars($description), $filetype, $filename, $filesize,
$current_version, time());
+ $valArr = array(htmlspecialchars($title),
htmlspecialchars($description), $filetype, $filename, $filesize,
$current_version, $updatetimestamp);
if (!$this->setValueinDB($version, $colArr, $valArr)) {
db_rollback();
return false;
-----------------------------------------------------------------------
Summary of changes:
src/common/docman/Document.class.php | 36 ++++++++++++++++-------------
src/common/docman/DocumentGroup.class.php | 20 ++++++++++++----
src/common/docman/DocumentVersion.class.php | 10 ++++----
3 files changed, 41 insertions(+), 25 deletions(-)
hooks/post-receive
--
FusionForge
_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits