Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: XMXBULL

XMXBULL.m

Go to the documentation of this file.
  1. XMXBULL ;ISC-SF/GMB-Send Bulletin ;04/23/2002 08:46
  1. ;;8.0;MailMan;;Jun 28, 2002
  1. ; Replaces ^XMB (ISC-WASH/THM/RWF/CAP)
  1. ; TASKBULL creates and delivers a bulletin in background.
  1. ; SENDBULL creates bulletin in foreground; delivers in background
  1. ; TASK for use by TaskMan only
  1. ; The recipients of the message include any entries in the XMTO
  1. ; array that the caller has defined and the members of mail groups
  1. ; that are included in the definition of the entry in the Bulletin
  1. ; file (#3.6) at the time of delivery. There must be valid
  1. ; recipients or the message will not be delivered.
  1. ; Inputs:
  1. ; XMDUZ Sender DUZ
  1. ; XMBNAME The name of a bulletin (an entry in File #3.6)
  1. ; XMPARM(parameter#)=The value to be stuffed into the bulletin for each
  1. ; required parameter. (eg. XMPARM(1)=data for parameter#1
  1. ; XMBODY (optional) Additional text of the message
  1. ; XMTO (optional) Array of recipients of a bulletin
  1. ; XMINSTR("FLAGS") (optional)
  1. ; ["P" - priority
  1. ; XMINSTR("FROM") (optional) String saying from whom (default is sender)
  1. ; XMINSTR("LATER") (optional) date/time to send the bulletin (default is now)
  1. ; XMINSTR("VAPOR") (optional) date/time to vaporize the bulletin.
  1. ; If supplied, it takes precedence over the bulletin's
  1. ; RETENTION DAYS field.
  1. ; XMATTACH (in) Array of files to attach to message
  1. ; ("IMAGE",x) imaging (BLOB) files
  1. ; Output:
  1. ; XMZ (from entry SENDBULL only) Message number if successful
  1. ; XMTASK (from entry TASKBULL only) Task number (ZTSK) if successful
  1. TASKBULL(XMDUZ,XMBNAME,XMPARM,XMBODY,XMTO,XMINSTR,XMTASK,XMATTACH) ; Tasks it
  1. N XMBIEN
  1. K XMERR,^TMP("XMERR",$J)
  1. I XMDUZ=.6 D ERRSET^XMXUTIL(39321) Q ;SHARED,MAIL may not send a bulletin.
  1. S XMBIEN=$O(^XMB(3.6,"B",XMBNAME,""))
  1. D BULLETIN^XMKPO(XMDUZ,XMBNAME,XMBIEN,.XMPARM,.XMBODY,.XMTO,.XMINSTR,.XMTASK,.XMATTACH)
  1. Q
  1. TASK ; TaskMan uses this entry point, and supplies variables:
  1. ; XMDUZ,XMBIEN,XMPARM,XMBODY,XMTO,XMINSTR,XMATTACH
  1. N XMZ
  1. K XMERR,^TMP("XMERR",$J)
  1. D SEND(XMDUZ,XMBIEN,.XMPARM,.XMBODY,.XMTO,.XMINSTR,.XMZ,.XMATTACH)
  1. S ZTREQ="@"
  1. Q
  1. SENDBULL(XMDUZ,XMBNAME,XMPARM,XMBODY,XMTO,XMINSTR,XMZ,XMATTACH) ; Does it now
  1. N XMBIEN
  1. K XMERR,^TMP("XMERR",$J)
  1. I XMDUZ=.6 D ERRSET^XMXUTIL(39321) Q ;SHARED,MAIL may not send a bulletin.
  1. S XMBIEN=$O(^XMB(3.6,"B",XMBNAME,""))
  1. D SEND(XMDUZ,XMBIEN,.XMPARM,.XMBODY,.XMTO,.XMINSTR,.XMZ,.XMATTACH)
  1. Q
  1. SEND(XMDUZ,XMBIEN,XMPARM,XMBODY,XMTO,XMINSTR,XMZ,XMATTACH) ; Create and send the bulletin
  1. N XMREC,XMSUBJ,XMVDAYS
  1. S XMREC=^XMB(3.6,XMBIEN,0)
  1. S XMSUBJ=$$SUBJECT($P(XMREC,U,2),.XMPARM) Q:$D(XMERR)
  1. S XMVDAYS=$P(XMREC,U,3)
  1. I XMVDAYS,'$D(XMINSTR("VAPOR")) D
  1. . S XMINSTR("VAPOR")=$$FMADD^XLFDT(DT,XMVDAYS)
  1. E K XMVDAYS
  1. D CRE8XMZ^XMXSEND(XMSUBJ,.XMZ) Q:$D(XMERR)
  1. D:$G(XMINSTR("ADDR FLAGS"))'["I" INIT^XMXADDR
  1. D BULLADDR(XMDUZ,XMBIEN,.XMINSTR)
  1. D CHKADDR^XMXADDR(XMDUZ,.XMTO,.XMINSTR)
  1. I '$$GOTADDR^XMXADDR D Q
  1. . D CLEANUP^XMXADDR
  1. . D ERRSET^XMXUTIL(39320) ;No addressees. Bulletin not sent.
  1. . D KILLMSG^XMXUTIL(XMZ)
  1. . S XMZ=-1
  1. I $P(XMREC,U,4),$G(XMINSTR("FLAGS"))'["P" S XMINSTR("FLAGS")=$G(XMINSTR("FLAGS"))_"P"
  1. D:$D(XMATTACH("IMAGE"))>9 ADDBLOB^XMXSEND(XMZ,.XMATTACH)
  1. D MOVEPART^XMXSEND(XMDUZ,XMZ,.XMINSTR)
  1. D MOVEBODY^XMXSEND(XMZ,"^XMB(3.6,"_XMBIEN_",1)") ; Bulletin text
  1. D DOPARMS(XMZ,.XMPARM)
  1. I $G(XMBODY)'="",$D(@XMBODY)>9,$O(@XMBODY@(0)) D MOVEBODY^XMXSEND(XMZ,XMBODY,"A") ; Append the text (no parm translation)
  1. I $E(XMREC,1,2)="XM" D CHKNONVF(XMZ,$P(XMREC,U))
  1. D SEND^XMKP(XMDUZ,XMZ)
  1. I $D(XMVDAYS) K XMINSTR("VAPOR")
  1. D CLEANUP^XMXADDR
  1. D CHECK^XMKPL
  1. Q
  1. BULLADDR(XMDUZ,XMBIEN,XMINSTR) ;
  1. N XMGIEN,XMGROUP
  1. S XMGIEN=""
  1. F S XMGIEN=$O(^XMB(3.6,XMBIEN,2,"B",XMGIEN)) Q:XMGIEN="" D
  1. . S XMGROUP="G."_$P($G(^XMB(3.8,XMGIEN,0)),U,1)
  1. . D:XMGROUP]"G." CHKADDR^XMXADDR(XMDUZ,XMGROUP,.XMINSTR)
  1. Q
  1. SUBJECT(XMSUBJ,XMPARM) ;
  1. D:XMSUBJ["|" FILL(.XMSUBJ,.XMPARM)
  1. I $L(XMSUBJ)<3 S XMSUBJ=XMSUBJ_"..."
  1. I $L(XMSUBJ)>65 S XMSUBJ=$E(XMSUBJ,1,65)
  1. Q $$XMSUBJ^XMXPARM("XMSUBJ",XMSUBJ)
  1. DOPARMS(XMZ,XMPARM) ;
  1. N I,XMLINE
  1. S I=0
  1. F S I=$O(^XMB(3.9,XMZ,2,I)) Q:I="" D
  1. . Q:^XMB(3.9,XMZ,2,I,0)'["|"
  1. . S XMLINE=^XMB(3.9,XMZ,2,I,0)
  1. . D:XMLINE["|" FILL(.XMLINE,.XMPARM)
  1. . S ^XMB(3.9,XMZ,2,I,0)=XMLINE
  1. Q
  1. FILL(XMLINE,XMPARM) ;
  1. ; This gets confused by "\027||1|, your Help Request from, |2|,":
  1. ;F D Q:XMLINE'["|"
  1. ;. S XMLINE=$P(XMLINE,"|",1)_$G(XMPARM(+$P(XMLINE,"|",2)))_$P(XMLINE,"|",3,999)
  1. ; This can handle it:
  1. Q:XMLINE'?.E1"|"1.N1"|".E
  1. N XML
  1. S XML=""
  1. F D Q:XMLINE'?.E1"|"1.N1"|".E
  1. . I $P(XMLINE,"|",2)?1N.N S XMLINE=$P(XMLINE,"|",1)_$G(XMPARM(+$P(XMLINE,"|",2)))_$P(XMLINE,"|",3,999) Q
  1. . S XML=XML_$P(XMLINE,"|",1)_"|",XMLINE=$P(XMLINE,"|",2,999)
  1. S XMLINE=XML_XMLINE
  1. Q
  1. CHKNONVF(XMZ,XMBNAME) ; (CHecK NO eNVelope From)
  1. Q:$O(^TMP("XMY",$J,""),-1)'["@"
  1. I XMBNAME'="XM SEND ERR RECIPIENT",XMBNAME'="XM SEND ERR MSG" Q
  1. ; This is an error bulletin sent by MailMan to someone at a remote site
  1. ; indicating that their message could not be delivered for some reason.
  1. ; We want to make sure that the 'envelope from' is null, so we pre-set
  1. ; it here. It's a little trick.
  1. S $P(^XMB(3.9,XMZ,.7),U,1)="<>"
  1. Q