rename reviser to revisor, added revision workflow to document page

This commit is contained in:
Uwe Steinmann 2015-05-11 09:30:13 +02:00
parent 0fab2df676
commit 608a86d45c
4 changed files with 153 additions and 33 deletions

View File

@ -126,15 +126,15 @@ class SeedDMS_AccessOperation {
} /* }}} */ } /* }}} */
/** /**
* Check if revisers may be edited * Check if revisors may be edited
* *
* This check can only be done for documents. Setting the document * This check can only be done for documents. Setting the document
* revisers is only allowed if version modification is turned on * revisors is only allowed if version modification is turned on
* in the settings. The * in the settings. The
* admin may even set revisers if is disallowed in the * admin may even set revisors if is disallowed in the
* settings. * settings.
*/ */
function maySetRevisers() { /* {{{ */ function maySetRevisors() { /* {{{ */
if(get_class($this->obj) == 'SeedDMS_Core_Document') { if(get_class($this->obj) == 'SeedDMS_Core_Document') {
$latestContent = $this->obj->getLatestContent(); $latestContent = $this->obj->getLatestContent();
$status = $latestContent->getStatus(); $status = $latestContent->getStatus();
@ -264,5 +264,24 @@ class SeedDMS_AccessOperation {
} }
return false; return false;
} /* }}} */ } /* }}} */
/**
* Check if document content may be revised
*
* Revising a document content is only allowed if the document was not
* obsoleted. There are other requirements which are not taken into
* account here.
*/
function mayRevise() { /* {{{ */
if(get_class($this->obj) == 'SeedDMS_Core_Document') {
$latestContent = $this->obj->getLatestContent();
$status = $latestContent->getStatus();
if ($status["status"]!=S_OBSOLETE) {
return true;
}
}
return false;
} /* }}} */
} }
?> ?>

View File

@ -56,6 +56,14 @@ if (!is_object($content)) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version")); UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
} }
if (isset($_POST["startdate"])) {
$startdate = $_POST["startdate"];
} else {
$startdate = date('Y-m-d');
}
$content->setRevisionDate($startdate);
$folder = $document->getFolder(); $folder = $document->getFolder();
// Retrieve a list of all users and groups that have read rights. // Retrieve a list of all users and groups that have read rights.
@ -87,8 +95,8 @@ foreach ($revisionStatus as $i=>$rs) {
} }
// Get the list of proposed recipients, stripping out any duplicates. // Get the list of proposed recipients, stripping out any duplicates.
$pIndRev = (isset($_POST["indRevisers"]) ? array_values(array_unique($_POST["indRevisers"])) : array()); $pIndRev = (isset($_POST["indRevisors"]) ? array_values(array_unique($_POST["indRevisors"])) : array());
$pGrpRev = (isset($_POST["grpRevisers"]) ? array_values(array_unique($_POST["grpRevisers"])) : array()); $pGrpRev = (isset($_POST["grpRevisors"]) ? array_values(array_unique($_POST["grpRevisors"])) : array());
foreach ($pIndRev as $p) { foreach ($pIndRev as $p) {
if (is_numeric($p)) { if (is_numeric($p)) {
if (isset($accessIndex["i"][$p])) { if (isset($accessIndex["i"][$p])) {
@ -96,7 +104,7 @@ foreach ($pIndRev as $p) {
if (!isset($revisionIndex["i"][$p])) { if (!isset($revisionIndex["i"][$p])) {
// Proposed recipient is not a current recipient, so add as a new // Proposed recipient is not a current recipient, so add as a new
// recipient. // recipient.
$res = $content->addIndReviser($accessIndex["i"][$p], $user); $res = $content->addIndRevisor($accessIndex["i"][$p], $user);
$unm = $accessIndex["i"][$p]->getFullName(); $unm = $accessIndex["i"][$p]->getFullName();
$uml = $accessIndex["i"][$p]->getEmail(); $uml = $accessIndex["i"][$p]->getEmail();
@ -147,17 +155,20 @@ foreach ($pIndRev as $p) {
} }
if (count($revisionIndex["i"]) > 0) { if (count($revisionIndex["i"]) > 0) {
foreach ($revisionIndex["i"] as $rx=>$rv) { foreach ($revisionIndex["i"] as $rx=>$rv) {
if ($rv["status"] == 0) { // if ($rv["status"] == 0) {
// User is to be removed from the recipients list. // User is to be removed from the recipients list.
if (!isset($accessIndex["i"][$rx])) { if (!isset($accessIndex["i"][$rx])) {
// User does not have any revision privileges for this document // User does not have any revision privileges for this document
// revision or does not exist. // revision or does not exist.
/* Take this out for now
$queryStr = "INSERT INTO `tblDocumentRevisionLog` (`revisionID`, `status`, `comment`, `date`, `userID`) ". $queryStr = "INSERT INTO `tblDocumentRevisionLog` (`revisionID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $revisionStatus[$rv["idx"]]["revisionID"] ."', '-2', '".getMLText("removed_recipient")."', NOW(), '". $user->getID() ."')"; "VALUES ('". $revisionStatus[$rv["idx"]]["revisionID"] ."', '-2', '".getMLText("removed_recipient")."', NOW(), '". $user->getID() ."')";
$res = $db->getResult($queryStr); $res = $db->getResult($queryStr);
*/
$res = $content->delIndRevisor($dms->getUser($rx), $user, getMLText("removed_recipient"));
} }
else { else {
$res = $content->delIndReviser($accessIndex["i"][$rx], $user); $res = $content->delIndRevisor($accessIndex["i"][$rx], $user);
$unm = $accessIndex["i"][$rx]->getFullName(); $unm = $accessIndex["i"][$rx]->getFullName();
$uml = $accessIndex["i"][$rx]->getEmail(); $uml = $accessIndex["i"][$rx]->getEmail();
switch ($res) { switch ($res) {
@ -195,7 +206,7 @@ if (count($revisionIndex["i"]) > 0) {
break; break;
} }
} }
} // }
} }
} }
foreach ($pGrpRev as $p) { foreach ($pGrpRev as $p) {
@ -205,7 +216,7 @@ foreach ($pGrpRev as $p) {
if (!isset($revisionIndex["g"][$p])) { if (!isset($revisionIndex["g"][$p])) {
// Proposed recipient is not a current recipient, so add as a new // Proposed recipient is not a current recipient, so add as a new
// recipient. // recipient.
$res = $content->addGrpReviser($accessIndex["g"][$p], $user); $res = $content->addGrpRevisor($accessIndex["g"][$p], $user);
$gnm = $accessIndex["g"][$p]->getName(); $gnm = $accessIndex["g"][$p]->getName();
switch ($res) { switch ($res) {
case 0: case 0:
@ -251,17 +262,20 @@ foreach ($pGrpRev as $p) {
} }
if (count($revisionIndex["g"]) > 0) { if (count($revisionIndex["g"]) > 0) {
foreach ($revisionIndex["g"] as $rx=>$rv) { foreach ($revisionIndex["g"] as $rx=>$rv) {
if ($rv["status"] == 0) { // if ($rv["status"] == 0) {
// Group is to be removed from the recipientist. // Group is to be removed from the recipientist.
if (!isset($accessIndex["g"][$rx])) { if (!isset($accessIndex["g"][$rx])) {
// Group does not have any revision privileges for this document // Group does not have any revision privileges for this document
// revision or does not exist. // revision or does not exist.
/*
$queryStr = "INSERT INTO `tblDocumentRevisionLog` (`revisionID`, `status`, `comment`, `date`, `userID`) ". $queryStr = "INSERT INTO `tblDocumentRevisionLog` (`revisionID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $revisionStatus[$rv["idx"]]["revisionID"] ."', '-2', '".getMLText("removed_recipient")."', NOW(), '". $user->getID() ."')"; "VALUES ('". $revisionStatus[$rv["idx"]]["revisionID"] ."', '-2', '".getMLText("removed_recipient")."', NOW(), '". $user->getID() ."')";
$res = $db->getResult($queryStr); $res = $db->getResult($queryStr);
*/
$res = $content->delGrpRevisor($dms->getGroup($rx), $user, getMLText("removed_recipient"));
} }
else { else {
$res = $content->delGrpReviser($accessIndex["g"][$rx], $user); $res = $content->delGrpRevisor($accessIndex["g"][$rx], $user);
$gnm = $accessIndex["g"][$rx]->getName(); $gnm = $accessIndex["g"][$rx]->getName();
switch ($res) { switch ($res) {
case 0: case 0:
@ -298,7 +312,7 @@ if (count($revisionIndex["g"]) > 0) {
break; break;
} }
} }
} // }
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* Implementation of SetRevisers view * Implementation of SetRevisors view
* *
* @category DMS * @category DMS
* @package SeedDMS * @package SeedDMS
@ -19,7 +19,7 @@
require_once("class.Bootstrap.php"); require_once("class.Bootstrap.php");
/** /**
* Class which outputs the html page for SetRevisers view * Class which outputs the html page for SetRevisors view
* *
* @category DMS * @category DMS
* @package SeedDMS * @package SeedDMS
@ -29,7 +29,7 @@ require_once("class.Bootstrap.php");
* 2010-2015 Uwe Steinmann * 2010-2015 Uwe Steinmann
* @version Release: @package_version@ * @version Release: @package_version@
*/ */
class SeedDMS_View_SetRevisers extends SeedDMS_Bootstrap_Style { class SeedDMS_View_SetRevisors extends SeedDMS_Bootstrap_Style {
function show() { /* {{{ */ function show() { /* {{{ */
$dms = $this->params['dms']; $dms = $this->params['dms'];
@ -49,12 +49,15 @@ class SeedDMS_View_SetRevisers extends SeedDMS_Bootstrap_Style {
// Retrieve a list of all users and groups that have revision privileges. // Retrieve a list of all users and groups that have revision privileges.
$docAccess = $document->getReadAccessList(); $docAccess = $document->getReadAccessList();
// Retrieve list of currently assigned revisers, along with // Retrieve list of currently assigned revisors, along with
// their latest status. // their latest status.
$revisionStatus = $content->getRevisionStatus(); $revisionStatus = $content->getRevisionStatus();
$startdate = '2015-05-23'; echo "<pre>";
print_r($revisionStatus);
echo "</pre>";
$startdate = substr($content->getRevisionDate(), 0, 10);
// Index the revision results for easy cross-reference with the reviser list. // Index the revision results for easy cross-reference with the revisor list.
$revisionIndex = array("i"=>array(), "g"=>array()); $revisionIndex = array("i"=>array(), "g"=>array());
foreach ($revisionStatus as $i=>$rs) { foreach ($revisionStatus as $i=>$rs) {
if ($rs["type"]==0) { if ($rs["type"]==0) {
@ -67,27 +70,28 @@ class SeedDMS_View_SetRevisers extends SeedDMS_Bootstrap_Style {
<?php $this->contentContainerStart(); ?> <?php $this->contentContainerStart(); ?>
<form action="../op/op.SetRevisers.php" method="post" name="form1"> <form action="../op/op.SetRevisors.php" method="post" name="form1">
<?php $this->contentSubHeading(getMLText("update_revisers"));?> <?php $this->contentSubHeading(getMLText("update_revisors"));?>
<span class="input-append date" style="display: inline;" id="revisionstartdate" data-date="<?php echo date('d-m-Y'); ?>" data-date-format="dd-mm-yyyy" data-date-language="<?php echo str_replace('_', '-', $this->params['session']->getLanguage()); ?>"> <span class="input-append date" style="display: inline;" id="revisionstartdate" data-date="<?php echo date('Y-m-d'); ?>" data-date-format="yyyy-mm-dd" data-date-language="<?php echo str_replace('_', '-', $this->params['session']->getLanguage()); ?>">
<input class="span4" size="16" name="startdate" type="text" value="<?php if($startdate) echo $startdate; else echo date('d-m-Y'); ?>"> <input class="span4" size="16" name="startdate" type="text" value="<?php if($startdate) echo $startdate; else echo date('Y-m-d'); ?>">
<span class="add-on"><i class="icon-calendar"></i></span> <span class="add-on"><i class="icon-calendar"></i></span>
</span> </span>
<div class="cbSelectTitle"><?php printMLText("individuals")?>:</div> <div class="cbSelectTitle"><?php printMLText("individuals")?>:</div>
<select class="chzn-select span9" name="indRevisers[]" multiple="multiple" data-placeholder="<?php printMLText('select_ind_revisers'); ?>" data-no_results_text="<?php printMLText('unknown_owner'); ?>"> <select class="chzn-select span9" name="indRevisors[]" multiple="multiple" data-placeholder="<?php printMLText('select_ind_revisors'); ?>" data-no_results_text="<?php printMLText('unknown_owner'); ?>">
<?php <?php
foreach ($docAccess["users"] as $usr) { foreach ($docAccess["users"] as $usr) {
if (isset($revisionIndex["i"][$usr->getID()])) { if (isset($revisionIndex["i"][$usr->getID()])) {
switch ($revisionIndex["i"][$usr->getID()]["status"]) { switch ($revisionIndex["i"][$usr->getID()]["status"]) {
case 0: case S_LOG_WAITING:
case S_LOG_SLEEPING:
print "<option value='". $usr->getID() ."' selected='selected'>".htmlspecialchars($usr->getLogin() . " - ". $usr->getFullName())."</option>"; print "<option value='". $usr->getID() ."' selected='selected'>".htmlspecialchars($usr->getLogin() . " - ". $usr->getFullName())."</option>";
break; break;
case -2: case S_LOG_USER_REMOVED:
print "<option value='". $usr->getID() ."'>".htmlspecialchars($usr->getLogin() . " - ". $usr->getFullName())."</option>"; print "<option value='". $usr->getID() ."'>".htmlspecialchars($usr->getLogin() . " - ". $usr->getFullName())."</option>";
break; break;
default: default:
@ -102,19 +106,20 @@ class SeedDMS_View_SetRevisers extends SeedDMS_Bootstrap_Style {
</select> </select>
<div class="cbSelectTitle"><?php printMLText("groups")?>:</div> <div class="cbSelectTitle"><?php printMLText("groups")?>:</div>
<select class="chzn-select span9" name="grpRevisers[]" multiple="multiple" data-placeholder="<?php printMLText('select_grp_revisers'); ?>" data-no_results_text="<?php printMLText('unknown_group'); ?>"> <select class="chzn-select span9" name="grpRevisors[]" multiple="multiple" data-placeholder="<?php printMLText('select_grp_revisors'); ?>" data-no_results_text="<?php printMLText('unknown_group'); ?>">
<?php <?php
foreach ($docAccess["groups"] as $group) { foreach ($docAccess["groups"] as $group) {
if (isset($revisionIndex["g"][$group->getID()])) { if (isset($revisionIndex["g"][$group->getID()])) {
switch ($revisionIndex["g"][$group->getID()]["status"]) { switch ($revisionIndex["g"][$group->getID()]["status"]) {
case 0: case S_LOG_WAITING:
case S_LOG_SLEEPING:
print "<option value='". $group->getID() ."' selected='selected'>".htmlspecialchars($group->getName())."</option>"; print "<option value='". $group->getID() ."' selected='selected'>".htmlspecialchars($group->getName())."</option>";
break; break;
case -2: case S_LOG_USER_REMOVED:
print "<option value='". $group->getID() ."'>".htmlspecialchars($group->getName())."</option>"; print "<option value='". $group->getID() ."'>".htmlspecialchars($group->getName())."</option>";
break; break;
default: default:
print "<option id='recGrp".$group->getID()."' type='checkbox' name='grpRevisers[]' value='". $group->getID() ."' disabled='disabled'>".htmlspecialchars($group->getName())."</option>"; print "<option id='recGrp".$group->getID()."' type='checkbox' name='grpRevisors[]' value='". $group->getID() ."' disabled='disabled'>".htmlspecialchars($group->getName())."</option>";
break; break;
} }
} else { } else {

View File

@ -178,6 +178,7 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
$reviewStatus = $latestContent->getReviewStatus(); $reviewStatus = $latestContent->getReviewStatus();
$approvalStatus = $latestContent->getApprovalStatus(); $approvalStatus = $latestContent->getApprovalStatus();
$receiptStatus = $latestContent->getReceiptStatus(); $receiptStatus = $latestContent->getReceiptStatus();
$revisionStatus = $latestContent->getRevisionStatus();
?> ?>
<div class="row-fluid"> <div class="row-fluid">
@ -330,6 +331,11 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
if(is_array($receiptStatus) && count($receiptStatus)>0) { if(is_array($receiptStatus) && count($receiptStatus)>0) {
?> ?>
<li><a data-target="#recipients" data-toggle="tab"><?php echo getMLText('recipients'); ?></a></li> <li><a data-target="#recipients" data-toggle="tab"><?php echo getMLText('recipients'); ?></a></li>
<?php
}
if(is_array($revisionStatus) && count($revisionStatus)>0) {
?>
<li><a data-target="#revision" data-toggle="tab"><?php echo getMLText('revise document'); ?></a></li>
<?php <?php
} }
?> ?>
@ -450,8 +456,8 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
if($accessop->maySetRecipients()) { if($accessop->maySetRecipients()) {
print "<li><a href='../out/out.SetRecipients.php?documentid=".$documentid."&version=".$latestContent->getVersion()."'><i class=\"icon-edit\"></i>".getMLText("change_recipients")."</a></li>"; print "<li><a href='../out/out.SetRecipients.php?documentid=".$documentid."&version=".$latestContent->getVersion()."'><i class=\"icon-edit\"></i>".getMLText("change_recipients")."</a></li>";
} }
if($accessop->maySetRevisers()) { if($accessop->maySetRevisors()) {
print "<li><a href='../out/out.SetRevisers.php?documentid=".$documentid."&version=".$latestContent->getVersion()."'><i class=\"icon-edit\"></i>".getMLText("change_revisers")."</a></li>"; print "<li><a href='../out/out.SetRevisors.php?documentid=".$documentid."&version=".$latestContent->getVersion()."'><i class=\"icon-edit\"></i>".getMLText("change_revisors")."</a></li>";
} }
if($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') { if($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') {
// Allow changing reviewers/approvals only if not reviewed // Allow changing reviewers/approvals only if not reviewed
@ -1036,6 +1042,82 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
$this->contentContainerEnd(); $this->contentContainerEnd();
?> ?>
</div> </div>
<?php
}
if(is_array($revisionStatus) && count($revisionStatus)>0) {
?>
<div class="tab-pane" id="revision">
<?php
$this->contentContainerStart();
print "<table class=\"table-condensed\">\n";
print "<tr><td colspan=5>\n";
$this->contentSubHeading(getMLText("revisors"));
print "</tr>";
print "<tr>\n";
print "<td width='20%'><b>".getMLText("name")."</b></td>\n";
print "<td width='20%'><b>".getMLText("last_update")."</b></td>\n";
print "<td width='25%'><b>".getMLText("comment")."</b></td>";
print "<td width='15%'><b>".getMLText("status")."</b></td>\n";
print "<td width='20%'></td>\n";
print "</tr>\n";
foreach ($revisionStatus as $r) {
$required = null;
$is_recipient = false;
switch ($r["type"]) {
case 0: // Reviewer is an individual.
$required = $dms->getUser($r["required"]);
if (!is_object($required)) {
$reqName = getMLText("unknown_user")." '".$r["required"]."'";
}
else {
$reqName = htmlspecialchars($required->getFullName()." (".$required->getLogin().")");
}
if($r["required"] == $user->getId() && ($user->getId() != $owner->getId() || $enableownerrevapp == 1))
$is_recipient = true;
break;
case 1: // Reviewer is a group.
$required = $dms->getGroup($r["required"]);
if (!is_object($required)) {
$reqName = getMLText("unknown_group")." '".$r["required"]."'";
}
else {
$reqName = "<i>".htmlspecialchars($required->getName())."</i>";
if($required->isMember($user) && ($user->getId() != $owner->getId() || $enableownerrevapp == 1))
$is_recipient = true;
}
break;
}
print "<tr>\n";
print "<td>".$reqName."</td>\n";
print "<td><ul class=\"unstyled\"><li>".$r["date"]."</li>";
/* $updateUser is the user who has done the receipt */
$updateUser = $dms->getUser($r["userID"]);
print "<li>".(is_object($updateUser) ? htmlspecialchars($updateUser->getFullName()." (".$updateUser->getLogin().")") : "unknown user id '".$r["userID"]."'")."</li></ul></td>";
print "<td>".htmlspecialchars($r["comment"])."</td>\n";
print "<td>".getReceiptStatusText($r["status"])."</td>\n";
print "<td><ul class=\"unstyled\">";
if($accessop->mayReview()) {
if ($is_recipient && $r["status"]==0) {
print "<li><a href=\"../out/out.ReviseDocument.php?documentid=".$documentid."&version=".$latestContent->getVersion()."&receiptid=".$r['receiptID']."\" class=\"btn btn-mini\">".getMLText("add_receipt")."</a></li>";
}else if (($updateUser==$user)&&(($r["status"]==1)||($r["status"]==-1))&&(!$document->hasExpired())){
print "<li><a href=\"../out/out.ReviseDocument.php?documentid=".$documentid."&version=".$latestContent->getVersion()."&receiptid=".$r['receiptID']."\" class=\"btn btn-mini\">".getMLText("edit")."</a></li>";
}
}
print "</ul></td>\n";
print "</td>\n</tr>\n";
}
?>
</table>
<?php
$this->contentContainerEnd();
?>
</div>
<?php <?php
} }
if (count($versions)>1) { if (count($versions)>1) {