/** * @desc Almacena la característica en la base de datos **/ function dt_save_features($edit = 0) { global $xoopsSecurity, $functions; $query = ''; foreach ($_POST as $k => $v) { ${$k} = $v; if ($k == 'XOOPS_TOKEN_REQUEST' || $k == 'action') { continue; } $query = $query == '' ? $k . '=' . urlencode($v) : '&' . $k . '=' . urlencode($v); } if (!$xoopsSecurity->check()) { redirectMsg('features.php?action=' . ($edit ? 'edit&id=' . $id : 'new') . '&item=' . $item, __('Session token not valid!', 'dtransport'), RMMSG_ERROR); } //Verificamos que el software sea válido if ($item <= 0) { redirectMsg('items.php', __('Download item ID not provided!', 'dtransport'), RMMSG_WARN); } //Verificamos que el software exista $sw = new DTSoftware($item); if ($sw->isNew()) { redirectMsg('items.php', __('Specified download item does not exists!', 'dtransport'), RMMSG_ERROR); } $db = XoopsDatabaseFactory::getDatabaseConnection(); if ($edit) { if ($id <= 0) { redirectMsg('features.php?item=' . $item, __('Feature ID not specified!', 'dtransport'), RMMSG_WARN); } //Verificamos que la característica exista $ft = new DTFeature($id); if ($ft->isNew()) { redirectMsg('features.php?item=' . $item, __('Specified feature does not exists!', 'dtransport'), RMMSG_ERROR); } } else { $ft = new DTFeature(); } $tc = TextCleaner::getInstance(); if (trim($nameid) == '') { $nameid = $tc->sweetstring($title); } else { $nameid = $tc->sweetstring($nameid); } //Comprueba que el título de la característica no exista $sql = "SELECT COUNT(*) FROM " . $db->prefix('dtrans_features') . " WHERE (title='{$title}' OR nameid='{$nameid}' AND id_feat<>" . $ft->id() . " AND id_soft=" . $item; list($num) = $db->fetchRow($db->queryF($sql)); if ($num > 0) { redirectMsg('features.php?' . $query . ($edit ? '&action=edit' : '&action=new'), __('Another feature with same title already exists!', 'dtransport'), RMMSG_WARN); } $ft->setSoftware($item); $ft->setTitle($title); $ft->setContent($content); if (!$edit) { $ft->setCreated(time()); } $ft->setModified(time()); $ft->setNameId($nameid); if (!$ft->save()) { redirectMsg('features.php?' . $query . ($edit ? '&action=edit' : '&action=new'), __('Feature could not be saved!', 'dtransport') . '<br />' . $ft->errors(), 1); } if (!$functions->save_meta('feat', $ft->id())) { redirectMsg('features.php?item=' . $item, __('Feature saved correctly, however custom fields could not be stored in database!', 'dtransport'), RMMSG_INFO); } redirectMsg('features.php?item=' . $item, __('Featured saved successfully!', 'dtransport'), RMMSG_SAVED); }