Foro - Borrar 1 tema creado por el usuario

  • Autor Autor ChatOrbi
  • Fecha de inicio Fecha de inicio
ChatOrbi

ChatOrbi

Épsilon
Hola tengo un foro pero no puedo eliminar el 1 tema creado por un usuario, solo puedo borra los mensajes despues del 1 post.

Cuando lo quiero eliminar me sale este mensaje:

you can not delete the primary post. To delete the thread instead

PHP:
function deletethread($tid) {
		global $client;
		need_login();
		$thread = valid_thread($tid);
		if (!forum_mod($thread['fid'])) die('access denied');
		// delete thread
		sql_query("delete from ".tb()."forum_threads where id='$tid' ");
		// delete post
		sql_query("delete from ".tb()."forum_posts where tid='$tid' ");
		// delete attach
		$res = sql_query("select * from ".tb()."forum_attachments where tid='$tid' ");
		while ($attach = sql_fetch_array($res)) {
			sql_query("delete from ".tb()."forum_attachments where id='{$attach['id']}' ");
			unlink($attach['uri']);
		}
		// update num
		sql_query("update ".tb()."forums set threads=threads-1,posts=posts-{$thread['posts']} where id='{$thread['fid']}' ");
		redirect(url('forums/listthreads/'.$thread['fid']),1);
	}

PHP:
function deletepost($pid) {
		global $client;
		if (!$client['id']) {
			redirect('member/login/1');
		}
		$res = sql_query("select * from ".tb()."forum_posts where id='{$pid}' ");
		$post = sql_fetch_array($res);
		if (!$post['id']) die('wrong pid');
		if ($post['is_first']) die('you can not delete the primary post. To delete the thread instead');
		if ($post['uid'] != $client['id'] && !allow_access(3)) die('access denied');
		$thread = valid_thread($post['tid']);
		sql_query("delete from ".tb()."forum_posts where id='$pid' ");
		// delete attach
		$res = sql_query("select * from ".tb()."forum_attachments where pid='$pid' ");
		while ($attach = sql_fetch_array($res)) {
			sql_query("delete from ".tb()."forum_attachments where id='{$attach['id']}' ");
			unlink($attach['uri']);
		}
		// update num
		sql_query("update ".tb()."forum_threads set posts=posts-1 where id='{$thread['id']}' ");
		sql_query("update ".tb()."forums set posts=posts-1 where id='{$thread['fid']}' ");
		redirect(url('forums/viewthread/'.$post['tid']),1);
	}

¿Alguien sabe como editar el codigo para poder borrarlo?
 

Temas similares

Edison Martinez
Respuestas
4
Visitas
305
Daniel Muñoz
Daniel Muñoz
M
Respuestas
6
Visitas
682
jimcarde
J
Atrás
Arriba