Skip to content

Commit ea4aa30

Browse files
committed
create workflow association on duplicating modules
1 parent 17ac2e3 commit ea4aa30

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
@@ -476,6 +476,16 @@ public function duplicate(&$pks)
476476
{
477477
$tuples[] = (int) $table->id . ',' . (int) $menuid;
478478
}
479+
480+
$query = $db->getQuery(true)
481+
->select($db->quoteName('stage_id'))
482+
->from($db->quoteName('#__workflow_associations'))
483+
->where($db->quoteName('extension') . ' = ' . $db->quote('com_modules.module'))
484+
->where($db->quoteName('item_id') . ' = :moduleid')
485+
->bind(':moduleid', $pk, ParameterType::INTEGER);
486+
487+
$db->setQuery($query);
488+
$stageIdTuples[] = (int) $table->id . ',' . (int) $db->loadResult() . ',' . $db->quote('com_modules.module');
479489
}
480490
else
481491
{
@@ -505,6 +515,27 @@ public function duplicate(&$pks)
505515
}
506516
}
507517

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

0 commit comments

Comments
 (0)