Merge branch 'seeddms-5.0.x' into develop

This commit is contained in:
Uwe Steinmann 2015-12-09 21:54:02 +01:00
commit 6b95229ff7
10 changed files with 82 additions and 152 deletions

View File

@ -2,6 +2,10 @@
Changes in version 4.3.23
--------------------------------------------------------------------------------
- send notification if document is delete to those users watching the folder
- fix editing of customer attributes of type checkbox
- disallow read access for group didn't prevent the users from being selected
as a reviewer/approver
- move the last bits of plain sql code from op/*.php into the core
--------------------------------------------------------------------------------
Changes in version 4.3.22

View File

@ -2565,5 +2565,39 @@ class SeedDMS_Core_DMS {
$this->callbacks[$name] = array($func, $params);
} /* }}} */
/**
* Create an sql dump of the complete database
*
* @param string $filename name of dump file
*/
function createDump($filename) { /* {{{ */
$h = fopen($filename, "w");
if(!$h)
return false;
$tables = $this->db->TableList('TABLES');
foreach($tables as $table) {
$query = "SELECT * FROM `".$table."`";
$records = $this->db->getResultArray($query);
fwrite($h,"\n-- TABLE: ".$table."--\n\n");
foreach($records as $record) {
$values="";
$i = 1;
foreach ($record as $column) {
if (is_numeric($column)) $values .= $column;
else $values .= $this->db->qstr($column);
if ($i<(count($record))) $values .= ",";
$i++;
}
fwrite($h, "INSERT INTO `".$table."` VALUES (".$values.");\n");
}
}
fclose($h);
return true;
} /* }}} */
}
?>

View File

