/** * Save feature */ function dt_save_feature($edit) { global $item, $feature, $tpl, $xoopsTpl, $mc, $dtfunc; $query = ''; foreach ($_POST as $k => $v) { ${$k} = $v; } $db = XoopsDatabaseFactory::getDatabaseConnection(); if ($edit) { //Verificamos que la característica exista $ft = new DTFeature($feature); if ($ft->isNew()) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/features/' . $item->id() . '/' : '/?p=cpanel&action=features&id=' . $item->id()), 1, __('Specified feature does not exists!', 'dtransport')); } } 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->id(); list($num) = $db->fetchRow($db->queryF($sql)); if ($num > 0) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/features/' . $item->id() . '/edit/' . $ft->id() : '/?p=cpanel&action=features&id=' . $item->id() . '/&op=edit&feature=' . $ft->id()), 1, __('Another feature with same title already exists!', 'dtransport')); } $ft->setSoftware($item->id()); $ft->setTitle($title); $ft->setContent($content); if (!$edit) { $ft->setCreated(time()); } $ft->setModified(time()); $ft->setNameId($nameid); if (!$ft->save()) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/features/' . $item->id() . '/' : '/?p=cpanel&action=features&id=' . $item->id()), 1, __('Feature could not be saved! Please try again.', 'dtransport')); } if (!$dtfunc->save_meta('feat', $ft->id())) { redirectMsg(DT_URL . ($mc['permalinks'] ? '/cp/features/' . $item->id() . '/' : '/?p=cpanel&action=features&id=' . $item->id()), 1, __('Feature saved correctly, however custom fields could not be stored in database!', 'dtransport')); } redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/features/' . $item->id() . '/' : '/?p=cpanel&action=features&id=' . $item->id()), 1, __('Featured saved successfully!', 'dtransport')); }
/** * @desc Cambia a nueva una característica **/ function newFeatures() { $ids = isset($_REQUEST['id']) ? $_REQUEST['id'] : null; $item = isset($_REQUEST['item']) ? intval($_REQUEST['item']) : 0; //Verificamos si se proporcionó una caracteristica if (!is_array($ids) || empty($ids)) { redirectMsg('./features.php?item=' . $item, _AS_DT_ERRFEAT, 1); die; } $errors = ''; foreach ($ids as $k) { //Verificamos si la característica es válida if ($k <= 0) { $errors .= sprintf(_AS_DT_ERRFEATVAL, $k); continue; } //Verificamos si la caracteristica existe $ft = new DTFeature($k); if ($ft->isNew()) { $errors .= sprintf(_AS_DT_ERRFEATEX, $k); continue; } $ft->setShowNew(!$ft->showNew()); $ft->setModified(time()); if (!$ft->save()) { $errors .= sprintf(_AS_DT_ERRFEATSAVE, $k); } } if ($errors != '') { redirectMsg('./features.php?item=' . $item, _AS_DT_ERRORS . $errors, 1); die; } else { redirectMsg('./features.php?item=' . $item, _AS_DT_DBOK, 0); die; } }