| 1 | XMJBN1 ;ISC-SF/GMB-Access new mail in mailbox (cont.) ;04/06/2002  08:52 | 
|---|
| 2 | ;;8.0;MailMan;;Jun 28, 2002 | 
|---|
| 3 | INIT(XMDUZ,XMK,XMKN,XMNEW,XMKMULT,XMABORT) ; | 
|---|
| 4 | N I F I="N","N0" D BOGUS(XMDUZ,I) | 
|---|
| 5 | D CHECK^XMVVITAE | 
|---|
| 6 | I XMDUZ'=DUZ,'$$RPRIV^XMXSEC D  Q | 
|---|
| 7 | . S XMABORT=1 | 
|---|
| 8 | . D SHOW^XMJERR | 
|---|
| 9 | S XMK=$O(^XMB(3.7,XMDUZ,"N0",0)) | 
|---|
| 10 | I XMK>0,XMK<1 D | 
|---|
| 11 | . D FIXIT(XMDUZ) | 
|---|
| 12 | . S XMK=$O(^XMB(3.7,XMDUZ,"N0",0)) | 
|---|
| 13 | I XMK="" D  Q | 
|---|
| 14 | . S XMABORT=1 | 
|---|
| 15 | . S $P(^XMB(3.7,XMDUZ,0),U,6)="" ; Just to make sure we're in synch. | 
|---|
| 16 | . N XMPARM S XMPARM(2)=XMV("NAME") | 
|---|
| 17 | . W !,$$EZBLD^DIALOG($S(XMDUZ=DUZ:34017,1:38156.2),.XMPARM) ; You have no new messages. / |2| has no new messages. | 
|---|
| 18 | S XMNEW=$$TNMSGCT^XMXUTIL(XMDUZ) | 
|---|
| 19 | I $O(^XMB(3.7,XMDUZ,"N0",XMK)) D | 
|---|
| 20 | . S XMKMULT=1 | 
|---|
| 21 | . W !!,$$EZBLD^DIALOG($S(XMDUZ=DUZ:34019,1:34019.1),XMV("NAME")) ; You have/|1| has new mail in more than one basket | 
|---|
| 22 | E  S XMKMULT=0 | 
|---|
| 23 | S XMKN=$P(^XMB(3.7,XMDUZ,2,XMK,0),U) | 
|---|
| 24 | Q | 
|---|
| 25 | BOGUS(XMDUZ,XMTYPE) ; Check for and kill bogus node. | 
|---|
| 26 | ; This shouldn't be needed, but something (not MailMan) is setting it. | 
|---|
| 27 | I $D(^XMB(3.7,XMDUZ,XMTYPE,0)) K ^XMB(3.7,XMDUZ,XMTYPE,0) | 
|---|
| 28 | Q | 
|---|
| 29 | FIXIT(XMDUZ) ; In case mail in the waste basket is new. | 
|---|
| 30 | N XMK,XMZ | 
|---|
| 31 | S (XMK,XMZ)="" | 
|---|
| 32 | F  S XMK=$O(^XMB(3.7,XMDUZ,"N0",XMK)) Q:XMK'<1!'XMK  D | 
|---|
| 33 | . F  S XMZ=$O(^XMB(3.7,XMDUZ,"N0",XMK,XMZ)) Q:'XMZ  D | 
|---|
| 34 | . . D:$D(^XMB(3.7,XMDUZ,2,XMK,1,XMZ,0)) NONEW^XMXUTIL(XMDUZ,XMK,XMZ,1) | 
|---|
| 35 | . . K:$D(^XMB(3.7,XMDUZ,"N0",XMK,XMZ)) ^XMB(3.7,XMDUZ,"N0",XMK,XMZ) | 
|---|
| 36 | . . K:$D(^XMB(3.7,XMDUZ,"N",XMK,XMZ)) ^XMB(3.7,XMDUZ,"N",XMK,XMZ) | 
|---|
| 37 | Q | 
|---|
| 38 | NXTBSKT(XMDUZ,XMTYPE,XMKN,XMK,XMKPRI) ; | 
|---|
| 39 | D NXTINIT(XMDUZ,XMTYPE) | 
|---|
| 40 | I '$D(^TMP("XM",$J,XMTYPE)) D  Q | 
|---|
| 41 | . S XMK=0,XMKN="",XMKPRI=0,XMKPRI("XMKN")="" | 
|---|
| 42 | . K ^TMP("XM",$J,"APX") | 
|---|
| 43 | F  D  Q:XMKN'="" | 
|---|
| 44 | . I XMKN="" S XMKPRI=0,XMKPRI("XMKN")="" K ^TMP("XM",$J,"APX") | 
|---|
| 45 | . I XMKN=XMKPRI("XMKN") D  Q:XMKN'="" | 
|---|
| 46 | . . D NXTPRI(XMDUZ,XMTYPE,.XMKPRI) | 
|---|
| 47 | . . S XMKN=XMKPRI("XMKN") | 
|---|
| 48 | . E  S XMKPRI=0,XMKPRI("XMKN")="" | 
|---|
| 49 | . F  S XMKN=$O(^TMP("XM",$J,XMTYPE,XMKN)) Q:XMKN=""  Q:'$D(^TMP("XM",$J,"APX",XMTYPE,XMKN)) | 
|---|
| 50 | S XMK=^TMP("XM",$J,XMTYPE,XMKN) | 
|---|
| 51 | K ^TMP("XM",$J,XMTYPE) | 
|---|
| 52 | Q | 
|---|
| 53 | NXTINIT(XMDUZ,XMTYPE) ; | 
|---|
| 54 | N XMK,XMKN | 
|---|
| 55 | K ^TMP("XM",$J,XMTYPE) | 
|---|
| 56 | D BOGUS(XMDUZ,XMTYPE) | 
|---|
| 57 | S XMK=0 | 
|---|
| 58 | F  S XMK=$O(^XMB(3.7,XMDUZ,XMTYPE,XMK)) Q:'XMK  D | 
|---|
| 59 | . S XMKN=$P(^XMB(3.7,XMDUZ,2,XMK,0),U) | 
|---|
| 60 | . S ^TMP("XM",$J,XMTYPE,XMKN)=XMK | 
|---|
| 61 | Q | 
|---|
| 62 | NXTPRI(XMDUZ,XMTYPE,XMKPRI) ; | 
|---|
| 63 | I XMKPRI=100 S XMKPRI("XMKN")="" Q | 
|---|
| 64 | I $D(^XMB(3.7,XMDUZ,2,"AP")) D  I XMKPRI S ^TMP("XM",$J,"APX",XMTYPE,XMKPRI("XMKN"))="" Q | 
|---|
| 65 | . N XMK,XMKN | 
|---|
| 66 | . K ^TMP("XM",$J,"AP") | 
|---|
| 67 | . S:XMKPRI XMKPRI=XMKPRI-.1 | 
|---|
| 68 | . S XMK=0 | 
|---|
| 69 | . F  S XMKPRI=$O(^XMB(3.7,XMDUZ,2,"AP",XMKPRI)) Q:'XMKPRI  D  Q:XMKPRI("XMKN")'="" | 
|---|
| 70 | . . F  S XMK=$O(^XMB(3.7,XMDUZ,2,"AP",XMKPRI,XMK)) Q:'XMK  D | 
|---|
| 71 | . . . S XMKN=$P(^XMB(3.7,XMDUZ,2,XMK,0),U) | 
|---|
| 72 | . . . Q:'$D(^TMP("XM",$J,XMTYPE,XMKN)) | 
|---|
| 73 | . . . S ^TMP("XM",$J,"AP",XMKPRI,XMKN)="" | 
|---|
| 74 | . . S XMKPRI("XMKN")=$O(^TMP("XM",$J,"AP",XMKPRI,XMKPRI("XMKN"))) | 
|---|
| 75 | . K ^TMP("XM",$J,"AP") | 
|---|
| 76 | S XMKPRI=100 | 
|---|
| 77 | N XMIN | 
|---|
| 78 | S XMIN=$$EZBLD^DIALOG(37005) ; IN | 
|---|
| 79 | I $D(^TMP("XM",$J,XMTYPE,XMIN)) S XMKPRI("XMKN")=XMIN,^TMP("XM",$J,"APX",XMTYPE,XMKPRI("XMKN"))="" Q | 
|---|
| 80 | S XMKPRI("XMKN")="" | 
|---|
| 81 | Q | 
|---|
| 82 | ; It used to be that the list of messages to "new" was kept in ^TMP. | 
|---|
| 83 | ; But if the user got forced off for some reason, the global was lost, | 
|---|
| 84 | ; and the messages were never "new"ed. So I changed to ^XTMP.  We check | 
|---|
| 85 | ; ^XTMP whenever a user logs on (in ^XMVVITAE). | 
|---|
| 86 | ; Possible problem: one user is in the middle of reading new messages | 
|---|
| 87 | ; and "new"ing ones he wants to have "new" again, and a surrogate logs | 
|---|
| 88 | ; on, and triggers an immediate "new"ing of all those messages. | 
|---|
| 89 | ; I think it's an acceptable risk.  Maybe not. | 
|---|
| 90 | ; This may be a case of 'damned if you do; damned if you don't'. | 
|---|
| 91 | ; Perhaps we should also check ^XTMP in the wee hours of the morning | 
|---|
| 92 | ; (in ^XMTDT), just in case the user doesn't log on again. | 
|---|
| 93 | NEWAGAIN(XMDUZ) ; "new" messages which the user wanted to "new". | 
|---|
| 94 | S ^XTMP("XM",0)=$$FMADD^XLFDT(DT,7)_U_DT | 
|---|
| 95 | N XMZ,XMK | 
|---|
| 96 | S XMZ="" | 
|---|
| 97 | F  S XMZ=$O(^XTMP("XM","MAKENEW",XMDUZ,XMZ)) Q:XMZ=""  D  K ^XTMP("XM","MAKENEW",XMDUZ,XMZ) | 
|---|
| 98 | . S XMK=$O(^XMB(3.7,"M",XMZ,XMDUZ,0)) Q:'XMK | 
|---|
| 99 | . Q:$D(^XMB(3.7,XMDUZ,"N0",XMK,XMZ)) | 
|---|
| 100 | . D MAKENEW^XMXUTIL(XMDUZ,XMK,XMZ,1) | 
|---|
| 101 | Q | 
|---|