@ -2389,7 +2389,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
(strlen($userIDs) == 0 ? "" : " OR (`tblUsers`.`id` IN (". $userIDs ."))").
") ORDER BY `login`";
}
/* If default access is equal or greate then read, $userIDs and
/* If default access is equal or greater then M_READ, $userIDs and
* $groupIDs contains a list of user without read access
*/
else {
@ -2399,15 +2399,20 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
"WHERE `tblGroupMembers`.`groupID` NOT IN (". $groupIDs .")".
"AND `tblUsers`.`role` != ".SeedDMS_Core_User::role_guest." ".
(strlen($userIDs) == 0 ? "" : " AND (`tblUsers`.`id` NOT IN (". $userIDs ."))")." UNION ";
} else {
$queryStr .=
"SELECT `tblUsers`.* FROM `tblUsers` ".
"WHERE `tblUsers`.`role` != ".SeedDMS_Core_User::role_guest." ".
(strlen($userIDs) == 0 ? "" : " AND (`tblUsers`.`id` NOT IN (". $userIDs ."))")." UNION ";
}
$queryStr .=
"SELECT `tblUsers`.* FROM `tblUsers` ".
"WHERE (`tblUsers`.`id` = ". $this->_ownerID . ") ".
"OR (`tblUsers`.`role` = ".SeedDMS_Core_User::role_admin.") ".
"UNION ".
"SELECT `tblUsers`.* FROM `tblUsers` ".
"WHERE `tblUsers`.`role` != ".SeedDMS_Core_User::role_guest." ".
(strlen($userIDs) == 0 ? "" : " AND (`tblUsers`.`id` NOT IN (". $userIDs ."))").
// "UNION ".
// "SELECT `tblUsers`.* FROM `tblUsers` ".
// "WHERE `tblUsers`.`role` != ".SeedDMS_Core_User::role_guest." ".
// (strlen($userIDs) == 0 ? "" : " AND (`tblUsers`.`id` NOT IN (". $userIDs ."))").
" ORDER BY `login`";
}
$resArr = $db->getResultArray($queryStr);
@ -4265,11 +4270,9 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
return self::setRevision($group, $requestUser, $status, $comment);
} /* }}} */
function delIndReviewer($user, $requestUser) { /* {{{ */
function delIndReviewer($user, $requestUser, $msg='') { /* {{{ */
$db = $this->_document->_dms->getDB();
$userID = $user->getID();
// Check to see if the user can be removed from the review list.
$reviewStatus = $user->getReviewStatus($this->_document->getID(), $this->_version);
if (is_bool($reviewStatus) && !$reviewStatus) {
@ -4288,7 +4291,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
}
$queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $indstatus["reviewID"] ."', '-2', '', ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')";
"VALUES ('". $indstatus["reviewID"] ."', '-2', ".$db->qstr($msg).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr);
if (is_bool($res) && !$res) {
return -1;
@ -4297,7 +4300,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
return 0;
} /* }}} */
function delGrpReviewer($group, $requestUser) { /* {{{ */
function delGrpReviewer($group, $requestUser, $msg='') { /* {{{ */
$db = $this->_document->_dms->getDB();
$groupID = $group->getID();
@ -4319,7 +4322,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
}
$queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $reviewStatus[0]["reviewID"] ."', '-2', '', ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')";
"VALUES ('". $reviewStatus[0]["reviewID"] ."', '-2', ".$db->qstr($msg).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr);
if (is_bool($res) && !$res) {
return -1;
@ -4328,7 +4331,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
return 0;
} /* }}} */
function delIndApprover($user, $requestUser) { /* {{{ */
function delIndApprover($user, $requestUser, $msg='') { /* {{{ */
$db = $this->_document->_dms->getDB();
$userID = $user->getID();
@ -4351,7 +4354,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
}
$queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $indstatus["approveID"] ."', '-2', '', ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')";
"VALUES ('". $indstatus["approveID"] ."', '-2', ".$db->qstr($msg).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr);
if (is_bool($res) && !$res) {
return -1;
@ -4360,7 +4363,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
return 0;
} /* }}} */
function delGrpApprover($group, $requestUser) { /* {{{ */
function delGrpApprover($group, $requestUser, $msg='') { /* {{{ */
$db = $this->_document->_dms->getDB();
$groupID = $group->getID();
@ -4382,7 +4385,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
}
$queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $approvalStatus[0]["approveID"] ."', '-2', '', ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')";
"VALUES ('". $approvalStatus[0]["approveID"] ."', '-2', ".$db->qstr($msg).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr);
if (is_bool($res) && !$res) {
return -1;

View File

@ -124,7 +124,7 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
$mimetype = $version->getMimeType();
if(isset($_convcmd[$mimetype])) {
$cmd = sprintf($_convcmd[$mimetype], $path);
$content = self::execWithTimeout($cmd);
$content = self::execWithTimeout($cmd, $timeout);
/*
$fp = popen($cmd, 'r');
if($fp) {

View File

@ -129,7 +129,7 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
$mimetype = $version->getMimeType();
if(isset($_convcmd[$mimetype])) {
$cmd = sprintf($_convcmd[$mimetype], $path);
$content = self::execWithTimeout($cmd);
$content = self::execWithTimeout($cmd, $timeout);
if($content) {
$this->addField('content', $content, 'unstored');
}

View File

@ -16,6 +16,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
include("../inc/inc.Version.php");
include("../inc/inc.Settings.php");
include("../inc/inc.LogInit.php");
include("../inc/inc.Language.php");
@ -33,40 +34,12 @@ if($settings->_backupDir && file_exists($settings->_backupDir))
$basedir = $settings->_backupDir;
else
$basedir = $setting->_contentDir;
$dump_name = $basedir.time().".sql";
$h=fopen($dump_name,"w");
if (is_bool($h)&&!$h)
$v = new SeedDMS_Version;
$dump_name = $basedir.date('Y-m-d\TH:i:s')."_".$v->_number.".sql";
if(!$dms->createDump($dump_name))
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
$tables = $db->TableList('TABLES');
foreach ($tables as $table){
$query = "SELECT * FROM ".$table;
$records = $db->getResultArray($query);
fwrite($h,"\n-- TABLE: ".$table."--\n\n");
foreach ($records as $record){
$values="";
$i = 1;
foreach ($record as $column) {
if (is_numeric($column)) $values .= $column;
else $values .= "'".$column."'";
if ($i<(count($record))) $values .= ",";
$i++;
}
fwrite($h, "INSERT INTO " . $table . " VALUES (" . $values . ");\n");
}
}
fclose($h);
if (SeedDMS_Core_File::gzcompressfile($dump_name,9)) unlink($dump_name);
else UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));

View File

@ -1,90 +0,0 @@
<?php
// MyDMS. Document Management System
// Copyright (C) 2002-2005 Markus Westphal
// Copyright (C) 2006-2008 Malcolm Cowe
//
// This program 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 License, or
// (at your option) any later version.
//
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
include("../inc/inc.Settings.php");
include("../inc/inc.Utils.php");
include("../inc/inc.Language.php");
include("../inc/inc.Init.php");
include("../inc/inc.Extension.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
UI::htmlStartPage("Create Initial Status Index");
UI::globalNavigation();
UI::pageNavigation("Create Initial Status Index");
UI::contentHeading("Generate a New Document Status Index.");
UI::contentContainerStart();
if (!$user->isAdmin()) {
print "<p>Error: User must have administrative privileges to create the status index.</p>";
UI::contentContainerEnd();
UI::htmlEndPage();
exit;
}
if (!isset($_GET["genIndex"]) || $_GET["genIndex"]!=1) {
print "<form method=\"GET\">";
print "<input type=\"checkbox\" name=\"genIndex\" id=\"genIndex\" value=\"1\"/><label for=\"genIndex\">Generate the Initial Status Index (for MyDMS upgrades only)</label>";
print "<p><input type=\"submit\" value=\"go\"/></p>";
print "</form>";
UI::contentContainerEnd();
UI::htmlEndPage();
exit;
}
$queryStr = "SELECT `tblDocumentContent`.`document`, `tblDocumentContent`.`version` FROM `tblDocumentContent`";
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr)) {
print "<p>Error: unable to retrieve document content listing.</p>";
UI::contentContainerEnd();
UI::htmlEndPage();
exit;
}
print "<ul>";
foreach ($resArr as $row) {
echo "<li>Creating status log for: '".$row["document"]."', version: '".$row["version"]."'";
$queryStr = "INSERT INTO `tblDocumentStatus` (`documentID`, `version`) ".
"VALUES ('".$row["document"]."', '".$row["version"]."')";
if (!$db->getResult($queryStr)) {
print "<p>Error: unable to insert status row.</p>";
echo "</li>";
UI::contentContainerEnd();
UI::htmlEndPage();
exit;
}
$statusID = $db->getInsertID();
$queryStr = "INSERT INTO `tblDocumentStatusLog` (`statusID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('".$statusID."', '2', '-', NOW(), '".$user->getID()."')";
if (!$db->getResult($queryStr)) {
print "<p>Error: unable to insert status log entry.</p>";
echo "</li>";
UI::contentContainerEnd();
UI::htmlEndPage();
exit;
}
echo "</li>";
}
print "<ul>";
print "<p>Status Index Generation is complete.</p>";
UI::contentContainerEnd();
UI::htmlEndPage();
?>

View File

@ -113,6 +113,7 @@ else {
*/
$emailUserList = array();
$emailUserList[] = $version->_userID;
$emailGroupList = array();
$status = $version->getReviewStatus();
foreach ($status as $st) {
if ($st["status"]==0 && !in_array($st["required"], $emailUserList)) {

View File

@ -125,9 +125,6 @@ foreach ($pIndRev as $p) {
// Proposed reviewer is not a current reviewer, so add as a new
// reviewer.
$res = $content->addIndReviewer($docAccess["users"][$accessIndex["i"][$p]], $user);
$unm = $docAccess["users"][$accessIndex["i"][$p]]->getFullName();
$uml = $docAccess["users"][$accessIndex["i"][$p]]->getEmail();
switch ($res) {
case 0:
// Send an email notification to the new reviewer.
@ -172,6 +169,12 @@ foreach ($pIndRev as $p) {
}
}
}
/* $reviewIndex['i'] has now those individual reviewers which are left over
* and must be removed. There are two cases to distinguish: 1. The user may
* access the document but shall no longer review the document, 2. the user
* many not access the document any more.
*/
if (count($reviewIndex["i"]) > 0) {
foreach ($reviewIndex["i"] as $rx=>$rv) {
if ($rv["status"] == 0) {
@ -179,14 +182,15 @@ if (count($reviewIndex["i"]) > 0) {
if (!isset($docAccess["users"][$accessIndex["i"][$rx]])) {
// User does not have any review privileges for this document
// revision or does not exist.
/*
$queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $reviewStatus[$rv["idx"]]["reviewID"] ."', '-2', '".getMLText("removed_reviewer")."', NOW(), '". $user->getID() ."')";
$res = $db->getResult($queryStr);
*/
$res = $content->delIndReviewer($dms->getUser($reviewStatus[$rv["idx"]]["required"]), $user, getMLText("removed_reviewer"));
}
else {
$res = $content->delIndReviewer($docAccess["users"][$accessIndex["i"][$rx]], $user);
$unm = $docAccess["users"][$accessIndex["i"][$rx]]->getFullName();
$uml = $docAccess["users"][$accessIndex["i"][$rx]]->getEmail();
switch ($res) {
case 0:
// Send an email notification to the reviewer.
@ -233,7 +237,6 @@ foreach ($pGrpRev as $p) {
// Proposed reviewer is not a current reviewer, so add as a new
// reviewer.
$res = $content->addGrpReviewer($docAccess["groups"][$accessIndex["g"][$p]], $user);
$gnm = $docAccess["groups"][$accessIndex["g"][$p]]->getName();
switch ($res) {
case 0:
// Send an email notification to the new reviewer.
@ -283,13 +286,15 @@ if (count($reviewIndex["g"]) > 0) {
if (!isset($docAccess["groups"][$accessIndex["g"][$rx]])) {
// Group does not have any review privileges for this document
// revision or does not exist.
/*
$queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $reviewStatus[$rv["idx"]]["reviewID"] ."', '-2', '".getMLText("removed_reviewer")."', NOW(), '". $user->getID() ."')";
$res = $db->getResult($queryStr);
*/
$res = $content->delGrpReviewer($dms->getGroup($reviewStatus[$rv["idx"]]["required"]), $user, getMLText("removed_reviewer"));
}
else {
$res = $content->delGrpReviewer($docAccess["groups"][$accessIndex["g"][$rx]], $user);
$gnm = $docAccess["groups"][$accessIndex["g"][$rx]]->getName();
switch ($res) {
case 0:
// Send an email notification to the review group.
@ -352,8 +357,6 @@ foreach ($pIndApp as $p) {
// Proposed approver is not a current approver, so add as a new
// approver.
$res = $content->addIndApprover($docAccess["users"][$accessIndex["i"][$p]], $user);
$unm = $docAccess["users"][$accessIndex["i"][$p]]->getFullName();
$uml = $docAccess["users"][$accessIndex["i"][$p]]->getEmail();
switch ($res) {
case 0:
// Send an email notification to the new approver.
@ -403,14 +406,15 @@ if (count($approvalIndex["i"]) > 0) {
if (!isset($docAccess["users"][$accessIndex["i"][$rx]])) {
// User does not have any approval privileges for this document
// revision or does not exist.
/*
$queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $approvalStatus[$rv["idx"]]["approveID"] ."', '-2', '".getMLText("removed_approver")."', NOW(), '". $user->getID() ."')";
$res = $db->getResult($queryStr);
*/
$res = $content->delIndApprover($dms->getUser($approvalStatus[$rv["idx"]]["required"]), $user, getMLText("removed_approver"));
}
else {
$res = $content->delIndApprover($docAccess["users"][$accessIndex["i"][$rx]], $user);
$unm = $docAccess["users"][$accessIndex["i"][$rx]]->getFullName();
$uml = $docAccess["users"][$accessIndex["i"][$rx]]->getEmail();
switch ($res) {
case 0:
// Send an email notification to the approver.
@ -457,7 +461,6 @@ foreach ($pGrpApp as $p) {
// Proposed approver is not a current approver, so add as a new
// approver.
$res = $content->addGrpApprover($docAccess["groups"][$accessIndex["g"][$p]], $user);
$gnm = $docAccess["groups"][$accessIndex["g"][$p]]->getName();
switch ($res) {
case 0:
// Send an email notification to the new approver.
@ -507,14 +510,15 @@ if (count($approvalIndex["g"]) > 0) {
if (!isset($docAccess["groups"][$accessIndex["g"][$rx]])) {
// Group does not have any approval privileges for this document
// revision or does not exist.
/*
$queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $approvalStatus[$rv["idx"]]["approveID"] ."', '-2', '".getMLText("removed_approver")."', NOW(), '". $user->getID() ."')";
$res = $db->getResult($queryStr);
*/
$res = $content->delGrpApprover($dms->getGroup($approvalStatus[$rv["idx"]]["required"]), $user, getMLText("removed_approver"));
}
else {
$res = $content->delGrpApprover($docAccess["groups"][$accessIndex["g"][$rx]], $user);
$gnm = $docAccess["groups"][$accessIndex["g"][$rx]]->getName();
switch ($res) {
case 0:
// Send an email notification to the approval group.

View File

@ -1167,6 +1167,7 @@ function folderSelected<?php echo $form ?>(id, name) {
function printAttributeEditField($attrdef, $attribute, $fieldname='attributes') { /* {{{ */
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_boolean:
echo "<input type=\"hidden\" name=\"".$fieldname."[".$attrdef->getId()."]\" value=\"0\" />";
echo "<input type=\"checkbox\" name=\"".$fieldname."[".$attrdef->getId()."]\" value=\"1\" ".(($attribute && $attribute->getValue()) ? 'checked' : '')." />";
break;
case SeedDMS_Core_AttributeDefinition::type_date: