vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Deleting thread when there's reply (https://vborg.vbsupport.ru/showthread.php?t=53934)

warpeditor 06-06-2003 05:38 PM

Deleting thread when there's reply
 
Hi,

Right now, our registered members can delete their own post and thread they started. However, is it possible to make registered members CAN delete post but CANNOT delete thread when there's reply?

Is there any hack for this? I couldn't find one.

MetroSports82 06-06-2003 07:45 PM

i've tried to come up with something similar to this in the past, but gave up after coming up unsuccessful. :( but, thats a very good idea there warpeditor! especially when you want to avoid having users delete a large thread, that might have alot of replies, (for intent purpose to get back at someone, or whatever). but on the other hand, having them the access to delete it, if it was a thread that was mistakenly created, or what not. and also, just to quickly add to this idea if you will. there should be a way to have it selectable. say after 5 or 10 replies, that a thread is allowed to be deleted by the thread starter, from deleting the first post. after that number, it should then be disabled. that would be nice. ;)

warpeditor 06-07-2003 01:53 AM

Thanks for reply.

One of our registered member deleted all the thread he created because he got upset with others reply/comments about his post. There even was some thread with 200+ replies but all gone. Then I thought this could be a good idea.

Any ideas?

MetroSports82 06-08-2003 02:50 PM

ok, tell ya what.. i'm gonna try this again, even thought i came up flat out my face the first time. i'll let you know if i get anything to work properly, with the correct functions. in the meantime, this is the block of code that i will be working on, to see what needs to be tweaked around, to get this feature working. ;)

- editpost.php -
PHP Code:

// ############################### start update post ###############################
if ($HTTP_POST_VARS['action']=="updatepost") {

  
// check for message
  
if ($message=="") {
    eval(
"standarderror(\"".gettemplate("error_nosubject")."\");");
    exit;
  }

  
// decode check boxes
  
$parseurl=iif($parseurl=="yes",1,0);
  
$email=iif($email=="yes",1,0);
  
$allowsmilie=iif($disablesmilies=="yes",0,1);
  
$signature=iif($signature=="yes",1,0);

  
$editedbysql="";
  if (
$showeditedby and $postinfo[dateline]<(time()-($noeditedbytime*60)) and !($getperms[ismoderator] and !$showeditedbyadmin)) {
    
$editedbysql=",edituserid='$bbuserinfo[userid]',editdate='".time()."'";
  }

  
// check max images
  
if ($maximages!=0) {
    
$parsedmessage=bbcodeparse($message,$threadinfo['forumid'],$allowsmilie);
    if (
countchar($parsedmessage,"<img")>$maximages) {
      eval(
"standarderror(\"".gettemplate("error_toomanyimages")."\");");
      exit;
    }
  }

  if (!isset(
$iconid) or $iconid=="") {
    
$iconid=0;
  }
  
$iconid=intval($iconid);

  if (
$parseurl) {
    
$message=parseurl($message);
  }

  
$attachmentsql="";
  if (
$postinfo[attachmentid]!=0) {
    
// check attachment status
    // keep, delete, update
    
if (trim($attachmentaction)=="delete") {
      
$attachmentsql=",attachmentid=0";
      
$DB_site->query("DELETE FROM attachment WHERE attachmentid=$postinfo[attachmentid]");
      
updatethreadcount($threadinfo[threadid]);
    }
    if (
trim($attachmentaction)=="new") {
            
// sort attachement
            
if (is_array($HTTP_POST_FILES)) {
                
$attachment $HTTP_POST_FILES['attachment']['tmp_name'];
                
$attachment_name $HTTP_POST_FILES['attachment']['name'];
                
$attachment_size $HTTP_POST_FILES['attachment']['size'];
            }
            if (
trim($attachment)!="none" and trim($attachment)!="" and trim($attachment_name)!="") {
                
$attachmentid=acceptupload($foruminfo[moderateattach]);
              
$attachmentsql=",attachmentid='$attachmentid'";
              
$DB_site->query("DELETE FROM attachment WHERE attachmentid=$postinfo[attachmentid]");
            }
    }
  }

  
// remove sessionhash from urls:
  
$message stripsession($message);

  
$title=censortext($title);
  
$message=censortext($message);

  if (
strlen($message)>$postmaxchars and $postmaxchars!=0) {
    eval(
"standarderror(\"".gettemplate("error_toolong")."\");");
  }

  
// find out if first post
  
$getpost=$DB_site->query_first("SELECT postid FROM post WHERE threadid=$threadinfo[threadid] ORDER BY dateline LIMIT 1");
  if (
$getpost[postid]==$postid) {
    
$isfirst=1;
  } else {
    
$isfirst=0;
  }
  if (
$isfirst and $title!="" and $postinfo[dateline]+$editthreadtitlelimit*60>time()) {
    
$DB_site->query("UPDATE thread SET title='".addslashes(htmlspecialchars($title))."', iconid=".intval($iconid)." WHERE threadid=$threadinfo[threadid]");
    
//$title="";
  
}

  if (
$email) {
    if (!
$checkid=$DB_site->query_first("SELECT subscribethreadid FROM subscribethread WHERE userid=$postinfo[userid] AND threadid=$threadinfo[threadid]")) {
      
$DB_site->query("INSERT INTO subscribethread (subscribethreadid,userid,threadid) VALUES (NULL,$postinfo[userid],$threadinfo[threadid])");
    } 
// else : already subscribed, so no need to do that again
  
} else {
    if (
$checkid=$DB_site->query_first("SELECT subscribethreadid FROM subscribethread WHERE userid=$postinfo[userid] AND threadid=$threadinfo[threadid]")) {
      
$DB_site->query("DELETE FROM subscribethread WHERE userid=$postinfo[userid] AND threadid=$threadinfo[threadid]");
    } 
// else : already unsubscribed, so no need to unsubscribe
  
}

  
$DB_site->query("UPDATE post SET title='".addslashes(htmlspecialchars($title))."',pagetext='".addslashes($message)."',allowsmilie='$allowsmilie',showsignature='$signature',iconid='$iconid'$editedbysql$attachmentsql WHERE postid='$postid'");
  
unindexpost($postid);
  
indexpost($postid);

  eval(
"standardredirect(\"".gettemplate("redirect_editthanks")."\",\"showthread.php?s=$session[sessionhash]&postid=$postid#post$postid\");");
}

