Page 4 of 5

Re: Save full drafts

Posted: Fri Jul 24, 2009 2:02 pm
by asinshesq
NicksNet wrote:thanks for funtcions_recenttopics.php but now i have a sql-error...
Looks to me like you tried to edit your file rather than using the one I sent you (which I do not think has that error). Either try using my entire file again or pm me your file and I will take a look. But let's do this with private messages because this has nothing to do with the save full drafts mod.

Re: adapting recent topic and portal mods to this mod...

Posted: Fri Jul 24, 2009 2:07 pm
by asinshesq
NicksNet wrote:
asinshesq wrote: It may be that the place where you saw a draft comes from your recenttopics mod rather than your portal mod. Or perhaps there are other files in the portal mod that look up posts or topics and maybe the problem in in those files?

i think this one can be such a file?
No, that's fine too. Again, dutch did not see this problem so maybe it's coming from your NV recent topics mod. What about portal/block/recent.php?

Let's do the rest of this with private messages because it's got nothing to do with this mod.

Re: adapting recent topic and portal mods to this mod...

Posted: Sat Jul 25, 2009 11:08 am
by asinshesq
asinshesq wrote:Let's do the rest of this with private messages because it's got nothing to do with this mod.
Thanks for sending me that private message, NicksNet, but you have your private message notification turned off so I couldn't send it back that way. Please turn your private message notification back on so we can finish this up with private message.

In the meantime, here are the changes you need to make to the files you sent me:

Here are the changes for portal/block/recent.php:

Code: Select all

OPEN
portal/block/recent.php

FIND
// Get a list of forums the user cannot read

BEFORE, ADD
$sql_where .= ' AND topic_approved <> ' . POST_DRAFT;
Here are the changes for portal/block/user_menu.php:

Code: Select all

OPEN
portal/block/user_menu.php

FIND
					AND t.topic_moved_id = 0

AFTER, ADD
					AND t.topic_approved <> ' . POST_DRAFT . '
And here are the changes for includes/functions_recent_topics.php:

Code: Select all

OPEN
includes/functions_recenttopics.php

FIND
	  )
	  OR t.topic_type = ' . POST_GLOBAL . '

REPLACE WITH
		 AND t.topic_approved <> ' . POST_DRAFT . '
	  )
	  OR (t.topic_type = ' . POST_GLOBAL . 'AND t.topic_approved <> ' . POST_DRAFT . ')

FIND
		 )
		 OR t.topic_type = ' . POST_GLOBAL . '

REPLACE WITH
			AND t.topic_approved <> ' . POST_DRAFT . '
		 )
		 OR (t.topic_type = ' . POST_GLOBAL . ' AND t.topic_approved <> ' . POST_DRAFT . ')

Re: Save full drafts

Posted: Sat Jul 25, 2009 11:24 am
by asinshesq
NicksNet wrote:but a suggestion i have...

if i save a draft, is there a possibility to redirect (or link) after saving to the post (so that i can create this post) because now i will redirected to the forum, not to the site where i create a topic/post
When a user saves a draft, this mod gives him a choice to go to the forum where the post was made OR to go back to the place where the drafts are. If the user does nothing for 3 seconds he automatically gets redirected to the forum. But if you want to change that so that if the user does nothing he goes to the place where the drafts are, you can do this:

Code: Select all

OPEN
includes/functions_save_full_drafts.php

FIND
	$redirect_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $data['forum_id']);
	meta_refresh(3, $redirect_url);
	$message = ($mode == 'save') ? $user->lang['DRAFT_SAVED'] : $user->lang['DRAFT_DELETED'];
	$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect_url . '">', '</a>');
	$message .= '<br /><br />' . sprintf($user->lang['CLICK_RETURN_FOLDER'], '<a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=main&mode=drafts') . '">', '</a>', $user->lang['UCP_MAIN_DRAFTS']);

REPLACE WITH
	$redirect_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=main&mode=drafts');
	meta_refresh(3, $redirect_url);
	$message = ($mode == 'save') ? $user->lang['DRAFT_SAVED'] : $user->lang['DRAFT_DELETED'];
	$message .= '<br /><br />' . sprintf($user->lang['CLICK_RETURN_FOLDER'], '<a href="' . $redirect_url . '">', '</a>', $user->lang['UCP_MAIN_DRAFTS']);
	$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $data['forum_id']) . '">', '</a>');

