Skip to content

Commit 8dd00e7

Browse files
committed
create workflow association on duplicating modules
1 parent dde3803 commit 8dd00e7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

administrator/components/com_modules/src/Model/ModuleModel.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,16 @@ public function duplicate(&$pks)
474474
{
475475
$tuples[] = (int) $table->id . ',' . (int) $menuid;
476476
}
477+
478+
$query = $db->getQuery(true)
479+
->select($db->quoteName('stage_id'))
480+
->from($db->quoteName('#__workflow_associations'))
481+
->where($db->quoteName('extension') . ' = ' . $db->quote('com_modules.module'))
482+
->where($db->quoteName('item_id') . ' = :moduleid')
483+
->bind(':moduleid', $pk, ParameterType::INTEGER);
484+
485+
$db->setQuery($query);
486+
$stageIdTuples[] = (int) $table->id . ',' . (int) $db->loadResult() . ',' . $db->quote('com_modules.module');
477487
}
478488
else
479489
{
@@ -503,6 +513,27 @@ public function duplicate(&$pks)
503513
}
504514
}
505515

516+
if (!empty($stageIdTuples))
517+
{
518+
$query = $db->getQuery(true)
519+
->insert($db->quoteName('#__workflow_associations'))
520+
->columns($db->quoteName(array('item_id', 'stage_id', 'extension')))
521+
->values($stageIdTuples);
522+
523+
$db->setQuery($query);
524+
525+
try
526+
{
527+
$db->execute();
528+
}
529+
catch (\RuntimeException $e)
530+
{
531+
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
532+
533+
return false;
534+
}
535+
}
536+
506537
// Clear modules cache
507538
$this->cleanCache();
508539

0 commit comments

Comments
 (0)