Multi user environment.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Angelos

    Multi user environment.

    Hello, I am developing a CMS and I would like to be able when a user is
    editing a page to inform any other user that the page is being edited by
    User X . Ofcourse that's not so difficult if you set a flag in the database
    for example that the current document is being edited, and remove the flag
    when the user saves the document and exits.

    BUT what happens if user exits the editing page without folowing any link or
    submit button that I can control. What happens if his computer
    restarts/crashes or he kills the browser.

    Database will have the document flaged as being edited by User X.

    Do you know any good way of avoiding that problem or if you don't already
    know, can you think of something similar ?

    Thanks Angelos.


  • Maarten

    #2
    Re: Multi user environment.

    Hi there Angelos,

    You could create a javascript function that sends a signal to the
    server when the editing page unloads. onUnload is a standard javascript
    event supported by every browser (that has javascript support switched
    on).

    Alternatively, if your server supports cron jobs, you could create a
    program that runs in the background and checks the flag's status every
    30 minutes or so. If the status hasn't changed for, say more than 30
    minutes, you may assume the user has left the page and the flag should
    be reset. This acts as a sort of timeout function.

    Kind of a cool problem you are dealing with!

    Regards, Maarten

    Comment

    • Oli Filth

      #3
      Re: Multi user environment.

      Maarten said the following on 08/11/2005 14:45:[color=blue]
      > Hi there Angelos,
      >
      > You could create a javascript function that sends a signal to the
      > server when the editing page unloads. onUnload is a standard javascript
      > event supported by every browser (that has javascript support switched
      > on).[/color]

      Unfortunately, this isn't failsafe by any stretch of the imagination;
      e.g. Javascript disabled, browser crashes, computer crashes, internet
      connection lost. I also believe that onUnload is fired if the user
      refreshes the page in their browser.

      Even if these events only occur once in a day, your database is
      immediately unsynchronised, and will probably require manual
      intervention to sort it out.

      [color=blue]
      > Alternatively, if your server supports cron jobs, you could create a
      > program that runs in the background and checks the flag's status every
      > 30 minutes or so. If the status hasn't changed for, say more than 30
      > minutes, you may assume the user has left the page and the flag should
      > be reset. This acts as a sort of timeout function.[/color]

      IMO, a cron job is unnecessary. If you store the "check-out" time of
      each article in the DB, then you can perform time-out checks can be
      performed every time a user requests a PHP page.

      e.g. perform the following query at the top of every script:

      UPDATE articles
      SET isCheckedOut = 0
      WHERE (checkOutTime + X) < NOW()

      In practice, you can probably find ways to avoid doing this amount of
      processing in every script, but you get the general idea...


      --
      Oli

      Comment

      • Joseph S.

        #4
        Re: Multi user environment.

        > Even if these events only occur once in a day, your database is[color=blue]
        > immediately unsynchronised, and will probably require manual
        > intervention to sort it out.
        > IMO, a cron job is unnecessary. If you store the "check-out" time of
        > each article in the DB, then you can perform time-out checks can be
        > performed every time a user requests a PHP page.[/color]
        [color=blue]
        > e.g. perform the following query at the top of every script:
        >
        > UPDATE articles
        > SET isCheckedOut = 0
        > WHERE (checkOutTime + X) < NOW()
        >
        > In practice, you can probably find ways to avoid doing this amount of
        > processing in every script, but you get the general idea...[/color]

        I had the same problem, too. I did the cleaning up process through a
        php page that was called less frequently, but not as much to keep the
        flag On for half a day. By estimate,(not reliable, but the best I could
        think of at that time) this page would be run every half or one hour.
        After doing all the work the page was supposed to do, it called this
        little cleanup() function, something which it was not _supposed_ to do,
        but did a good job of.

        My question is, is there no daemon creating mechanism in PHP?

        Any clues, googling gave this one useful result:

        but not exactly what I am looking for -

        making any script or function run continuously.

        The only things we have continuously present is the superglobals
        $_GET,$_POST,$_ SERVER etc.- no code.

        Joseph S.

        Comment

        • Angelos

          #5
          Re: Multi user environment.

          Thanks For all your Answers !!!
          It is a hard one ... I haven't found any mechanism to get rid of the
          FLAG but I think is one of those things that require the human
          intervention. :)

          Cheers

          Comment

          • Oli Filth

            #6
            Re: Multi user environment.

            Angelos wrote:[color=blue]
            > Thanks For all your Answers !!!
            > It is a hard one ... I haven't found any mechanism to get rid of the
            > FLAG but I think is one of those things that require the human
            > intervention. :)[/color]

            What was wrong with the timestamp (i.e. storing the check-out time in
            the DB, and automatically resetting documents that have been checked
            out longer than time X) suggestion?

            --
            Oli

            Comment

            • Ian B

              #7
              Re: Multi user environment.

              Personally, I'd go with checking the timestamp when you want to check
              the page out, but you could add in an ajax routine to update the time
              stamp every 60 seconds while it is being edited. It could also pick up
              and warn the person editing that someone else was trying to get to it.

              Ian

              Comment

              Working...