/** * @desc Almacena los datos de un foro */ function bx_save_forum($edit = 0) { global $xoopsSecurity, $xoopsModuleConfig, $xoopsConfig; $q = $edit ? 'action=edit' : 'action=new'; $prefix = 1; foreach ($_POST as $k => $v) { if (substr($k, 0, 5) == 'perm_') { $permissions[substr($k, 5)] = $v; } else { ${$k} = $v; } if ($k == 'XOOPS_TOKEN_REQUEST' || $k == 'action') { continue; } $q = '&' . $k . '=' . $v; } if (!$xoopsSecurity->check()) { redirectMsg('forums.php?' . $q, __('Session token expired', 'bxpress'), 1); die; } if ($edit) { $id = rmc_server_var($_REQUEST, 'id', 0); if ($id <= 0) { redirectMsg('forums.php', __('Specified id is not valid!', 'bxpress'), 1); die; } $forum = new bXForum($id); if ($forum->isNew()) { redirectMsg('forums.php', __('Specified forum does not exists!', 'bxpress'), 1); die; } } else { $forum = new bXForum(); } $forum->setName($name); $forum->setDescription($desc); if (!$edit) { $forum->setTopics(0); $forum->setPosts(0); $forum->setPostId(0); $forum->setSubforums(0); } $forum->setCategory($cat); $forum->setActive($active); $forum->setSignature($sig); $forum->setPrefix($prefix); $forum->setHotThreshold($hot_threshold); $forum->setOrder($order); $forum->setAttachments($attachments); $forum->setMaxSize($attach_maxkb); $forum->setExtensions(explode('|', $attach_ext)); $forum->setFriendName(TextCleaner::getInstance()->sweetstring($name)); $forum->setPermissions($permissions); if ($forum->save()) { if ($parent > 0) { $pf = new bXForum($parent); if (!$pf->isNew()) { $pf->setSubforums($pf->subforums() + 1); $pf->save(); } } if (!$edit) { //Redireccionamos a ventana de selección de moderadores redirectMsg('forums.php?action=moderators&id=' . $forum->id(), __('Forum saved successfully! Redirecting to moderators assignment...', 'bxpress'), 0); } else { redirectMsg('forums.php', __('Changes saved successfully!', 'bxpress'), 0); } } else { redirectMsg('forums.php?' . $q, __('Forum could not be saved!', 'bxpress') . $forum->errors(), 1); } }
/** * @desc Eliminar temas */ function deleteTopics() { global $db, $xoopsModuleConfig, $bxpress, $forum, $xoopsUser, $xoopsSecurity; $ok = isset($_POST['ok']) ? $_POST['ok'] : 0; $topics = isset($_REQUEST['topics']) ? $_REQUEST['topics'] : null; if (empty($topics) || is_array($topics) && empty($topics)) { redirect_header('moderate.php?id=' . $forum->id(), 2, __('Select at least one topic to delete!', 'bxpress')); die; } $topics = !is_array($topics) ? array($topics) : $topics; $lastpost = false; if (!$xoopsSecurity->check()) { redirect_header('moderate.php?id=' . $forum->id(), 2, __('Session token expired!', 'bxpress')); die; } foreach ($topics as $k) { $topic = new bXTopic($k); if ($topic->isNew()) { continue; } if ($topic->forum() != $forum->id()) { continue; } //Verificamos si el tema contiene el último mensaje del foro if (!$lastpost && array_key_exists($forum->lastPostId(), $topic->getPosts(0))) { $lastpost = true; } $topic->delete(); } //Actualizamos el último mensaje del foro if ($lastpost) { $forum = new bXForum($forum->id()); $post = $forum->getLastPost(); $forum->setPostId($post); $forum->save(); } redirect_header('moderate.php?id=' . $forum->id(), 1, __('Action completed!', 'bxpress')); }