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.
Post Reply

Rating:

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

Extensions Robot
Extensions Robot
Extensions Robot
Posts: 29216
Joined: Sat Aug 16, 2003 7:36 am

Save posts as drafts

Post by Extensions Robot »

MOD Name: Save posts as drafts
Author: asinshesq
MOD Description: Allow users to save their posts or pms as drafts so they can begin a post or pm and finish it later. Since it is a draft, others will not see it until it is done.

MOD Version: 1.0.25 (Updated 10/17/06)
Tested on phpBB Version: 2.0.21

Download File: save_posts_as_drafts_1-0-25.zip
mods overview page: View
File Size: 77087 Bytes



Support for this MOD needs to be asked within this topic. The phpBB Teams are not responsible or required to give anyone support for this MOD. By installing this MOD, the phpBB Support Team or phpBB MODifications Team may not be able to provide support.

This MOD has only been tested by the phpBB MOD Team with the phpBB version listed in the topic. It may not work in any other versions of phpBB.
Last edited by Extensions Robot on Mon Apr 30, 2007 12:31 am, edited 1 time in total.
(this is a non-active account manager for the phpBB Extension Customisations Team)
Darkmonkey
Former Team Member
Posts: 1707
Joined: Fri Oct 24, 2003 3:48 pm
Location: Where the trout streams flow and the air is nice

Post by Darkmonkey »

MOD Validated/Released

Notes:
This MOD allows users to save their posts as drafts. Once saved, a draft is hidden, and can only be accessed from the index, where it can be finished, and submitted as a post.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

Wow, two of my mods validated in the same day (and four in the last week)...you guys are really moving fast!

Anyway, this mod gives you a 'save as draft' button right next to the preview and submit buttons in a post that will allow you to save the post as a draft. If you save it as a draft, it will not show up in viewtopics when others look at the topic and will not be reflected in updated stats (new posts, number of posts) and will not appear in any searches.

If you want to see your drafts, you click on the index page where it says "view your drafts and posts" and that will take you to a search page where you will see a list of your drafts on top of a list of your regular posts. When you click on one of those drafts, you can continue editing it and save it as a draft or you can go ahead and submit it for real.

I also tinkered with review topic so that it shows up even during edit mode (so that you can revise the draft in the context of the other posts).

I got the idea and borrowed some of the code from this mod: http://www.phpbb.com/phpBB/viewtopic.ph ... sc&start=0
but this mod is different enough from that mod in functionality that I thought it merited its own seperate mod.

