/** * @desc Almacena los usuarios moderadores **/ function bx_save_moderators() { global $xoopsSecurity; if (!$xoopsSecurity->check()) { redirectMsg('forums.php', __('Session token expired!', 'bxpress'), 1); die; } foreach ($_POST as $k => $v) { ${$k} = $v; } //Verificamos si el foro es válido if ($id <= 0) { redirectMsg('forums.php', __('A forum ID has not been provided!', 'bxpress'), 1); die; } //Comprobamos que el foro exista $forum = new bXForum($id); if ($forum->isNew()) { redirectMsg('forums.php', __('Sepecified forum does not exists!', 'bxpress'), 1); die; } $forum->setModerators($users); if ($forum->save()) { redirectMsg('forums.php', __('Moderator saved successfully!', 'bxpress'), 0); } else { redirectMsg('forums.php', __('Moderators could not be saved!', 'bxpress') . '<br />' . $forum->errors(), 1); } }
public function delete() { foreach ($this->getPosts() as $post) { $post->delete(); } $forum = new bXForum($this->forum()); $forum->setTopics($forum->topics() - 1 > 0 ? $forum->topics() - 1 : 0); $forum->save(); return $this->deleteFromTable(); }
/** * @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')); }