To delete post permanently, just for users who need that

  1. 6 years ago
    Edited 6 years ago by bitikas

    esotalk/core/controllers/ETConversationController.class.php

    public function deletePost($postId = false)
    {
    	if (!($post = $this->getPostForEditing($postId)) or !$this->validateToken()) return;
    
    	#ET::postModel()->deletePost($post);#original
    	ET::postModel()->deleteById($postId);#deleting the post, not conversation
    
    	// Normally, redirect back to the conversation.
    	#if ($this->responseType === RESPONSE_TYPE_DEFAULT) {
    		redirect(URL(R("return", postURL($postId))));
    	#}
    
    	// For an AJAX request, render the post view.
    	#elseif ($this->responseType === RESPONSE_TYPE_AJAX) {
    	#	$this->data("post", $this->formatPostForTemplate($post, $post["conversation"]));
    	#	$this->render("conversation/post");
    		return;
    	#}
    }

    How to update the conversation table, column countPosts ?
    In the begining deletion is perfect, but after is loading and loading and so one...

  2. Edited 6 years ago by bitikas

    Again found my self :)
    esotalk/core/controllers/ETConversationController.class.php

    public function deletePost($postId = false)
    {
    	// getting category number
    	$aruteluid = ET::SQL()
    		->select("conversationId")
    		->from("post")
    		->where("postid",$postId)
    		->exec()
    		->result();
    
    	// updating category posts count
    	ET::SQL()
    		->update("conversation")
    		->set("countPosts", "countPosts - 1", false)
    		->where("conversationid",$aruteluid)
    		->exec();
    
    	if (!($post = $this->getPostForEditing($postId)) or !$this->validateToken()) return;
    	ET::postModel()->deleteById($postId);
    
    	// Normally, redirect back to the conversation.
    	if ($this->responseType === RESPONSE_TYPE_DEFAULT) {
    		redirect(URL(R("return", postURL($postId))));
    
    	}
    
    	// For an AJAX request, render the post view.
    	elseif ($this->responseType === RESPONSE_TYPE_AJAX) {
    		$this->data("post", $this->formatPostForTemplate($post, $post["conversation"]));
    		$this->render("conversation/post");
    	redirect(URL(R("return", postURL($postId))));
    	return;
    	}
    }
  3. Its not perfect and need some attachment handling but so far it is all right...

  4. 5 years ago

    Here is my dirty (but working?) variant:

    https://github.com/gl00my/esoTalk/commit/f2f3a77f2c24ae3db4d76f146bc10b756ccf82a3

    To delete post you need delete marked as delete post. :)

    Hope it helps.

  5. Edited 5 years ago by Tristan

    @peter
    Thanks for that, does work for me. Although I noticed it does not remove the <div class="timeMarker">%TIME%</div> on a permanent pos delete. Small detail though ;)

    I have fixed this here!

  6. @bitikas Its not perfect and need some attachment handling but so far it is all right...

    Not sure if @peter his commit has the correct attachment handling. I can see my attachments are still in /uploads/attachments even when I have permanently deleted the post with attachments. Need to look into it.

  7. @Tristan Thank you for bugreport. I have fixed attachment removing here: https://github.com/gl00my/esoTalk/commit/2e34a55502f2e088507c4705ec8615ebe741d8ff

  8. @peter @Tristan Thank you for bugreport. I have fixed attachment removing here: https://github.com/gl00my/esoTalk/commit/2e34a55502f2e088507c4705ec8615ebe741d8ff

    @peter

    Please see my commit here

    I had to change a lot to make it work 99%. There is still a bug left which I reported here

  9. Eh... My code currenly work fine (after fixing unlink). At least i see that files are removed and db is ok.
    I am not sure about your code, but i will try to see it too. Bug about removing before commiting to db is interesting too.

  10. Well, one thing I noticed is that the function getById() and deleteByID() were completely missing in the AttachmentModel.class.php. So I am not sure how your current code is working.

  11. It ok. getById is used from another place. I looked at your code and i think that with my last fix it is not needed. I do not see any problems it solves. Of course, i am not php expert, :)

    Btw, here is fix of second bug (cleanup attachment when there was no commit): https://github.com/gl00my/esoTalk/commit/5b7e8b496f163a32c2a4bceae4a15ad3e07a4332

    Tell me if there are still problems.

  12. Yes, I figured as there is no other way for it to work. I will revert my changes and implement your fixes. Thanks for that.

    I have forked your repo but made some decent changes to it already. We should somehow not be working beside each other but with each other. How should we proceed?

  13. Edited 5 years ago by peter

    I am not sure how we can. In fact, my repo currently is used in my web project (it is personal) and it contains a lot of dirty hacks that cant be pushed to upstream, but it works for me. So, there is a lot of work to maintain "clean" branch, that can be merged to upstream. I am not ready for that, i am just using this forum. :)

  14. Well, dirty hacks or not. Your version works perfectly for me.

  15. Hy guys, i write here just to let know i seriously want to collect all the plugins in my site, for the community.
    I'm not an expert, but least something for the moment i achieve some success to get som list for the ideas.
    This is my site discussion for the plugins i found http://brunn.ee/248-esotalk-foorumi-pluginad
    In the moment my timelimit is zero to do some writing my self, but i just hope to help.
    In the future i hope to find more time to dive in.

  16. Edited 5 years ago by Tristan

    Good idea, I was thinking of it myself but then put them on GitHub so you can easily clone then, track them and submit issues. How about we create a esoTalk-addons GitHub account where we both collaborate in?

    [edit]
    I have created a esoTalk Addons GitHub account What is your accountname so I can make you member?

  17. https://github.com/brunn is my github address.

  18. Done!

  19. Edited 5 years ago by Tristan

    Thinking about it, we might need to create 3 GitHub organisations, esoTalk-plugins, esoTalk-languages and esoTalk-skins as I think that is the only way to separate them into different "folders".

    I have renamed the repo to esoTalk-plugins and uploaded the first plugins.

  20. Edited 5 years ago by bitikas

    Super Cool!

 

or Sign Up to reply!