//Usuarios Anonimos $item->setVar('uid', 0); $item->setVar('approved', $mc['approve_anonymous']); } if ($edit) { $item->setVar('modified', time()); } else { $item->setVar('created', time()); $item->setVar('modified', time()); } if ($edit && !$mc['aprove_edit']) { $item->setVar('created', time()); } $item->setVar('secure', $mc['secure_public'] ? $secure : 0); $item->setVar('groups', $groups); $item->setCategories($category); $item->setVar('version', $version); $item->setVar('author_name', $author_name); $item->setVar('author_url', formatURL($author_url)); $item->setVar('author_email', $author_email); $item->setVar('author_contact', $author_contact); $item->setVar('image', $image); $item->setVar('password', $mc['pass_public'] ? $password : ''); $item->setVar('langs', $langs); $item->setTags(explode(',', $tags)); //Licencias $item->setLicences($licences); //Plataformas $item->setPlatforms($platforms); if (!$item->save(true)) { redirect_header(DT_URL . ($mc['permalinks'] ? '/submit/' . ($edit ? 'edit/' . $item->id() . '/' : '') : '/p=submit' . ($edit ? '?action=edit&id=' . $id : '')), 1, __('Download item could not be saved! Please try again.', 'dtransport'));
/** * Save new o existing download * @param int Indicates if edit or create a download */ function dt_save_download($edit = 0) { global $xoopsSecurity, $functions; foreach ($_POST as $k => $v) { ${$k} = $v; } // Check xoops security if (!$xoopsSecurity->check()) { dt_send_message(__('Session token not valid!', 'dtransport'), 1, 0); } // Check data if ($name == '') { dt_send_message(__('Name must be specified!', 'dtransport'), 1, 1); } if ($shortdesc == '' || $desc == '') { dt_send_message(__('A short description and full description must be specified for this download!', 'dtransport'), 1, 1); } if (empty($catids)) { dt_send_message(__('Select a category to assign this download!', 'dtransport'), 1, 1); } if (empty($lics)) { dt_send_message(__('A license must be selected at least!', 'dtransport'), 1, 1); } if (empty($platforms)) { dt_send_message(__('A platform must be selected at least!', 'dtransport'), 1, 1); } if (empty($groups)) { dt_send_message(__('A group must be selected at least!', 'dtransport'), 1, 1); } if ($edit) { if ($id <= 0) { dt_send_message(__('You must specified a download item to be edited!', 'dtransport'), 1, 1); } $down = new DTSoftware($id); if ($down->isNew()) { dt_send_message(__('Sepecified download item does not exists!', 'dtransport'), 1, 1); } } else { $down = new DTSoftware(); } $tc = TextCleaner::getInstance(); $down->setVar('name', $name); $down->setVar('nameid', $tc->sweetstring($name)); $down->setVar('version', $version); $down->setVar('shortdesc', $shortdesc); $down->setVar('desc', $desc); $down->setVar('image', $image); $down->setVar('limits', $limits); if (!$edit) { $down->setVar('created', time()); } $down->setVar('modified', time()); $down->setVar('uid', $user); $down->setVar('password', $password); $down->setVar('secure', $password != '' ? 1 : $secure); $down->setVar('groups', $groups); $down->setVar('approved', $approved); $down->setVar('featured', $mark); $down->setVar('siterate', $siterate); $down->setVar('author_name', $author); $down->setVar('author_email', $email); $down->setVar('author_url', $url); $down->setVar('author_contact', $contact); $down->setVar('langs', $langs); // Categories $down->setCategories($catids); // Licences $down->setLicences($lics); // Platforms $down->setPlatforms($platforms); // Tags $down->setTags($tags); // Alert if ($alert) { $down->createAlert(); $down->setLimit($limitalert); $down->setMode($mode); } global $xoopsDB; $db = $xoopsDB; // Check if exists another download with same name $sql = "SELECT COUNT(*) FROM " . $db->prefix("dtrans_software") . " WHERE name='{$name}' AND nameid='" . $down->getVar('nameid') . "'"; if ($edit) { $sql .= " AND id_soft<>" . $down->id(); } list($num) = $db->fetchRow($db->query($sql)); if ($num > 0) { dt_send_message(__('Another item with same name already exists!', 'dtransport'), 1, 1); } $ev = RMEvents::get(); $ev->run_event('dtransport.saving.item', $down); // Save item if (!$down->save() && $down->isNew()) { dt_send_message(__('Item could not be saved!', 'dtransport') . '<br />' . $down->errors(), 1, 1); } elseif (!$down->save() && !$down->isNew()) { dt_send_message(__('Item saved but with some errors!', 'dtransport') . '<br />' . $down->errors(), 1, 1); } $functions->save_meta('down', $down->id()); $ev->run_event('dtransport.item.saved', $down); $ret['id'] = $down->id(); $ret['created'] = $down->getVar('created'); $ret['modified'] = $down->getVar('modified'); $ret['link'] = $down->permalink(1); $ret['message'] = $edit ? __('Changes saved successfully!', 'dtransport') : __('Item created successfully!', 'dtransport'); dt_send_message($ret, 0, 1); }