Some people have asked about differences from the other mod. This is a much bigger (and IMHO more complete) mod. The other one simply hides a draft with red letters saying 'draft under construction' if you designate it as a draft, but it still shows up in viewtopics and it still is included in the search index (and it still triggers reply email notifications, gets marked as a new post and updates all board stats). Drafts in this mod are completely invisible (their existence won't even by known by others) till you actually submit the draft as a real post.

Other differences:

The other one has the draft designation as a checkbox in the post (like the 'check for notification' option) while this one has a save as draft button just like the preview or submit button (right next to the preview button).

And the other one has you go into your profile to view your drafts...this one changes the regular link in the index from 'view your posts' to 'view your drafts and posts' and if you click that it takes you to a list of drafts followed by a list of posts you have made.

Also, this one changes the edit function generally (for drafts but also for regular edits) so that when you are editing a post you can see the prior posts (same behavior as you have when you reply to a piost and can see prior posts).

Both can be installed by easymod so it's easy to check and see which you prefer.

Let me know what you think!!
Last edited by asinshesq on Tue Jan 03, 2006 5:05 pm, edited 6 times in total.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

Murphy's law of mods: I've been running this on my board for quite some time now without any problems, but I just noticed today (the day this mod got validated) that I have a small error in search.php that will count drafts as new posts when the user clicks the New Posts link on the index (it doesn't actually show the posts since it squelches any posts with post_draft=1, but it does count them and show the topic the draft is in until you open that topic).

Easy to fix, but I think I'll wait a few weeks before uploading a new version for validation in case there are other things people notice. In the meantime, here's the fix:

When you get to search.php, the first change in the mod should be the following:

Code: Select all

#
#-----[ OPEN ]------------------------------------------------
#
search.php

#
#-----[ FIND ]------------------------------------------------
#
						WHERE post_time >= " . $userdata['user_lastvisit'];

#
#-----[ REPLACE WITH ]------------------------------------------------
#
						WHERE post_time >= " . $userdata['user_lastvisit'] . " AND post_draft = 0";
[edit: fixed in current version]
Last edited by asinshesq on Wed Jan 12, 2005 2:59 pm, edited 1 time in total.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

Here's another minor glitch I just discovered: when the board thinks things are out of sync and resyncs them (for example when you go to the forum management page in the ACP and click 'resync'), it in some contexts counts drafts as real so the post or topic count can get messed up. An easy fix:

Code: Select all

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

#
#-----[ FIND ]------------------------------------------------
#
				FROM " . TOPICS_TABLE;

#
#-----[ REPLACE WITH ]---------------------------------------- 
#
				FROM " . TOPICS_TABLE . "
				WHERE topic_last_post_id > 0";
// start mod save posts as drafts (and end too)...added constraint that topic_last_post_id be greater than 0 so that this function doesn't try to erroneously sync a topic that is only a draft

#
#-----[ FIND ]------------------------------------------------
#
				FROM " . POSTS_TABLE . "  
				WHERE forum_id = $id";

#
#-----[ REPLACE WITH ]---------------------------------------- 
#
				FROM " . POSTS_TABLE . "  
				WHERE forum_id = $id
				AND post_draft = 0";
// start mod save posts as drafts (and end too)...added constraint that post_draft be 0 so that this function doesn't count drafts as posts in a topic or forum

#
#-----[ FIND ]------------------------------------------------
#
				FROM " . TOPICS_TABLE . "
				WHERE forum_id = $id";

#
#-----[ REPLACE WITH ]---------------------------------------- 
#
				FROM " . TOPICS_TABLE . "
				WHERE forum_id = $id
				AND topic_last_post_id > 0";
// start mod save posts as drafts (and end too)...added constraint that topic_last_post_id be greater than 0 so that this function doesn't count draft topics as real topics in a forum
Like before, I'll hold up on submitting a new version for validation for a few weeks in case anyone has feedback.


[edit: fixed in current version]
Last edited by asinshesq on Wed Jan 12, 2005 3:00 pm, edited 1 time in total.
Thallium
Registered User
Posts: 395
Joined: Mon Aug 30, 2004 12:30 am
Contact:

Post by Thallium »

Well I hate to be the first to point out problems but I'm having some major ones with this mod, I must have done something wrong when installing it, maybe. The 'Save as Draft' button just posts the reply, it doesn't save it. The 'View posts and Drafts' link on the index doesn't show said "drafts" or replies. I'm not sure what went wrong, the mod seemed very straightforward to install.

Could I get some help with this please, I'm stumped as to where it went wrong and I'd really prefer not to abandon this mod, its a good one.

Hopeful,
Thallium

Btw.... a really nice addition to this mod would be a button on the post reply page to view drafts so users could just go where they want and access them from there. Dunno if its possible though, but it seems most things are given enough thought.
Complete phpBB powered websites, Mods/Hacks installed, unique templates, updates and repairs... reasonable. Email, PM or IM.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

Thallium wrote: Well I hate to be the first to point out problems but I'm having some major ones with this mod, I must have done something wrong when installing it, maybe. The 'Save as Draft' button just posts the reply, it doesn't save it. The 'View posts and Drafts' link on the index doesn't show said "drafts" or replies. I'm not sure what went wrong, the mod seemed very straightforward to install....


That is odd. Did you install by hand or by easymod? Is your board heavily modded?

When you hit the 'Save as Draft' button it should save the post as a draft (the post_draft column in the POSTS table should get set at 1) and then it should take you directly to the forum index page. Is it taking you somewhere else (like does it give you the regular screen you get on a reply or first post)? If so, maybe you've got soemthing wrong in the posting_body.tpl file...try checking this line in posting.tpl to make sure you have it right (especially the "name=save_as_dfaft" part):

Code: Select all

	  <td class="catBottom" colspan="3" align="center" height="28"> {S_HIDDEN_FORM_FIELDS}<input type="submit" tabindex="4" name="save_as_draft" class="mainoption" value="{L_SAVE_AS_DRAFT}" />&nbsp;<input type="submit" tabindex="5" name="preview" class="mainoption" value="{L_PREVIEW}" />&nbsp;<input type="submit" accesskey="s" tabindex="6" name="post" class="mainoption" value="{L_SUBMIT}" /></td>
As far as the view your posts and drafts link problem, that should only show your regular posts (looks like the screen you get to on an unmodded board if you hit the view your posts link) unless you have some unreleased drafts. If you do, those drafts get listed at the top of the list as 'Drafts'.
Thallium
Registered User
Posts: 395
Joined: Mon Aug 30, 2004 12:30 am
Contact:

Post by Thallium »

Well I installed it (and every other mod before it) by hand, from what I've read there can be problems with easymod and I don't mind taking the time to do it manually. I'm learning quite a bit from it too. Anyway, the board is not heavily modded (imo) maybe 5 or 6 other mods and most of those are additions to the bbcode.

I've looked over the whole thing and it seems right, and the code you cited is precisely what i have. It does take you to the index after clicking 'save as draft' but the message is posted just the same as if you hit submit. I have saved four items as draft, three were posted as replies immediately, and were not added to the list of my posts, they also were not listed on the index as most recent post, and one was a new topic saved as a draft that seems to have been consigned to oblivion. <sighs>

The only thing I can think of, which shouldn't be an issue is I'm using the Charcoal2 template, and its a little weird in a couple places like the index footer but not anything that should affect this.

I appreciate the quick and helpful reply, hope I was a little more specific here.

Thallium
Complete phpBB powered websites, Mods/Hacks installed, unique templates, updates and repairs... reasonable. Email, PM or IM.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

This is a long-shot, but are you sure you ran the sql query to add the new post_draft column to the posts table?

Another thing to try is to take a look at the phpbb error log and see if it is telling you anything interesting.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

Assuming the problem is that you forgot to add the post_draft column to the posts table (as I strongly suspect), everything should when you fix that then go and find the posts in the phpbb_posts table that you meant to save as draft and change their post_draft column to 1. That will resurrect your lost new topic, hide the other posts as drafts and assure that your user post stats stay correct (not that that really matters to anyone).
Thallium
Registered User
Posts: 395
Joined: Mon Aug 30, 2004 12:30 am
Contact:

Post by Thallium »

I'm sorry, I'm not sure which error log you mean or where it would be. I did try something that turned out to be very interesting though, and I think it might nail this down some.

The sql querry was executed correctly before i started the mod, I looked up the table corresponding to my most recent posts and the post_draft column was all set to 0's so I manually changed the most recent post to a '1' and saved it, went back to the forums and refreshed. The post disappeared and for the first time in teh list of my posts there was a draft post available. I clicked it and the message came up as I left it. I clicked submit to post it back in the forum and it said the post didn't exist, which was a little odd, but the point is (I think) that the post_draft column isn't being updated with the corresponding 1's

Does this narrow it down or just confuse the issue more? :?

I'm really sorry to take so much of your time with this, but thank you for your help.
Thallium
Complete phpBB powered websites, Mods/Hacks installed, unique templates, updates and repairs... reasonable. Email, PM or IM.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

PHP.ini telss you where the error log is, and that may tell you the problem. If you have a backup set of files, try installing with easymod (it's really dependible...if it can't find a line because of another mod, it tells you before it changes anything so you can conform the mod file to your actual board and try again). But obviously don't let it run the sql again.

If that doesn't work, send me your php files (I pm'd you my email address) and I'll take a look.
MasterHelp
Registered User
Posts: 5
Joined: Mon Sep 20, 2004 12:07 am

Post by MasterHelp »

Does this run on other templates other than subsilver?
James Spears
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

MasterHelp wrote: Does this run on other templates other than subsilver?


Never tried it on anything other than subsilver. But it only changes one line in templates/subSilver/posting_body.tpl and one line in templates/subSilver/search_results_topics.tpl and both those lines are garden variety, so it should be easy to adapt to other templates.
sikita
Registered User
Posts: 47
Joined: Tue Jun 29, 2004 9:40 am

Attachment

Post by sikita »

Does this mod work with attachments? Becuse I have installed this mod and when I attach any file and later come back to this draft I lost any attachment in the draft. So is it error or inability?
Post Reply

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