We use file sharing to protect the files from being written to by multiple people.
But what if someone overwrites a file that someone has already edited within the same time frame? i.e. edit conflict.
The plan for dealing with edit conflicts of two or more people editing page is to use flags by making use of sessions and cookies together, along with tracking original ip address that person entered the page with and binding it to a cookie on their machine. This is so that incase their IP changes while they are editing the page (AOL accounts) it is still safe.
Edit conflict implementation
-----------------------------
Each user has a cookie set on his computer, mapping to his original IP address. Cookie expires.. in 30 days or so.
This way, his IP address is bound to the cookie. Some AOL accounts flip IP address constantly
USER1 enters the Edit Page view. A SetCookie call is made...
His original IP address is stored in cookie. Cookie is called Lufdoc or similar.
SetSession call is now made, containing IP address that is in the cookie, and IN TIME.
While USER2 comes, another SetCookie call is made. And a Session is made with IP and IN TIME
USER2 saves the page... no conflicts.. SetSession OUT TIME is made.
USER1 tries to save the page, but USER2 has already saved the page before. USER1 IN and OUT time compared with other
users IN and OUT time. USER1 receives error saying edit conflict, please refresh page and see changes.
Easy to check.. scan through all sessions using FetchSess function from Powtils... iterating by index and total count
from FetchSessCount.
uses
pwumain
begin
// setcookie, getcookie
// ...
highcnt:= FetchSessCount;
for i:= 0 to highcnt do
begin
otherusers{i}:= FetchSess('InTime', i)
if (curuser.OutTime > otherusers.OutTime) and (otheruser.InTime < curuser.OutTime) then
ShowEditConflictPage;
end;
end.
Once edit conflicts are resolved or dealt with, some sessions deleted.
This is not complete code obviously.. there will need to be lots more. Refreshing and what not.