forked from coldsource/evqueue-frontend-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkflow.php
More file actions
88 lines (71 loc) · 2.55 KB
/
workflow.php
File metadata and controls
88 lines (71 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/*
* This file is part of evQueue
*
* evQueue 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 3 of the License, or
* (at your option) any later version.
*
* evQueue 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 evQueue. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Nicolas Jean, Christophe Marti
*/
require_once __DIR__ . '/includes/inc/auth_check.php';
if(isset($_GET['cancel'])){
if ($_GET["cancel"] != ''){
unset($_SESSION['edition'][$_GET["cancel"]]);
}
else{
unset($_SESSION['edition']['new']);
}
}
$xsl = new XSLEngine();
// INSTALL WORKFLOW
if(isset($_FILES['workflow_zip_file']))
{
try
{
if(!$_FILES['workflow_zip_file']['tmp_name'])
throw new Exception('No zip file was uploaded');
$zip = new ZipArchive();
if($zip->open($_FILES['workflow_zip_file']['tmp_name'])!==true)
throw new Exception('Uploaded file is not a valid workflow archive');
$workflow_xml = $zip->getFromName('workflow.xml');
if($workflow_xml===false)
throw new Exception('Uploaded file is not a valid workflow archive : could not read workflow.xml');
$workflow_dom = new DOMDocument();
$workflow_dom->loadXML($workflow_xml);
$attributes = [];
foreach($workflow_dom->documentElement->attributes as $attribute)
$attributes[$attribute->name] = $attribute->value;
$attributes['content'] = base64_encode($workflow_dom->saveXML($workflow_dom->documentElement->firstChild));
$xsl->Api('workflow','create',$attributes);
$workflow_xpath = new DOMXPath($workflow_dom);
$tasks = $workflow_xpath->query('//task');
foreach($tasks as $task)
{
$task_xml = $zip->getFromName('tasks/'.$task->getAttribute('name').'.xml');
if($task_xml===false)
throw new Exception('Uploaded file is not a valid workflow archive : could not read '.$task->getAttribute('name').'.xml');
$task_dom = new DOMDocument();
$task_dom->loadXML($task_xml);
$attributes = [];
foreach($task_dom->documentElement->attributes as $attribute)
$attributes[$attribute->name] = $attribute->value;
$xsl->Api('task','create',$attributes);
}
}
catch(Exception $e)
{
$xsl->AddError($e->getMessage());
}
}
$xsl->DisplayXHTML('xsl/workflow.xsl');
?>