FIND
	$redirect_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox');
	meta_refresh(3, $redirect_url);
	$message = $user->lang['DRAFT_SAVED'];
	$message .= '<br /><br />' . sprintf($user->lang['CLICK_RETURN_FOLDER'], '<a href="' . $redirect_url . '">', '</a>', $user->lang['PM_INBOX']);
	$message .= '<br /><br />' . sprintf($user->lang['CLICK_RETURN_FOLDER'], '<a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=drafts') . '">', '</a>', $user->lang['UCP_MAIN_DRAFTS']);

REPLACE WITH
	$redirect_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=drafts');
	meta_refresh(3, $redirect_url);
	$message = $user->lang['DRAFT_SAVED'];
	$message .= '<br /><br />' . sprintf($user->lang['CLICK_RETURN_FOLDER'], '<a href="' . $redirect_url . '">', '</a>', $user->lang['UCP_MAIN_DRAFTS']);
	$message .= '<br /><br />' . sprintf($user->lang['CLICK_RETURN_FOLDER'], '<a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox') . '">', '</a>', $user->lang['PM_INBOX']);
I haven't tried this but it should do it or at least it should be close. Let me know if this is what you were looking for and if it works.

Re: Save full drafts

Posted: Tue Aug 11, 2009 7:30 am
by MKULTRA
Great mod, what needs to get changed so that the has drafts button only shows when the user only has drafts? I made several attempts at this an it either never showed or always showed, not even the default codes works anymore, I could not track down what is causing this. TIA

Re: Save full drafts

Posted: Tue Aug 11, 2009 5:40 pm
by asinshesq
MKULTRA wrote:...what needs to get changed so that the has drafts button only shows when the user only has drafts?...
I don't like a user interface that changes in this way (I think it's confusing to users who won't all understand why the screen sometimes looks one way and sometimes looks another way) so I purposefully set it up to always show the button. But if you want to change that, try this (I haven't tried it but it should be close):

Code: Select all

OPEN
posting.php

FIND
	$sql = 'SELECT draft_id
		FROM ' . DRAFTS_TABLE . '
		WHERE user_id = ' . $user->data['user_id'] .
			(($forum_id) ? ' AND forum_id = ' . (int) $forum_id : '') .
			(($topic_id) ? ' AND topic_id = ' . (int) $topic_id : '') .
			(($draft_id) ? " AND draft_id <> $draft_id" : '');

REPLACE WITH
	$sql = 'SELECT post_id
		FROM ' . POSTS_TABLE . '
		WHERE poster_id = ' . $user->data['user_id'] . '
			AND post_approved = ' . POST_DRAFT;
	$result = $db->sql_query_limit($sql, 1);

FIND
	'S_HAS_DRAFTS'				=> ($auth->acl_get('u_savedrafts') && $user->data['is_registered']) ? true : false,

REPLACE WITH
	'S_HAS_DRAFTS'				=> ($auth->acl_get('u_savedrafts') && $user->data['is_registered'] && $post_data['drafts']) ? true : false,
MKULTRA wrote:I made several attempts at this an it either never showed or always showed, not even the default codes works anymore, I could not track down what is causing this. TIA
Are you saying you can't go back to your backups and get things working again? What file did you change?

Re: Save full drafts

Posted: Wed Aug 12, 2009 1:48 am
by MKULTRA
Hmmm... that just throws up an error:

Code: Select all

SQL ERROR [ mysqli ]

Unknown column 'user_id' in 'where clause' [1054]

SQL

SELECT post_id FROM php_posts WHERE user_id = 53 AND post_approved = 2 LIMIT 1

BACKTRACE

FILE: includes/db/mysqli.php
LINE: 163
CALL: dbal->sql_error()

FILE: includes/db/mysqli.php
LINE: 205
CALL: dbal_mysqli->sql_query()

FILE: includes/db/dbal.php
LINE: 170
CALL: dbal_mysqli->_sql_query_limit()

FILE: posting.php
LINE: 478
CALL: dbal->sql_query_limit()
And I agree, but I also like pages to be dynamic and do not like showing buttons until they actually serve a purpose, otherwise, they tend to clutter the page (I converted my editor to mostly graphic images).

And I did just happen to backup my files on this MOD but I want it installed, I just would like the drafts button to show only when there are drafts pending.

Re: Save full drafts

Posted: Wed Aug 12, 2009 2:32 am
by asinshesq
MKULTRA wrote:Hmmm... that just throws up an error...
Typo. Change WHERE user_id to WHERE poster_id

(I have edited my first post to fix.)

And my point about backups was that you had said you went back to the original code and couldn't get it to work so it sounded like you messed something up that my change wouldn't fix.

