Search

I lied — you can indeed add items to the front-end. In class.frontendpage.php where it a delegate that provides the rendered HTML output after rendering is complete. You could parse this as XML and append an item to the head.

Thanks Nick, Custom Admin was the basis for most of it, and I totally tore that apart. And setInterval is an annoying thing really.

I was thinking to inject JS/CSS into the front-end page where a lock entry event was attached to handle the renewing of the lock, because if it’s not handled the lock will fail (unless the lease time is huge), and when the user tries to submit it, the lock-entry event will explain why. It was just to lessen what a developer had to do, so they only had to style the lock-related stuff, and not deal with the ajax.

I saw there were a couple delegates, and just picked one and haven’t played with it. I’ll have a look trying to mess with the frontend this weekend hopefully.

Oh, and I only use the ‘lightbox’ when a lease expires (which I have setup as 10 minutes), if someone steals the lease, or it doesn’t exist. Otherwise when another user hits the page it just shows a symphony notice.

How do you solve the issue with Symphony saving the entry but by default reopening the editor again? Does that reopened editor get the lease again?

Edit: let’s use “lease” instead of “lock” (one being a Symphony-feature, the other one being a MySQL-command).

The lease is released when an entry is saved (not implemented yet, but the lease is short, so it’s released quickly). I haven’t tried releasing it on window close yet.

You’re right, a lease is opened once someone hits an edit page, or eventually, and hopefully, a front-end page with the lock entry event attached. And that page renews the lease with a simple ajax call.

I also added the ability to forcefully take the lease, but I should make that configurable.

I lied — you can indeed add items to the front-end. In class.frontendpage.php where it a delegate that provides the rendered HTML output after rendering is complete. You could parse this as XML and append an item to the head.

Sidenote: While it’s possible this seems not to be the Symphony way. Symphony normally gives the developer the full control of what’s happening on the frontend - manipulating the frontend HTML “automagically” is nothing I would expect using this system.

If it’s to test whether the current entry is locked, you could provide a Data Source with the extension that looks up in the locks table and returns entry IDs of currently-locked entries. In the XSLT one can then decide how this should be handled.

That’s the Symphony way of life :)

I don’t mind leaving it to the developer. In fact, that means I’m halfway done.

I’ve come across a little snag for getting this to work in the backend. A way to check if a lock exists prior to an entry being committed, is using the delegate EntryPreEdit, then it goes on to use the Class Entry’s function called commit(). But I can’t forcefully cause this entry to fail being committed, so I can never properly check if the person submitting the entry actually HAS a lock or not. Changing the entry data doesn’t do anything helpful, since it’s already been validated.

The commit function ->edit()s or ->add()s based on whether or not the entry has an ID. Edit never returns false in symphony’s code. Add can only return false if there’s a problem grabbing an insert id. And it looks like I can’t force that to happen.

If there was a way in PHP to halt the calling function’s processing in someway, it could be done.

But it looks like unless that delegate is changed, this will never work on the backend in a situation where User #1 submits the form, regains the lease, stays idle. Their lease expires, User #2 takes it over, changed some stuff. Then User #1 just re-submits the form by refreshing, it can’t check if he has the lock.

So perhaps I can’t use this delegate, but maybe there’s another delegate that I can use that’s called before the action is processed to unset the $_REQUEST[‘action’] so it NEVER get’s processed.

Edit: I was thinking too hard, I can just use the initaliseadminpagehead delegate and unset the $_REQUEST and $_POST when a user tries to resubmit a form even if they don’t have a lease.

I’ve finished the frontend event filter called ‘lock-entry’; I’ve got it to the point where it’s stable enough to test (i.e. it works for me fine). Unfortunately to use it, it requires javascript since I can’t reliably figure out the entry-id (which I need to request a lease).

There’s an example in the documentation.

http://github.com/scottkf/pessimistic-db-locking/tree/master

Hello!

This extension looks very promising. Is someone using this with the recent Symphony version and can provide any feedback?

Cheers, Mark

Hello there! I only implemented as a way of checking whether or not it was possible in Symphony. While it was possible, it wasn't very practical, as there were easier methods of accomplishing the same thing in Rails. This extension relied on javascript, and while it worked, it wouldn't work well on a system with lots of authors.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details