if (
$action=="deletepost") {
  if (
$deletepost=="yes") {
    
//get first post in thread
    
$getfirst=$DB_site->query_first("SELECT postid,dateline FROM post WHERE threadid='$threadid' ORDER BY dateline LIMIT 1");
    if (
$getfirst[postid]==$postid) {
      
// delete thread
      
if ($getperms[candeletethread]) {
        
deletethread($threadinfo[threadid],$foruminfo[countposts]);
        
updateforumcount($threadinfo[forumid]);
        eval(
"standardredirect(\"".gettemplate("redirect_deletethread")."\",\"forumdisplay.php?s=$session[sessionhash]&forumid=$threadinfo[forumid]\");");
      } else {
        
show_nopermission();
      }
    } else {
      
//delete just this post
      
$foruminfo=getforuminfo($threadinfo[forumid]);
      
deletepost($postid,$foruminfo[countposts],$threadinfo[threadid]);

      
updatethreadcount($threadinfo[threadid]);
      
updateforumcount($threadinfo[forumid]);

     eval(
"standardredirect(\"".gettemplate("redirect_deletepost")."\",\"showthread.php?s=$session[sessionhash]&threadid=$threadinfo[threadid]\");");
    }
  } else {
    eval(
"standardredirect(\"".gettemplate("redirect_nodelete")."\",\"showthread.php?s=$session[sessionhash]&postid=$postid#post$postid\");");
  }


hopefully for me anyway, the 2nd time around will be a charm. though i'm very pesimistic.. :disappointed:

Metro.

warpeditor 06-08-2003 03:03 PM

Thanks for your interest, Metro!

Since I don't know php enough to do hack, I will just wait for you to come up with something then. Thanks again.


All times are GMT. The time now is 01:46 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01136 seconds
  • Memory Usage 1,795KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete