Save posts as drafts

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.

Rating:

Excellent!
47
72%
Very Good
10
15%
Good
5
8%
Fair
1
2%
Poor
2
3%
 
Total votes: 65

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq » Fri Sep 24, 2004 11:10 am

Pisqon, it sounds like either you have some other mod that is conflicting with this mod or you were installling onto a board that is not phpbb version 2.0.10. Which is it?

I know that when I upgraded from 2.0.6 to 2.0.7 I started getting identical errors with someone's Keep Unread Flags mod...I describe that and how I traced it down here: http://www.phpbb.com/phpBB/viewtopic.ph ... 3&start=60

So, are you using 2.0.10? And if not, what mods are you running?

If you are using a version before 2.0.10, I would suggest you go back to your backup files (pre this mod) and then upgrade to 2.0.10. (There are step by step mods that take you from each version to the next starting from at least 2.0.6, and you can run those with easymod.)

Once you have 2.0.10 up and running, then try installing this mod again with easymod and see what happens. Good luck.

pisqon
Registered User
Posts: 132
Joined: Mon Aug 09, 2004 5:12 am
Contact:

Post by pisqon » Fri Sep 24, 2004 3:09 pm

It must be a conflicting mod, because I'm running 2.0.10

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq » Fri Sep 24, 2004 3:12 pm

pisqon wrote: It must be a conflicting mod, because I'm running 2.0.10
That's always tough...unrelated mods often don't play nicely together.

If you want to send my your phpbb files I'll take a look in due course (but it may not be for a while).

pisqon
Registered User
Posts: 132
Joined: Mon Aug 09, 2004 5:12 am
Contact:

Post by pisqon » Fri Sep 24, 2004 5:15 pm

Tried removing all the code that it added so that I could try to reinstall the mod a little bit later. Unfortunately this now happeneds whenever one tries to post a new topic:

Code: Select all

Error in posting

DEBUG MODE

SQL Error : 1062 Duplicate entry '817' for key 1

INSERT INTO phpbb_posts_text (post_id, post_subject, bbcode_uid, post_text) VALUES (817, 'test', '92f7a9003a', 'test')

Line : 295
File : /usr/home/matt/corbantis/forums/includes/functions_post.php 
working on getting it resolved, any suggestions?

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq » Fri Sep 24, 2004 5:54 pm

Pisqon, the line it is giving you an error on is line 295 of includes/functions_post but that line appears at line 279 of functions_post in an unmodded board, so you must still have a fair amount of other modding in that file.

The error message is telling you that when you create a new topic and click submit, it tries to put the new text in a row in the posts_text table that has exactly the same post_id as an earlier post you already made. Sounds like when you tried to take out the mod you messed something up, since the lines right above the line where it is giving you an error (lines 290 through 294 on your board I imagine since they appear on lines 274 through 277 on an unmodded board) should (if not modded) be telling it to increment to the next post_id before it inserts the new row into the POSTS_TEXT TABLE when you are posting a new topic.

Did you save all your files before you did the mod? If so, replace your files with that backup. If not, then 30 lashes for you ( ;) ) and I guess if you pm me your includes/functions_post.php file I'll take a look at what you've done.

pisqon
Registered User
Posts: 132
Joined: Mon Aug 09, 2004 5:12 am
Contact:

Post by pisqon » Fri Sep 24, 2004 6:09 pm

i had to replace viewtopic.php and functions_post.php from a vanilla phpBB2. things *seem* to be working normally. but yeah, definitely 30 lashes for me. im backing my stuff up from now on.

also i found some code from your mod in an admin file. do a grep for draft and it seems to have found its way into there as well as another file i think

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq » Fri Sep 24, 2004 7:44 pm

pisqon wrote: i had to replace viewtopic.php and functions_post.php from a vanilla phpBB2. things *seem* to be working normally. but yeah, definitely 30 lashes for me. im backing my stuff up from now on....

Did you originally install the mod with easymod? If so, I think easymod will have automatically made a backup of the changed files and you could use those and be all set.

Mc ToM
Registered User
Posts: 78
Joined: Sat Aug 07, 2004 1:59 am

Post by Mc ToM » Fri Sep 24, 2004 9:51 pm

i installed the mod...
i press save post
and this is return to the index page... and this is don't save... why?

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq » Sat Sep 25, 2004 2:11 am

Mc ToM wrote: i installed the mod...
i press save post
and this is return to the index page... and this is don't save... why?


Sounds like it is doing exactly what it is supposed to do. When you hit the 'save as draft' button it saves the post and returns you to the index page so you can do whatever else you want to do.

If you then want to see your drafts, just click the link at the top right of the index page that says "View Your Drafts and Posts". That will take you to a page where your drafts and posts are listed. Just click on one of your drafts and it will open again so you can edit it some more and save it or post it as a real post.

User avatar
tbtguide
Registered User
Posts: 29
Joined: Sat Sep 25, 2004 7:34 am

Post by tbtguide » Sat Sep 25, 2004 7:41 am

My board is configured so that users may not delete their posts but I would like them to be able to delete or cancel their drafts. Is there anything I can do?

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq » Sat Sep 25, 2004 10:33 am

tbtguid wrote: My board is configured so that users may not delete their posts but I would like them to be able to delete or cancel their drafts. Is there anything I can do?


Great catch, tbtguid. I would never have thought of htat because I always allow people to delete their own posts.

Here's the fix, which I will include in my next version:

Code: Select all

OPEN
posting.php

FIND
if ( !$is_auth[$is_auth_type] )

REPLACE WITH
if ( !$is_auth[$is_auth_type] && !$was_a_draft )
Please confirm this works (or let me know if it doesn't).


[edit: fixed in current version]
Last edited by asinshesq on Wed Jan 12, 2005 3:03 pm, edited 1 time in total.

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

For anyone using the attachment mod...

Post by asinshesq » Sat Sep 25, 2004 12:10 pm

If you have the fabulous attachment mod installed and you want to tweak this mod after it is installed to allow users to post attachments in drafts, all you need to do are two things:

Code: Select all

#
#-----[ OPEN ]------------------------------------------------
#
posting.php

#
#-----[ FIND ]------------------------------------------------
#
	if ( $error_msg == '' && $save_as_draft || ($mode == 'delete' && $was_a_draft) )

#
#-----[ BEFORE, ADD ]------------------------------------------------
#
//	But before adding that block, added line to assure that any attachments get added even in the case where the post is submitted as a draft
//	(the usual attachment mod line that does this is ptherwise skipped in the case of a post submitted as a draft)
		$attachment_mod['posting']->insert_attachment($post_id);

#
#-----[ OPEN ]------------------------------------------------
#
includes/functions_post.php

#
#-----[ FIND ]------------------------------------------------
#
// in the below added code, we delete the old post from the posts table if the post was a draft getting finally submitted as a real post; and we also in that case save the $relevant_post_id for purposes of fidning the text in the topic table and then reset $post_id to match the new $post_id of the new post inserted above

		if ($was_a_draft && !$save_as_draft)
		{
			$relevant_post_id = $post_id;
			$post_id = $db->sql_nextid();

#
#-----[ REPLACE WITH ]------------------------------------------------
#
// start mod save posts as drafts
// in the below added code, we see if this is a draft getting submitted as a post; if it is, we see if there are attachments and if so fix the new post to reflect the attachment;
// then, we delete the old post from the posts table if the post was a draft getting finally submitted as a real post; and we also in that case save the $relevant_post_id for purposes of fidning the text in the topic table and then reset $post_id to match the new $post_id of the new post inserted above

		if ($was_a_draft && !$save_as_draft)
		{
			$relevant_post_id = $post_id;
			$post_id = $db->sql_nextid();

		// this part deals with attachments as mentioned above
		$sql = "SELECT post_attachment FROM " . POSTS_TABLE . " WHERE post_id = $relevant_post_id";
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
		}
		$post_info = $db->sql_fetchrow($result);
		$post_attachment = $post_info['post_attachment'];
		// test to see if there is an attachment; if there is, fix the new post to reflect it
		if ($post_attachment == 1)
		{
			$sql = "UPDATE " . POSTS_TABLE . " SET post_attachment = 1 WHERE post_id = $post_id";
			if (!$db->sql_query($sql))
			{
				message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
			}

			$sql = "UPDATE " . TOPICS_TABLE . " SET topic_attachment = 1 WHERE topic_id = $topic_id";
			if (!$db->sql_query($sql))
			{
				message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
			}

			$sql = "UPDATE " . ATTACHMENTS_TABLE . " SET post_id = $post_id WHERE post_id = $relevant_post_id";
			if (!$db->sql_query($sql))
			{
				message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
			}
		}

		// and this next part deletes the old post as mentioned above
I think this will work...it works fine on my board. But I have such a heavily modded board that there is always a possibility I am reflecting something different from a plain vanilla phpbb board with attachment, and I didn't feel like installing the attachment mod onto a clean board just to test this. So, I would appreciate it if someone would try this out and confirm it works.

[edit: additional mod to the mod for people with the attachment mod is included in the current version]
Last edited by asinshesq on Wed Jan 12, 2005 3:04 pm, edited 3 times in total.

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq » Sat Sep 25, 2004 12:50 pm

Oh, and one more thing...in an earlier post someone asked how to make this mod redirect the user to the relevant forum when he saves a draft, and I gave the answer. But it occurs to me that this would really not be ideal for most users, since sometimes a user will have more than one draft post or will want to save and go right back to a draft. The viewforum page does not have the link I put on the index page to where the draft list is, so a user would need to click back to the index in order to get to his draft.

I personally think this mod works best if you redirect the user to the index where he can go anywhere after he submits a draft, but if anyone wants to redirect to the relevant forum as suggested in the prior post, I think it would probably make sense to stick a link to the drafts list on the top right of the viewforum page. Since I won't be doing this on my board, I'll leave the nuts and bolts of that as a 'fun exercise' for whoever wants their board to function this way ;) (It is an easy fix since you can see exactly how the link on the index page works and then mimic that.)

Mc ToM
Registered User
Posts: 78
Joined: Sat Aug 07, 2004 1:59 am

Post by Mc ToM » Sat Sep 25, 2004 3:09 pm

asinshesq wrote:
Mc ToM wrote:i installed the mod...
i press save post
and this is return to the index page... and this is don't save... why?


Sounds like it is doing exactly what it is supposed to do. When you hit the 'save as draft' button it saves the post and returns you to the index page so you can do whatever else you want to do.

If you then want to see your drafts, just click the link at the top right of the index page that says "View Your Drafts and Posts". That will take you to a page where your drafts and posts are listed. Just click on one of your drafts and it will open again so you can edit it some more and save it or post it as a real post.


i remove this..
so i now add to viewtopic:

Code: Select all

<a href="{U_SEARCH_SELF}" class="gensmall">{L_SEARCH_SELF}</a>
and now this is good :D

thank you good mod!

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq » Sat Sep 25, 2004 6:53 pm

Mc ToM wrote: ...so i now add to viewtopic:

Code: Select all

<a href="{U_SEARCH_SELF}" class="gensmall">{L_SEARCH_SELF}</a>
and now this is good :D

thank you good mod!


Are you saying that you added the view your drafts and posts link (the one that appears on the index page) to your viewtopic page? Interesting...I wouldn't have though that people would use it on the viewtopics page, but everyone is entitled to his opinion.

Post Reply

Return to “[2.0.x] MOD Database Releases”