Re: Save full drafts

Posted: Wed Aug 12, 2009 11:56 am
by MKULTRA
OK that seems to work perfect, thank you. And I meant only the original portions of the code you modded, I was just tinkering with it hoping to get it working, but could not.

Re: Save full drafts

Posted: Wed Aug 12, 2009 1:02 pm
by MKULTRA
I discovered some additional errors now, I have soft delete installed along with other MODS, when I soft delete a post it is still visible in view forum, but not visible in view topic. And I did the changed listed here: http://www.phpbb.com/community/viewtopi ... 5&start=15 and I am a bit confused, as there are about three or so instances of these queries, are you suppose to do them all or just the very first instance?

Also I discovered an additional error, when I try to quote a post it states it does not exist. I think I majorly messed up the queries though as I had installed save full drafts first and then soft delete and it just did not work out well at all and I tried using my backup but that is not providing any aid either.

Re: Save full drafts

Posted: Wed Aug 12, 2009 1:04 pm
by asinshesq
MKULTRA wrote:...And I agree, but I also like pages to be dynamic and do not like showing buttons until they actually serve a purpose, otherwise, they tend to clutter the page (I converted my editor to mostly graphic images)...
I suppose another alternative would be for the text on that button to toggle between 'List drafts' and 'You have no drafts'. That would be pretty easy to do as well, but perhaps that's even worse clutter.

Re: Save full drafts

Posted: Wed Aug 12, 2009 1:09 pm
by asinshesq
MKULTRA wrote:I discovered some additional errors now, I have soft delete installed along with other MODS, when I soft delete a post it is still visible in view forum, but not visible in view topic. And I did the changed listed here: http://www.phpbb.com/community/viewtopi ... 5&start=15 and I am a bit confused, as there are about three or so instances of these queries, are you suppose to do them all or just the very first instance?

Also I discovered an additional error, when I try to quote a post it states it does not exist. I think I majorly messed up the queries though as I had installed save full drafts first and then soft delete and it just did not work out well at all and I tried using my backup but that is not providing any aid either.
Sounds like you did mess up the install because you installed save drafts first and then soft delete and didn't make the corresponding changes correctly. We could reverse engineer and figure out the changes to soft delete that you need to do to make it work with an already installed save drafts, but if you have a backup of your files before you installed save drafts and soft delete it might be easier to go back to those, then install soft delete, and then install save drafts using a modified install.xml that is described here: http://www.phpbb.com/community/viewtopi ... #p10285805

Re: Save full drafts

Posted: Wed Aug 12, 2009 1:21 pm
by MKULTRA
I went back and redid it from an older copy and then worked back through and added the suggested code (only on the first instance) and when I go to view a thread I get "Parse error: syntax error, unexpected T_LOGICAL_AND in ...viewtopic.php on line 98" which is:


CORRECTION (code replaced copied wrong section):

Code: Select all

		$sql = 'SELECT post_id, topic_id, forum_id
			FROM ' . POSTS_TABLE . "
			WHERE topic_id = $topic_id
                                " . (($auth->acl_get('m_approve', $forum_id)) ? 'AND post_approved <> ' . POST_DRAFT : 'AND post_approved = 1') . ($auth->acl_get('m_harddelete', $forum_id) || $auth->acl_get('m_delete', $forum_id)) ? '' : (($auth->acl_get('f_delete', $forum_id)) ? " AND (post_deleted = '0' OR post_deleted = '{$user->data['user_id']}')" : " AND post_deleted = '0'");
                        AND post_time > $topic_last_read
			ORDER BY post_time ASC";

Re: Save full drafts

Posted: Wed Aug 12, 2009 1:56 pm
by MKULTRA
OK I found two copies from several hours ago (viewtopic and viewforum), I just went and copied them over the newer ones, now these are my issues:

1. When trying to quote, message advises "The requested post does not exist." (unless I do it as an administator).
2. Soft deleted posts show up on forum index as the last post, but does not show in viewtopic (when viewed by a non posting/admin user).

Re: Save full drafts

Posted: Wed Aug 12, 2009 2:38 pm
by MKULTRA
Oh geez, I just realized I have been working on the wrong one, I missed the ";" the correct one is down on line ~430. So I am no longer getting errors and the issue of the soft deletes showing up in the index seems to have vanished. Though I still cannot quote posts, unless I do it as admin. Would the issue with quoting have to do with something in posting.php?

Also I do have the MOD quote to new posts installed, though I don't think that has anything of conflict with either of these other MODS, right?