News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Drafts

Started by Arantor, July 26, 2010, 05:07:17 AM

Previous topic - Next topic

Grammy

Quote from: Arantor on July 02, 2016, 09:00:15 AM
If in doubt do it on a test forum first :)


I'm all about the test forum, ha! 

Boskonovic

Hello!

I have been able to install on 2.0.11 without any issue (apart from a warning related to the "Core" Theme, which i don't use).
I also translated it to Italian (standard and utf-8). See attached file.


Thank You for this Mod!

Best Regards

Boskonovic

Dear All,

I noticed an issue with the autosave functionality: The Topic/Post saved has the "Sticky" and "Closed" parameters checked, while they were unchecked while i was writing the Post.
I think the cause is how the JS code checks for these 2 parameters. Here below the syntax:

parseInt(document.getElementById('check_lock').value)

parseInt(document.getElementById('check_sticky').value)


Since the HTML is the following:

<input type="checkbox" name="lock" id="check_lock" value="1" class="input_check">

The result of the check is always True, because of the "value=1" parameter.

Shouldn't be the syntax something like this:

document.getElementById('check_lock').checked

This returns True of False, which can be then converted to 0 or 1 for the Ajax call

Best Regards

Gwenwyfar

Interesting find, this could be related to some random locking/unlocking of some topics on my forum. It happens rarely, but it reduced greatly when I increased the time of the drafts auto-save.

Boskonovic

This is the modification i applied to the JS file. I just tested it and it seems to work as expected:


if (document.getElementById('check_lock'))
x[x.length] = 'lock=' + (document.getElementById('check_lock').checked ? 1 : 0);
if (document.getElementById('check_sticky'))
x[x.length] = 'sticky=' + (document.getElementById('check_sticky').checked ? 1 : 0);



Bye

GL700Wing

Quote from: Goten22 on July 22, 2015, 05:54:01 PM
I figured out how to massive delete drafts. It deletes all drafts from all users but I think it's still better than deleting it one by one. It works as scheduled task so you can set the interval as you wish.


In themes/default/languages/ManageScheduledTasks.english.php add
$txt['scheduled_task_cleardrafts'] = 'clear ALL drafts';
$txt['scheduled_task_desc_cleardrafts'] = 'Delete all drafts for every user, clears database.';



In Sources/ScheduledTasks.php
function scheduled_cleardrafts()
{
global $modSettings, $sourcedir, $mbname, $txt, $smcFunc, $scripturl;

$timestamp = time() - (30 * 86400);
$query = 'TRUNCATE TABLE {db_prefix}post_drafts';

$result = $smcFunc['db_query']('',
$query,
array(
'timestamp' => $timestamp,
)
);
return true;
}


Now go to PHPmyADMIN on your server and find smf_scheduled_tasks. There copy existing or create new record. Here simple pattern.
   INSERT INTO {db_prefix}scheduled_tasks (id_task, next_time, time_offset, time_regularity, time_unit, disabled, task)
      VALUES (NULL, 0, 0, 1, "d", 1, "cleardrafts")

See attachment.

You can find new option under admin>scheduled tasks


Great mod BTW, thanks for it!

Thanks for sharing this information.

For my forum I've changed the line of code that actually does the deletion so that, instead of all drafts getting deleted, 30 days worth of drafts are retained (I don't want users losing recently saved drafts).

To retain drafts for 30 days I have replaced the following:
$query = 'TRUNCATE TABLE {db_prefix}post_drafts';

with:
$query = 'DELETE FROM {db_prefix}post_drafts WHERE post_time < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 30 DAY))';

I know that a 'DELETE' statement is slower than a 'TRUNCATE' statement but if the task is scheduled to run daily hopefully it won't cause any performance issues.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Arantor

So I just updated this mod to support 2.0.12, partial rewrite to use hooks and to fix the long standing bug around marking things as sticky and/or locked when it shouldn't.

Gwenwyfar

Yay! I'll put the update up and increase the auto-saves :) Though it has been a while I don't see anyone complain of the "haunted topics closing themselves". Could keep it as a pet bug...  :laugh:

anidea

#148
Hi Arantor,

I just installed this mod...well, re-installed it in a new forum, as it was working great in a much older forum, but for some odd reason, after re-installing, I can't find the Drafts section in Permissions in order to turn it on.  I reinstalled twice, triple checked to make sure it was your SimpleDesk mod (it says so in package-info), and then even manually went through the edits myself, and they're all there.

