Foros del Web » Programando para Internet » PHP »

Foro - Borrar 1 tema creado por el usuario

Estas en el tema de Foro - Borrar 1 tema creado por el usuario en el foro de PHP en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 28/05/2013, 22:31
Avatar de ChatDelMundo  
Fecha de Ingreso: abril-2013
Mensajes: 98
Antigüedad: 11 años
Puntos: 1
Foro - Borrar 1 tema creado por el usuario

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

Código 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);
    } 
Código 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?
__________________
chatdelmundo.es
  #2 (permalink)  
Antiguo 29/05/2013, 01:43
Avatar de repara2  
Fecha de Ingreso: septiembre-2010
Ubicación: München
Mensajes: 2.445
Antigüedad: 13 años, 7 meses
Puntos: 331
Respuesta: Foro - Borrar 1 tema creado por el usuario

Esta linea impide que borres el primer post:

Código PHP:
Ver original
  1. if ($post['is_first']) die('you can not delete the primary post. To delete the thread instead');
__________________
Fere libenter homines, id quod volunt, credunt.
  #3 (permalink)  
Antiguo 29/05/2013, 12:56
Avatar de ChatDelMundo  
Fecha de Ingreso: abril-2013
Mensajes: 98
Antigüedad: 11 años
Puntos: 1
Respuesta: Foro - Borrar 1 tema creado por el usuario

Cita:
Iniciado por repara2 Ver Mensaje
Esta linea impide que borres el primer post:

Código PHP:
Ver original
  1. if ($post['is_first']) die('you can not delete the primary post. To delete the thread instead');
Cuando quito esa linea no se borra bien,

¿Sabes si se puede dejar la misma forma de borrar los mensajes despues del 1 post?
__________________
chatdelmundo.es

Etiquetas: creado, foro, select, sql, tema, usuario
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:52.