Soma Posted October 27, 2011 Posted October 27, 2011 PageEditSoftLock ProcessWire2+ Module There was a request for a page lock feature in PW2.1 for pages being edited by an other user already, it would lock or throw a message of along the line of: "This page is currently being edited by "username'." Thanks to Ryan for helping getting this done quickly! Download: https://github.com/s...ageEditSoftLock How it works Only the module "PageEditSoftLock" needs to be installed/uninstalled, the "ProcessPageEditSoftLock" Module will install/uninstall itself. The module creates a table and a hidden admin page under /page/edit/ for pinging in the background while editing a page. You can configure the ping interval and expiration timeout to what you think is good. Defaults - 20 seconds for pinging, - 60 seconds for expiration time (all entries in the table older than this will get deleted). ---- 27-02-2012 update https://github.com/s...1f204bc1b6c740a Fix for new repeater field throwing the lock message because of the way repeater work and this module. Thanks to Ryan for finding a quick fix. 4
Soma Posted October 28, 2011 Author Posted October 28, 2011 Thanks apeisa. Just released first version. See first post for link and infos.
apeisa Posted October 28, 2011 Posted October 28, 2011 Amazing stuff Soma! Will test this sooner than later. Seems like a great implementation.
Soma Posted October 28, 2011 Author Posted October 28, 2011 I have installed it on some projects and now I noticed a problem with the file upload. It doesn't update upload status and doesn't finish it, but after refresh the image is uploaded. I'm sure it has to do with this module, but not sure what's causing it. Any suggestions appreciated! Thanks
ryan Posted October 28, 2011 Posted October 28, 2011 Nice job Soma, just tested out and it seems to work beautifully! I'm amazed how quickly you got this out. This may not matter much, but if you want, I think you can replace the try/catch in ProcessPageEditSoftLock with just this below. That would get rid of the try/catch and condense it down to one more efficient query. Though in this case, I don't expect it would really matter since the query happens once every 20 seconds rather than hundreds of times a second. $this->db->query("INSERT INTO users_editing_page (page_id, user_id, ts) VALUES($page_id, $user_id, $time) ON DUPLICATE KEY UPDATE ts=VALUES(ts), user_id=VALUES(user_id)"); I love that the times are configurable. The only question I had was about why times are in two different formats on the config screen (seconds and milliseconds)? I'm thinking that many non-programmers might not recognize exactly what milliseconds are at first.
ryan Posted October 28, 2011 Posted October 28, 2011 I have installed it on some projects and now I noticed a problem with the file upload. It doesn't update upload status and doesn't finish it, but after refresh the image is uploaded. I'm sure it has to do with this module, but not sure what's causing it. Any suggestions appreciated! Thanks I think I see what the problem is. In your checkpagestatus() function, at the top, have it abort if it's an ajax request. i.e. if($this->config->ajax) return;
Soma Posted October 28, 2011 Author Posted October 28, 2011 Thanks a lot Ryan, this would have taken me ages to find out! Lovely It works now again. Only problem I noticed now in Firefox it doesn't seem to work at all, my module. Even with the fix. I got tested now with all except FF, I got latest. Anyone experience the same? Stupid me, I logged in with same user... But still I think the pining window.setInterval doesn't work in my FF. Will test now some more. EDIT: There's something strange going on in FF, no errors and it doesn't seem to work at all... Confused...
Soma Posted October 28, 2011 Author Posted October 28, 2011 Well I'm already used to it, but now it works without doing something... tested again in FF and it works now. Oh well. Thanks Ryan for the suggestions, I implemented your suggestions. And have adjusted the config times to be both in seconds. I commited the new version to github. Thanks!
Soma Posted February 27, 2012 Author Posted February 27, 2012 Just commited an update to this module fixing an issue with brand new repeater field, where the lock message would appear after saving page. 1
evanmcd Posted June 14, 2012 Posted June 14, 2012 Awesome module, Soma. JUST what I needed. Thanks so much for it. 1
adrian Posted February 19, 2013 Posted February 19, 2013 Hi Soma, This is a great setup, but I am thinking about the issue of more than one person using the same login details. I have a project where each team of people will have a single login and I'd like to be able to have the warning popup even if the page is being edited by the same username. An IP address won't be appropriate since many will likely appear from the same address. I am thinking a cookie approach might be best. The other thing I want to be able to do is use this to warn users editing pages via a front-end form. I plan on implementing these shortly, but thought I'd ask if perhaps you already had any plans along these lines, or any suggestions.
Soma Posted February 19, 2013 Author Posted February 19, 2013 No I haven't . Give them all a separate login, problem solved. You don't want to have various people with same login in a CMS generally and working simultaneously from same place. Anyway I don't see a simple way to implement this. I'm also not sure if it would work for frontend as you would have to take care of it anyway, but maybe my module helps you getting started.
adrian Posted February 19, 2013 Posted February 19, 2013 I agree that separate logins would help, but all the editing I am talking about is front-end, and will be by groups of people that may change on a daily basis, so it starts to get complicated. I am sure I will make use of your module as a starter, but you are right, I may have to do this differently to handle front-end protection.
Peter Falkenberg Brown Posted April 3, 2013 Posted April 3, 2013 Hi Soma, Thanks for doing this module. How hard would it be to add an option to make it a hard lock, rather than a soft one? Thanks, Peter
Soma Posted April 3, 2013 Author Posted April 3, 2013 Hi Peter I don't know really how hard a hard lock in a soft lock module is. The reason to only have a soft lock is clear, and hard locks can get a burden if someone lock a page by having the page open. I think it's possible, but have to think about some time. It would be as you suggest and option you need to enable. But then also the Module name doesn't fit anymore.
Peter Falkenberg Brown Posted April 3, 2013 Posted April 3, 2013 Dear Soma, Your points are well taken. Still, it might be good to have a hard lock module as an option. I guess it's a toss up between the incovenience of open records, verus two conflicts where both people ignore the soft lock. Thanks, Peter
Martijn Geerts Posted April 3, 2013 Posted April 3, 2013 Hello Peter, If the traffic lights are turned red, you could drive through. But you know you're wrong. If there's an emergency, you could take the risk to driving through red. ( soft lock. ) But if there's a hard lock, the lock must be openend somehow if someone didn't logout for example. So an other thing is needed to re-open locked pages. ( Making the hard-lock a little soft again. ) Think Soma did a great job with the soft-lock.
Peter Falkenberg Brown Posted April 3, 2013 Posted April 3, 2013 Dear Martijn, Yes, he did a great job; thanks Soma! I guess it depends on the business requirements of a particular website. I do understand your logic. . Yours, Peter
Martijn Geerts Posted April 3, 2013 Posted April 3, 2013 Hai Peter, you said: "I guess it depends on the business requirements of a particular website." (If I understand what you're saying) If you don't "trust" your editors, you're better off with with a front-end edit solution with the PW API.
Peter Falkenberg Brown Posted April 3, 2013 Posted April 3, 2013 Hai Peter, you said: "I guess it depends on the business requirements of a particular website." (If I understand what you're saying) If you don't "trust" your editors, you're better off with with a front-end edit solution with the PW API. Dear Martijn, Perhaps so. I haven't run into the situation yet, so we'll have to see. But I'm grateful that Soma wrote the module. It will indeed come in handy. Peter
Soma Posted April 3, 2013 Author Posted April 3, 2013 Lol love that analogy. Either way you can end up with a problem. SInce finally you decide which one you think makes most sense. I understand if one wants or needs this feature and I added a option to enable hard lock. Pushed an update 1.0.1 to github now. - added option to enable hard lock - made alert message translatable https://github.com/somatonic/PageEditSoftLock 2
Peter Falkenberg Brown Posted April 3, 2013 Posted April 3, 2013 Dear Soma, This must be why you're a Hero Member. My, that was fast! I shall update my version. Thank you! Peter
Macrura Posted April 3, 2013 Posted April 3, 2013 thanks Soma - btw have you considered a flattr account... i 'flattred' a few of your modules... 2
Soma Posted April 3, 2013 Author Posted April 3, 2013 Hey Macrura, thanks. No I didn't knew flattr...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now