home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Examples / publish / admin / addcontent3.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  2.7 KB  |  97 lines

  1. <CFPARAM NAME="Session.AddContent.ObjectID" DEFAULT="">
  2.  
  3. <CFTRANSACTION ISOLATION="READ_COMMITTED">
  4.  
  5. <CFIF Session.AddContent.ObjectID IS "">
  6.  
  7.     <CFSET CurrentDateTime = Now()>
  8.  
  9.     <CFQUERY DATASOURCE="CFexamples" NAME="GetTopObjID">
  10.     SELECT Max(ObjectID) AS MaxID FROM PubObjects
  11.     </CFQUERY>
  12.  
  13.     <CFIF GetTopObjID.MaxID IS "">
  14.         <CFSET NewObjectID = 1>
  15.     <CFELSE>
  16.         <CFSET NewObjectID = GetTopObjID.MaxID + 1>
  17.     </CFIF>
  18.     
  19.     <CFQUERY DATASOURCE="CFexamples" NAME="CreateNewObject">
  20.     INSERT INTO PubObjects (ObjectID, ClassID, DateCreated, DateUpdated)
  21.     VALUES (#NewObjectID#, #Session.AddContent.ClassID#, #CurrentDateTime#, #CurrentDateTime#)
  22.     </CFQUERY>
  23.  
  24.     <CFQUERY DATASOURCE="CFexamples" NAME="GetNewObjectID">
  25.     SELECT ObjectID FROM PubObjects
  26.     WHERE ClassID = #Session.AddContent.ClassID#
  27.         AND DateCreated = #CurrentDateTime#
  28.     </CFQUERY>
  29.         
  30.     <CFSET ObjectID = GetNewObjectID.ObjectID>
  31.  
  32. <CFELSE>
  33.  
  34.     <CFSET ObjectID = Session.AddContent.ObjectID>
  35.  
  36. </CFIF>
  37.  
  38. <CFLOOP LIST="#Session.AddContent.ReqContentTypes#" INDEX="CurrType">
  39.  
  40.     <CFQUERY DATASOURCE="CFexamples" NAME="KillExisting">
  41.     DELETE FROM PubContent
  42.     WHERE ObjectID = #ObjectID#
  43.         AND TypeID = #CurrType#
  44.     </CFQUERY>
  45.     
  46.     <CFQUERY DATASOURCE="CFexamples" NAME="GetTopContentID">
  47.     SELECT Max(ContentID) AS MaxID FROM PubContent
  48.     </CFQUERY>
  49.  
  50.     <CFIF GetTopContentID.MaxID IS "">
  51.         <CFSET NewContentID = 1>
  52.     <CFELSE>
  53.         <CFSET NewContentID = GetTopContentID.MaxID + 1>
  54.     </CFIF>
  55.  
  56.     <!--- "Pay no attention to the man behind the curtain." --->
  57.     <CFSET DataVar = evaluate("Session.AddContent.Content.Type" & CurrType)>
  58.  
  59.     <CFQUERY DATASOURCE="CFexamples" NAME="InsertNew">
  60.     INSERT INTO PubContent (ContentID, ObjectID, TypeID, Data)
  61.     VALUES (#NewContentID#, #ObjectID#, #CurrType#, '#DataVar#')
  62.     </CFQUERY>
  63.  
  64.     <CFSET "Session.AddContent.Content.Type#CurrType#" = "">
  65.  
  66. </CFLOOP>
  67.  
  68. <CFLOOP LIST="#Session.AddContent.OptContentTypes#" INDEX="CurrType">
  69.  
  70.     <CFQUERY DATASOURCE="CFexamples" NAME="KillExisting">
  71.     DELETE FROM PubContent
  72.     WHERE ObjectID = #ObjectID#
  73.         AND TypeID = #CurrType#
  74.     </CFQUERY>
  75.     
  76.     <CFQUERY DATASOURCE="CFexamples" NAME="GetTopContentID">
  77.     SELECT Max(ContentID) AS MaxID FROM PubContent
  78.     </CFQUERY>
  79.  
  80.     <CFIF GetTopContentID.MaxID IS "">
  81.         <CFSET NewContentID = 1>
  82.     <CFELSE>
  83.         <CFSET NewContentID = GetTopContentID.MaxID + 1>
  84.     </CFIF>
  85.  
  86.     <CFQUERY DATASOURCE="CFexamples" NAME="InsertNew">
  87.     INSERT INTO PubContent (ContentID, ObjectID, TypeID, Data)
  88.     VALUES (#NewContentID#, #ObjectID#, #CurrType#, '#evaluate("Session.AddContent.Content.Type" & CurrType)#')
  89.     </CFQUERY>
  90.  
  91.     <CFSET "Session.AddContent.Content.Type#CurrType#" = "">
  92.  
  93. </CFLOOP>
  94.  
  95. </CFTRANSACTION>
  96.  
  97. <CFLOCATION URL="properties.cfm?ObjectID=#ObjectID#" ADDTOKEN="NO">