> I'm trying to determine how to unlock objects after a certain amount of
> inactivity. I swiped some code from iBuild or Restorenet that had a lock
> checking routine just before the PLP call. However, it seems that the
> 'datetimelastupdated' field in the objects table only gets changed when
the
> <CFA_contentObjectData> tag is used.
Hello all,
After looking through the coLock, coUnlock and coIsLocked tags, I now know
that you can't alter the locking status of a locked object unless you are
the 'lockedby' user. This means that in order to alter the lock status on a
locked object you must use the coData tag to change the attr_locked and
attr_lockedby attributes because the coLock and coUnlock tags will not allow
you to change the status.
In this way I can cancel the locking for an aborted PLP by looking at the
the dtExpires field of the PLPInstances table.
Just thought I'd answer my own question. I hope this helps somebody else.
Here's my code. It's much easier to read in studio
-----
<!--------------------------------------
| OBJECT LOCKING CHECKS AND LOCKING
--------------------------------------->
<!--- check to see if the object is locked --->
<cfa_contentObjectIsLocked
datasource="#request.cfa.objectStore.dsn#"
objectID="#url.oID#"
r_status="status">
<!--- by default, don't allow users to edit this object --->
<!--- we'll check the check out status below and set this to
true if they're allowed to edit it --->
<cfset bEditAllowed = FALSE>
<!--- If its checked out, inform user and show the display method instead
--->
<cfif status is "locked">
<!--- get the username of the locking person --->
<CFQUERY DATASOURCE="#request.cfa.objectstore.dsn#" NAME="Q_GetLocker">
SELECT LockedBy
FROM objects
WHERE objectID = '#url.oID#'
</CFQUERY>
<!--- get the plpinstance for the locker --->
<CFQUERY DATASOURCE="#request.cfa.objectstore.dsn#" NAME="Q_IsPLPActive">
SELECT w.wddxdata, i.dtexpires
FROM plpinstances i, wddxdata w
WHERE i.username = '#Q_GetLocker.LockedBy#'
AND i.plpid = '#url.plpID#'
AND i.plpinstanceid = w.plpinstanceid
</CFQUERY>
<!--- loop through the PLP's for the locking user --->
<CFOUTPUT QUERY="Q_IsPLPActive">
<!--- break data into a struct --->
<CFWDDX ACTION="WDDX2CFML" INPUT="#Q_IsPLPActive.WddxData#"
OUTPUT="stWddxData">
<!--- <CFA_DUMP VAR="#stWddxData#"> --->
<!--- check the object id's to make sure this record is the locked object
--->
<CFIF stWddxData.plp.input.objectID IS url.oID>
<CFSET NowJulian = Now()+0>
<CFIF NowJulian LTE Q_IsPLPActive.dtExpires>
<script>
msg = "This content item is currently checked out to another user.";
window.alert(msg);
</script>
<!--- user can't edit, so let them see the current object instead --->
<BR>
This object is locked by the user <I>#Q_GetLocker.LockedBy#</I>.
The lock on this object will time out in
#CEILING(DATEDIFF("n",NowJulian,Q_IsPLPActive.dtExpires))# minutes
or when <I>#Q_GetLocker.LockedBy#</I> unlocks the object.<BR><BR>
<CFA_contentObject
DATASOURCE="#request.cfa.objectstore.dsn#"
OBJECTID="#url.oID#"
METHOD="display"
>
<CFELSE>
<!--- if the object has timed out, lock the object to the current user
--->
<CFA_CONTENTOBJECTDATA
DATASOURCE="#request.cfa.objectstore.dsn#"
OBJECTID=""
>
<CFA_CONTENTOBJECTPROPERTY NAME="attr_locked" VALUE="1">
<CFA_CONTENTOBJECTPROPERTY NAME="attr_lockedBy"
VALUE="#request.cfa.activeuser#">
</CFA_CONTENTOBJECTDATA>
<!--- allow the user access to the PLP call --->
<CFSET bEditAllowed = TRUE>
</CFIF>
</CFIF>
</CFOUTPUT>
<!--- If this user currently has this checked out, simply permit editing
--->
<cfelseif status is "lockedByUser">
<cfset bEditAllowed = TRUE>
<!--- If it isn't checked out yet, check it out! --->
<cfelse>
<cfa_contentObjectLock
datasource="#request.cfa.objectstore.dsn#"
objectID="#url.oID#">
<cfset bEditAllowed = TRUE>
</cfif>
-
Nate Smith,
Lead Developer
[EMAIL PROTECTED]
www.doceus.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
------------------------------------------------------------------------------
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/spectra_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.