public function onItemAfterSave($context, $table, $isNew) { $params = JComponentHelper::getParams('com_djcatalog2'); $app = JFactory::getApplication(); $data = $app->input->get('jform', array(), 'array'); // saving additional categories $db = JFactory::getDbo(); $db->setQuery('DELETE FROM #__djc2_items_categories WHERE item_id=\'' . $table->id . '\''); $category_limit = (int) $params->get('fed_multiple_categories_limit', 3); if ($db->query()) { if (!isset($data['categories'])) { $data['categories'] = array(); } if ($category_limit > 0) { $data['categories'] = array_slice($data['categories'], 0, $category_limit); } $data['categories'][] = $table->cat_id; if (!empty($data['categories'])) { $data['categories'] = array_unique($data['categories']); foreach ($data['categories'] as $cat_id) { if ($cat_id > 0) { $db->setQuery('INSERT INTO #__djc2_items_categories VALUES (\'' . $table->id . '\', \'' . $cat_id . '\')'); $db->query(); } } } } // saving images if (!DJCatalog2ImageHelper::saveImages('item', $table, $params, $isNew)) { $app->enqueueMessage(JText::_('COM_DJCATALOG2_ERROR_SAVING_IMAGES'), 'error'); } // saving attachments if (!DJCatalog2FileHelper::saveFiles('item', $table, $params, $isNew)) { $app->enqueueMessage(JText::_('COM_DJCATALOG2_ERROR_SAVING_FILES'), 'error'); } // saving additional attributes $attribs = $app->input->get('attribute', array(), 'array'); $model = JModelAdmin::getInstance('Itemform', 'Djcatalog2Model', array()); if (!$model->saveAttributes($attribs, $table)) { $app->enqueueMessage($model->getError(), 'error'); } }
public function onProducerAfterSave($context, $table, $isNew) { $params = JComponentHelper::getParams('com_djcatalog2'); $app = JFactory::getApplication(); if (!DJCatalog2ImageHelper::saveImages('producer', $table, $params, $isNew)) { $app->enqueueMessage(JText::_('COM_DJCATALOG2_ERROR_SAVING_IMAGES'), 'error'); } }