mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-11-28 10:30:42 +00:00
lots of bug fixes
This commit is contained in:
parent
e55047fb58
commit
7b065e7b05
|
|
@ -53,6 +53,12 @@ function getRevAppLog($reviews) { /* {{{ */
|
|||
$newlog['status'] = $log['attributes']['status'];
|
||||
$newlog['comment'] = $log['attributes']['comment'];
|
||||
$newlog['date'] = $log['attributes']['date'];
|
||||
if(!empty($log['data'])) {
|
||||
$filecontents = base64_decode($log['data']);
|
||||
$filename = tempnam('/tmp', 'FOO-revapp');
|
||||
file_put_contents($filename, $filecontents);
|
||||
$newlog['file'] = $filename;
|
||||
}
|
||||
$newreview['logs'][] = $newlog;
|
||||
}
|
||||
}
|
||||
|
|
@ -394,22 +400,7 @@ function insert_document($document) { /* {{{ */
|
|||
$folder = $rootfolder;
|
||||
|
||||
if(in_array('documents', $sections)) {
|
||||
$error = false;
|
||||
$initversion = array_shift($document['versions']);
|
||||
if(!empty($initversion['fileref'])) {
|
||||
$filename = tempnam('/tmp', 'FOO');
|
||||
copy($contentdir.$initversion['fileref'], $filename);
|
||||
} else {
|
||||
$filecontents = base64_decode($initversion['data']);
|
||||
if(strlen($filecontents) != $initversion['data_length']) {
|
||||
$logger->warning("File length (".strlen($filecontents).") doesn't match expected length (".$initversion['data_length'].").");
|
||||
$newDocument = null;
|
||||
$error = true;
|
||||
}
|
||||
$filename = tempnam('/tmp', 'FOO');
|
||||
file_put_contents($filename, $filecontents);
|
||||
}
|
||||
if(!$error) {
|
||||
$reviews = array('i'=>array(), 'g'=>array());
|
||||
/*
|
||||
if($initversion['reviews']) {
|
||||
|
|
@ -440,15 +431,24 @@ function insert_document($document) { /* {{{ */
|
|||
*/
|
||||
|
||||
$workflow = null;
|
||||
$workflowstate = null;
|
||||
if(isset($initversion['workflow']) && $initversion['workflow']) {
|
||||
if(array_key_exists((int) $initversion['workflow']['id'], $objmap['workflows'])) {
|
||||
$workflow = $dms->getWorkflow($objmap['workflows'][(int) $initversion['workflow']['id']]);
|
||||
if(!$workflow) {
|
||||
$logger->warning("Workflow ".$orgid." cannot be mapped");
|
||||
$logger->warning("Workflow ".$initversion['workflow']['id']." cannot be mapped");
|
||||
}
|
||||
} else {
|
||||
$logger->warning("Workflow ".$initversion['workflow']['id']." cannot be mapped");
|
||||
}
|
||||
if(array_key_exists((int) $initversion['workflow']['state'], $objmap['workflowstates'])) {
|
||||
$workflowstate = $dms->getWorkflow($objmap['workflowstates'][(int) $initversion['workflow']['state']]);
|
||||
if(!$workflowstate) {
|
||||
$logger->warning("Workflowstate ".$initversion['workflow']['state']." cannot be mapped");
|
||||
}
|
||||
} else {
|
||||
$logger->warning("Workflowstate ".$initversion['workflow']['state']." cannot be mapped");
|
||||
}
|
||||
}
|
||||
if($initversion['workflowlogs']) {
|
||||
}
|
||||
|
|
@ -463,6 +463,17 @@ function insert_document($document) { /* {{{ */
|
|||
}
|
||||
}
|
||||
}
|
||||
if(!empty($initversion['fileref'])) {
|
||||
$filename = tempnam('/tmp', 'FOO');
|
||||
copy($contentdir.$initversion['fileref'], $filename);
|
||||
} else {
|
||||
$filecontents = base64_decode($initversion['data']);
|
||||
if(strlen($filecontents) != $initversion['data_length']) {
|
||||
$logger->warning("File length (".strlen($filecontents).") doesn't match expected length (".$initversion['data_length'].").");
|
||||
}
|
||||
$filename = tempnam('/tmp', 'FOO');
|
||||
file_put_contents($filename, $filecontents);
|
||||
}
|
||||
if(!$result = $folder->addDocument(
|
||||
$document['attributes']['name'],
|
||||
$document['attributes']['comment'],
|
||||
|
|
@ -487,7 +498,9 @@ function insert_document($document) { /* {{{ */
|
|||
unlink($filename);
|
||||
$logger->err("Could not add document '".$document['attributes']['name']."'");
|
||||
return false;
|
||||
} else {
|
||||
}
|
||||
|
||||
/* The document and its initial version was added */
|
||||
$logger->info("Added document '".$document['attributes']['name']."'");
|
||||
$newDocument = $result[0];
|
||||
unlink($filename);
|
||||
|
|
@ -504,6 +517,8 @@ function insert_document($document) { /* {{{ */
|
|||
|
||||
$newVersion = $result[1]->getContent();
|
||||
$newVersion->setDate(dateToTimestamp($initversion['attributes']['date']));
|
||||
if($workflowstate)
|
||||
$newVersion->setWorkflowState($workflowstate);
|
||||
$newlogs = array();
|
||||
foreach($initversion['statuslogs'] as $i=>$log) {
|
||||
if(!array_key_exists($log['attributes']['user'], $objmap['users'])) {
|
||||
|
|
@ -518,6 +533,7 @@ function insert_document($document) { /* {{{ */
|
|||
|
||||
/* Set reviewers and review log */
|
||||
if($initversion['reviews']) {
|
||||
// print_r($initversion['reviews']);
|
||||
$newreviews = getRevAppLog($initversion['reviews']);
|
||||
$newVersion->rewriteReviewLog($newreviews);
|
||||
}
|
||||
|
|
@ -528,6 +544,7 @@ function insert_document($document) { /* {{{ */
|
|||
|
||||
$newDocument->setDate(dateToTimestamp($document['attributes']['date']));
|
||||
$newDocument->setDefaultAccess($document['attributes']['defaultaccess']);
|
||||
$newDocument->setInheritAccess($document['attributes']['inheritaccess']);
|
||||
foreach($document['versions'] as $version) {
|
||||
if(!array_key_exists((int) $version['attributes']['owner'], $objmap['users'])) {
|
||||
$logger->err("Owner of document cannot be mapped");
|
||||
|
|
@ -563,6 +580,30 @@ function insert_document($document) { /* {{{ */
|
|||
}
|
||||
}
|
||||
*/
|
||||
|
||||
$workflow = null;
|
||||
$workflowstate = null;
|
||||
if(isset($version['workflow']) && $version['workflow']) {
|
||||
if(array_key_exists((int) $version['workflow']['id'], $objmap['workflows'])) {
|
||||
$workflow = $dms->getWorkflow($objmap['workflows'][(int) $version['workflow']['id']]);
|
||||
if(!$workflow) {
|
||||
$logger->warning("Workflow ".$version['workflow']['id']." cannot be mapped");
|
||||
}
|
||||
} else {
|
||||
$logger->warning("Workflow ".$version['workflow']['id']." cannot be mapped");
|
||||
}
|
||||
if(array_key_exists((int) $version['workflow']['state'], $objmap['workflowstates'])) {
|
||||
$workflowstate = $dms->getWorkflow($objmap['workflowstates'][(int) $version['workflow']['state']]);
|
||||
if(!$workflowstate) {
|
||||
$logger->warning("Workflowstate ".$version['workflow']['state']." cannot be mapped");
|
||||
}
|
||||
} else {
|
||||
$logger->warning("Workflowstate ".$version['workflow']['state']." cannot be mapped");
|
||||
}
|
||||
}
|
||||
if($version['workflowlogs']) {
|
||||
}
|
||||
|
||||
$version_attributes = array();
|
||||
if(isset($version['user_attributes'])) {
|
||||
foreach($version['user_attributes'] as $orgid=>$value) {
|
||||
|
|
@ -595,10 +636,17 @@ function insert_document($document) { /* {{{ */
|
|||
$approvals, //approvers
|
||||
$version['version'],
|
||||
$version_attributes,
|
||||
null //workflow
|
||||
$workflow
|
||||
))) {
|
||||
unlink($filename);
|
||||
$logger->err("Could not add version '".$version['version']."' of document '".$document['attributes']['name']."'");
|
||||
return false;
|
||||
}
|
||||
|
||||
$logger->info("Added version '".$version['version']."' of document '".$document['attributes']['name']."'");
|
||||
$newVersion = $result->getContent();
|
||||
if($workflowstate)
|
||||
$newVersion->setWorkflowState($workflowstate);
|
||||
$newVersion->setDate(dateToTimestamp($version['attributes']['date']));
|
||||
$newlogs = array();
|
||||
foreach($version['statuslogs'] as $i=>$log) {
|
||||
|
|
@ -623,7 +671,7 @@ function insert_document($document) { /* {{{ */
|
|||
|
||||
unlink($filename);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($document['notifications']['users']) && $document['notifications']['users']) {
|
||||
foreach($document['notifications']['users'] as $userid) {
|
||||
if(!array_key_exists($userid, $objmap['users'])) {
|
||||
|
|
@ -643,7 +691,6 @@ function insert_document($document) { /* {{{ */
|
|||
}
|
||||
}
|
||||
if(isset($document['acls']) && $document['acls']) {
|
||||
$newDocument->setInheritAccess(false);
|
||||
foreach($document['acls'] as $acl) {
|
||||
if($acl['type'] == 'user') {
|
||||
if(!array_key_exists($acl['user'], $objmap['users'])) {
|
||||
|
|
@ -691,7 +738,6 @@ function insert_document($document) { /* {{{ */
|
|||
unlink($filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$newDocument = null;
|
||||
}
|
||||
|
|
@ -744,6 +790,7 @@ function insert_folder($folder) { /* {{{ */
|
|||
|
||||
$newFolder->setDate(dateToTimestamp($folder['attributes']['date']));
|
||||
$newFolder->setDefaultAccess($folder['attributes']['defaultaccess']);
|
||||
$newFolder->setInheritAccess($folder['attributes']['inheritaccess']);
|
||||
if(isset($folder['notifications']['users']) && $folder['notifications']['users']) {
|
||||
foreach($folder['notifications']['users'] as $userid) {
|
||||
if(!array_key_exists($userid, $objmap['users'])) {
|
||||
|
|
@ -763,7 +810,6 @@ function insert_folder($folder) { /* {{{ */
|
|||
}
|
||||
}
|
||||
if(isset($folder['acls']) && $folder['acls']) {
|
||||
$newFolder->setInheritAccess(false);
|
||||
foreach($folder['acls'] as $acl) {
|
||||
if($acl['type'] == 'user') {
|
||||
if(!array_key_exists($acl['user'], $objmap['users'])) {
|
||||
|
|
@ -828,6 +874,46 @@ function resolve_links() { /* {{{ */
|
|||
}
|
||||
} /* }}} */
|
||||
|
||||
function set_mandatory() { /* {{{ */
|
||||
global $logger, $dms, $users, $objmap;
|
||||
|
||||
if(!$users)
|
||||
return;
|
||||
|
||||
foreach($users as $user) {
|
||||
if ($newUser = $dms->getUserByLogin($user['attributes']['login'])) {
|
||||
if($user['individual']['reviewers']) {
|
||||
foreach($user['individual']['reviewers'] as $u) {
|
||||
if($uobj = $dms->getUser($objmap['users'][$u])) {
|
||||
$newUser->setMandatoryReviewer($uobj->getID(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if($user['individual']['approvers']) {
|
||||
foreach($user['individual']['approvers'] as $u) {
|
||||
if($uobj = $dms->getUser($objmap['users'][$u])) {
|
||||
$newUser->setMandatoryApprover($uobj->getID(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if($user['group']['reviewers']) {
|
||||
foreach($user['group']['reviewers'] as $u) {
|
||||
if($uobj = $dms->getGroup($objmap['groups'][$u])) {
|
||||
$newUser->setMandatoryReviewer($uobj->getID(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if($user['group']['approvers']) {
|
||||
foreach($user['group']['approvers'] as $u) {
|
||||
if($uobj = $dms->getGroup($objmap['groups'][$u])) {
|
||||
$newUser->setMandatoryApprover($uobj->getID(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
function startElement($parser, $name, $attrs) { /* {{{ */
|
||||
global $logger, $dms, $noversioncheck, $elementstack, $objmap, $cur_user, $cur_group, $cur_folder, $cur_document, $cur_version, $cur_statuslog, $cur_workflowlog, $cur_approval, $cur_approvallog, $cur_review, $cur_reviewlog, $cur_attrdef, $cur_documentcat, $cur_keyword, $cur_keywordcat, $cur_file, $cur_link, $cur_workflow, $cur_workflowtransition, $cur_workflowaction, $cur_workflowstate, $cur_transition;
|
||||
|
||||
|
|
@ -1070,6 +1156,12 @@ function startElement($parser, $name, $attrs) { /* {{{ */
|
|||
$cur_file['fileref'] = $attrs['FILEREF'];
|
||||
else
|
||||
$cur_file['data'] = "";
|
||||
} elseif($parent['name'] == 'REVIEWLOG') {
|
||||
$cur_reviewlog['data_length'] = (int) $attrs['LENGTH'];
|
||||
if(isset($attrs['FILEREF']))
|
||||
$cur_reviewlog['fileref'] = $attrs['FILEREF'];
|
||||
else
|
||||
$cur_reviewlog['data'] = "";
|
||||
}
|
||||
break;
|
||||
case "KEYWORD":
|
||||
|
|
@ -1451,6 +1543,9 @@ function characterData($parser, $data) { /* {{{ */
|
|||
case 'FILE':
|
||||
$cur_file['data'] .= $data;
|
||||
break;
|
||||
case 'REVIEWLOG':
|
||||
$cur_reviewlog['data'] .= $data;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'USER':
|
||||
|
|
@ -1609,6 +1704,7 @@ while ($data = fread($fp, 65535)) {
|
|||
}
|
||||
|
||||
resolve_links();
|
||||
set_mandatory();
|
||||
|
||||
if($exportmapping) {
|
||||
if($fp = fopen($exportmapping, 'w')) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user