public function duplicateModule(RokCommon_Event $event) { $db = JFactory::getDbo(); $arguments = $event->getParameters(); $old_pk = $arguments['old_pk']; $new_pk = $arguments['new_pk']; /** @var $table_a AdvancedModulesTableAdvancedModules */ $table_a = JTable::getInstance('AdvancedModules', 'AdvancedModulesTable'); if (!$table_a->load($new_pk)) { $table_a->moduleid = $new_pk; $db->insertObject($table_a->getTableName(), $table_a, $table_a->getKeyName()); } if ($table_a->load($old_pk, true)) { $table_a->moduleid = $new_pk; if (!$table_a->check() || !$table_a->store()) { throw new Exception($table_a->getError()); } } }
/** * Filters a value by calling all listeners of a given event. * * @param RokCommon_Event $event A RokCommon_Event instance * @param mixed $value The value to be filtered * * @return RokCommon_Event The RokCommon_Event instance */ public function filter(RokCommon_Event $event, $value) { if (isset($this->listeners[$event->getName()])) { foreach ($this->listeners[$event->getName()] as $priority_listeners) { foreach ($priority_listeners as $listener) { $value = call_user_func_array($listener, array($event, $value)); } } $event->setReturnValue($value); } return $event; }
public function duplicatePerItemsForModule(RokCommon_Event $event) { $db = JFactory::getDbo(); $arguments = $event->getParameters(); $old_pk = $arguments['old_pk']; $new_pk = $arguments['new_pk']; $query = $db->getQuery(true); $query->select('*')->from('#__roksprocket_items')->where('module_id = ' . $db->quote($old_pk)); $db->setQuery($query); $old_module_item_entries = $db->loadObjectList(); if ($db->getErrorNum()) { $this->setError($db->getErrorMsg()); return false; } if ($old_module_item_entries) { foreach ($old_module_item_entries as $old_module_item_entry) { $old_module_item_entry->id = null; $old_module_item_entry->module_id = $new_pk; $db->insertObject('#__roksprocket_items', $old_module_item_entry); } } }