(FILECREATED " 4-Jun-86 16:39:57" {QV}<NOTECARDS>1.3K>FGHPATCH050.;1 5508   

      changes to:  (VARS FGHPATCH050COMS))


(* Copyright (c) 1986 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT FGHPATCH050COMS)

(RPAQQ FGHPATCH050COMS ((* * Fix to bug %# 69 -- close w/o saving shouldn't confirmin no changes)
			  (FNS NC.QuitWithoutSaving)))
(* * Fix to bug %# 69 -- close w/o saving shouldn't confirmin no changes)

(DEFINEQ

(NC.QuitWithoutSaving
  (LAMBDA (CardIdentifier)                                   (* fgh: " 4-Jun-86 16:34")

          (* Quit from a note card without saving its contents on the database. But must make sure that any updates that 
	  would have been done to this card even if it had been on the database are carried out on the old image currently on
	  the database)



          (* * rht 2/1/85: Now only writes out links if it has to. Also resets dirty flags and calls normal quit procedure.
	  I think we've still got possible problems with recently changed titles, both ours and those of cards we point to.)



          (* * rht 2/3/85: Now handles title changes properly. Also fixed so that changes to from links will force links to 
	  be written.)



          (* * rht 2/9/85: Now accepts IDs as arg.)



          (* * fgh 11/12/85: Updated to handle Card objects. Removed DatabaseStream argument.)



          (* * fgh 6/4/86 No longer asks fopr confirmation if no changes have been made.)


    (LET (Window Card FromLinks ToLinks DeletedLinks Process TextObj MadeNewLinksP ChangedFromLinksP 
		 OldFromLinks OldToLinks)
         (SETQ Card (NC.CoerceToCard CardIdentifier))
         (SETQ Window (NC.FetchWindow Card))
         (SETQ FromLinks (NC.FetchFromLinks Card))
         (SETQ ToLinks (NC.FetchToLinks Card))
         (COND
	   ((OR (NULL (OR (NC.CardDirtyP Card)
				(NC.FetchLinksDirtyFlg Card)
				(NC.FetchTitleDirtyFlg Card)
				(NC.FetchPropListDirtyFlg Card)))
		  (NC.AskYesOrNo "Are you sure you want to flush your changes?" " -- " "Yes" T 
				   Window NIL NIL))

          (* * EIther no changes have been made or the user has confirmed.)


	     (COND
	       ((NC.CardP (NC.GetNoteCard Card))         (* If from links have changed then we'll have to write
							     the new ones out.)
		 (SETQ OldFromLinks (NC.FetchFromLinks Card))
		 (COND
		   ((NOT (NC.SameLinksP FromLinks OldFromLinks))
		     (NC.SetFromLinks Card FromLinks)
		     (SETQ ChangedFromLinksP T)))          (* Delete the back links from all links that are not 
							     in the old to link set.)
		 (SETQ OldToLinks (NC.FetchToLinks Card))
		 (for ToLink in ToLinks when (NOT (for Link in OldToLinks
							     bind (ToLinkID ←(fetch (Link UID)
										  of ToLink))
							     thereis (EQ ToLinkID
									     (fetch (Link UID)
										of Link))
							     eachtime (BLOCK)))
		    do (NC.DelFromLink ToLink T)
			 (SETQ MadeNewLinksP T))           (* Check to make sure none of the old To links point 
							     to a deleted card. If so, replace with a deleted 
							     marker.)
		 (SETQ DeletedLinks (bind DestinationCard for Link in OldToLinks
					 when (PROGN (SETQ DestinationCard (fetch
							     (Link DestinationCard) of Link))
							 (AND (NOT (NC.ActiveCardP 
										  DestinationCard))
								(EQ (QUOTE DELETED)
								      (NC.FetchStatus 
										  DestinationCard))))
					 eachtime (BLOCK) collect (NC.DelReferencesToCard
									  Card DestinationCard)
									Link))
		 (NC.SetToLinks Card (LDIFFERENCE OldToLinks DeletedLinks))
                                                             (* Mark links dirty if we had to delete any to links 
							     or if the from links changed.)
		 (NC.SetLinksDirtyFlg Card (OR DeletedLinks ChangedFromLinksP))
                                                             (* Mark the substance dirty if had to delete any to 
							     links.)
		 (COND
		   (DeletedLinks (NC.MarkCardDirty Card))
		   (T (NC.MarkCardDirty Card (QUOTE RESET))))
		 (NC.SetPropListDirtyFlg Card NIL)
		 (COND
		   ((NC.FetchTitleDirtyFlg Card)

          (* If we've changed title and any of the cards pointing to this one are up on the screen, then we need to update 
	  their images.)


		     (for FromLink in OldFromLinks bind SourceCard eachtime (BLOCK)
			when (AND (NC.ActiveCardP (SETQ SourceCard (fetch (Link SourceCard)
									      of FromLink)))
				      (WINDOWP (NC.FetchWindow SourceCard)))
			do (NC.UpdateLinkImages SourceCard Card))
		     (NC.SetTitleDirtyFlg Card NIL)))
		 (NC.QuitCard Card T T))
	       (T                                            (* If the card has never been written to the database 
							     quit w/o saving is equivalent to deleting the card.)
		  (NC.PrintMsg Window T "This card has never been saved." (CHARACTER 13)
				 "It will be deleted from the database."
				 (CHARACTER 13))
		  (NC.DeleteNoteCards Card NIL T))))))))
)
(PUTPROPS FGHPATCH050 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (446 5426 (NC.QuitWithoutSaving 456 . 5424)))))
STOP