News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Drafts

Started by live627, June 24, 2008, 01:11:04 PM

Previous topic - Next topic

kizley

Ohhh i get the answer,pls ignore my above post.

Kimmie

when I post drafts from my profile - all my posts are getting a bunch of garbled code added to them that shouldnt be there. Code like <br /><br /> and a bunch of &'s.


When you click on Additional options and post it that way, all that garbled code doesnt show up.

Any ideas how to fix this?

SunilDVR

This is an excellent mod - thank you for taking the time to create it.

Once SMF 2 is released properly, will you be updating the mod to make it compatible?

Charles Hill

Yes, when I have time.

Kimmie

Quote from: Kimmie on July 31, 2008, 02:43:21 AM
when I post drafts from my profile - all my posts are getting a bunch of garbled code added to them that shouldnt be there. Code like <br /><br /> and a bunch of &'s.


When you click on Additional options and post it that way, all that garbled code doesnt show up.

Any ideas how to fix this?

bumping this up. Any resolutions on this yet?

Charles Hill

Unsure as to what might be causing that problem.  I don't have any time to look at that right now, either.  Sorry :(

Kimmie

#86
Quote from: Charles Hill on August 13, 2008, 07:47:57 PM
Unsure as to what might be causing that problem.  I don't have any time to look at that right now, either.  Sorry :(

Its mostly adding <br /> and its doing it when there are multiple things put in the post such as images and text. Its putting the code after each place there is a line break (or each place it "thinks" there should be one). It appears that part of the draft mod code may not be handling line breaks correctly so its trying to add the break in html format and the tags are showing up because html tags are not accepted in posts.

Also, when you use the character "&", it is adding this instead "&amp;"

I dont know that much about coding but it appears it thinks that whatever is being posted is in html format and it should treat it as such.

Charles Hill

#87
Ok I just looked at the code around where the posting of drafts as new topics/replies from the Show Drafts page and seem to have come up with a solution for you.

Find in Sources/Post.php:
// sanitize and prepare for entry into the database
$msgOptions['body'] = addslashes($func['htmlspecialchars']($msgOptions['body'], ENT_QUOTES));
$msgOptions['subject'] = addslashes($func['htmlspecialchars']($msgOptions['subject'], ENT_QUOTES));


Note: the comment may be different

Replace with the following:
// sanitize and prepare for entry into the database
$bodyText addslashes($func['htmlspecialchars']($msgOptions['body'], ENT_QUOTES));
$subject addslashes($func['htmlspecialchars']($msgOptions['subject'], ENT_QUOTES));


And in the INSERT INTO database query AND the UPDATE database query after that... Replace $msgOptions['body'] with $bodyText... and... Replace $msgOptions['subject'] with $subject


Now in Sources/Profile.php....
Find:
// let's set some variables before we create the post
$posterOptions['id'] = $memID;

$msgOptions['body'] = $row['body'];
$msgOptions['subject'] = $row['subject'];


Replace with the following:
// let's set some variables before we create the post
$posterOptions['id'] = $memID;

$msgOptions['body'] = un_htmlspecialchars($row['body']);
$msgOptions['subject'] = un_htmlspecialchars($row['subject']);


That should do it.

Kimmie

I'm running a back up at the moment so as soon as it finishes I will do the above and let you know how it goes :)

Cal O'Shaw

Charles,

Will you be updating the MOD with this fix?

And I really hate to ask, as I really appreciate that you've shared this MOD with us, but have you had a chance to look at when the MOD will support PMs?

Grazie mille,

Cal

Charles Hill

Presently all my free time is going towards finishing v1.12 of Blog: Community.  About a month ago I did look at the code of SMF to get a rough estimate of how much of a pain supporting PMs would be..... It didn't look good...  I doubt I'll ever support PMs with drafts.  The only way I'd ever add PM support would be if someone paid me to do so.  Sorry :(

Cal O'Shaw

No need to apologise, truly.  This MOD is great for posts.  I've held off rolling it out to my general membership only because I was waiting to see what you decided about PMs and polls.  If you have the time to put the fix into the MOD I'm going to wait to uninstall the 1.07 version, install 1.08(?), and then announce it.

Thanks for all your hard work on this :).

Cal

Kimmie

#92
can you be a bit more specific on this part"

And in the INSERT INTO database query AND the UPDATE database query after that... Replace $msgOptions['body'] with $bodyText... and... Replace $msgOptions['subject'] with $subject


sorry.. im not totally sure what to do here :)


nm I figured it out :). I will be testing it in a little bit to make sure it corrected the problem.

Kimmie

Unfortunately, that  didnt fix it :(

Charles Hill

Really...... I tested the & and the line breaks and managed to replicate the problem you were having.  I then fixed it with the fixes I gave you above.  Perhaps I did other things when I was working on v1.08 a month or so ago...... When I get some time I'll look into it.

Kimmie

Quote from: Charles Hill on August 15, 2008, 01:14:01 AM
Really...... I tested the & and the line breaks and managed to replicate the problem you were having.  I then fixed it with the fixes I gave you above.  Perhaps I did other things when I was working on v1.08 a month or so ago...... When I get some time I'll look into it.

no problem. I will just make sure and remind staff they need to keep a close eye on posts for a bit longer. I have attached both those files so you can look at the edits I made. I am always careful whenever I make edits however, that doesnt mean mistakes cant be made lol

Ncen

Is it possible to make the ;sa=showDrafts -page viewable to everyone? For my site, that would be really useful. :D What changes do i have to make to the code for this to be possible?

Charles Hill

Do you mean make a member's show drafts page viewable to other users?   Hmmm, because of how the profile page is structured in SMF, you would have to modify several parts of the Sources/Profile.php to affect the overall permission of a profile page.  Then there are a few things you'd have to edit in the show drafts page itself to make sure only the profile owner can see certain links.

I suggest you open up Sources/Profile.php and do searches for the word "draft".  This should show you all the bits of code in the file that have to do with drafts.  There are lots of comments.  Just remember that in the showDrafts function you HAVE TO prevent users who are guests, are not the profile owner, or are not allowed to save drafts from using the delete, modify, post drafts bit of that function.  Also you will want to make only the edit, delete, post links visible to the profile owner.

Ncen

Quote from: Charles Hill on August 23, 2008, 04:10:17 PM
Do you mean make a member's show drafts page viewable to other users?
Yes! ^^ That's it. :) I'll take a look at the Sources/Profile.php then, ^^' The links and that, do i edit that too in Sources or is that in themes? :)

Also, if possible, could you tell how you made sa=showdrafts? I've been trying to create a new sa=x page in the profile viewable for other users for showing information from customfields without success. I of course do understand if you prefer not to explain since it's of topic but I've been trying to solve this for months so it would be greatly appreciated. A PM would be fine if you would like the topic free from of topic-talk. ^^

Thanks in advance.
Inno.

Charles Hill

The edit, post, modify links for the show drafts page you will have to put flags on.  A flag is a condition that determines whether or not to display something (if then statement).

It took me a while to figure out how the profile pages worked too.  It's very different from the rest of SMF.  If you want to add a new page of your own... just find the place where the draft code is, and you should be able to figure out how it works.  It's all in the Profile sources folder.  The template function is just what you want to be displayed by the function you make in the Profile page.  HINT: whatever your new sub-action (sa) is... your template function and your new function in the source folder should use that subaction name.... template_subAction() and subAction($memID)

Hope that helps :)

Advertisement: