Leafpub/leafpub

User with Editor role can't edit draft posts created by Author role

robertem128 opened this issue · 6 comments

Issue Summary

When logged in user who has the role of Admin or Editor attempts to edit a post that has been saved as a draft by an Author, the edit page results in a 404 as drafts appear to be locked until they are published.

I would like an Editor to review new posts prior to publication. Currently, the only way I see for an editor (or admin) to edit a post is to publish it first which does not seem like a proper editorial workflow. Would it be possible to a) unlock the Draft after the Author has saved the file or b) have another option such as "Submit for Review" that would allow the Editor to make necessary changes prior to publication?

Thanks,
Rob

Steps to Reproduce

Tell us how to replicate the problem.

  1. Create a new post as Author and save as draft
  2. Log in as Editor or Admin
  3. Attempt to edit new post.

Additional info

  • Leafpub version: 1.1.8
  • PHP version:7.1.4
  • Affected browsers: All
  • Operating system: macOS 10.12.5

Looking further into this, I'm not sure if there is a bug or an issue with OSX and time conversions but var dumping the meta data is changing the date to 4 hours ahead (ex. 2017-07-21 20:03:44 vs db value of 2017-07-21 16:03:44). I tried changing time zones but it had no effect. I've been developing in Laravel but have little experience with Slim but will keep looking for an answer.

Hi @robertem128 ,
thanks for posting.
Leafpub saves the local date in UTC format to the database (https://github.com/Leafpub/leafpub/blob/master/app/source/classes/Leafpub.php#L345)
and converts the database date, which is in UTC format, to local format
(https://github.com/Leafpub/leafpub/blob/master/app/source/classes/Leafpub.php#L830)

I tested a clean installation of Leafpub 1.1.9 and I was able to open an author post with an admin/editor user, so I can't reproduce this strange bug 🙁
On line 275 of AdminController, there's the check for owner/admin/editor

Thanks @karsasmus,
I did see those but I think there is something else going on in my case. I had tried comment out the code in both functions before I posted with the same results. I have also verified my timezone settings in both PHP and the app. I'm going to try a fresh install on both my local and a DO LAMP and see if I can track it down what's happening. It's very possible that the problem is in my local setup but I have not seen this behavior on any of the apps that I have wrote.

I was able to resolve the issue by changing the getPostMeta function on post.php. the problem I was experiencing was related to the time change in that the setting of the post meta 'lock' is not converting the time to UTC so the page was not accessible for 1 day + 4 hours (in my timezone).

I replaced
$time = strtotime($ret['lock'][1]);
with
$time = strtotime(Leafpub::utcToLocal($ret['lock'][1]));

and now everything works as expected.

Thanks,
Rob

Thank you for finding and fixing the bug, @robertem128 👍

Stupid question, but it appears this is commented out from post.php in the new version, presume this function is now obsolete, however, I still have issues where a draft can't be published and/or doesn't save after the 'first' save. I've written whole posts, hit save, and the progress bar/message doesn't display.

This is all within a few seconds, so should still be under same session.