48 switch (strtolower($command)) {
54 return $this->handleUploadSubmit();
66 return $this->startProcess();
77 case 'startlistening':
78 return $this->startListening();
96 if ($this->dic->rbac()->system()->checkAccess(
'write',
$_GET[
'ref_id'])) {
99 require_once
'./Services/WorkflowEngine/classes/administration/class.ilWorkflowEngineDefinitionsTableGUI.php';
101 $table_gui->setFilterCommand(
"definitions.applyfilter");
102 $table_gui->setResetCommand(
"definitions.resetFilter");
103 $table_gui->setDisableFilterHiding(
false);
105 return $table_gui->getHTML();
113 require_once
'./Services/WorkflowEngine/classes/administration/class.ilWorkflowEngineDefinitionsTableGUI.php';
115 $table_gui->writeFilterToSession();
116 $table_gui->resetOffset();
126 require_once
'./Services/WorkflowEngine/classes/administration/class.ilWorkflowEngineDefinitionsTableGUI.php';
128 $table_gui->resetOffset();
129 $table_gui->resetFilter();
139 require_once
'./Services/WorkflowEngine/classes/administration/class.ilUploadDefinitionForm.php';
141 $form = $form_definition->getForm(
142 $this->parent_gui->ilCtrl->getLinkTarget($this->parent_gui,
'definitions.upload')
145 return $form->getHTML();
154 public function handleUploadSubmit()
158 require_once
'./Services/WorkflowEngine/classes/administration/class.ilUploadDefinitionForm.php';
160 $form = $form_definition->getForm(
161 $this->parent_gui->ilCtrl->getLinkTarget($this->parent_gui,
'definitions.upload')
164 if (!$form->checkInput()) {
165 $form->setValuesByPost();
166 return $form->getHTML();
169 $fs = $this->dic->filesystem()->storage();
170 $upload = $this->dic->upload();
173 if (!$fs->hasDir($repositoryDirectory)) {
174 $fs->createDir($repositoryDirectory);
178 if (!$fs->hasDir($tmpDirectory)) {
179 $fs->createDir($tmpDirectory);
182 if (!$upload->hasUploads() || $upload->hasBeenProcessed()) {
183 $form->setValuesByPost();
184 return $form->getHTML();
190 $uploadResult = array_values($upload->getResults())[0];
192 $form->setValuesByPost();
193 return $form->getHTML();
196 $upload->moveOneFileTo(
199 \
ILIAS\FileUpload\Location::STORAGE,
200 $uploadResult->getName(),
204 $repo_base_name =
'il' . substr($uploadResult->getName(), 0, strpos($uploadResult->getName(),
'.'));
205 $wf_base_name =
'wfd.' . $repo_base_name .
'_v';
208 $fileList = $fs->listContents($repositoryDirectory,
true);
210 foreach ($fileList as $file) {
211 if ($file->isDir()) {
215 $fileBaseName = basename($file->getPath());
218 substr(strtolower($fileBaseName), 0, strlen($wf_base_name)) == strtolower($wf_base_name) &&
219 substr($fileBaseName, -4) ==
'.php' 221 $number = substr($fileBaseName, strlen($wf_base_name), -4);
222 if ($number > $version) {
229 $repo_name = $repo_base_name .
'_v' . $version .
'.php';
231 require_once
'./Services/WorkflowEngine/classes/parser/class.ilBPMN2Parser.php';
233 $bpmn = $fs->read($tmpDirectory . $uploadResult->getName());
234 $code =
$parser->parseBPMN2XML($bpmn, $repo_name);
236 $fs->put($repositoryDirectory .
'wfd.' . $repo_name, $code);
237 $fs->put($repositoryDirectory .
'wfd.' . $repo_base_name .
'_v' . $version .
'.bpmn2', $bpmn);
238 $fs->delete($tmpDirectory . $uploadResult->getName());
242 $sourceFile = $absRepositoryDirectory . str_replace(
'.',
'',
'wfd.' . $repo_name) .
'.sec';
243 $targetFile = $absRepositoryDirectory .
'wfd.' . $repo_name;
244 if (file_exists($sourceFile)) {
245 rename($sourceFile, $targetFile);
248 ilUtil::sendSuccess($this->parent_gui->lng->txt(
'upload_parse_success'),
true);
250 html_entity_decode($this->parent_gui->ilCtrl->getLinkTarget($this->parent_gui,
'definitions.view'))
259 require_once
'./Services/UIComponent/Button/classes/class.ilLinkButton.php';
261 $upload_wizard_button->setCaption($this->parent_gui->lng->txt(
'upload_process'),
false);
262 $upload_wizard_button->setUrl(
263 $this->parent_gui->ilCtrl->getLinkTarget($this->parent_gui,
'definitions.uploadform')
265 $this->parent_gui->ilToolbar->addButtonInstance($upload_wizard_button);
273 if (isset(
$_POST[
'cmd'][
'cancel'])) {
277 $this->parent_gui->ilCtrl->getLinkTarget($this->parent_gui,
'definitions.view')
286 public function startListening()
288 $identifier = basename(
$_GET[
'process_id']);
291 $class = substr($identifier, 4);
293 $workflow_instance =
new $class;
295 $workflow_instance->setWorkflowClass(
'wfd.' . $class .
'.php');
298 $show_armer_form =
true;
300 case isset(
$_POST[
'process_id']):
301 case isset(
$_POST[
'se_type']):
302 case isset(
$_POST[
'se_content']):
303 case isset(
$_POST[
'se_subject_type']):
304 case isset(
$_POST[
'se_context_type']):
305 $show_armer_form =
false;
308 $show_armer_form =
true;
312 require_once
'./Services/WorkflowEngine/classes/administration/class.ilWorkflowArmerGUI.php';
313 $this->parent_gui->ilCtrl->saveParameter($this->parent_gui,
'process_id', $identifier);
314 $action = $this->parent_gui->ilCtrl->getLinkTarget($this->parent_gui,
'definitions.start');
317 $form = $armer->getForm($workflow_instance->getInputVars(), $workflow_instance->getStartEventInfo());
319 if ($show_armer_form) {
320 return $form->getHTML();
324 'type' => stripslashes(
$_POST[
'se_type']),
325 'content' => stripslashes(
$_POST[
'se_content']),
326 'subject_type' => stripslashes(
$_POST[
'se_subject_type']),
327 'subject_id' => (
int)
$_POST[
'se_subject_id'],
328 'context_type' => stripslashes($_POST[
'se_context_type']),
329 'context_id' => (
int) $_POST[
'se_context_id']
331 $process_id = stripslashes($_POST[
'process_id']);
333 require_once
'./Services/WorkflowEngine/classes/utils/class.ilWorkflowDbHelper.php';
334 $event_id = ilWorkflowDbHelper::writeStartEventData($event_data, $process_id);
336 foreach ($workflow_instance->getInputVars() as $input_var) {
337 ilWorkflowDbHelper::writeStaticInput($input_var[
'name'], stripslashes($_POST[$input_var[
'name']]), $event_id);
340 ilUtil::sendSuccess($this->parent_gui->lng->txt(
'wfe_started_listening'),
true);
343 $this->parent_gui->ilCtrl->getLinkTarget($this->parent_gui,
'definitions.view')
352 require_once
'./Services/WorkflowEngine/classes/utils/class.ilWorkflowDbHelper.php';
353 ilWorkflowDbHelper::deleteStartEventData($process_id);
355 ilUtil::sendSuccess($this->parent_gui->lng->txt(
'wfe_stopped_listening'),
true);
358 $this->parent_gui->ilCtrl->getLinkTarget($this->parent_gui,
'definitions.view')
368 public function startProcess()
370 if (isset(
$_POST[
'cmd'][
'cancel'])) {
374 $this->parent_gui->ilCtrl->getLinkTarget($this->parent_gui,
'definitions.view')
379 $identifier = basename(
$_GET[
'process_id']);
382 $class = substr($identifier, 4);
384 $workflow_instance =
new $class;
386 $workflow_instance->setWorkflowClass(
'wfd.' . $class .
'.php');
389 if (count($workflow_instance->getInputVars())) {
390 $show_launcher_form =
false;
391 foreach ($workflow_instance->getInputVars() as $input_var) {
392 if (!isset(
$_POST[$input_var[
'name']])) {
393 $show_launcher_form =
true;
395 $workflow_instance->setInstanceVarById($input_var[
'name'],
$_POST[$input_var[
'name']]);
399 require_once
'./Services/WorkflowEngine/classes/administration/class.ilWorkflowLauncherGUI.php';
400 $this->parent_gui->ilCtrl->saveParameter($this->parent_gui,
'process_id', $identifier);
401 $action = $this->parent_gui->ilCtrl->getLinkTarget($this->parent_gui,
'definitions.start');
403 $form = $launcher->getForm($workflow_instance->getInputVars());
405 if ($show_launcher_form || $form->checkInput() ==
false) {
406 $form->setValuesByPost();
407 return $form->getHTML();
411 require_once
'./Services/WorkflowEngine/classes/utils/class.ilWorkflowDbHelper.php';
412 ilWorkflowDbHelper::writeWorkflow($workflow_instance);
414 $workflow_instance->startWorkflow();
415 $workflow_instance->handleEvent(
426 ilWorkflowDbHelper::writeWorkflow($workflow_instance);
428 ilUtil::sendSuccess($this->parent_gui->lng->txt(
'process_started'),
true);
431 $this->parent_gui->ilCtrl->getLinkTarget($this->parent_gui,
'definitions.view')
441 if (!isset($this->dic->http()->request()->getQueryParams()[
'process_id'])) {
442 ilUtil::sendInfo($this->parent_gui->lng->txt(
'wfe_request_missing_process_id'));
443 $this->parent_gui->ilCtrl->redirect($this->parent_gui,
'definitions.view');
452 $processId = str_replace([
'\\',
'/'],
'', stripslashes($this->dic->http()->request()->getQueryParams()[
'process_id']));
454 return basename($processId);
469 if (file_exists($pathToProcessPhpFile)) {
470 unlink($pathToProcessPhpFile);
472 if (file_exists($pathToProcessBpmn2File)) {
473 unlink($pathToProcessBpmn2File);
476 ilUtil::sendSuccess($this->parent_gui->lng->txt(
'definition_deleted'),
true);
479 $this->parent_gui->ilCtrl->getLinkTarget($this->parent_gui,
'definitions.view')
493 require_once
'Services/WorkflowEngine/classes/administration/class.ilWorkflowDefinitionRepository.php';
495 $this->dic->database(),
496 $this->dic->filesystem(),
499 $processDefinition = $repository->
getById($processId);
501 require_once
'Services/Utilities/classes/class.ilConfirmationGUI.php';
503 $confirmation->addItem(
'process_id[]', $processDefinition[
'id'], $processDefinition[
'title']);
504 $this->parent_gui->ilCtrl->setParameter($this->parent_gui,
'process_id', $processDefinition[
'id']);
505 $confirmation->setFormAction($this->parent_gui->ilCtrl->getFormAction($this->parent_gui,
'definitions.view'));
506 $confirmation->setHeaderText($this->parent_gui->lng->txt(
'wfe_sure_to_delete_process_def'));
507 $confirmation->setConfirm($this->parent_gui->lng->txt(
'confirm'),
'definitions.delete');
508 $confirmation->setCancel($this->parent_gui->lng->txt(
'cancel'),
'definitions.view');
510 return $confirmation->getHTML();
processUploadFormCancellation()
Class ilWorkflowEngineDefinitionsGUI.
Class ChatMainBarProvider .
ensureProcessIdInRequest()
static getRepositoryDir($relative=false)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
confirmDeleteDefinition()
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Class ilWorkflowDefinitionRepository.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
__construct(ilObjWorkflowEngineGUI $parent_gui, \ILIAS\DI\Container $dic=null)
ilWorkflowEngineDefinitionsGUI constructor.
static getTempDir($relative=false)
getProcessIdFromRequest()
handle($command)
Handle the command given.
static redirect($a_script)
Confirmation screen class.