/** * @desc Elimina el grupo especificado **/ function deleteGroups() { global $xoopsModule, $util, $xoopsSecurity; $id = rmc_server_var($_REQUEST, 'id', array()); $item = rmc_server_var($_REQUEST, 'item', 0); if (!$xoopsSecurity->check()) { redirectMsg('files.php?item=' . $item, __('Session token not valid!', 'dtransport'), RMMSG_WARN); die; } //Verificamos si el software es válido if ($item <= 0) { redirectMsg('files.php', __('Download item ID not provided!', 'dtransport'), RMMSG_WARN); die; } //Verificamos si existe el software $sw = new DTSoftware($item); if ($sw->isNew()) { redirectMsg('files.php', __('Specified download item does not exists!', 'dtransport'), RMMSG_WARN); die; } //Verificamos si grupo es válido if ($id <= 0) { redirectMsg('files.php?item=' . $item, __('Group id not provided!', 'dtransport'), RMMSG_ERROR); die; } //Verificamos si el grupo existe $group = new DTFileGroup($id); if ($group->isNew()) { redirectMsg('files.php?item=' . $item, __('Specified group does not exists!', 'dtransport'), RMMSG_ERROR); die; } if (!$group->delete()) { redirectMsg('files.php?item=' . $item, sprintf(__('Group %s could not be deleted!', 'dtransport'), '<strong>' . $group->name() . '</strong>') . '<br />' . $group->errors(), 1); die; } else { redirectMsg('files.php?item=' . $item, sprintf(__('Group %s deleted successfully!', 'dtransport'), '<strong>' . $group->name() . '</strong>'), 0); die; } }
function dt_reasign_file() { global $xoopsSecurity, $functions; if (!$xoopsSecurity->check()) { $functions->dt_send_message(__('Session token not valid!', 'dtransport'), 1, 0); } $id = rmc_server_var($_POST, 'id', 0); $idgroup = rmc_server_var($_POST, 'idgroup', 0); $item = rmc_server_var($_POST, 'item', 0); $file = new DTFile($id); if ($file->isNew()) { $functions->dt_send_message(__('Specified file does not exists!', 'dtransport'), 1, 1); } if ($idgroup > 0) { $group = new DTFileGroup($idgroup); if ($group->isNew()) { $functions->dt_send_message(__('Specified group does not exists!', 'dtransport'), 1, 1); } } if ($file->software() != $item) { $functions->dt_send_message(__('This file seems not belong to specified download item!', 'dtransport'), 1, 1); } $file->setGroup($idgroup); if ($file->save()) { $functions->dt_send_message(array('message' => __('File reasigned successfully!', 'dtransport')), 0, 1); } else { $functions->dt_send_message(__('File could not be reasigned!', 'dtransport'), 1, 1); } }