<?php
/**
- * FusionForge document manager
+ * FusionForge Documentation Manager
*
* Copyright 2000, Quentin Cregan/Sourceforge
* Copyright 2002-2003, Tim Perdue/GForge, LLC
* Copyright 2009, Roland Mas
* Copyright 2010-2011, Franck Villaume - Capgemini
- * Copyright 2011-2016, Franck Villaume - TrivialDev
* Copyright (C) 2011-2012 Alain Peyrat - Alcatel-Lucent
+ * Copyright 2011-2016, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
require_once $gfcommon.'docman/DocumentManager.class.php';
require_once $gfcommon.'docman/DocumentGroup.class.php';
require_once $gfcommon.'docman/DocumentStorage.class.php';
+require_once $gfcommon.'docman/DocumentVersion.class.php';
require_once $gfcommon.'include/MonitorElement.class.php';
$DOCUMENT_OBJ = array();
}
db_begin();
- $result = db_query_params('INSERT INTO doc_data (group_id, title, description, createdate, doc_group,
- stateid, filename, filetype, filesize, data_words, created_by)
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)',
- array($this->Group->getId(),
- htmlspecialchars($title),
- htmlspecialchars($description),
- time(),
- $doc_group,
- $doc_initstatus,
- $filename,
- $filetype,
- $filesize,
- $kwords,
- $user_id)
- );
+ $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));
$docid = db_insertid($result, 'doc_data', 'docid');
+ if (!$result || !$docid) {
+ $this->setError(_('Error Adding Document')._(': ').db_error().$result);
+ db_rollback();
+ return false;
+ }
+
+ $dv = new DocumentVersion($this);
+ $idversion = $dv->create($docid, $title, $description, $user_id, $filetype, $filename, $filesize, $kwords);
+ if (!$idversion) {
+ $this->setError($dv->getErrorMessage());
+ db_rollback();
+ return false;
+ }
+
if ($filesize) {
if (is_file($data)) {
- if (!DocumentStorage::instance()->store($docid, $data)) {
+ if (!DocumentStorage::instance()->store($idversion, $data)) {
DocumentStorage::instance()->rollback();
db_rollback();
$this->setError(DocumentStorage::instance()->getErrorMessage());
}
}
- if (!$result || !$docid) {
- $this->setError(_('Error Adding Document')._(': ').db_error().$result);
- if ($filesize) {
- DocumentStorage::instance()->rollback();
- }
- db_rollback();
- return false;
- }
-
if (!$this->fetchData($docid)) {
- $this->setError(_('Error fetching Document'));
if ($filesize) {
DocumentStorage::instance()->rollback();
}
if ($perm->isDocEditor()) {
$localDg = documentgroup_get_object($doc_group, $this->Group->getID());
- if (!$localDg->update($localDg->getName(), $localDg->getParentID(), 1)) {
+ if (!$localDg->update($localDg->getName(), $localDg->getParentID(), 1, $localDg->getState())) {
$this->setError(_('Error updating document group')._(': ').$localDg->getErrorMessage());
if ($filesize) {
DocumentStorage::instance()->rollback();
* @return string The file where the file is stored.
*/
function getFilePath() {
- return DocumentStorage::instance()->get($this->getID());
+ return DocumentStorage::instance()->get($this->getSerialIDVersion());
+ }
+
+ function getSerialIDVersion() {
+ return $this->data_array['serial_id'];
+ }
+
+ function getVersion() {
+ return $this->data_array['version'];
}
/**
/**
* update - use this function to update an existing 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 contents of this document.
- * @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 doc_states table.
+ * @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 contents of this document.
+ * @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 doc_states table.
+ * @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.
* @return boolean success.
*/
- function update($filename, $filetype, $data, $doc_group, $title, $description, $stateid) {
+ function update($filename, $filetype, $data, $doc_group, $title, $description, $stateid, $version = 1, $current_version = 1, $new_version = 0) {
$perm =& $this->Group->getPermission();
if (!$perm || !is_object($perm) || !$perm->isDocEditor()) {
}
db_begin();
- $colArr = array('title', 'description', 'stateid', 'doc_group', 'filetype', 'filename', 'updatedate', 'locked', 'locked_by');
- $valArr = array(htmlspecialchars($title), htmlspecialchars($description), $stateid, $doc_group, $filetype, $filename, time(), 0, NULL);
+ $colArr = array('stateid', 'doc_group', 'updatedate', 'locked', 'locked_by');
+ $valArr = array($stateid, $doc_group, time(), 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)) {
+ if (!$localDg->update($localDg->getName(), $localDg->getParentID(), 1, $localDg->getState())) {
$this->setOnUpdateError(_('Error updating document group')._(': ').$localDg->getErrorMessage());
db_rollback();
return false;
}
+ if ($new_version) {
+ $dv = new DocumentVersion($this);
+ } else {
+ $dv = documentversion_get_object($version, $this->getID(), $this->Group->getID());
+ }
+ if (!$dv) {
+ $this->setOnUpdateError(_('Error getting document version'));
+ db_rollback();
+ return false;
+ }
if (filesize($data)) {
+ $filesize = filesize($data);
// key words for in-document search
if ($this->Group->useDocmanSearch()) {
$kw = new Parsedata();
$kwords = $kw->get_parse_data($data, $filetype);
- } else {
- $kwords = '';
}
+ } else {
+ $filesize = $dv->getFileSize();
+ if ($filesize == null) {
+ $filesize = 0;
+ }
+ }
- $colArr = array('filesize', 'data_words');
- $valArr = array(filesize($data), $kwords);
- if (!$this->setValueinDB($colArr, $valArr)) {
+ if ($new_version) {
+ if ($dv->isError()) {
+ $this->setOnUpdateError(_('Error updating document version')._(': ').$dv->getErrorMessage());
+ db_rollback();
+ return false;
+ }
+ //new version to create. We overwrite the param.
+ $version = $dv->getMaxVersionID();
+ $version++;
+ $version_kwords = '';
+ if (isset($kwords)) {
+ $version_kwords = $kwords;
+ }
+ $serial_id = $dv->create($this->getID(), $title, $description, user_getid(), $filetype, $filename, $filesize, $version_kwords, $version, $current_version);
+ 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)) {
+ $this->setOnUpdateError(_('Error updating document version')._(': ').$dv->getErrorMessage());
+ db_rollback();
+ return false;
+ }
+ }
+ if (isset($kwords)) {
+ if(!$dv->updateDataWords($version, $kwords)) {
+ $this->setOnUpdateError(_('Error updating document version')._(': ').$dv->getErrorMessage());
db_rollback();
return false;
}
+ }
- DocumentStorage::instance()->delete($this->getID())->commit();
- DocumentStorage::instance()->store($this->getID(), $data);
+ if (filesize($data)) {
+ if ($new_version) {
+ if (!DocumentStorage::instance()->store($serial_id, $data)) {
+ DocumentStorage::instance()->rollback();
+ db_rollback();
+ $this->setError(DocumentStorage::instance()->getErrorMessage());
+ return false;
+ }
+ DocumentStorage::instance()->commit();
+ } else {
+ DocumentStorage::instance()->delete($dv->getID())->commit();
+ DocumentStorage::instance()->store($dv->getID(), $data);
+ }
}
+
db_commit();
$this->fetchData($this->getID());
$this->sendNotice(false);
* setValueinDB - private function to update columns in db
*
* @param array $colArr the columns to update in array form array('col1', col2')
- * @param int $valArr the values to store in array form array('val1', 'val2')
+ * @param array $valArr the values to store in array form array('val1', 'val2')
* @return boolean success or not
* @access private
*/
$qpa = db_construct_qpa(false, 'UPDATE doc_data SET ');
for ($i = 0; $i < count($colArr); $i++) {
switch ($colArr[$i]) {
- case 'filesize':
- case 'data_words':
case 'reserved':
case 'reserved_by':
- case 'title':
- case 'description':
- case 'filetype':
- case 'filename':
case 'updatedate':
case 'stateid':
case 'doc_group':
return false;
}
$localDg = documentgroup_get_object($this->getDocGroupID(), $this->Group->getID());
- if (!$localDg->update($localDg->getName(), $localDg->getParentID(), 1)) {
+ if (!$localDg->update($localDg->getName(), $localDg->getParentID(), 1, $localDg->getState())) {
$this->setError(_('Error updating document group')._(': ').$localDg->getErrorMessage());
return false;
}
for ($i = 0; $i < count($colArr); $i++) {
switch ($colArr[$i]) {
- case 'filesize':
- case 'data_words':
case 'reserved':
case 'reserved_by':
- case 'title':
- case 'description':
- case 'filetype':
- case 'filename':
case 'updatedate':
case 'stateid':
case 'doc_group':
$this->sendNotice(false);
return true;
}
-
- function createVersion() {
-
- }
-
- function deleteVersion() {
-
- }
}
// Local Variables:
--- /dev/null
+<?php
+/**
+ * FusionForge Documentation Manager
+ *
+ * Copyright 2016, Franck Villaume - TrivialDev
+ * http://fusionforge.org
+ *
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+require_once $gfcommon.'include/FFError.class.php';
+require_once $gfcommon.'docman/DocumentStorage.class.php';
+
+function &documentversion_get_object($ver_id, $docid, $group_id, $res = false) {
+ global $DOCUMENTVERSION_OBJ;
+ if (!isset($DOCUMENTVERSION_OBJ['_'.$ver_id.'_'])) {
+ if ($res) {
+ //the db result handle was passed in
+ } else {
+ // data_words is not retrieve. Too much memory consumption.
+ $res = db_query_params('SELECT serial_id, version, docid, current_version, title, updatedate, createdate, created_by, description, filename, filetype, filesize FROM doc_data_version WHERE version = $1 AND docid = $2',
+ array($ver_id, $docid));
+ }
+ if (!$res || db_numrows($res) < 1) {
+ $DOCUMENTVERSION_OBJ['_'.$ver_id.'_'] = false;
+ } else {
+ $DOCUMENTVERSION_OBJ['_'.$ver_id.'_'] = new DocumentVersion(document_get_object($docid, $group_id), $ver_id, db_fetch_array($res));
+ }
+ }
+ return $DOCUMENTVERSION_OBJ['_'.$ver_id.'_'];
+}
+
+class DocumentVersion extends FFError {
+ /**
+ * Associative array of data from db.
+ *
+ * @var array $data_array.
+ */
+ var $data_array;
+
+ /**
+ * The Document object.
+ *
+ * @var object $Document.
+ */
+ var $Document;
+
+ /**
+ * Constructor.
+ *
+ * @param $Document
+ * @param bool $verid
+ * @param bool $arr
+ * @internal param \The $object Document object to which this version is associated.
+ * @internal param \The $int verid.
+ * @internal param \The $array associative array of data.
+ * @return \DocumentVersion
+ */
+ function __construct(&$Document, $verid = false, $arr = false) {
+ parent::__construct();
+ if (!$Document || !is_object($Document)) {
+ $this->setError(_('No Valid Document Object'));
+ return false;
+ }
+ if ($Document->isError()) {
+ $this->setError(_('Document Version')._(': ').$Document->getErrorMessage());
+ return false;
+ }
+ $this->Document =& $Document;
+ if ($verid) {
+ if ($arr && is_array($arr) && ($arr['docid'] == $this->Document->getID()) && ($arr['version'] == $verid)) {
+ $this->data_array =& $arr;
+ } else {
+ if (!$this->fetchData($verid)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ function getID() {
+ return $this->data_array['serial_id'];
+ }
+
+ function getFileName() {
+ return $this->data_array['filename'];
+ }
+
+ function getFileType() {
+ return $this->data_array['filetype'];
+ }
+
+ function getFileSize() {
+ return $this->data_array['filesize'];
+ }
+
+ function getTitle() {
+ return $this->data_array['title'];
+ }
+
+ function getDescription() {
+ return $this->data_array['description'];
+ }
+
+ /**
+ * getFileData - the filedata of this document.
+ *
+ * @param boolean $download update the download flag or not. default is true
+ * @return string The filedata.
+ */
+ function getFileData() {
+ return file_get_contents($this->getFilePath());
+ }
+
+ /**
+ * getFilePath - the filepath of this document.
+ *
+ * @return string The file where the file is stored.
+ */
+ function getFilePath() {
+ return DocumentStorage::instance()->get($this->getID());
+ }
+
+ function fetchData($verid) {
+ // everything but data_words. Too much memory consumption.
+ $res = db_query_params('SELECT serial_id, version, docid, current_version, title, updatedate, createdate, created_by, description, filename, filetype, filesize FROM doc_data_version WHERE version = $1 AND docid = $2',
+ array($verid, $this->Document->getID()));
+ if (!$res || db_numrows($res) < 1) {
+ $this->setError(_('DocumentVersion')._(': ')._('Invalid version id'));
+ return false;
+ }
+ $this->data_array = db_fetch_array($res);
+ db_free_result($res);
+ return true;
+ }
+
+ /**
+ * create - create a new version of a document
+ *
+ * @param int $docid The linked document to which we create a new version
+ * @param string $title The title of the new version
+ * @param string $description The description of the new version
+ * @param int $created_by The user id who creates the version
+ * @param string $filetype The filetype of the content
+ * @param string $filename The name of the file (content)
+ * @param int $filesize The size of the file (content)
+ * @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)
+ * return bool true on success
+ */
+ function create($docid, $title, $description, $created_by, $filetype, $filename, $filesize, $kwords, $version = 1, $current_version = 1) {
+ 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()));
+ $serial_id = db_insertid($res, 'doc_data_version', 'serial_id');
+ if (!$res || !$serial_id) {
+ $this->setError(_('Document Version')._(': ')._('Cannot create version.').' '.db_error());
+ db_rollback();
+ return false;
+ }
+ if ($current_version) {
+ $res = db_query_params('UPDATE doc_data_version SET current_version = $1 WHERE docid = $2 AND version != $3',
+ array(0, $this->Document->getID(), $version));
+ if (!$res) {
+ $this->setOnUpdateError(_('Cannot update current version on creation.').' '.db_error());
+ db_rollback();
+ return false;
+ }
+ }
+ db_commit();
+ return $serial_id;
+ }
+
+ /**
+ * delete - delete a specific version
+ *
+ * @param int $verid The version to delete
+ * @return bool true on success
+ */
+ function delete($verid) {
+ db_begin();
+ $res = db_query_params('DELETE FROM doc_data_version WHERE docid = $1 and version = $2',
+ array($this->Document->getID(), $verid));
+ if (!$res) {
+ $this->setError(_('DocumentVersion')._(': ')._('Invalid version id').' '.db_error());
+ db_rollback();
+ return false;
+ }
+ if ($this->getNumberOfVersions() == 1) {
+ $this->getMaxVersionData();
+ $this->update($this->data_array['version'], $this->data_array['title'], $this->data_array['description'], $this->data_array['filetype'], $this->data_array['filename'], $this->data_array['filesize'], 1);
+ }
+ db_commit();
+ db_free_result($res);
+ return true;
+ }
+
+ /**
+ * getVersion - retrieve the data of a specific version
+ *
+ * @param int $version The version to retrive
+ * @return array the content of a version
+ */
+ function getVersion($version) {
+ $this->fetchData($version);
+ return $this->data_array;
+ }
+
+ /**
+ * getMaxVersionID - get the highest value of version of a document
+ *
+ * @return int The max value.
+ */
+ function getMaxVersionID() {
+ $res = db_query_params('SELECT MAX(version) FROM doc_data_version WHERE docid = $1',
+ array($this->Document->getID()));
+ if ($res) {
+ $arr = db_fetch_array($res);
+ return (int)$arr[0];
+ }
+ return 0;
+ }
+
+ /**
+ * getMaxVersionData - retrieve the content of the highest version of the document
+ *
+ * @return array the content of a version.
+ */
+ function getMaxVersionData() {
+ return $this->fetchData($this->getMaxVersionID());
+ }
+
+ /**
+ * getNumberOfVersions - get the number of versions of this document
+ *
+ * @return int Number of versions
+ */
+ function getNumberOfVersions() {
+ $res = db_query_params('SELECT COUNT(version) FROM doc_data_version WHERE docid = $1',
+ array($this->Document->getID()));
+ if ($res) {
+ $arr = db_fetch_array($res);
+ return (int)$arr[0];
+ }
+ }
+
+ /**
+ * isURL - whether this document is a URL and not a local file.
+ *
+ * @return boolean is_url.
+ */
+ function isURL() {
+ return ($this->data_array['filetype'] == 'URL');
+ }
+
+ function isCurrent() {
+ return $this->data_array['current_version'];
+ }
+
+ /**
+ * update - Update an existing version of a document
+ *
+ * @param int $version The version id to update
+ * @param string $title The new title
+ * @param string $description The new description
+ * @param string $filetype The new filetype
+ * @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.
+ * @return bool true on success
+ */
+ function update($version, $title, $description, $filetype, $filename, $filesize, $current_version = 1) {
+ db_begin();
+ $colArr = array('title', 'description', 'filetype', 'filename', 'filesize', 'current_version', 'updatedate');
+ $valArr = array(htmlspecialchars($title), htmlspecialchars($description), $filetype, $filename, $filesize, $current_version, time());
+ if (!$this->setValueinDB($version, $colArr, $valArr)) {
+ db_rollback();
+ return false;
+ }
+ if ($current_version) {
+ $res = db_query_params('UPDATE doc_data_version SET current_version = $1 WHERE docid = $2 AND version != $3',
+ array(0, $this->Document->getID(), $version));
+ if (!$res) {
+ $this->setOnUpdateError(_('Cannot set current_version.').' '.db_error());
+ db_rollback();
+ return false;
+ }
+ }
+ db_commit();
+ return true;
+ }
+
+ /**
+ * updateDataWords - update the indexation of content of a version of the document
+ *
+ * @param int $version The version to update
+ * @param string $data_words The content of the document as parsed
+ * @return bool true on success
+ */
+ function updateDataWords($version, $data_words) {
+ db_begin();
+ $colArr = array('data_words');
+ $valArr = array($data_words);
+ if (!$this->setValueinDB($version, $colArr, $valArr)) {
+ db_rollback();
+ return false;
+ }
+ db_commit();
+ return true;
+ }
+
+ /**
+ * setValueinDB - private function to update columns in db
+ *
+ * @param int $version the version id to update
+ * @param array $colArr the columns to update in array form array('col1', col2')
+ * @param array $valArr the values to store in array form array('val1', 'val2')
+ * @return boolean success or not
+ * @access private
+ */
+ private function setValueinDB($version, $colArr, $valArr) {
+ if ((count($colArr) != count($valArr)) || !count($colArr) || !count($valArr)) {
+ $this->setOnUpdateError(_('wrong parameters'));
+ return false;
+ }
+
+ $qpa = db_construct_qpa(false, 'UPDATE doc_data_version SET ');
+ for ($i = 0; $i < count($colArr); $i++) {
+ switch ($colArr[$i]) {
+ case 'filesize':
+ case 'title':
+ case 'description':
+ case 'filetype':
+ case 'filename':
+ case 'updatedate':
+ case 'data_words':
+ case 'current_version': {
+ if ($i) {
+ $qpa = db_construct_qpa($qpa, ',');
+ }
+ $qpa = db_construct_qpa($qpa, $colArr[$i]);
+ $qpa = db_construct_qpa($qpa, ' = $1 ', array($valArr[$i]));
+ break;
+ }
+ default: {
+ $this->setOnUpdateError(_('wrong column name'));
+ return false;
+ }
+ }
+ }
+ $qpa = db_construct_qpa($qpa, ' WHERE version = $1 AND docid = $2',
+ array($version, $this->Document->getID()));
+ $res = db_query_qpa($qpa);
+ if (!$res || db_affected_rows($res) < 1) {
+ $this->setOnUpdateError(db_error());
+ return false;
+ }
+ for ($i = 0; $i < count($colArr); $i++) {
+ switch ($colArr[$i]) {
+ case 'filesize':
+ case 'title':
+ case 'description':
+ case 'filetype':
+ case 'filename':
+ case 'updatedate':
+ case 'current_version': {
+ $this->data_array[$colArr[$i]] = $valArr[$i];
+ }
+ }
+ }
+ return true;
+ }
+}
--- /dev/null
+<?php
+/**
+ * FusionForge Documentation Manager
+ *
+ * Copyright 2016, Franck Villaume - TrivialDev
+ * http://fusionforge.org
+ *
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+require_once $gfcommon.'include/FFError.class.php';
+require_once $gfcommon.'docman/DocumentVersion.class.php';
+
+class DocumentVersionFactory extends FFError {
+ /**
+ * The Document object.
+ *
+ * @var object $Document.
+ */
+ var $Document;
+
+ /**
+ * Constructor.
+ *
+ * @param $Document
+ * @internal param \The $object Document object to which this version factory is associated.
+ * @return \DocumentVersionFactory
+ */
+ function __construct(&$Document) {
+ parent::__construct();
+ if (!$Document || !is_object($Document)) {
+ $this->setError(_('No Valid Document Object'));
+ return false;
+ }
+ if ($Document->isError()) {
+ $this->setError(_('Document')._(': ').$Document->getErrorMessage());
+ return false;
+ }
+ $this->Document =& $Document;
+ return true;
+ }
+
+ /**
+ * getVersions - retrieve a limited number of version of a document
+ *
+ * @param int $limit the number of versions to retrieve. Default is 0 = No limit
+ * @param int $start Paging the retrieve. Start point. Default is 0.
+ * @return array Array of enriched version datas from database.
+ */
+ function getVersions($limit = 0, $start = 0) {
+ global $HTML;
+ $versions = array();
+ $res = db_query_params('SELECT serial_id, version, docid, current_version, title, updatedate, createdate, created_by, description, filename, filetype, filesize FROM doc_data_version WHERE docid = $1 ORDER by version ASC',
+ array($this->Document->getID()), $limit, $start);
+ if ($res) {
+ $numrows = db_numrows($res);
+ while ($arr = db_fetch_array($res)) {
+ $user = user_get_object($arr['created_by']);
+ $arr['created_by_username'] = $user->getRealName();
+ $arr['filesize_readable'] = human_readable_bytes($arr['filesize']);
+ if ($arr['updatedate']) {
+ $arr['lastdate'] = date(_('Y-m-d H:i'), $arr['updatedate']);
+ } else {
+ $arr['lastdate'] = date(_('Y-m-d H:i'), $arr['createdate']);
+ }
+ $isURL = 0;
+ if ($arr['filetype'] == 'URL') {
+ $isURL = 1;
+ }
+ $isText = 0;
+ if (preg_match('|^text/|i', $arr['filetype'])) { // text plain, text html, text x-patch, etc
+ $isText = 1;
+ }
+ $isHtml = 0;
+ if (preg_match('/html/i', $arr['filetype'])) { // text plain, text html, text x-patch, etc
+ $isHtml = 1;
+ }
+ $arr['versionactions'][] = util_make_link('#', $HTML->getEditFilePic(_('Edit this version'), 'editversion'), array('id' => 'version_action_edit', 'onclick' => 'javascript:controllerListFile.toggleEditVersionView({title: \''.addslashes($arr['title']).'\', description: \''.addslashes($arr['description']).'\', version: '.$arr['version'].', current_version: '.$arr['current_version'].', isURL: '.$isURL.', isText: '.$isText.', isHtml: '.$isHtml.', filename: \''.addslashes($arr['filename']).'\'})'), true);
+ if ($numrows > 1) {
+ $arr['versionactions'][] = util_make_link('#', $HTML->getRemovePic(_('Permanently delete this version'), 'delversion'), array('id' => 'version_action_delete', 'onclick' => 'javascript:controllerListFile.deleteVersion({version: '.$arr['version'].'})'), true);
+ }
+ $versions[$arr['version']] = $arr;
+ }
+ }
+ db_free_result($res);
+ return $versions;
+ }
+}
--- /dev/null
+<?php
+/**
+ * FusionForge Documentation Manager
+ *
+ * Copyright 2016, Franck Villaume - TrivialDev
+ * http://fusionforge.org
+ *
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/* please do not add require here : use www/docman/index.php to add require */
+/* global variables used */
+global $g; // Group object
+global $group_id; // id of group
+global $HTML;
+
+$sysdebug_enable = false;
+$result = array();
+$result['status'] = 0;
+
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+ $result['html'] = $HTML->error_msg(_('Document Manager Action Denied.'));
+ echo json_encode($result);
+ exit;
+}
+
+$docid = getIntFromRequest('docid');
+$version = getIntFromRequest('version');
+
+if ($docid && $version) {
+ $documentObject = document_get_object($docid, $group_id);
+ if ($documentObject && !$documentObject->isError()) {
+ $dv = new DocumentVersion($documentObject);
+ if ($dv && !$dv->isError()) {
+ if ($dv->delete($version)) {
+ $result['html'] = $HTML->feedback(_('Version deleted successfully'));
+ $result['status'] = 1;
+ } else {
+ $result['html'] = $HTML->error_msg(_('Cannot delete version')._(': ').$version.' '.$dv->getErrorMessage());
+ }
+ } else {
+ $result['html'] = $HTML->error_msg(_('Cannot create object documentversion'));
+ }
+ } else {
+ $result['html'] = $HTML->error_msg(_('Cannot retrieve document')._(': ').$docid);
+ }
+} else {
+ $result['html'] = $HTML->warning_msg(_('No document ID. Cannot retrieve versions.'));
+}
+
+echo json_encode($result);
+exit;
global $g; // Group object
global $group_id; // id of group
global $childgroup_id; // id of child group if any
+global $feedback;
+global $error_msg;
+global $warning_msg;
$urlparam = '/docman/?group_id='.$group_id;
$stateid = getIntFromRequest('stateid');
$filetype = getStringFromRequest('filetype');
$editor = getStringFromRequest('editor');
+$current_version_radio = getIntFromRequest('doc_version_cv_radio');
+$current_version = getIntFromRequest('current_version', 0);
+$version = getIntFromRequest('edit_version', 0);
+$new_version = getIntFromRequest('new_version', 0);
if (!$docid) {
$warning_msg = _('No document found to update');
$sanitizer = new TextSanitizer();
$details = $sanitizer->SanitizeHtml($details);
$data = '';
-if (($editor) && ($d->getFileData() != $details) && (!$uploaded_data['name'])) {
- $filename = $d->getFileName();
- $datafile = tempnam("/tmp", "docman");
- $fh = fopen($datafile, 'w');
- fwrite($fh, $details);
- fclose($fh);
- $data = $datafile;
- if (!$filetype)
- $filetype = $d->getFileType();
-} elseif (!empty($uploaded_data) && $uploaded_data['name']) {
- if (!is_uploaded_file($uploaded_data['tmp_name'])) {
- $error_msg = sprintf(_('Invalid file attack attempt %s.'), $uploaded_data['name']);
- session_redirect($urlparam);
- }
- $data = $uploaded_data['tmp_name'];
- $filename = $uploaded_data['name'];
- if (function_exists('finfo_open')) {
- $finfo = finfo_open(FILEINFO_MIME_TYPE);
- $filetype = finfo_file($finfo, $uploaded_data['tmp_name']);
+if ($version) {
+ $dv = documentversion_get_object($version, $docid, $group_id);
+ if (($editor) && ($dv->getFileData() != $details) && (!$uploaded_data['name'])) {
+ $filename = $dv->getFileName();
+ $datafile = tempnam('/tmp', 'docman');
+ $fh = fopen($datafile, 'w');
+ fwrite($fh, $details);
+ fclose($fh);
+ $data = $datafile;
+ if (!$filetype)
+ $filetype = $dv->getFileType();
+
+ } elseif (!empty($uploaded_data) && $uploaded_data['name']) {
+ if (!is_uploaded_file($uploaded_data['tmp_name'])) {
+ $error_msg = sprintf(_('Invalid file attack attempt %s.'), $uploaded_data['name']);
+ session_redirect($urlparam);
+ }
+ $data = $uploaded_data['tmp_name'];
+ $filename = $uploaded_data['name'];
+ if (function_exists('finfo_open')) {
+ $finfo = finfo_open(FILEINFO_MIME_TYPE);
+ $filetype = finfo_file($finfo, $uploaded_data['tmp_name']);
+ } else {
+ $filetype = $uploaded_data['type'];
+ }
+ } elseif ($file_url) {
+ $filename = $file_url;
+ $filetype = 'URL';
} else {
- $filetype = $uploaded_data['type'];
+ $filename = $dv->getFileName();
+ $filetype = $dv->getFileType();
}
-} elseif ($file_url) {
- $filename = $file_url;
- $filetype = 'URL';
+} elseif ($new_version) {
+ if ($editor && $details && $name) {
+ $filename = $name;
+ $datafile = tempnam('/tmp', 'docman');
+ $fh = fopen($datafile, 'w');
+ fwrite($fh, $details);
+ fclose($fh);
+ $data = $datafile;
+ if (!$filetype)
+ $filetype = 'text/html';
+
+ } elseif (!empty($uploaded_data) && $uploaded_data['name']) {
+ if (!is_uploaded_file($uploaded_data['tmp_name'])) {
+ $error_msg = sprintf(_('Invalid file attack attempt %s.'), $uploaded_data['name']);
+ session_redirect($urlparam);
+ }
+ $data = $uploaded_data['tmp_name'];
+ $filename = $uploaded_data['name'];
+ if (function_exists('finfo_open')) {
+ $finfo = finfo_open(FILEINFO_MIME_TYPE);
+ $filetype = finfo_file($finfo, $uploaded_data['tmp_name']);
+ } else {
+ $filetype = $uploaded_data['type'];
+ }
+ } elseif ($file_url) {
+ $filename = $file_url;
+ $filetype = 'URL';
+ }
+} elseif (($d->getDocGroupID() != $doc_group) || ($d->getState() != $stateid)) {
+ // we do the update based on the current version.
+ $dv = documentversion_get_object($current_version_radio, $docid, $group_id);
+ $filename = $dv->getFileName();
+ $filetype = $dv->getFileType();
+ $title = $dv->getTitle();
+ $description = $dv->getDescription();
+ $version = $current_version_radio;
+ $current_version = 1;
} else {
- $filename = $d->getFileName();
- $filetype = $d->getFileType();
+ $warning_msg = _('No action to perform');
+ session_redirect($urlparam);
}
-if (!$d->update($filename, $filetype, $data, $doc_group, $title, $description, $stateid)) {
+if (!$d->update($filename, $filetype, $data, $doc_group, $title, $description, $stateid, $version, $current_version, $new_version)) {
$error_msg = $d->getErrorMessage();
session_redirect($urlparam);
}
-$feedback = sprintf(_('Document %s updated successfully.'), $filename);
+$feedback = sprintf(_('Document [D%s] updated successfully.'), $d->getID());
session_redirect($urlparam);
--- /dev/null
+<?php
+/**
+ * FusionForge Documentation Manager
+ *
+ * Copyright 2016, Franck Villaume - TrivialDev
+ * http://fusionforge.org
+ *
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/* please do not add require here : use www/docman/index.php to add require */
+/* global variables used */
+global $group_id; // id of group
+global $HTML;
+
+$sysdebug_enable = false;
+$result = array();
+
+if (!forge_check_perm('docman', $group_id, 'approve')) {
+ $result['html'] = $HTML->error_msg(_('Document Manager Action Denied.'));
+ echo json_encode($result);
+ exit;
+}
+
+$docid = getIntFromRequest('docid');
+$start = getIntFromRequest('start', 0);
+$limit = getIntFromRequest('limit', 25);
+
+if ($docid) {
+ $documentObject = document_get_object($docid, $group_id);
+ if ($documentObject && !$documentObject->isError()) {
+ $dvf = new DocumentVersionFactory($documentObject);
+ if ($dvf && !$dvf->isError()) {
+ $result = $dvf->getVersions($limit, $start);
+ } else {
+ $result['html'] = $HTML->warning_msg(_('Cannot retrieve versions')._(': ').$docid);
+ }
+ } else {
+ $result['html'] = $HTML->warning_msg(_('Cannot retrieve document')._(': ').$docid);
+ }
+} else {
+ $result['html'] = $HTML->warning_msg(_('No document ID. Cannot retrieve versions.'));
+}
+
+echo json_encode($result);
+exit;
/**
* FusionForge Documentation Manager
*
- * Copyright 2012, Franck Villaume - TrivialDev
+ * Copyright 2012,2016, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
$itemid = getIntFromRequest('itemid');
$details = getIntFromRequest('details');
+$version = getIntFromRequest('version');
$d = document_get_object($itemid, $g->getID());
if ($d->isError()) {
$filearray = array();
if ($details) {
- $filearray['name'] = $d->getFileName();
- $filearray['type'] = $d->getFileType();
- $filearray['title'] = $d->getName();
- $filearray['description'] = $d->getDescription();
- $filearray['stateid'] = $d->getStateID();
+ if ($version) {
+ $dv = documentversion_get_object($version, $itemid, $g->getID());
+ if ($dv->isError()) {
+ $error_msg = $dv->getErrorMessage();
+ session_redirect($urlparam);
+ }
+ $filearray['name'] = $dv->getFileName();
+ $filearray['type'] = $dv->getFileType();
+ $filearray['title'] = $dv->getTitle();
+ $filearray['description'] = $dv->getDescription();
+ $filearray['isurl'] = $dv->isURL();
+ } else {
+ $filearray['name'] = $d->getFileName();
+ $filearray['type'] = $d->getFileType();
+ $filearray['title'] = $d->Name();
+ $filearray['description'] = $d->getDescription();
+ $filearray['isurl'] = $d->isURL();
+ }
$filearray['docgroupid'] = $d->getDocGroupID();
$filearray['isurl'] = $d->isURL();
}
foreach ($arr_fileid as $fileid) {
if (!empty($fileid)) {
$d = document_get_object($fileid, $g->getID());
+ if (!$d) {
+ $error_msg = _('Cannot retrieve document');
+ session_redirect($redirecturl);
+ }
if ($d->isError() || !$d->addMonitoredBy(user_getid())) {
$error_msg = $d->getErrorMessage();
session_redirect($redirecturl);
foreach ($arr_fileid as $fileid) {
if (!empty($fileid)) {
$d = document_get_object($fileid, $g->getID());
+ if (!$d) {
+ $error_msg = _('Cannot retrieve document');
+ session_redirect($redirecturl);
+ }
if ($d->isError() || !$d->removeMonitoredBy($LUSER->getID())) {
$error_msg = $d->getErrorMessage();
session_redirect($redirecturl);
* FusionForge Documentation Manager
*
* Copyright 2010-2011, Franck Villaume - Capgemini
- * Copyright 2012-2015, Franck Villaume - TrivialDev
+ * Copyright 2012-2016, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
foreach ($arr_fileid as $fileid) {
if (!empty($fileid)) {
$d = document_get_object($fileid, $g->getID());
- if ($d->isError() || !$d->update($d->getFilename(), $d->getFileType(), NULL, $moveto_dirid, $d->getName(), $d->getDescription(), $d->getStateID())) {
+ if (!$d) {
+ $error_msg = _('Cannot retrieve document');
+ session_redirect($redirecturl);
+ }
+ var_dump($d);
+ if ($d->isError() || !$d->update($d->getFilename(), $d->getFileType(), NULL, $moveto_dirid, $d->getName(), $d->getDescription(), $d->getStateID(), $d->getVersion())) {
$error_msg = $d->getErrorMessage();
session_redirect($redirecturl);
}
/**
* FusionForge Documentation Manager
*
- * Copyright 2012-2015, Franck Villaume - TrivialDev
+ * Copyright 2012-2016, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
session_redirect('/docman/?group_id='.$group_id);
}
+echo html_ao('script', array('type' => 'text/javascript'));
+?>
+//<![CDATA[
+var controllerEditFile;
+
+jQuery(document).ready(function() {
+ controllerEditFile = new DocManAddFileController({
+ fileRow: jQuery('#uploadnewroweditfile'),
+ urlRow: jQuery('#fileurlroweditfile'),
+ pathRow: jQuery('#pathroweditfile'),
+ editRow: jQuery('#editonlineroweditfile'),
+ editNameRow: jQuery('#editnamerow'),
+ buttonFile: jQuery('#editButtonFile'),
+ buttonUrl: jQuery('#editButtonUrl'),
+ buttonManualUpload: jQuery('#editButtonManualUpload'),
+ buttonEditor: jQuery('#editButtonEditor')
+ });
+});
+
+//]]>
+<?php
+echo html_ac(html_ap() - 1);
+
echo html_ao('div', array('id' => 'editFile'));
echo $HTML->openForm(array('id' => 'editdocdata', 'name' => 'editdocdata', 'method' => 'post', 'enctype' => 'multipart/form-data'));
-echo $HTML->listTableTop(array());
+echo $HTML->listTableTop();
+$cells = array();
+$cells[] = array(_('Folder that document belongs to')._(':'), 'class' => 'docman_editfile_title');
+$cells[][] = html_e('select', array('name' => 'doc_group', 'id' => 'doc_group'), '', false);
+$cells[] = array(_('State')._(':'), 'class' => 'docman_editfile_title');
+$cells[][] = html_e('select', array('name' => 'stateid', 'id' => 'stateid'), '', false);
+echo $HTML->multiTableRow(array(), $cells);
+echo $HTML->listTableBottom();
+$thArr = array(_('Current'), _('Filename'), _('Title'), _('Description'), _('Author'), _('Last Time'), _('Size'), _('Actions'));
+$thClass = array('unsortable', '', '', '', '', '', '', 'unsortable');
+echo $HTML->listTableTop($thArr, array(), 'sortable full', 'sortable_doc_version_table', $thClass);
+echo $HTML->listTableBottom();
+echo html_e('button', array('id' => 'doc_version_addbutton', 'type' => 'button', 'onclick' => 'javascript:controllerListFile.toggleAddVersionView()'), _('Add new version'));
+echo $HTML->listTableTop(array(), array(), 'listing full hide', 'doc_version_edit');
$cells = array();
$cells[] = array(_('Document Title').utils_requiredField()._(':'), 'class' => 'docman_editfile_title');
$cells[][] = html_e('input', array('pattern' => '.{5,}', 'title' => sprintf(_('(at least %s characters)'), 5), 'id' => 'title', 'type' => 'text', 'name' => 'title', 'size' => '40', 'maxlength' => '255'));
echo $HTML->multiTableRow(array(), $cells);
$cells = array();
-$cells[] = array(_('Description').utils_requiredField()._(':'), 'class' => 'docman_editfile_title');
-$cells[][] = html_e('input', array('pattern' => '.{10,}', 'title' => sprintf(_('(at least %s characters)'), 10), 'id' => 'description', 'type' => 'text', 'name' => 'description', 'size' => '40', 'maxlength' => '255'));
+$cells[] = array(_('Description').utils_requiredField()._(':'), 'class' => 'docman_editfile_description');
+$cells[][] = html_e('textarea', array('pattern' => '.{10,}', 'title' => sprintf(_('(at least %s characters)'), 10), 'id' => 'description', 'name' => 'description', 'maxlength' => '255', 'rows' => '5', 'cols' => '50'), '', false);
echo $HTML->multiTableRow(array(), $cells);
if ($g->useDocmanSearch()) {
$cells = array();
echo $HTML->multiTableRow(array(), $cells);
}
$cells = array();
-$cells[] = array(_('File')._(':'), 'class' => 'docman_editfile_title');
-$cells[][] = html_e('a', array('id' => 'filelink'), '', false);
+$cells[] = array(_('Current Version')._(':'), 'class' => 'docman_editfile_currentversion');
+$cells[][] = html_e('input', array('type' => 'checkbox', 'title' => _('Make this version the current version'), 'id' => 'current_version', 'name' => 'current_version', 'value' => 1));
+echo $HTML->multiTableRow(array(), $cells);
+$cells = array();
+$cells[][] = _('Type of Document') .utils_requiredField();
+$nextcell = html_e('input', array('type' => 'radio', 'id' => 'editButtonFile', 'name' => 'type', 'value' => 'httpupload', 'checked' => 'checked', 'required' => 'required')).html_e('label', array('for' => 'editButtonFile'), _('File')).
+ html_e('input', array('type' => 'radio', 'id' => 'editButtonUrl', 'name' => 'type', 'value' => 'pasteurl', 'required' => 'required')).html_e('label', array('for' => 'editButtonUrl'), _('URL'));
+if (forge_get_config('use_manual_uploads')) {
+ $nextcell .= html_e('input', array('type' => 'radio', 'id' => 'editButtonManualUpload', 'name' => 'type', 'value' => 'manualupload', 'required' => 'required')).html_e('label', array('for' => 'editButtonManualUpload'), _('Already-uploaded file'));
+}
+if ($g->useCreateOnline()) {
+ $nextcell .= html_e('input', array('type' => 'radio', 'id' => 'editButtonEditor', 'name' => 'type', 'value' => 'editor', 'required' => 'required')).html_e('label', array('for' => 'editButtonEditor'), _('Create online'));
+}
+$cells[][] = $nextcell;
echo $HTML->multiTableRow(array(), $cells);
+ if (forge_get_config('use_manual_uploads')) {
+ $cells = array();
+ $cells[][] = _('File').utils_requiredField();
+ $incoming = forge_get_config('groupdir_prefix')."/".$g->getUnixName()."/incoming";
+ $manual_files_arr = ls($incoming, true);
+ if (count($manual_files_arr)) {
+ $cells[][] = html_build_select_box_from_arrays($manual_files_arr, $manual_files_arr, 'manual_path', '').
+ html_e('br').
+ html_e('span', array(), sprintf(_('Pick a file already uploaded (by SFTP or SCP) to the <a href="%1$s">project\'s incoming directory</a> (%2$s).'),
+ 'sftp://'.forge_get_config('shell_host').$incoming.'/', $incoming), false);
+ } else {
+ $cells[][] = html_e('p', array('class' => 'warning'), sprintf(_('You need first to upload file in %s'),$incoming), false);
+ }
+ echo $HTML->multiTableRow(array('id' => 'pathroweditfile', 'class' => 'hide'), $cells);
+ }
if ($g->useCreateOnline()) {
$cells = array();
$cells[] = array(_('Edit the contents to your desire or leave them as they are to remain unmodified.').html_e('br').
- html_e('textarea', array('id' => 'defaulteditzone', 'name' => 'details', 'rows' => '15', 'cols' => '70'), '', false).
+ html_e('textarea', array('id' => 'defaulteditzone', 'name' => 'details', 'rows' => '15', 'cols' => '100'), '', false).
html_e('input', array('id' => 'defaulteditfiletype', 'type' => 'hidden', 'name' => 'filetype', 'value' => 'text/plain')).
html_e('input', array('id' => 'editor', 'type' => 'hidden', 'name' => 'editor', 'value' => 'online')),
'colspan' => 2);
- echo $HTML->multiTableRow(array('id' => 'editonlineroweditfile'), $cells);
+ echo $HTML->multiTableRow(array('id' => 'editonlineroweditfile', 'class' => 'hide'), $cells);
}
-$cells = array();
-$cells[] = array(_('Folder that document belongs to')._(':'), 'class' => 'docman_editfile_title');
-$cells[][] = html_e('select', array('name' => 'doc_group', 'id' => 'doc_group'), '', false);
-echo $HTML->multiTableRow(array(), $cells);
-$cells = array();
-$cells[] = array(_('State')._(':'), 'class' => 'docman_editfile_title');
-$cells[][] = html_e('select', array('name' => 'stateid', 'id' => 'stateid'), '', false);
-echo $HTML->multiTableRow(array(), $cells);
+
$cells = array();
$cells[] = array(_('Specify an new outside URL where the file will be referenced').utils_requiredField()._(':'), 'class' => 'docman_editfile_title');
-$cells[][] = html_e('input', array('id' => 'fileurl', 'type' => 'url', 'name' => 'file_url', 'size' => '50', 'pattern' => 'ftp://.+|https?://.+'));
-echo $HTML->multiTableRow(array('id' => 'fileurlroweditfile'), $cells);
+$cells[][] = html_e('input', array('id' => 'editFileurl', 'type' => 'url', 'name' => 'file_url', 'size' => '50', 'pattern' => 'ftp://.+|https?://.+'));
+echo $HTML->multiTableRow(array('id' => 'fileurlroweditfile', 'class' => 'hide'), $cells);
$cells = array();
-$cells[] = array(_('OPTIONAL Upload new file')._(':'), 'class' => 'docman_editfile_title');
+$cells[] = array(_('File')._(':'), 'class' => 'docman_editfile_file');
$cells[][] = html_e('input', array('type' => 'file', 'name' => 'uploaded_data')).html_e('br').sprintf(_('(max upload size: %s)'),human_readable_bytes(util_get_maxuploadfilesize()));
-echo $HTML->multiTableRow(array('id' => 'uploadnewroweditfile'), $cells);
+echo $HTML->multiTableRow(array('id' => 'uploadnewroweditfile', 'class' => 'hide'), $cells);
echo $HTML->listTableBottom();
echo html_e('input', array('type' => 'hidden', 'id' => 'docid', 'name' => 'docid'));
+echo html_e('input', array('type' => 'hidden', 'id' => 'edit_version', 'name' => 'edit_version'));
+echo html_e('input', array('type' => 'hidden', 'id' => 'new_version', 'name' => 'new_version', 'value' => 0));
echo $HTML->closeForm();
echo html_ac(html_ap() -1);
enableResize: true,
page: 'listfile',
docgroupId: <?php echo $dirid ?>,
- lockIntervalDelay: 60000
+ lockIntervalDelay: 60000,
+ tableAddVersion: jQuery('#doc_version_edit')
});
});
$classth[] = 'unsortable';
}
echo html_ao('div', array('class' => 'docmanDiv'));
- echo $HTML->listTableTop($tabletop, array(), 'sortable_docman_listfile', 'sortable', $classth);
+ echo $HTML->listTableTop($tabletop, array(), 'sortable', 'sortable_docman_listfile', $classth);
$time_new = 604800;
foreach ($nested_docs[$dirid] as $d) {
$cells = array();
}
}
if (!$d->getLocked() && !$d->getReserved()) {
- $cells[][] = html_e('input', array('type' => 'checkbox', 'value' => $d->Group->getID().'-'.$d->getID(), 'class' => 'checkeddocidactive', 'title' => _('Select / Deselect this document for massaction'), 'onClick' => 'controllerListFile.checkgeneral("active")'));
+ $cells[][] = html_e('input', array('type' => 'checkbox', 'value' => $d->getID(), 'class' => 'checkeddocidactive', 'title' => _('Select / Deselect this document for massaction'), 'onClick' => 'controllerListFile.checkgeneral("active")'));
} else {
if (session_loggedin() && ($d->getReservedBy() != $LUSER->getID())) {
$cells[][] = html_e('input', array('type' => 'checkbox', 'name' => 'disabled', 'disabled' => 'disabled'));
} else {
- $cells[][] = html_e('input', array('type' => 'checkbox', 'value' => $d->Group->getID().'-'.$d->getID(), 'class' => 'checkeddocidactive', 'title' => _('Select / Deselect this document for massaction'), 'onClick' => 'controllerListFile.checkgeneral("active")'));
+ $cells[][] = html_e('input', array('type' => 'checkbox', 'value' => $d->getID(), 'class' => 'checkeddocidactive', 'title' => _('Select / Deselect this document for massaction'), 'onClick' => 'controllerListFile.checkgeneral("active")'));
}
}
switch ($d->getFileType()) {
break;
}
default: {
- $cells[][] = util_make_link('/docman/view.php/'.$d->Group->getID().'/'.$d->getID().'/'.urlencode($d->getFileName()), html_image($d->getFileTypeImage(), 22, 22, array('alt' => $d->getFileType())), array('title' => _('View this document')));
+ $cells[][] = util_make_link('/docman/view.php/'.$d->Group->getID().'/'.$d->getID(), html_image($d->getFileTypeImage(), 22, 22, array('alt' => $d->getFileType())), array('title' => _('View this document')));
}
}
$nextcell = '';
}
$cells[][] = $d->getDownload();
- if (forge_check_perm('docman', $group_id, 'approve')) {
+ if (forge_check_perm('docman', $g->getID(), 'approve')) {
$nextcell = '';
$editfileaction = '/docman/?action=editfile&fromview=listfile&dirid='.$d->getDocGroupID();
$notifyaction = '/docman/?action=notifyusers&fromview=listfile&dirid='.$d->getDocGroupID();
$notifyaction .= '&group_id='.$GLOBALS['group_id'];
if (!$d->getLocked() && !$d->getReserved()) {
$nextcell .= util_make_link($redirecturl.'&action=trashfile&fileid='.$d->getID(), $HTML->getDeletePic(_('Move this document to trash'), 'delfile'));
- $nextcell .= util_make_link('#', html_image('docman/edit-file.png', 22, 22, array('alt' => _('Edit this document'))), array('onclick' => 'javascript:controllerListFile.toggleEditFileView({action:\''.util_make_uri($editfileaction).'\', lockIntervalDelay: 60000, childGroupId: '.util_ifsetor($childgroup_id, 0).' ,id:'.$d->getID().', groupId:'.$d->Group->getID().', docgroupId:'.$d->getDocGroupID().', statusId:'.$d->getStateID().', statusDict:'.$dm->getStatusNameList('json').', docgroupDict:'.$dm->getDocGroupList($nested_groups, 'json').', title:\''.addslashes($d->getName()).'\', filename:\''.addslashes($d->getFilename()).'\', description:\''.addslashes($d->getDescription()).'\', isURL:\''.$d->isURL().'\', isText:\''.$d->isText().'\', isHtml:\''.$d->isHtml().'\', useCreateOnline:'.$d->Group->useCreateOnline().', docManURL:\''.util_make_uri('/docman').'\'})', 'title' => _('Edit this document')), true);
+ $nextcell .= util_make_link('#', $HTML->getEditFilePic(_('Edit this document'), 'editdocument'), array('onclick' => 'javascript:controllerListFile.toggleEditFileView({action:\''.util_make_uri($editfileaction).'\', lockIntervalDelay: 60000, childGroupId: '.util_ifsetor($childgroup_id, 0).' , id:'.$d->getID().', groupId:'.$d->Group->getID().', docgroupId:'.$d->getDocGroupID().', statusId:'.$d->getStateID().', statusDict:'.$dm->getStatusNameList('json').', docgroupDict:'.$dm->getDocGroupList($nested_groups, 'json').', isText:\''.$d->isText().'\', isHtml:\''.$d->isHtml().'\', useCreateOnline:'.$d->Group->useCreateOnline().', docManURL:\''.util_make_uri('/docman').'\'})', 'title' => _('Edit this document')), true);
if (session_loggedin()) {
$nextcell .= util_make_link($redirecturl.'&action=reservefile&fileid='.$d->getID(), html_image('docman/reserve-document.png', 22, 22, array('alt' => _('Reserve this document'))), array('title' => _('Reserve this document for later edition')));
}
}
} else {
$nextcell .= util_make_link($redirecturl.'&action=trashfile&fileid='.$d->getID(), $HTML->getDeletePic(_('Move this document to trash'), 'delfile'));
- $nextcell .= util_make_link('#', html_image('docman/edit-file.png', 22 ,22, array('alt' => _('Edit this document'))), array('onclick' => 'javascript:controllerListFile.toggleEditFileView({action:\''.util_make_uri($editfileaction).'\', lockIntervalDelay: 60000, childGroupId: '.util_ifsetor($childgroup_id, 0).' ,id:'.$d->getID().', groupId:'.$d->Group->getID().', docgroupId:'.$d->getDocGroupID().', statusId:'.$d->getStateID().', statusDict:'.$dm->getStatusNameList('json').', docgroupDict:'.$dm->getDocGroupList($nested_groups, 'json').', title:\''.addslashes($d->getName()).'\', filename:\''.addslashes($d->getFilename()).'\', description:\''.addslashes($d->getDescription()).'\', isURL:\''.$d->isURL().'\', isText:\''.$d->isText().'\', isHtml:\''.$d->isHtml().'\', useCreateOnline:'.$d->Group->useCreateOnline().', docManURL:\''.util_make_uri('/docman').'\'})', 'title' => _('Edit this document')), true);
+ $nextcell .= util_make_link('#', $HTML->getEditFilePic(_('Edit this document'), 'editdocument'), array('onclick' => 'javascript:controllerListFile.toggleEditFileView({action:\''.util_make_uri($editfileaction).'\', lockIntervalDelay: 60000, childGroupId: '.util_ifsetor($childgroup_id, 0).' , id:'.$d->getID().', groupId:'.$d->Group->getID().', docgroupId:'.$d->getDocGroupID().', statusId:'.$d->getStateID().', statusDict:'.$dm->getStatusNameList('json').', docgroupDict:'.$dm->getDocGroupList($nested_groups, 'json').', isText:\''.$d->isText().'\', isHtml:\''.$d->isHtml().'\', useCreateOnline:'.$d->Group->useCreateOnline().', docManURL:\''.util_make_uri('/docman').'\'})', 'title' => _('Edit this document')), true);
$nextcell .= util_make_link($redirecturl.'&action=releasefile&fileid='.$d->getID(), html_image('docman/release-document.png', 22, 22, array('alt' => _('Release reservation'))), array('title' => _('Release reservation')));
}
}
}
$nextcell .= util_make_link($redirecturl.'&action=monitorfile&option='.$option.'&fileid='.$d->getID(), $image, array('title' => $titleMonitor));
}
- $nextcell .= util_make_link('#', html_image('ic/mail-send.png', 22, 22, array('alt' => _('Notify'))), array('onclick' => 'javascript:controllerListFile.toggleNotifyUserView({action:\''.util_make_uri($notifyaction).'\', lockIntervalDelay: 60000, childGroupId: '.util_ifsetor($childgroup_id, 0).' ,id:'.$d->getID().', groupId:'.$d->Group->getID().', docgroupId:'.$d->getDocGroupID().', title:\''.addslashes($d->getName()).'\', filename:\''.addslashes($d->getFilename()).'\', description:\''.addslashes($d->getDescription()).'\', isURL:\''.$d->isURL().'\', isText:\''.$d->isText().'\', isHtml:\''.$d->isHtml().'\', docManURL:\''.util_make_uri('/docman').'\'})', 'title' => _('Notify users')), true);
+ $nextcell .= util_make_link('#', html_image('ic/mail-send.png', 22, 22, array('alt' => _('Notify'))), array('onclick' => 'javascript:controllerListFile.toggleNotifyUserView({action:\''.util_make_uri($notifyaction).'\', lockIntervalDelay: 60000, childGroupId: '.util_ifsetor($childgroup_id, 0).' , id:'.$d->getID().', groupId:'.$d->Group->getID().', docgroupId:'.$d->getDocGroupID().', title:\''.addslashes($d->getName()).'\', filename:\''.addslashes($d->getFilename()).'\', description:\''.addslashes($d->getDescription()).'\', isURL:\''.$d->isURL().'\', isText:\''.$d->isText().'\', isHtml:\''.$d->isHtml().'\', docManURL:\''.util_make_uri('/docman').'\'})', 'title' => _('Notify users')), true);
$cells[][] = $nextcell;
}
echo $HTML->multiTableRow(array(), $cells);
echo util_make_link('#', html_image('docman/move-document.png', 22, 22, array('alt' => _('Move files to another folder'))), array('onclick' => 'javascript:controllerListFile.toggleMoveFileView({})', 'title' => _('Move files to another folder')), true);
}
}
- echo util_make_link('#', html_image('docman/download-directory-zip.png', 22, 22, array('alt' => _('Download as a ZIP'))) , array('onclick' => 'window.location.href=\''.util_make_uri('/docman/view.php/'.$group_id.'/zip/selected/'.$dirid.'/\'+controllerListFile.buildUrlByCheckbox("active")'), 'title' => _('Download as a ZIP')), true);
+ echo util_make_link('#', html_image('docman/download-directory-zip.png', 22, 22, array('alt' => _('Download as a ZIP'))) , array('onclick' => 'window.location.href=\''.util_make_uri('/docman/view.php/'.$g->getID().'/zip/selected/'.$dirid.'/\'+controllerListFile.buildUrlByCheckbox("active")'), 'title' => _('Download as a ZIP')), true);
echo html_ac(html_ap() - 3);
if (forge_check_perm('docman', $ndg->Group->getID(), 'approve') && session_loggedin()) {
echo html_ao('div', array('class' => 'docman_div_include hide', 'id' => 'movefile'));
}
if ($DocGroupName) {
- if (forge_check_perm('docman', $group_id, 'approve') && $DocGroupName) {
+ if (forge_check_perm('docman', $g->getID(), 'approve') && $DocGroupName) {
include ($gfcommon.'docman/views/pendingfiles.php');
}
$foundFiles = 0;
include ($gfcommon.'docman/views/notifyusers.php');
$directViewFileRequestedID = getIntFromRequest('filedetailid', null);
if ($directViewFileRequestedID) {
- $localDocumentObject = document_get_object($directViewFileRequestedID, $group_id);
+ $localDocumentObject = document_get_object($directViewFileRequestedID, $g->getID());
echo html_ao('script', array('type' => 'text/javascript'));
echo '//<![CDATA['."\n";
echo 'jQuery(document).ready(function() {javascript:controllerListFile.toggleEditFileView({action:\''.util_make_uri($editfileaction).'\',
echo html_ao('script', array('type' => 'text/javascript'));
?>
//<![CDATA[
-var controllerListTrash;
+var controllerListFile;
jQuery(document).ready(function() {
- controllerListTrash = new DocManListFileController({
+ controllerListFile = new DocManListFileController({
groupId: <?php echo $group_id ?>,
divEditDirectory: jQuery('#editdocgroup'),
buttonEditDirectory: jQuery('#docman-editdirectory'),
enableResize: true,
page: 'trashfile',
docgroupId: <?php echo $dirid ?>,
- lockIntervalDelay: 60000
+ lockIntervalDelay: 60000,
+ tableAddVersion: jQuery('#doc_version_edit')
});
});
//]]>
$headerPath .= html_e('i', array(), $generalpath, false).' ';
echo html_e('h2', array('class' => 'docman_h2'), $headerPath, false);
if ($DocGroupName != '.trash') {
- echo util_make_link('#', $HTML->getConfigurePic(_('Edit this folder'), 'edit'), array('id' => 'docman-editdirectory', 'onclick' => 'javascript:controllerListTrash.toggleEditDirectoryView()'), true);
+ echo util_make_link('#', $HTML->getConfigurePic(_('Edit this folder'), 'edit'), array('id' => 'docman-editdirectory', 'onclick' => 'javascript:controllerListFile.toggleEditDirectoryView()'), true);
echo util_make_link($redirecturl.'&action=deldir', $HTML->getRemovePic(_('Delete permanently this folder and his content.'), 'deldir'), array('id' => 'docman-deletedirectory'));
}
}
if (isset($nested_docs[$dirid]) && is_array($nested_docs[$dirid])) {
- $tabletop = array(html_e('input', array('id' => 'checkallactive', 'title' => _('Select / Deselect all documents for massaction'), 'type' => 'checkbox', 'onClick' => 'controllerListTrash.checkAll("checkeddocidactive", "active")')), '', _('File Name'), _('Title'), _('Description'), _('Author'), _('Last time'), _('Status'), _('Size'), _('Actions'));
+ $tabletop = array(html_e('input', array('id' => 'checkallactive', 'title' => _('Select / Deselect all documents for massaction'), 'type' => 'checkbox', 'onClick' => 'controllerListFile.checkAll("checkeddocidactive", "active")')), '', _('File Name'), _('Title'), _('Description'), _('Author'), _('Last time'), _('Status'), _('Size'), _('Actions'));
$classth = array('unsortable', 'unsortable', '', '', '', '', '', '', '', 'unsortable');
echo html_ao('div', array('class' => 'docmanDiv'));
- echo $HTML->listTableTop($tabletop, array(), 'sortable_docman_listfile', 'sortable', $classth);
+ echo $HTML->listTableTop($tabletop, array(), 'sortable', 'sortable_docman_listfile', $classth);
$time_new = 604800;
foreach ($nested_docs[$dirid] as $d) {
$cells = array();
- $cells[][] = html_e('input', array('type' => 'checkbox', 'class' => 'checkeddocidactive', 'value' => $d->getID(), 'title' => _('Select / Deselect this document for massaction'), 'onClick' => 'controllerListTrash.checkgeneral("active")'));
+ $cells[][] = html_e('input', array('type' => 'checkbox', 'class' => 'checkeddocidactive', 'value' => $d->getID(), 'title' => _('Select / Deselect this document for massaction'), 'onClick' => 'controllerListFile.checkgeneral("active")'));
switch ($d->getFileType()) {
case 'URL': {
$cells[][] = util_make_link($d->getFileName(), html_image($d->getFileTypeImage(), '22', '22', array('alt' => $d->getFileType())), array('title' => _('Visit this link')));
$editfileaction .= '&group_id='.$GLOBALS['group_id'];
$nextcell = '';
$nextcell .= util_make_link($redirecturl.'&action=delfile&fileid='.$d->getID(), $HTML->getRemovePic(_('Delete permanently this document.'), 'delfile'));
- $nextcell .= util_make_link('#', html_image('docman/edit-file.png',22,22,array('alt'=>_('Edit this document'))), array('onclick' => 'javascript:controllerListTrash.toggleEditFileView({action:\''.util_make_uri($editfileaction).'\', lockIntervalDelay: 60000, childGroupId: '.util_ifsetor($childgroup_id, 0).' ,id:'.$d->getID().', groupId:'.$d->Group->getID().', docgroupId:'.$d->getDocGroupID().', statusId:'.$d->getStateID().', statusDict:'.$dm->getStatusNameList('json','2').', docgroupDict:'.$dm->getDocGroupList($newdgf->getNested(array(1, 5)), 'json').', title:\''.addslashes($d->getName()).'\', filename:\''.addslashes($d->getFilename()).'\', description:\''.addslashes($d->getDescription()).'\', isURL:\''.$d->isURL().'\', isText:\''.$d->isText().'\', useCreateOnline:'.$d->Group->useCreateOnline().', docManURL:\''.util_make_uri("docman").'\'})', 'title' => _('Edit this document')), true);
+ $nextcell .= util_make_link('#', $HTML->getEditFilePic(_('Edit this document'), 'editdocument'), array('onclick' => 'javascript:controllerListFile.toggleEditFileView({action:\''.util_make_uri($editfileaction).'\', lockIntervalDelay: 60000, childGroupId: '.util_ifsetor($childgroup_id, 0).' ,id:'.$d->getID().', groupId:'.$d->Group->getID().', docgroupId:'.$d->getDocGroupID().', statusId:'.$d->getStateID().', statusDict:'.$dm->getStatusNameList('json','2').', docgroupDict:'.$dm->getDocGroupList($newdgf->getNested(array(1, 5)), 'json').', isText:\''.$d->isText().'\', useCreateOnline:'.$d->Group->useCreateOnline().', docManURL:\''.util_make_uri("docman").'\'})', 'title' => _('Edit this document')), true);
$cells[][] = $nextcell;
echo $HTML->multiTableRow(array(), $cells);
}
echo html_ao('p');
echo html_ao('span', array('id' => 'massactionactive', 'class' => 'hide'));
echo html_e('span', array('id' => 'docman-massactionmessage', 'title' => _('Actions availables for selected documents, you need to check at least one document to get actions')), _('Mass actions for selected documents:'), false);
- echo util_make_link('#', $HTML->getRemovePic(_('Permanently Delete'), 'del'), array('onclick' => 'window.location.href=\''.util_make_uri($redirecturl.'&action=delfile&fileid=\'+controllerListTrash.buildUrlByCheckbox("active")')), true);
- echo util_make_link('#', html_image('docman/download-directory-zip.png', 22, 22, array('alt' => _('Download as a ZIP'))), array('onclick' => 'window.location.href=\''.util_make_uri('/docman/view.php/'.$group_id.'/zip/selected/\'+controllerListTrash.buildUrlByCheckbox("active")'), 'title' => _('Download as a ZIP')), true);
+ echo util_make_link('#', $HTML->getRemovePic(_('Permanently Delete'), 'del'), array('onclick' => 'window.location.href=\''.util_make_uri($redirecturl.'&action=delfile&fileid=\'+controllerListFile.buildUrlByCheckbox("active")')), true);
+ echo util_make_link('#', html_image('docman/download-directory-zip.png', 22, 22, array('alt' => _('Download as a ZIP'))), array('onclick' => 'window.location.href=\''.util_make_uri('/docman/view.php/'.$group_id.'/zip/selected/\'+controllerListFile.buildUrlByCheckbox("active")'), 'title' => _('Download as a ZIP')), true);
echo html_ac(html_ap() - 3);
} else {
if ($dirid) {
--- /dev/null
+CREATE TABLE doc_data_version (
+ serial_id SERIAL PRIMARY KEY,
+ version integer DEFAULT 1 NOT NULL,
+ docid integer REFERENCES doc_data ON DELETE CASCADE,
+ current_version integer DEFAULT 1 NOT NULL,
+ title character varying(255) DEFAULT ''::character varying NOT NULL,
+ updatedate integer DEFAULT 0 NOT NULL,
+ createdate integer DEFAULT 0 NOT NULL,
+ created_by integer DEFAULT 0 NOT NULL,
+ description text,
+ filename text,
+ filetype text,
+ filesize integer DEFAULT 0 NOT NULL,
+ data_words text DEFAULT ''::text NOT NULL
+);
+
+INSERT INTO doc_data_version (serial_id, docid, title, updatedate, createdate, created_by, description, filename, filetype, filesize, data_words)
+ (SELECT docid, docid, title, updatedate, createdate, created_by, description, filename, filetype, filesize, data_words FROM doc_data);
+
+SELECT setval('doc_data_version_serial_id_seq', (SELECT MAX(serial_id) from doc_data_version));
+
+DROP VIEW docdata_vw CASCADE;
+
+ALTER TABLE doc_data ADD COLUMN version integer DEFAULT 1 NOT NULL;
+UPDATE doc_data set version = 1;
+ALTER TABLE doc_data DROP COLUMN title;
+ALTER TABLE doc_data DROP COLUMN created_by;
+ALTER TABLE doc_data DROP COLUMN description;
+ALTER TABLE doc_data DROP COLUMN filename;
+ALTER TABLE doc_data DROP COLUMN filetype;
+ALTER TABLE doc_data DROP COLUMN filesize;
+ALTER TABLE doc_data DROP COLUMN data_words;
+
+CREATE VIEW docdata_vw AS
+ SELECT users.user_name, users.realname, users.email,
+ d.group_id, d.docid, d.stateid,
+ dv.title, dv.updatedate, d.createdate, dv.created_by, d.doc_group, dv.description,
+ dl.downloads AS download,
+ dv.filename, dv.filetype, dv.filesize, d.reserved, d.reserved_by, d.locked, d.locked_by, d.lockdate,
+ doc_states.name AS state_name, doc_groups.groupname AS group_name, dv.version, dv.serial_id
+ FROM doc_data d, users, doc_groups, doc_states, docman_dlstats_doctotal_agg dl, doc_data_version dv
+ WHERE dv.created_by = users.user_id
+ and doc_groups.doc_group = d.doc_group
+ and doc_states.stateid = d.stateid
+ and d.docid = dl.docid
+ and d.docid = dv.docid
+ and dv.current_version = 1;
+
+CREATE OR REPLACE VIEW activity_vw AS
+ SELECT
+ agl.group_id, 'trackeropen'::text AS section, agl.group_artifact_id AS ref_id,
+ a.artifact_id as subref_id, a.summary as description, a.open_date AS activity_date, u.user_id, u.user_name, u.realname
+ FROM artifact_group_list agl JOIN artifact a using (group_artifact_id),
+ users u WHERE u.user_id=a.submitted_by
+ UNION
+ SELECT
+ agl.group_id, 'trackerclose'::text AS section, agl.group_artifact_id AS ref_id,
+ a.artifact_id as subref_id, a.summary as description, a.close_date AS activity_date, u.user_id, u.user_name, u.realname
+ FROM artifact_group_list agl JOIN artifact a using (group_artifact_id), users u WHERE u.user_id=a.assigned_to
+--actually should join against
+ AND a.close_date > 0
+ UNION
+ SELECT
+ frsp.group_id, 'frsrelease'::text as section,frsp.package_id as ref_id,
+ frsr.release_id as subref_id, frsp.name::text||' - '||frsr.name::text AS description, frsr.release_date AS activity_date,
+ u.user_id, u.user_name, u.realname FROM frs_package frsp JOIN frs_release frsr USING (package_id), users u WHERE
+ u.user_id=frsr.released_by
+ UNION
+ SELECT
+ fgl.group_id, 'forumpost'::text as section,fgl.group_forum_id as ref_id, forum.msg_id
+ as subref_id, forum.subject AS description, forum.post_date AS activity_date, u.user_id,
+ u.user_name, u.realname FROM forum_group_list fgl JOIN forum USING (group_forum_id), users u WHERE
+ u.user_id=forum.posted_by
+ UNION
+ SELECT group_id, 'docmannew'::text AS section, doc_group AS ref_id, docid AS subref_id,
+ filename AS description, createdate AS activity_date, created_by as user_id,
+ user_name, realname FROM docdata_vw
+ UNION
+ SELECT group_id, 'docmanupdate'::text AS section, doc_group AS ref_id, docid AS subref_id,
+ filename AS description, updatedate AS activity_date, created_by as user_id,
+ user_name, realname FROM docdata_vw
+ UNION
+ SELECT doc_groups.group_id, 'docgroupnew'::text AS section, doc_groups.parent_doc_group AS ref_id, doc_groups.doc_group AS subref_id,
+ doc_groups.groupname AS description, doc_groups.createdate AS activity_date, doc_groups.created_by as user_id,
+ users.user_name, users.realname FROM doc_groups, users WHERE doc_groups.created_by = users.user_id
+ UNION
+ SELECT news_bytes.group_id,'news' AS section,news_bytes.id AS ref_id,news_bytes.forum_id AS subref_id,
+ news_bytes.summary AS description, news_bytes.post_date AS activity_date, u.user_id, u.user_name, u.realname
+ FROM news_bytes, users u WHERE u.user_id = news_bytes.submitted_by
+ UNION
+ SELECT pgl.group_id, 'taskopen'::text AS section, p.group_project_id AS ref_id,
+ p.project_task_id AS subref_id, p.summary AS description, p.last_modified_date AS activity_date,
+ u.user_id, u.user_name, u.realname
+ FROM project_task p
+ JOIN project_group_list pgl USING (group_project_id), users u
+ WHERE u.user_id = p.created_by AND p.status_id = 1
+ UNION
+ SELECT pgl.group_id, 'taskclose'::text AS section, p.group_project_id AS ref_id,p.project_task_id AS subref_id,
+ p.summary AS description, p.last_modified_date AS activity_date, u.user_id,
+ u.user_name, u.realname
+ FROM project_task p
+ JOIN project_group_list pgl USING (group_project_id), users u
+ WHERE u.user_id = p.created_by AND p.status_id = 2
+ UNION
+ SELECT pgl.group_id, 'taskdelete'::text AS section, p.group_project_id AS ref_id,
+ p.project_task_id AS subref_id, p.summary AS description, p.last_modified_date AS activity_date,
+ u.user_id, u.user_name, u.realname
+ FROM project_task p
+ JOIN project_group_list pgl USING (group_project_id), users u
+ WHERE u.user_id = p.created_by AND p.status_id = 3;
+
+ALTER TABLE doc_data_idx ADD COLUMN version integer;
+ALTER TABLE doc_data_words_idx ADD COLUMN version integer;
+
+CREATE OR REPLACE FUNCTION update_vectors() RETURNS TRIGGER AS '
+DECLARE
+table_name TEXT;
+BEGIN
+ table_name := TG_ARGV[0];
+ -- **** artifact table ****
+ IF table_name = ''artifact'' THEN
+ IF TG_OP = ''DELETE'' THEN
+ DELETE FROM artifact_idx WHERE artifact_id=OLD.artifact_id;
+ ELSE
+ DELETE FROM artifact_idx WHERE artifact_id=NEW.artifact_id;
+ INSERT INTO artifact_idx (SELECT a.artifact_id, to_tsvector(a.artifact_id::text) || to_tsvector(a.summary) || to_tsvector(a.details) || coalesce(ff_tsvector_agg(to_tsvector(am.body)), to_tsvector('''')) AS vectors FROM artifact a LEFT OUTER JOIN artifact_message am USING (artifact_id) WHERE a.artifact_id=NEW.artifact_id GROUP BY a.artifact_id, a.summary, a.details);
+ END IF;
+ -- **** artifact_message table ****
+ ELSIF table_name = ''artifact_message'' THEN
+ IF TG_OP = ''DELETE'' THEN
+ DELETE FROM artifact_idx WHERE artifact_id=OLD.artifact_id;
+ ELSE
+ DELETE FROM artifact_idx WHERE artifact_id=NEW.artifact_id;
+ INSERT INTO artifact_idx (SELECT a.artifact_id, to_tsvector(a.artifact_id::text) || to_tsvector(a.summary) || to_tsvector(a.details) || coalesce(ff_tsvector_agg(to_tsvector(am.body)), to_tsvector('''')) AS vectors FROM artifact a LEFT OUTER JOIN artifact_message am USING (artifact_id) WHERE a.artifact_id=NEW.artifact_id GROUP BY a.artifact_id, a.summary, a.details);
+ END IF;
+ -- **** doc_data_version table ****
+ ELSIF table_name = ''doc_data_version'' THEN
+ IF TG_OP = ''INSERT'' THEN
+ INSERT INTO doc_data_idx (docid, version, group_id, vectors) VALUES (NEW.docid, NEW.version, (select group_id from doc_data where docid = NEW.docid), to_tsvector(coalesce(NEW.title,'''') ||'' ''|| coalesce(NEW.description,'''')));
+ INSERT INTO doc_data_words_idx (docid, version, group_id, vectors) VALUES (NEW.docid, (select group_id from doc_data where docid = NEW.docid), to_tsvector(coalesce(NEW.title,'''') ||'' ''|| coalesce(NEW.description,'''') ||'' ''|| coalesce(NEW.filename,'''') ||'' ''|| coalesce(NEW.filetype,'''') ||'' ''|| coalesce(NEW.data_words,'''')));
+ ELSIF TG_OP = ''UPDATE'' THEN
+ UPDATE doc_data_idx SET group_id = (select group_id from doc_data where docid = NEW.docid), vectors=to_tsvector(coalesce(NEW.title,'''') ||'' ''|| coalesce(NEW.description,'''')) WHERE docid = NEW.docid and version = NEW.version;
+ UPDATE doc_data_words_idx SET group_id = (select group_id from doc_data where docid = NEW.docid), vectors=to_tsvector(coalesce(NEW.title,'''') ||'' ''|| coalesce(NEW.description,'''') ||'' ''|| coalesce(NEW.filename,'''') ||'' ''|| coalesce(NEW.filetype,'''') ||'' ''|| coalesce(NEW.data_words,'''')) WHERE docid = NEW.docid and version = NEW.version;
+ ELSIF TG_OP = ''DELETE'' THEN
+ DELETE FROM doc_data_idx WHERE version = OLD.version;
+ DELETE FROM doc_data_words_idx WHERE version = OLD.version;
+ END IF;
+ -- **** forum table ****
+ ELSIF table_name = ''forum'' THEN
+ IF TG_OP = ''INSERT'' THEN
+ INSERT INTO forum_idx (msg_id, group_id, vectors) (SELECT f.msg_id, g.group_id, to_tsvector(coalesce(f.subject,'''') ||'' ''||
+ coalesce(f.body,'''')) AS vectors FROM forum f, forum_group_list g WHERE f.group_forum_id = g.group_forum_id AND f.msg_id = NEW.msg_id);
+ ELSIF TG_OP = ''UPDATE'' THEN
+ UPDATE forum_idx SET vectors=to_tsvector(coalesce(NEW.subject,'''') ||'' ''|| coalesce(NEW.body,'''')) WHERE msg_id=NEW.msg_id;
+ ELSIF TG_OP = ''DELETE'' THEN
+ DELETE FROM forum_idx WHERE msg_id=OLD.msg_id;
+ END IF;
+ -- **** frs_file table ****
+ ELSIF table_name = ''frs_file'' THEN
+ IF TG_OP = ''INSERT'' THEN
+ INSERT INTO frs_file_idx (file_id, release_id, vectors) VALUES (NEW.file_id, NEW.release_id, to_tsvector(coalesce(NEW.filename,'''')));
+ ELSIF TG_OP = ''UPDATE'' THEN
+ UPDATE frs_file_idx SET vectors=to_tsvector(coalesce(NEW.filename,'''')), release_id=NEW.release_id WHERE file_id=NEW.file_id;
+ ELSIF TG_OP = ''DELETE'' THEN
+ DELETE FROM frs_file_idx WHERE file_id=OLD.file_id;
+ END IF;
+ -- **** frs_release table ****
+ ELSIF table_name = ''frs_release'' THEN
+ IF TG_OP = ''INSERT'' THEN
+ INSERT INTO frs_release_idx (release_id, vectors) VALUES (NEW.release_id, to_tsvector(coalesce(NEW.changes,'''') ||'' ''|| coalesce(NEW.notes,'''') ||'' ''|| coalesce(NEW.name,'''')));
+ ELSIF TG_OP = ''UPDATE'' THEN
+ UPDATE frs_release_idx SET vectors=to_tsvector(coalesce(NEW.changes,'''') ||'' ''|| coalesce(NEW.notes,'''') ||'' ''|| coalesce(NEW.name,'''')) WHERE release_id=NEW.release_id;
+ ELSIF TG_OP = ''DELETE'' THEN
+ DELETE FROM frs_release_idx WHERE release_id=OLD.release_id;
+ DELETE FROM frs_file_idx WHERE release_id=OLD.release_id;
+ END IF;
+ -- **** groups table ****
+ ELSIF table_name = ''groups'' THEN
+ IF TG_OP = ''DELETE'' THEN
+ DELETE FROM groups_idx WHERE group_id=OLD.group_id;
+ ELSE
+ DELETE FROM groups_idx WHERE group_id=NEW.group_id;
+ INSERT INTO groups_idx (group_id, vectors) (SELECT g.group_id, to_tsvector(coalesce(g.group_name,'''') ||'' ''|| coalesce(g.short_description,'''') ||'' ''|| coalesce(g.unix_group_name,'''')||'' ''|| coalesce(ff_tsvector_agg(to_tsvector(t.name)),to_tsvector(''''))) FROM groups g LEFT OUTER JOIN project_tags t USING (group_id) WHERE g.group_id = NEW.group_id GROUP BY g.group_id ORDER BY g.group_id);
+ END IF;
+ -- **** news_bytes table ****
+ ELSIF table_name = ''news_bytes'' THEN
+ IF TG_OP = ''INSERT'' THEN
+ INSERT INTO news_bytes_idx (id, vectors) VALUES (NEW.id, to_tsvector(coalesce(NEW.summary,'''') ||'' ''|| coalesce(NEW.details,'''')));
+ ELSIF TG_OP = ''UPDATE'' THEN
+ UPDATE news_bytes_idx SET vectors=to_tsvector(coalesce(NEW.summary,'''') ||'' ''|| coalesce(NEW.details,'''')) WHERE id=NEW.id;
+ ELSIF TG_OP = ''DELETE'' THEN
+ DELETE FROM news_bytes_idx WHERE id=OLD.id;
+ END IF;
+ -- **** project_task table ****
+ ELSIF table_name = ''project_task'' THEN
+ IF TG_OP = ''DELETE'' THEN
+ DELETE FROM project_task_idx WHERE project_task_id=OLD.project_task_id;
+ ELSE
+ DELETE FROM project_task_idx WHERE project_task_id=NEW.project_task_id;
+ INSERT INTO project_task_idx (SELECT t.project_task_id, to_tsvector(t.project_task_id::text) || to_tsvector(t.summary) || to_tsvector(t.details) || coalesce(ff_tsvector_agg(to_tsvector(tm.body)), to_tsvector('''')) AS vectors FROM project_task t LEFT OUTER JOIN project_messages tm USING (project_task_id) WHERE t.project_task_id=NEW.project_task_id GROUP BY t.project_task_id, t.summary, t.details);
+ END IF;
+ -- **** project_messages table ****
+ ELSIF table_name = ''project_messages'' THEN
+ IF TG_OP = ''DELETE'' THEN
+ DELETE FROM project_task_idx WHERE project_task_id=OLD.project_task_id;
+ ELSE
+ DELETE FROM project_task_idx WHERE project_task_id=NEW.project_task_id;
+ INSERT INTO project_task_idx (SELECT t.project_task_id, to_tsvector(t.summary) || to_tsvector(t.details) || coalesce(ff_tsvector_agg(to_tsvector(tm.body)), to_tsvector('''')) AS vectors FROM project_task t LEFT OUTER JOIN project_messages tm USING (project_task_id) WHERE t.project_task_id=NEW.project_task_id GROUP BY t.project_task_id, t.summary, t.details);
+ END IF;
+ -- **** skills_data table ****
+ ELSIF table_name = ''skills_data'' THEN
+ IF TG_OP = ''INSERT'' THEN
+ INSERT INTO skills_data_idx (skills_data_id, vectors) VALUES (NEW.skills_data_id, to_tsvector(coalesce(NEW.title,'''') ||'' ''|| coalesce(NEW.keywords,'''')));
+ ELSIF TG_OP = ''UPDATE'' THEN
+ UPDATE skills_data_idx SET vectors=to_tsvector(coalesce(NEW.title,'''') ||'' ''|| coalesce(NEW.keywords,'''')) WHERE skills_data_id=NEW.skills_data_id;
+ ELSIF TG_OP = ''DELETE'' THEN
+ DELETE FROM skills_data_idx WHERE skills_data_id=OLD.skills_data_id;
+ END IF;
+ -- **** users table ****
+ ELSIF table_name = ''users'' THEN
+ IF TG_OP = ''INSERT'' THEN
+ INSERT INTO users_idx (user_id, vectors) VALUES (NEW.user_id, to_tsvector(coalesce(NEW.user_name,'''') ||'' ''|| coalesce(NEW.realname,'''')));
+ ELSIF TG_OP = ''UPDATE'' THEN
+ UPDATE users_idx SET vectors=to_tsvector(coalesce(NEW.user_name,'''') ||'' ''|| coalesce(NEW.realname,'''')) WHERE user_id=NEW.user_id;
+ ELSIF TG_OP = ''DELETE'' THEN
+ DELETE FROM users_idx WHERE user_id=OLD.user_id;
+ END IF;
+ END IF;
+
+ RETURN NEW;
+END;'
+LANGUAGE 'plpgsql';
+
+CREATE OR REPLACE FUNCTION rebuild_fti_indices() RETURNS void AS $$
+BEGIN
+ UPDATE groups SET short_description=short_description;
+ UPDATE artifact SET summary=summary;
+ UPDATE artifact_message SET body=body;
+ UPDATE doc_data_version SET title=title;
+ UPDATE forum SET subject=subject;
+ UPDATE frs_file SET filename=filename;
+ UPDATE frs_release SET name=name;
+ UPDATE news_bytes SET summary=summary;
+ UPDATE project_task SET summary=summary;
+ UPDATE project_messages SET body=body;
+ UPDATE skills_data SET keywords=keywords;
+ UPDATE users SET realname=realname;
+END;
+$$ LANGUAGE 'plpgsql';
+
+-- Rebuild all indices
+SELECT rebuild_fti_indices();
* Copyright 2002-2003, Tim Perdue/GForge, LLC
* Copyright 2010-2011, Franck Villaume - Capgemini
* Copyright (C) 2010-2011 Alain Peyrat - Alcatel-Lucent
- * Copyright 2012-2015, Franck Villaume - TrivialDev
+ * Copyright 2012-2016, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
require_once $gfcommon.'docman/DocumentManager.class.php';
require_once $gfcommon.'docman/Document.class.php';
require_once $gfcommon.'docman/DocumentFactory.class.php';
+require_once $gfcommon.'docman/DocumentVersion.class.php';
+require_once $gfcommon.'docman/DocumentVersionFactory.class.php';
require_once $gfcommon.'docman/DocumentGroup.class.php';
require_once $gfcommon.'docman/DocumentGroupFactory.class.php';
require_once $gfcommon.'docman/include/utils.php';
$childgroup_id = getIntFromRequest('childgroup_id');
-/* everything sounds ok, now let do the job */
+/* everything sounds ok, now let's do the job */
$action = getStringFromRequest('action');
if (file_exists(forge_get_config('source_path').'/common/docman/actions/'.$action.'.php')) {
include(forge_get_config('source_path').'/common/docman/actions/'.$action.'.php');
*
* Copyright 2010, Antoine Mercadal - Capgemini
* Copyright 2010-2011, Franck Villaume - Capgemini
- * Copyright 2011-2015, Franck Villaume - TrivialDev
* Copyright 2011, Alain Peyrat
+ * Copyright 2011-2016, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
DocManListFileController = function(params)
{
this.lockInterval = [];
- this.params = params;
+ this.listfileparams = params;
this.bindControls();
- if (this.params.enableResize) {
+ if (this.listfileparams.enableResize) {
this.resizableDiv();
}
this.initModalEditWindow();
DocManAddItemController = function(params)
{
- this.params = params;
+ this.additemparams = params;
this.bindControls();
};
DocManAddFileController = function(params)
{
- this.params = params;
+ this.addfileparams = params;
this.bindControls();
};
DocManSearchController = function(params)
{
- this.params = params;
+ this.searchparams = params;
this.bindControls();
};
/*! Binds the controls to the actions
*/
bindControls: function() {
- if (typeof(this.params.buttonAddItem) != 'undefined') {
- this.params.buttonAddItem.click(jQuery.proxy(this, "toggleAddItemView"));
+ if (typeof(this.listfileparams.buttonAddItem) != 'undefined') {
+ this.listfileparams.buttonAddItem.click(jQuery.proxy(this, "toggleAddItemView"));
}
},
var storedSplitterPosition = jQuery.Storage.get('splitterStyle').replace(/px;?/g, '').replace(/left: /g, '');
splitterPosition = Math.round(storedSplitterPosition * 100 / mainwidth )+'%';
}
- if (this.params.page == 'trashfile') {
- (this.params.divLeft.outerHeight() > this.params.divRight.outerHeight()) ? mainheight = this.params.divLeft.outerHeight() : mainheight = this.params.divRight.outerHeight();
+ if (this.listfileparams.page == 'trashfile') {
+ (this.listfileparams.divLeft.outerHeight() > this.listfileparams.divRight.outerHeight()) ? mainheight = this.listfileparams.divLeft.outerHeight() : mainheight = this.listfileparams.divRight.outerHeight();
} else {
var fixwidth = -40;
if (jQuery('#editFile').length >= 1) {
fixwidth += jQuery('#notifyUsers').outerHeight() - jQuery('[aria-describedby="notifyUsers"]').outerHeight();
}
var totalRightHeight = 0;
- this.params.divRight.children().each(function() {
+ this.listfileparams.divRight.children().each(function() {
if (jQuery(this).is(':visible')) {
totalRightHeight += jQuery(this).outerHeight();
}
});
totalRightHeight -= fixwidth;
- (this.params.divRight.outerHeight() - fixwidth < 0) ? useRightHeight = this.params.divRight.outerHeight() : useRightHeight = this.params.divRight.outerHeight() - fixwidth;
+ (this.listfileparams.divRight.outerHeight() - fixwidth < 0) ? useRightHeight = this.listfileparams.divRight.outerHeight() : useRightHeight = this.listfileparams.divRight.outerHeight() - fixwidth;
(useRightHeight < totalRightHeight) ? useRightHeight = totalRightHeight : useRightHeight ;
- (this.params.divLeft.outerHeight() + 30 > this.params.divRight.outerHeight()) ? mainheight = this.params.divLeft.outerHeight() + 30 : mainheight = useRightHeight;
+ (this.listfileparams.divLeft.outerHeight() + 30 > this.listfileparams.divRight.outerHeight()) ? mainheight = this.listfileparams.divLeft.outerHeight() + 30 : mainheight = useRightHeight;
}
jQuery('#views').height(mainheight)
.split({orientation:'vertical', limit:100, position: splitterPosition});
},
initModalEditWindow: function() {
- var modalId = this.params.divEditFile;
+ var modalId = this.listfileparams.divEditFile;
jQuery(modalId).dialog({
autoOpen: false,
- width: 475,
+ width: 800,
modal: true,
- title: this.params.divEditTitle,
+ title: this.listfileparams.divEditTitle,
buttons: {
Save: jQuery.proxy(function() {
jQuery('#editdocdata').submit();
var id = jQuery('#docid').attr('value');
- jQuery.get(this.params.docManURL+'/', {
- group_id: this.params.groupId,
+ jQuery.get(this.listfileparams.docManURL+'/', {
+ group_id: this.listfileparams.groupId,
action: 'lock',
lock: 0,
itemid: id,
type: 'file',
- childgroup_id: this.params.childGroupId
+ childgroup_id: this.listfileparams.childGroupId
});
- jQuery.get(this.params.docManURL+'/', {
- group_id: this.params.groupId,
+ jQuery.get(this.listfileparams.docManURL+'/', {
+ group_id: this.listfileparams.groupId,
action: 'lock',
lock: 0,
- itemid: this.params.docgroupId,
+ itemid: this.listfileparams.docgroupId,
type: 'dir',
- childgroup_id: this.params.childGroupId
+ childgroup_id: this.listfileparams.childGroupId
});
clearInterval(this.lockInterval[id]);
- clearInterval(this.lockInterval[this.params.docgroupId]);
+ clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
jQuery(modalId).dialog( "close" );
}, this),
Cancel: jQuery.proxy(function() {
var id = jQuery('#docid').attr('value');
- jQuery.get(this.params.docManURL+'/', {
- group_id: this.params.groupId,
+ jQuery.get(this.listfileparams.docManURL+'/', {
+ group_id: this.listfileparams.groupId,
action: 'lock',
lock: 0,
itemid: id,
type: 'file',
- childgroup_id: this.params.childGroupId
+ childgroup_id: this.listfileparams.childGroupId
});
- jQuery.get(this.params.docManURL+'/', {
- group_id: this.params.groupId,
+ jQuery.get(this.listfileparams.docManURL+'/', {
+ group_id: this.listfileparams.groupId,
action: 'lock',
lock: 0,
- itemid: this.params.docgroupId,
+ itemid: this.listfileparams.docgroupId,
type: 'dir',
- childgroup_id: this.params.childGroupId
+ childgroup_id: this.listfileparams.childGroupId
});
clearInterval(this.lockInterval[id]);
- clearInterval(this.lockInterval[this.params.docgroupId]);
+ clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
jQuery(modalId).dialog('close');
}, this)
}
});
jQuery(modalId).bind('dialogclose', jQuery.proxy(function() {
var id = jQuery('#docid').attr('value');
- jQuery.get(this.params.docManURL+'/', {
- group_id: this.params.groupId,
+ jQuery.get(this.listfileparams.docManURL+'/', {
+ group_id: this.listfileparams.groupId,
action: 'lock',
lock: 0,
itemid: id,
type: 'file',
- childgroup_id: this.params.childGroupId
+ childgroup_id: this.listfileparams.childGroupId
});
- jQuery.get(this.params.docManURL+'/', {
- group_id: this.params.groupId,
+ jQuery.get(this.listfileparams.docManURL+'/', {
+ group_id: this.listfileparams.groupId,
action: 'lock',
lock: 0,
- itemid: this.params.docgroupId,
+ itemid: this.listfileparams.docgroupId,
type: 'dir',
- childgroup_id: this.params.childGroupId
+ childgroup_id: this.listfileparams.childGroupId
});
clearInterval(this.lockInterval[id]);
- clearInterval(this.lockInterval[this.params.docgroupId]);
+ clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
}, this));
},
initModelNotifyWindow: function() {
- var modalId = this.params.divNotifyUsers;
+ var modalId = this.listfileparams.divNotifyUsers;
jQuery(modalId).dialog({
autoOpen: false,
width: 475,
modal: true,
- title: this.params.divNotifyTitle,
+ title: this.listfileparams.divNotifyTitle,
buttons: {
- Save: { text: this.params.divNotifySaveButtonTxt,
+ Save: { text: this.listfileparams.divNotifySaveButtonTxt,
click: jQuery.proxy(function() {
jQuery('#notifyusersdoc').submit();
var id = jQuery('#notifydocid').attr('value');
- jQuery.get(this.params.docManURL+'/', {
- group_id: this.params.groupId,
+ jQuery.get(this.listfileparams.docManURL+'/', {
+ group_id: this.listfileparams.groupId,
action: 'lock',
lock: 0,
itemid: id,
type: 'file',
- childgroup_id: this.params.childGroupId
+ childgroup_id: this.listfileparams.childGroupId
});
- jQuery.get(this.params.docManURL+'/', {
- group_id: this.params.groupId,
+ jQuery.get(this.listfileparams.docManURL+'/', {
+ group_id: this.listfileparams.groupId,
action: 'lock',
lock: 0,
- itemid: this.params.docgroupId,
+ itemid: this.listfileparams.docgroupId,
type: 'dir',
- childgroup_id: this.params.childGroupId
+ childgroup_id: this.listfileparams.childGroupId
});
clearInterval(this.lockInterval[id]);
- clearInterval(this.lockInterval[this.params.docgroupId]);
+ clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
jQuery(modalId).dialog( "close" );
}, this)},
Cancel: jQuery.proxy(function() {
var id = jQuery('#notifydocid').attr('value');
- jQuery.get(this.params.docManURL+'/', {
- group_id: this.params.groupId,
+ jQuery.get(this.listfileparams.docManURL+'/', {
+ group_id: this.listfileparams.groupId,
action: 'lock',
lock: 0,
itemid: id,
type: 'file',
- childgroup_id: this.params.childGroupId
+ childgroup_id: this.listfileparams.childGroupId
});
- jQuery.get(this.params.docManURL+'/', {
- group_id: this.params.groupId,
+ jQuery.get(this.listfileparams.docManURL+'/', {
+ group_id: this.listfileparams.groupId,
action: 'lock',
lock: 0,
- itemid: this.params.docgroupId,
+ itemid: this.listfileparams.docgroupId,
type: 'dir',
- childgroup_id: this.params.childGroupId
+ childgroup_id: this.listfileparams.childGroupId
});
clearInterval(this.lockInterval[id]);
- clearInterval(this.lockInterval[this.params.docgroupId]);
+ clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
jQuery(modalId).dialog('close');
}, this)
}
});
jQuery(modalId).bind('dialogclose', jQuery.proxy(function() {
var id = jQuery('#notifydocid').attr('value');
- jQuery.get(this.params.docManURL+'/', {
- group_id: this.params.groupId,
+ jQuery.get(this.listfileparams.docManURL+'/', {
+ group_id: this.listfileparams.groupId,
action: 'lock',
lock: 0,
itemid: id,
type: 'file',
- childgroup_id: this.params.childGroupId
+ childgroup_id: this.listfileparams.childGroupId
});
- jQuery.get(this.params.docManURL+'/', {
- group_id: this.params.groupId,
+ jQuery.get(this.listfileparams.docManURL+'/', {
+ group_id: this.listfileparams.groupId,
action: 'lock',
lock: 0,
- itemid: this.params.docgroupId,
+ itemid: this.listfileparams.docgroupId,
type: 'dir',
- childgroup_id: this.params.childGroupId
+ childgroup_id: this.listfileparams.childGroupId
});
clearInterval(this.lockInterval[id]);
- clearInterval(this.lockInterval[this.params.docgroupId]);
+ clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
}, this));
},
/*! toggle edit group view div visibility
*/
toggleEditDirectoryView: function() {
- if (!this.params.divEditDirectory.is(":visible")) {
- jQuery.getJSON(this.params.docManURL + '/?group_id=' + this.params.groupId + '&action=lock&json=1&type=dir&itemid=' + this.params.docgroupId, jQuery.proxy(function(data){
+ if (!this.listfileparams.divEditDirectory.is(":visible")) {
+ jQuery.getJSON(this.listfileparams.docManURL + '/?group_id='+this.listfileparams.groupId+'&action=lock&json=1&type=dir&itemid='+this.listfileparams.docgroupId, jQuery.proxy(function(data){
if (typeof data.html != 'undefined') {
jQuery('#maindiv > .feedback').remove();
jQuery('#maindiv > .error').remove();
jQuery('#maindiv > .warning_msg').remove();
jQuery('#maindiv').prepend(data.html);
} else {
- this.params.divEditDirectory.show();
- if (typeof(this.params.divAddItem) != 'undefined') {
- this.params.divAddItem.hide();
+ this.listfileparams.divEditDirectory.show();
+ if (typeof(this.listfileparams.divAddItem) != 'undefined') {
+ this.listfileparams.divAddItem.hide();
}
- computeHeight = this.params.divRight.outerHeight() + this.params.divEditDirectory.outerHeight();
- currentLeftHeight = this.params.divLeft.outerHeight();
- this.params.divLeft.height(currentLeftHeight + this.params.divEditDirectory.outerHeight());
- jQuery.get(this.params.docManURL+'/', {
- group_id: this.params.groupId,
+ computeHeight = this.listfileparams.divRight.outerHeight() + this.listfileparams.divEditDirectory.outerHeight();
+ currentLeftHeight = this.listfileparams.divLeft.outerHeight();
+ this.listfileparams.divLeft.height(currentLeftHeight + this.listfileparams.divEditDirectory.outerHeight());
+ jQuery.get(this.listfileparams.docManURL+'/', {
+ group_id: this.listfileparams.groupId,
action: 'lock',
lock: 1,
type: 'dir',
- itemid: this.params.docgroupId,
- childgroup_id: this.params.childGroupId
+ itemid: this.listfileparams.docgroupId,
+ childgroup_id: this.listfileparams.childGroupId
});
- this.lockInterval[this.params.docgroupId] = setInterval("jQuery.get('" + this.params.docManURL + "/', {group_id:"+this.params.groupId+",action:'lock',lock:1,type:'dir',itemid:"+this.params.docgroupId+",childgroup_id:"+this.params.childGroupId+"})", this.params.lockIntervalDelay);
- if (typeof(this.params.divLeft) != 'undefined' && typeof(this.params.divRight) != 'undefined') {
- if (this.params.divLeft.outerHeight() > computeHeight) {
- jQuery('#views').height(this.params.divLeft.outerHeight());
+ this.lockInterval[this.listfileparams.docgroupId] = setInterval("jQuery.get('" + this.listfileparams.docManURL + "/', {group_id:"+this.listfileparams.groupId+", action:'lock', lock:1, type:'dir', itemid:"+this.listfileparams.docgroupId+", childgroup_id:"+this.listfileparams.childGroupId+"})", this.listfileparams.lockIntervalDelay);
+ if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
+ if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
+ jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
} else {
jQuery('#views').height(computeHeight);
}
}
}, this));
} else {
- this.params.divEditDirectory.hide();
- computeHeight = this.params.divRight.outerHeight() - this.params.divEditDirectory.outerHeight();
- currentLeftHeight = this.params.divLeft.outerHeight();
- this.params.divLeft.height(currentLeftHeight - this.params.divEditDirectory.outerHeight());
- jQuery.get(this.params.docManURL+'/', {
- group_id: this.params.groupId,
+ this.listfileparams.divEditDirectory.hide();
+ computeHeight = this.listfileparams.divRight.outerHeight() - this.listfileparams.divEditDirectory.outerHeight();
+ currentLeftHeight = this.listfileparams.divLeft.outerHeight();
+ this.listfileparams.divLeft.height(currentLeftHeight - this.listfileparams.divEditDirectory.outerHeight());
+ jQuery.get(this.listfileparams.docManURL+'/', {
+ group_id: this.listfileparams.groupId,
action: 'lock',
lock: 0,
type: 'dir',
- itemid: this.params.docgroupId,
- childgroup_id: this.params.childGroupId
+ itemid: this.listfileparams.docgroupId,
+ childgroup_id: this.listfileparams.childGroupId
});
- clearInterval(this.lockInterval[this.params.docgroupId]);
- if (typeof(this.params.divLeft) != 'undefined' && typeof(this.params.divRight) != 'undefined') {
- if (this.params.divLeft.outerHeight() > computeHeight) {
- jQuery('#views').height(this.params.divLeft.outerHeight());
+ clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
+ if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
+ if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
+ jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
} else {
jQuery('#views').height(computeHeight);
}
/*! toggle add item view div visibility
*/
toggleAddItemView: function() {
- if (!this.params.divAddItem.is(":visible")) {
- jQuery.getJSON(this.params.docManURL + '/?group_id=' + this.params.groupId + '&action=lock&json=1&type=dir&itemid=' + this.params.docgroupId, jQuery.proxy(function(data){
+ if (!this.listfileparams.divAddItem.is(":visible")) {
+ jQuery.getJSON(this.listfileparams.docManURL + '/?group_id='+this.listfileparams.groupId+'&action=lock&json=1&type=dir&itemid='+this.listfileparams.docgroupId, jQuery.proxy(function(data){
if (typeof data.html != 'undefined') {
jQuery('#maindiv > .feedback').remove();
jQuery('#maindiv > .error').remove();
jQuery('#maindiv > .warning_msg').remove();
jQuery('#maindiv').prepend(data.html);
} else {
- jQuery.get(this.params.docManURL+'/', {
- group_id: this.params.groupId,
+ jQuery.get(this.listfileparams.docManURL+'/', {
+ group_id: this.listfileparams.groupId,
action: 'lock',
lock: 1,
type: 'dir',
- itemid: this.params.docgroupId,
- childgroup_id: this.params.childGroupId
+ itemid: this.listfileparams.docgroupId,
+ childgroup_id: this.listfileparams.childGroupId
});
- this.lockInterval[this.params.docgroupId] = setInterval("jQuery.get('" + this.params.docManURL + "/', {group_id:"+this.params.groupId+",action:'lock',lock:1,type:'dir',itemid:"+this.params.docgroupId+",childgroup_id:"+this.params.childGroupId+"})",this.params.lockIntervalDelay);
- this.params.divAddItem.show();
- this.params.divEditDirectory.hide();
- computeHeight = this.params.divRight.outerHeight() + jQuery(this.params.divAddItem).outerHeight();
- currentLeftHeight = this.params.divLeft.outerHeight();
- this.params.divLeft.height(currentLeftHeight + jQuery(this.params.divAddItem).outerHeight());
- if (typeof(this.params.divLeft) != 'undefined' && typeof(this.params.divRight) != 'undefined') {
- if (this.params.divLeft.outerHeight() > computeHeight) {
- jQuery('#views').height(this.params.divLeft.outerHeight());
+ this.lockInterval[this.listfileparams.docgroupId] = setInterval("jQuery.get('"+this.listfileparams.docManURL+"/', {group_id:"+this.listfileparams.groupId+", action:'lock', lock:1, type:'dir', itemid:"+this.listfileparams.docgroupId+", childgroup_id:"+this.listfileparams.childGroupId+"})", this.listfileparams.lockIntervalDelay);
+ this.listfileparams.divAddItem.show();
+ this.listfileparams.divEditDirectory.hide();
+ computeHeight = this.listfileparams.divRight.outerHeight() + jQuery(this.listfileparams.divAddItem).outerHeight();
+ currentLeftHeight = this.listfileparams.divLeft.outerHeight();
+ this.listfileparams.divLeft.height(currentLeftHeight + jQuery(this.listfileparams.divAddItem).outerHeight());
+ if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
+ if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
+ jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
} else {
jQuery('#views').height(computeHeight);
}
}
}, this));
} else {
- jQuery.get(this.params.docManURL+'/', {
- group_id: this.params.groupId,
+ jQuery.get(this.listfileparams.docManURL+'/', {
+ group_id: this.listfileparams.groupId,
action: 'lock',
lock: 0,
type: 'dir',
- itemid: this.params.docgroupId,
- childgroup_id: this.params.childGroupId
+ itemid: this.listfileparams.docgroupId,
+ childgroup_id: this.listfileparams.childGroupId
});
- clearInterval(this.lockInterval[this.params.docgroupId]);
- this.params.divAddItem.hide();
- computeHeight = this.params.divRight.outerHeight() - jQuery(this.params.divAddItem).outerHeight();
- currentLeftHeight = this.params.divLeft.outerHeight();
- this.params.divLeft.height(currentLeftHeight - jQuery(this.params.divAddItem).outerHeight());
- if (typeof(this.params.divLeft) != 'undefined' && typeof(this.params.divRight) != 'undefined') {
- if (this.params.divLeft.outerHeight() > computeHeight) {
- jQuery('#views').height(this.params.divLeft.outerHeight());
+ clearInterval(this.lockInterval[this.listfileparams.docgroupId]);
+ this.listfileparams.divAddItem.hide();
+ computeHeight = this.listfileparams.divRight.outerHeight() - jQuery(this.listfileparams.divAddItem).outerHeight();
+ currentLeftHeight = this.listfileparams.divLeft.outerHeight();
+ this.listfileparams.divLeft.height(currentLeftHeight - jQuery(this.listfileparams.divAddItem).outerHeight());
+ if (typeof(this.listfileparams.divLeft) != 'undefined' && typeof(this.listfileparams.divRight) != 'undefined') {
+ if (this.listfileparams.divLeft.outerHeight() > computeHeight) {
+ jQuery('#views').height(this.listfileparams.divLeft.outerHeight());
} else {
jQuery('#views').height(computeHeight);
}
/*! toggle add file edit view div visibility and play with lock
*
- * @param docparams array
+ * @param params array
*/
- toggleEditFileView: function(docparams) {
- this.docparams = docparams;
- jQuery('#title').val(this.docparams.title);
- jQuery('#description').val(this.docparams.description);
- jQuery('#docid').val(this.docparams.id);
- if (this.docparams.isHtml) {
- jQuery('#defaulteditfiletype').val('text/html');
- }
- if (this.docparams.isText && ! this.docparams.isHtml) {
- jQuery('#defaulteditfiletype').val('text/plain');
- }
- if (this.docparams.isURL) {
- jQuery('#uploadnewroweditfile').hide();
- jQuery('#fileurlroweditfile').show();
- jQuery('#fileurlroweditfile').find('input').attr('required', 'required');
- jQuery('#fileurlroweditfile').find('input').val(this.docparams.filename);
- } else {
- jQuery('#fileurlroweditfile').hide();
- jQuery('#uploadnewroweditfile').show();
- }
- if (!this.docparams.useCreateOnline || !this.docparams.isText) {
- jQuery('#editonlineroweditfile').hide();
- jQuery('#editor').attr('disabled', true);
- }
- jQuery('#filelink').text(this.docparams.filename);
- if (this.docparams.statusId != 2) {
- if (this.docparams.isURL) {
- jQuery('#filelink').attr('href', this.docparams.filename);
- } else {
- jQuery('#filelink').attr('href', this.docparams.docManURL + '/view.php/' + this.docparams.groupId + '/' + this.docparams.id + '/' + this.docparams.filename);
- }
- }
+ toggleEditFileView: function(params) {
+ this.docparams = params;
+ this.listfileparams.tableAddVersion.hide();
jQuery('#doc_group').empty();
for (var i = 0; i < this.docparams.docgroupDict.length; i++) {
- jQuery('#doc_group').append(jQuery("<option>").text(this.docparams.docgroupDict[i][1]).attr("value",this.docparams.docgroupDict[i][0]));
+ jQuery('#doc_group').append(jQuery('<option>').text(this.docparams.docgroupDict[i][1]).attr('value', this.docparams.docgroupDict[i][0]));
};
jQuery('#doc_group option[value='+this.docparams.docgroupId+']').attr('selected', 'selected');
jQuery('#stateid').empty();
jQuery('#stateid').append(jQuery('<option>').text(key).attr('value',value));
});
jQuery('#stateid option[value='+this.docparams.statusId+']').attr('selected', 'selected');
- if (this.docparams.isText) {
- jQuery.getJSON(this.docparams.docManURL + '/?group_id=' + this.docparams.groupId + '&action=getfile&type=file&itemid=' + this.docparams.id , jQuery.proxy(function(data){
- if (data) {
- jQuery('#defaulteditzone').text(data.body);
+ jQuery('#docid').val(this.docparams.id);
+ var docid_groupid = this.listfileparams.groupId;
+ if (this.listfileparams.childGroupId != 0) {
+ docid_groupid = this.listfileparams.childGroupId;
+ }
+ jQuery.getJSON(this.listfileparams.docManURL + '/?group_id=' + docid_groupid + '&action=getdocversions&docid='+ this.docparams.id, jQuery.proxy(function(data){
+ if (typeof data.html != 'undefined') {
+ jQuery('#editFile > .feedback').remove();
+ jQuery('#editFile > .error').remove();
+ jQuery('#editFile > .warning_msg').remove();
+ jQuery('#editFile').prepend(data.html);
+ } else {
+ jQuery('#sortable_doc_version_table > tbody').children().remove();
+ eachdocparams = this.docparams;
+ jQuery.each(data, function (i, val) {
+ //_('Current'), _('Filename'), _('Title'), _('Description'), _('Author'), _('Last Time'), _('Size'), _('Actions'));
+ currenttdcontent = jQuery('<input id="doc_version_cv_radio" name="doc_version_cv_radio" type="checkbox" value="'+val.version+'" onclick="return false" >');
+ if (val.current_version == 1) {
+ currenttdcontent.attr('checked', 'checked');
+ }
+ if (eachdocparams.statusId != 2) {
+ filenametdcontent = jQuery('<a>'+val.filename+'</a>');
+ if (val.filetype == 'URL') {
+
+ filenametdcontent.attr('href', val.filename);
+ } else {
+ filenametdcontent.attr('href', eachdocparams.docManURL+'/view.php/'+eachdocparams.groupId+'/versions/'+eachdocparams.id+'/'+val.version);
+ }
+ } else {
+ filenametdcontent = val.filename;
+ }
+ versionactiontdcontent = '';
+ versionActionsArrayLength = val.versionactions.length;
+ for (var i = 0; i < versionActionsArrayLength; i++) {
+ versionactiontdcontent += val.versionactions[i];
+ }
+ var htmlString = '<tr id="docversion'+val.version+'" ><td>'+currenttdcontent[0].outerHTML+'</td><td>'+filenametdcontent[0].outerHTML+'</td><td>'+val.title+'</td><td>'+val.description+'</td><td>'+val.created_by_username+'</td><td>'+val.lastdate+'</td><td>'+val.filesize_readable+'</td><td>'+versionactiontdcontent+'</td></tr>'
+ jQuery('#sortable_doc_version_table > tbody:last-child').append(htmlString);
+ });
}
}, this));
- }
+
jQuery('#editdocdata').attr('action', this.docparams.action);
jQuery.get(this.docparams.docManURL+'/', {
itemid: this.docparams.docgroupId,
childgroup_id: this.docparams.childGroupId
});
- this.lockInterval[this.docparams.id] = setInterval("jQuery.get('" + this.docparams.docManURL + "/', {group_id:"+this.docparams.groupId+",action:'lock',lock:1,type:'file',itemid:"+this.docparams.id+",childgroup_id:"+this.docparams.childGroupId+"})",this.docparams.lockIntervalDelay);
- this.lockInterval[this.docparams.docgroupId] = setInterval("jQuery.get('" + this.docparams.docManURL + "/', {group_id:"+this.docparams.groupId+",action:'lock',lock:1,type:'dir',itemid:"+this.docparams.docgroupId+",childgroup_id:"+this.docparams.childGroupId+"})",this.docparams.lockIntervalDelay);
- jQuery(this.params.divEditFile).dialog('open');
-
+ this.lockInterval[this.docparams.id] = setInterval("jQuery.get('" + this.docparams.docManURL + "/', {group_id:"+this.docparams.groupId+", action:'lock', lock:1, type:'file', itemid:"+this.docparams.id+", childgroup_id:"+this.docparams.childGroupId+"})", this.docparams.lockIntervalDelay);
+ this.lockInterval[this.docparams.docgroupId] = setInterval("jQuery.get('" + this.docparams.docManURL + "/', {group_id:"+this.docparams.groupId+", action:'lock', lock:1, type: 'dir', itemid:"+this.docparams.docgroupId+", childgroup_id:"+this.docparams.childGroupId+"})", this.docparams.lockIntervalDelay);
+ jQuery(this.listfileparams.divEditFile).dialog('open');
return false;
},
- toggleMoveFileView: function(params) {
- if (!this.params.divMoveFile.is(':visible')) {
- this.params.divMoveFile.show();
+ toggleAddVersionView: function() {
+ jQuery('#title').val('');
+ jQuery('#description').val('');
+ jQuery(':file').val('');
+ jQuery('#edit_version').val('');
+ jQuery('#defaulteditzone').text();
+ jQuery('#current_version').prop('checked', false);
+ jQuery('#current_version').attr('onclick', 'return true');
+ if (!this.listfileparams.tableAddVersion.is(':visible')) {
+ jQuery('#new_version').val(1);
+ this.listfileparams.tableAddVersion.show();
+ } else {
+ this.listfileparams.tableAddVersion.hide();
+ jQuery('#new_version').val(0);
+ }
+ },
+
+ toggleEditVersionView: function(params) {
+ this.version = params;
+ if (this.version.isHtml) {
+ jQuery('#defaulteditfiletype').val('text/html');
+ }
+ if (this.version.isText && !this.version.isHtml) {
+ jQuery('#defaulteditfiletype').val('text/plain');
+ }
+ if (this.version.isText) {
+ jQuery.getJSON(this.listfileparams.docManURL+'/?group_id='+this.docparams.groupId+'&action=getfile&type=file&itemid='+this.docparams.id+'&version='+this.version.version, jQuery.proxy(function(data){
+ if (data) {
+ jQuery('#defaulteditzone').text(data.body);
+ }
+ }, this));
+ }
+
+ if (!this.listfileparams.tableAddVersion.is(':visible')) {
+ if (this.version.isURL) {
+ jQuery('#uploadnewroweditfile').hide();
+ jQuery('#fileurlroweditfile').show();
+ jQuery('#fileurlroweditfile').find('input').attr('required', 'required').prop('required', true);
+ jQuery('#fileurlroweditfile').find('input').val(this.version.filename);
+ jQuery('#editonlineroweditfile').hide();
+ jQuery('#editor').attr('disabled', true);
+ jQuery('#editButtonUrl').prop('checked', true);
+ } else if (this.docparams.useCreateOnline && this.version.isText){
+ jQuery('#fileurlroweditfile').hide();
+ jQuery('#uploadnewroweditfile').hide();
+ jQuery('#editonlineroweditfile').show();
+ jQuery('#editor').removeAttr('disabled');
+ jQuery('#editButtonEditor').prop('checked', true);
+ } else {
+ jQuery('#onlineroweditfile').hide();
+ jQuery('#editor').attr('disabled', true);
+ jQuery('#fileurlroweditfile').hide();
+ jQuery('#uploadnewroweditfile').show();
+ jQuery('#editButtonFile').prop('checked', true);
+ }
+ jQuery('#title').val(this.version.title);
+ jQuery('#description').val(this.version.description);
+ jQuery('#edit_version').val(this.version.version);
+ if (this.version.current_version == 1) {
+ jQuery('#current_version').attr('checked', 'checked').prop('checked', true);
+ jQuery('#current_version').attr('onclick', 'return false');
+ }
+ this.listfileparams.tableAddVersion.show();
+ } else {
+ this.listfileparams.tableAddVersion.hide();
+ jQuery('#title').val('');
+ jQuery('#description').val('');
+ jQuery(':file').val('');
+ jQuery('#edit_version').val('');
+ jQuery('#current_version').removeAttr('checked');
+ jQuery('#current_version').attr('onclick', 'return true');
+ jQuery('#fileurlroweditfile').find('input').val('');
+ jQuery('#fileurlroweditfile').find('input').removeAttr('required');
+ jQuery('#fileurlroweditfile').hide();
+ jQuery('#uploadnewroweditfile').hide();
+ jQuery('#editonlineroweditfile').hide();
+ jQuery('#defaulteditzone').text('');
+ }
+ },
+
+ deleteVersion: function(params) {
+ this.delversion = params;
+ jQuery.getJSON(this.docparams.docManURL + '/?group_id=' + this.docparams.groupId + '&action=deleteversion&docid='+this.docparams.id+'&version='+this.delversion.version , jQuery.proxy(function(data){
+ if (typeof data.html != 'undefined') {
+ jQuery('#editFile > .feedback').remove();
+ jQuery('#editFile > .error').remove();
+ jQuery('#editFile > .warning_msg').remove();
+ jQuery('#editFile').prepend(data.html);
+ }
+ if (typeof data.status != 'undefined') {
+ if (data.status == 1) {
+ jQuery('#docversion'+this.version).remove();
+ if (jQuery('#sortable_doc_version_table tr').length <= 2) {
+ jQuery('#version_action_delete').remove();
+ }
+ }
+ }
+ }, this.delversion));
+ },
+
+ toggleMoveFileView: function() {
+ if (!this.listfileparams.divMoveFile.is(':visible')) {
+ this.listfileparams.divMoveFile.show();
jQuery('#movefileinput').val(function() {
var CheckedBoxes = new Array();
for (var h = 0; h < jQuery('input:checked').length; h++) {
return CheckedBoxes;
});
} else {
- this.params.divMoveFile.hide();
+ this.listfileparams.divMoveFile.hide();
}
},
- toggleNotifyUserView: function(docparams) {
- this.docparams = docparams;
- jQuery('#notifytitle').text(this.docparams.title);
- jQuery('#notifydescription').text(this.docparams.description);
- jQuery('#notifydocid').val(this.docparams.id);
- jQuery('#notifyfilelink').text(this.docparams.filename);
- if (this.docparams.statusId != 2) {
- if (this.docparams.isURL) {
- jQuery('#notifyfilelink').attr('href', this.docparams.filename);
+ toggleNotifyUserView: function(params) {
+ this.notifyparams = params;
+ jQuery('#notifytitle').text(this.notifyparams.title);
+ jQuery('#notifydescription').text(this.notifyparams.description);
+ jQuery('#notifydocid').val(this.notifyparams.id);
+ jQuery('#notifyfilelink').text(this.notifyparams.filename);
+ if (this.notifyparams.statusId != 2) {
+ if (this.notifyparams.isURL) {
+ jQuery('#notifyfilelink').attr('href', this.notifyparams.filename);
} else {
- jQuery('#notifyfilelink').attr('href', this.docparams.docManURL + '/view.php/' + this.docparams.groupId + '/' + this.docparams.id + '/' + this.docparams.filename);
+ jQuery('#notifyfilelink').attr('href', this.notifyparams.docManURL+'/view.php/'+this.notifyparams.groupId+'/'+this.notifyparams.id);
}
}
- jQuery('#notifyusersdoc').attr('action', this.docparams.action);
- jQuery.get(this.docparams.docManURL+'/', {
- group_id: this.docparams.groupId,
+ jQuery('#notifyusersdoc').attr('action', this.notifyparams.action);
+ jQuery.get(this.notifyparams.docManURL+'/', {
+ group_id: this.notifyparams.groupId,
action: 'lock',
lock: 1,
type: 'dir',
- itemid: this.docparams.docgroupId,
- childgroup_id: this.docparams.childGroupId
+ itemid: this.notifyparams.docgroupId,
+ childgroup_id: this.notifyparams.childGroupId
});
- this.lockInterval[this.docparams.id] = setInterval("jQuery.get('" + this.docparams.docManURL + "/', {group_id:"+this.docparams.groupId+",action:'lock',lock:1,type:'file',itemid:"+this.docparams.id+",childgroup_id:"+this.docparams.childGroupId+"})",this.docparams.lockIntervalDelay);
- this.lockInterval[this.docparams.docgroupId] = setInterval("jQuery.get('" + this.docparams.docManURL + "/', {group_id:"+this.docparams.groupId+",action:'lock',lock:1,type:'dir',itemid:"+this.docparams.docgroupId+",childgroup_id:"+this.docparams.childGroupId+"})",this.docparams.lockIntervalDelay);
- jQuery(this.params.divNotifyUsers).dialog('open');
+ this.lockInterval[this.notifyparams.id] = setInterval("jQuery.get('" + this.notifyparams.docManURL + "/', {group_id:"+this.notifyparams.groupId+",action:'lock',lock:1,type:'file',itemid:"+this.notifyparams.id+",childgroup_id:"+this.notifyparams.childGroupId+"})", this.notifyparams.lockIntervalDelay);
+ this.lockInterval[this.notifyparams.docgroupId] = setInterval("jQuery.get('" + this.notifyparams.docManURL + "/', {group_id:"+this.notifyparams.groupId+",action:'lock',lock:1,type:'dir',itemid:"+this.notifyparams.docgroupId+",childgroup_id:"+this.notifyparams.childGroupId+"})", this.notifyparams.lockIntervalDelay);
+ jQuery(this.listfileparams.divNotifyUsers).dialog('open');
return false;
/*! Binds the controls to the actions
*/
bindControls: function() {
- this.params.submitZip.click(jQuery.proxy(this, "submitFormZip"));
+ this.additemparams.submitZip.click(jQuery.proxy(this, "submitFormZip"));
},
submitFormZip: function() {
- this.params.injectZip.submit();
- this.params.submitZip.attr('disabled', true);
+ this.additemparams.injectZip.submit();
+ this.additemparams.submitZip.attr('disabled', true);
}
};
/*! Binds the controls to the actions
*/
bindControls: function() {
- this.params.buttonFile.click(jQuery.proxy(this, "toggleFileRowView"));
- this.params.buttonUrl.click(jQuery.proxy(this, "toggleUrlRowView"));
- if (typeof(this.params.buttonManualUpload) != 'undefined') {
- this.params.buttonManualUpload.click(jQuery.proxy(this, "toggleManualUploadView"));
+ this.addfileparams.buttonFile.click(jQuery.proxy(this, "toggleFileRowView"));
+ this.addfileparams.buttonUrl.click(jQuery.proxy(this, "toggleUrlRowView"));
+ if (typeof(this.addfileparams.buttonManualUpload) != 'undefined') {
+ this.addfileparams.buttonManualUpload.click(jQuery.proxy(this, "toggleManualUploadView"));
}
- if (typeof(this.params.buttonEditor) != 'undefined') {
- this.params.buttonEditor.click(jQuery.proxy(this, "toggleEditorView"));
+ if (typeof(this.addfileparams.buttonEditor) != 'undefined') {
+ this.addfileparams.buttonEditor.click(jQuery.proxy(this, "toggleEditorView"));
}
},
toggleFileRowView: function() {
- this.params.fileRow.show();
- this.params.fileRow.find('input').attr("required", "required");
- this.params.urlRow.hide();
- this.params.urlRow.find('input').removeAttr("required");
- this.params.pathRow.hide();
- this.params.pathRow.find('input').removeAttr("required");
- this.params.editRow.hide();
- this.params.editNameRow.hide();
+ this.addfileparams.fileRow.show();
+ this.addfileparams.fileRow.find('input').attr("required", "required");
+ this.addfileparams.urlRow.hide();
+ this.addfileparams.urlRow.find('input').removeAttr("required");
+ this.addfileparams.pathRow.hide();
+ this.addfileparams.pathRow.find('input').removeAttr("required");
+ this.addfileparams.editRow.hide();
+ this.addfileparams.editNameRow.hide();
},
toggleUrlRowView: function() {
- this.params.fileRow.hide();
- this.params.fileRow.find('input').removeAttr("required");
- this.params.urlRow.show();
- this.params.urlRow.find('input').attr("required", "required");
- this.params.pathRow.hide();
- this.params.pathRow.find('input').removeAttr("required");
- this.params.editRow.hide();
- this.params.editNameRow.hide();
+ this.addfileparams.fileRow.hide();
+ this.addfileparams.fileRow.find('input').removeAttr("required");
+ this.addfileparams.urlRow.show();
+ this.addfileparams.urlRow.find('input').attr("required", "required");
+ this.addfileparams.pathRow.hide();
+ this.addfileparams.pathRow.find('input').removeAttr("required");
+ this.addfileparams.editRow.hide();
+ this.addfileparams.editNameRow.hide();
},
toggleManualUploadView: function() {
- this.params.fileRow.hide();
- this.params.fileRow.find('input').removeAttr("required");
- this.params.urlRow.hide();
- this.params.urlRow.find('input').removeAttr("required");
- this.params.pathRow.show();
- this.params.pathRow.find('input').attr("required", "required");
- this.params.editRow.hide();
- this.params.editNameRow.hide();
+ this.addfileparams.fileRow.hide();
+ this.addfileparams.fileRow.find('input').removeAttr("required");
+ this.addfileparams.urlRow.hide();
+ this.addfileparams.urlRow.find('input').removeAttr("required");
+ this.addfileparams.pathRow.show();
+ this.addfileparams.pathRow.find('input').attr("required", "required");
+ this.addfileparams.editRow.hide();
+ this.addfileparams.editNameRow.hide();
},
toggleEditorView: function() {
- this.params.fileRow.hide();
- this.params.fileRow.find('input').removeAttr("required");
- this.params.urlRow.hide();
- this.params.urlRow.find('input').removeAttr("required");
- this.params.pathRow.hide();
- this.params.pathRow.find('input').removeAttr("required");
- this.params.editRow.show();
- this.params.editNameRow.show();
+ this.addfileparams.fileRow.hide();
+ this.addfileparams.fileRow.find('input').removeAttr("required");
+ this.addfileparams.urlRow.hide();
+ this.addfileparams.urlRow.find('input').removeAttr("required");
+ this.addfileparams.pathRow.hide();
+ this.addfileparams.pathRow.find('input').removeAttr("required");
+ this.addfileparams.editRow.show();
+ this.addfileparams.editNameRow.show();
}
};
/*! Binds the controls to the actions
*/
bindControls: function() {
- this.params.buttonStartDate.click(jQuery.proxy(this, 'setStartDate'));
- this.params.buttonEndDate.click(jQuery.proxy(this, 'setEndDate'));
+ this.searchparams.buttonStartDate.click(jQuery.proxy(this, 'setStartDate'));
+ this.searchparams.buttonEndDate.click(jQuery.proxy(this, 'setEndDate'));
},
setStartDate: function() {
- if (this.params.buttonStartDate.is(':checked')) {
- this.params.datePickerStartDate.removeAttr('disabled');
- this.params.datePickerStartDate.attr('required', 'required');
+ if (this.searchparams.buttonStartDate.is(':checked')) {
+ this.searchparams.datePickerStartDate.removeAttr('disabled');
+ this.searchparams.datePickerStartDate.attr('required', 'required');
} else {
- this.params.datePickerStartDate.attr('disabled', 'disabled');
- this.params.datePickerStartDate.removeAttr('required');
+ this.searchparams.datePickerStartDate.attr('disabled', 'disabled');
+ this.searchparams.datePickerStartDate.removeAttr('required');
}
},
setEndDate: function() {
- if (this.params.buttonEndDate.is(':checked')) {
- this.params.datePickerEndDate.removeAttr('disabled');
- this.params.datePickerEndDate.attr('required', 'required');
+ if (this.searchparams.buttonEndDate.is(':checked')) {
+ this.searchparams.datePickerEndDate.removeAttr('disabled');
+ this.searchparams.datePickerEndDate.attr('required', 'required');
} else {
- this.params.datePickerEndDate.attr('disabled', 'disabled');
- this.params.datePickerEndDate.removeAttr('required');
+ this.searchparams.datePickerEndDate.attr('disabled', 'disabled');
+ this.searchparams.datePickerEndDate.removeAttr('required');
}
},
};
$docid = isset($arr[4])? $arr[4]: '';
$g = group_get_object($group_id);
+
if (!$g || !is_object($g)) {
exit_no_group();
} elseif ($g->isError()) {
if (is_numeric($docid)) {
session_require_perm('docman', $group_id, 'read');
- $docname = urldecode($arr[5]);
-
$d = new Document($g, $docid);
if (!$d || !is_object($d)) {
* except for active (1), we need more right access than just read
*/
switch ($d->getStateID()) {
- case "2":
- case "3":
- case "4":
- case "5": {
+ case '2':
+ case '3':
+ case '4':
+ case '5': {
session_require_perm('docman', $group_id, 'approve');
break;
}
}
- /**
- * If the served document has wrong relative links, then
- * theses links may redirect to the same document with another
- * name, this way a search engine may loop and stress the
- * server.
- */
- if ($d->getFileName() != $docname) {
- session_redirect('/docman/view.php/'.$group_id.'/'.$docid.'/'.urlencode($d->getFileName()));
- }
ob_end_clean();
-
$file_path = $d->getFilePath();
$length = filesize($file_path);
$d->downloadUp();
utils_headers_download($d->getFileName(), $d->getFileType(), $length);
readfile_chunked($file_path);
+} elseif ($docid === 'versions') {
+ // let get the specific version
+ $doc_id = (int) $arr[5];
+ $version_id = (int) $arr[6];
+ session_require_perm('docman', $group_id, 'read');
+ $d = new Document($g, $doc_id);
+
+ if (!$d || !is_object($d)) {
+ exit_error(_('Document is not available.'), 'docman');
+ } elseif ($d->isError()) {
+ exit_error($d->getErrorMessage(), 'docman');
+ }
+
+ /**
+ * except for active (1), we need more right access than just read
+ */
+ switch ($d->getStateID()) {
+ case '2':
+ case '3':
+ case '4':
+ case '5': {
+ session_require_perm('docman', $group_id, 'approve');
+ break;
+ }
+ }
+
+ $dv = documentversion_get_object($version_id, $doc_id, $group_id);
+ if (!$dv || !is_object($dv)) {
+ exit_error(_('Document Version is not available.'), 'docman');
+ } elseif ($dv->isError()) {
+ exit_error($dv->getErrorMessage(), 'docman');
+ }
+
+ if (!$dv->isCurrent()) {
+ session_require_perm('docman', $group_id, 'approve');
+ }
+
+ ob_end_clean();
+ $file_path = $dv->getFilePath();
+ $length = filesize($file_path);
+ utils_headers_download($dv->getFileName(), $dv->getFileType(), $length);
+ readfile_chunked($file_path);
} elseif ($docid === 'backup') {
if (extension_loaded('zip')) {
unlink($file);
} else {
$warning_msg = _('This documents folder is empty.');
- //session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid);
+ session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid);
}
} elseif ( $arr[5] === 'selected' ) {
$dirid = $arr[6];
- $arr_groupIdfileId = explode(',',$arr[7]);
- foreach ($arr_groupIdfileId as $groupIdfileId) {
- $splited_val = explode('-', $groupIdfileId);
- $arr_groupid[] = $splited_val[0];
- $arr_fileid[] = $splited_val[1];
- }
- if (count($arr_groupid) != count($arr_fileid)) {
- exit_error(_('Cannot build ZIP archive for download as ZIP'), 'docman');
- }
+ $arr_fileid = explode(',', $arr[7]);
$filename = 'docman-'.$g->getUnixName().'-selected-'.time().'.zip';
$file = forge_get_config('data_path').'/docman/'.$filename;
@unlink($file);
@unlink($file);
exit_error(_('Unable to open ZIP archive for download as ZIP'), 'docman');
}
- foreach ($arr_fileid as $key => $docid) {
+ foreach ($arr_fileid as $docid) {
if (!empty($docid)) {
- $g = group_get_object($arr_groupid[$key]);
$d = new Document($g, $docid);
if (!$d || !is_object($d)) {
@unlink($file);
if (is_numeric($dirid)) {
$redirect_url .= '&dirir='.$dirid;
}
- //session_redirect($redirect_url);
+ session_redirect($redirect_url);
}
}
- if ( !$zip->close()) {
+ if (!$zip->close()) {
@unlink($file);
exit_error(_('Unable to close ZIP archive for download as ZIP'), 'docman');
}
if (!preg_match('/trident/i', $_SERVER['HTTP_USER_AGENT'])) {
header('Content-type: application/zip');
}
- header("Content-Transfer-Encoding: binary");
+ header('Content-Transfer-Encoding: binary');
ob_end_clean();
if(!readfile_chunked($file)) {
return $this->getPicto('ic/directory-add.png', $title, $alt, 20, 20, $otherAttr);
}
+ function getEditFilePic($title = '', $alt = '', $otherAttr = array()) {
+ return $this->getPicto('ic/edit-file.png', $title, $alt, 20, 20, $otherAttr);
+ }
+
function getNewPic($title = '', $alt = '', $otherAttr = array()) {
return $this->getPicto('ic/add.png', $title, $alt, 20, 20, $otherAttr);
}