Then I noticed that there is no edit listed for ManagePermissions.php...Wouldn't there have to be an edit to that template in order for something to show up on the Permissions page?  The options on the Post Settings page show up fine, but nothing on the Permissions page to make the mod show up.  Also weird is that my admin account does not show the Drafts count in my profile at all, I didn't think permissions would be needed for that at all...?

It's quite possible that I'm crazy and missed something, but maybe not?

TIA!

anidea :)

SMF 2.0.13
Drafts 1.2 as downloaded from here: http://custom.simplemachines.org/mods/index.php?mod=2621

Arantor

Drafts doesn't need an edit to ManagePermissions since the new version since it uses hooks to achieve that.

If you went through all the edits, did you run the new version of install.php?

anidea

#150
Thanks for the speedy reply!  :)  I'm new to this hooks stuff, didn't realize that, thanks!

I installed the mod by uploading it to the forum from the download link, and clicking Install, and checking that it successfully installed...then I went through the edits listed on the page to make sure they all ended up where they needed to be, and that the files were copied to their places successfully.  So I didn't *actually* do a manual install, but I will if you think it is needed?  And is there a separate event that I have to initiate from the forum or from the browser?  What would I have to run?

Edit: by "run the new version of install.php" I am assuming you mean did I upload the new version to the forum and install it, and the answer is yes, that is what I did.  If there's a secondary running of install.php that needs to be done, please let me know how to do it.

anidea

ok, I had to uninstall the mod, nobody could post because of this error:

Fatal error: Call to undefined function saveDraft() in /home/public/smf/Sources/Post.php on line 1396

asura88

#152
Quote from: anidea on January 10, 2017, 10:33:39 PM
ok, I had to uninstall the mod, nobody could post because of this error:

Fatal error: Call to undefined function saveDraft() in /home/public/smf/Sources/Post.php on line 1396
I noticed that the new version doesn't unpack the Subs-Drafts.php file at all
https://gyazo.com/4482cb6051b3d2f9b0866d025b2d82c6 [nofollow]
Copying file manually fixes it.


I have got a problem with Autosave though. For me it only starts triggering if, after loading the page, textarea already had some text it in (for example when clicking preview or loading old draft), but even then it only updates the database entry just once, while it should do it every time when it triggers.
No errors in console appear.

KungFuJoe

Quote from: asura88 on February 04, 2017, 04:01:45 PM
Quote from: anidea on January 10, 2017, 10:33:39 PM
ok, I had to uninstall the mod, nobody could post because of this error:

Fatal error: Call to undefined function saveDraft() in /home/public/smf/Sources/Post.php on line 1396
I noticed that the new version doesn't unpack the Subs-Drafts.php file at all
https://gyazo.com/4482cb6051b3d2f9b0866d025b2d82c6
Copying file manually fixes it.


I have got a problem with Autosave though. For me it only starts triggering if, after loading the page, textarea already had some text it in (for example when clicking preview or loading old draft), but even then it only updates the database entry just once, while it should do it every time when it triggers.
No errors in console appear.

I have a similar issue...except with mine...it doesn't auto save at all anymore.  Weird because when I first installed the mod, it auto saved with no issues at all...but it stopped working somewhere along the line.

Harvester

I installed this mod... had no errors with the install.. it seemed to install without issue.. however, now I do not see anywhere to save the draft... I see no signs that its been installed other than in my package manager..  I dont see a permission to turn on or off... nor have I found any admin panel for it.  what am I missing?

after reading the posts above mine, I too noticed that the Subs-Drafts was not extracted to my Sources folder either

however I am afraid to put it there manually as I am seeinng its causing errors. Kind of wish I read this before I installed the mod... though I have all my files before the install backed up and am going to remove this mod until I know its not an issue.

Arantor can you let me know when this is fixed and working properly so I can reinstall?  Thank you. :D

Arantor

You could just use the old version.

Wish I'd never tried to update it now. I'll see if I can look at it sometime.

Harvester

ok  cool. I will use the old version :)

Harvester

Quote from: Arantor on April 03, 2017, 04:26:39 PM
You could just use the old version.

Wish I'd never tried to update it now. I'll see if I can look at it sometime.

I downloaded        drafts_1-1-5.tar.gz   but when I try to install it, I get this error:

The package you are trying to download or install is either corrupt or not compatible with this version of SMF.

where else can i get the old version?

Arantor

That is the old version. Just use version emulate.

Again, wishing I had never bothered now.

Harvester

Quote from: Arantor on April 05, 2017, 08:01:04 AM
That is the old version. Just use version emulate.

Again, wishing I had never bothered now.

how do I use version emulate?

Advertisement: