- XMXAPIG ;ISC-SF/GMB-Mail Group APIs ;03/25/2003 14:48
- ;;8.0;MailMan;**16**;Jun 28, 2002
- ; All entry points covered by DBIA 3006
- ; Variables input:
- ; XMGROUP Group's IEN or exact name
- ADDMBRS(XMDUZ,XMGRP,XMMBR,XMINSTR,XMTSK) ; Add members to groups
- ; XMGRP Same as XMGROUP, or array XMGRP(XMGROUP)=""
- ; XMMBR Member or array of members to add.
- I '$D(XMV) N XMV,XMDISPI,XMDUN,XMNOSEND,XMPRIV
- K XMERR,^TMP("XMERR",$J)
- D XMDUZ^XMXPARM(.XMDUZ,.XMV)
- I $D(XMINSTR) D XMINSTR(.XMINSTR)
- Q:$D(XMERR)
- D ADDMBRS^XMXGRP(XMDUZ,.XMGRP,.XMMBR,.XMINSTR,.XMTSK)
- Q
- JOIN(XMDUZ,XMGROUP,XMINSTR,XMTSK) ; User chooses to join a group.
- I '$D(XMV) N XMV,XMDISPI,XMDUN,XMNOSEND,XMPRIV
- K XMERR,^TMP("XMERR",$J)
- D XMDUZ^XMXPARM(.XMDUZ,.XMV)
- I $D(XMINSTR) D XMINSTR(.XMINSTR)
- D JOIN^XMXGRP(XMDUZ,XMGROUP,.XMINSTR,.XMTSK)
- Q
- DROP(XMDUZ,XMGROUP) ; User chooses to drop from a group.
- I '$D(XMV) N XMV,XMDISPI,XMDUN,XMNOSEND,XMPRIV
- K XMERR,^TMP("XMERR",$J)
- D XMDUZ^XMXPARM(.XMDUZ,.XMV) Q:$D(XMERR)
- D DROP^XMXGRP(XMDUZ,XMGROUP)
- Q
- XMINSTR(XMINSTR) ;
- S:$D(XMINSTR("SELF BSKT")) XMINSTR("SELF BSKT")=$$XMK^XMXPARM(XMDUZ,"XMINSTR(""SELF BSKT"")",XMINSTR("SELF BSKT"),1)
- I $D(XMINSTR("FLAGS")) D XMFLAG^XMXPARM("XMINSTR(""FLAGS"")",XMINSTR("FLAGS"),"AF")
- S:$D(XMINSTR("FDATE")) XMINSTR("FDATE")=$$XMDATE^XMXPARMB("XMINSTR(""FDATE"")",XMINSTR("FDATE"))
- S:$D(XMINSTR("TDATE")) XMINSTR("TDATE")=$$XMDATE^XMXPARMB("XMINSTR(""TDATE"")",XMINSTR("TDATE"))
- Q
- GOTLOCAL(XMGROUP,XMDAYS,XMMBRS) ; Function: Any active local members? (1=yes; 0=no)
- ; XMDAYS (optional) add'l requirement that the member must have used
- ; MailMan within the last XMDAYS days.
- ; XMMBRS (optional) add'l requirement that this many local members must
- ; be in the group. (default is 1)
- N XMGIEN,XMSCREEN,XMLIST
- K XMERR,^TMP("XMERR",$J)
- S XMGIEN=$$IEN(XMGROUP) Q:$D(XMERR) 0
- ; User must have access code and mailbox
- S XMSCREEN="N XM S XM=+^(0) I $L($P($G(^VA(200,XM,0)),U,3)),$D(^XMB(3.7,XM,2))"
- I $G(XMDAYS) S XMSCREEN=XMSCREEN_",$P($G(^(""L"")),U,2)'<"_$$FMADD^XLFDT(DT,-XMDAYS)
- I '$G(XMMBRS) S XMMBRS=1
- D LIST^DIC(3.81,","_XMGIEN_",","@","I",XMMBRS,"","","",XMSCREEN,"","XMLIST")
- Q:+XMLIST("DILIST",0)=XMMBRS 1
- ; none found
- K:$D(DIERR) DIERR,^TMP("DIERR",$J)
- N XMPARM,XMDIALOG
- S XMPARM(1)=$$NAME(XMGIEN),XMDIALOG=39503 ;Mail group '|1|' has no active local members
- I $G(XMDAYS) S XMPARM(2)=$$FMTE^XLFDT($$FMADD^XLFDT(DT,-XMDAYS),5),XMDIALOG=39504 ;Mail group '|1|' has no local members active since '|2|'
- I $G(XMMBRS) S XMPARM(3)=XMMBRS,XMDIALOG=XMDIALOG+.1
- ;39503.1-Mail group '|1|' does not have at least |3| active local members
- ;39504.1-Mail group '|1|' does not have at least |3| local members who have been active since '|2|'.
- D ERRSET^XMXUTIL(XMDIALOG,.XMPARM)
- Q 0
- IEN(XMGROUP) ; INTERNAL USE ONLY function, given group's ien or exact name, returns ien
- I +XMGROUP=XMGROUP D Q XMGROUP
- . I $D(^XMB(3.8,XMGROUP,0)) Q
- . D ERRSET^XMXUTIL(39502,XMGROUP) ;Mail group IEN '|1|' not found.
- . S XMGROUP=0
- N XMGIEN
- S XMGIEN=$O(^XMB(3.8,"B",XMGROUP,0)) Q:XMGIEN XMGIEN
- D ERRSET^XMXUTIL(39501,XMGROUP) ;Mail group '|1|' not found.
- Q 0
- NAME(XMGIEN) ; INTERNAL USE ONLY function, given group's ien, returns name
- Q $P($G(^XMB(3.8,XMGIEN,0)),U,1)
- MEMBER(XMDUZ,XMGROUP,XMCHKSUB) ; Is user a member of the group?
- ; XMCHKSUB - Check member groups, too? (0=no; 1=yes)
- N XMGIEN,XMCHECKD
- K XMERR,^TMP("XMERR",$J)
- S XMGIEN=$$IEN(XMGROUP) Q:$D(XMERR) 0
- I '$G(XMCHKSUB) Q $D(^XMB(3.8,XMGIEN,1,"B",XMDUZ))>0
- Q $$SUBMBR(XMDUZ,XMGIEN)
- SUBMBR(XMDUZ,XMGIEN) ;
- I $D(^XMB(3.8,XMGIEN,1,"B",XMDUZ)) Q 1
- N XMI,XMMBR
- S XMCHECKD(XMGIEN)=""
- S XMI=0
- F S XMI=$O(^XMB(3.8,XMGIEN,5,"B",XMI)) Q:'XMI D Q:$G(XMMBR)
- . Q:'$D(^XMB(3.8,XMI))
- . Q:$D(XMCHECKD(XMI))
- . S XMMBR=$$SUBMBR(XMDUZ,XMI)
- Q +$G(XMMBR)
- XMXAPIG ;ISC-SF/GMB-Mail Group APIs ;03/25/2003 14:48
- +1 ;;8.0;MailMan;**16**;Jun 28, 2002
- +2 ; All entry points covered by DBIA 3006
- +3 ; Variables input:
- +4 ; XMGROUP Group's IEN or exact name
- ADDMBRS(XMDUZ,XMGRP,XMMBR,XMINSTR,XMTSK) ; Add members to groups
- +1 ; XMGRP Same as XMGROUP, or array XMGRP(XMGROUP)=""
- +2 ; XMMBR Member or array of members to add.
- +3 IF '$DATA(XMV)
- NEW XMV,XMDISPI,XMDUN,XMNOSEND,XMPRIV
- +4 KILL XMERR,^TMP("XMERR",$JOB)
- +5 DO XMDUZ^XMXPARM(.XMDUZ,.XMV)
- +6 IF $DATA(XMINSTR)
- DO XMINSTR(.XMINSTR)
- +7 IF $DATA(XMERR)
- QUIT
- +8 DO ADDMBRS^XMXGRP(XMDUZ,.XMGRP,.XMMBR,.XMINSTR,.XMTSK)
- +9 QUIT
- JOIN(XMDUZ,XMGROUP,XMINSTR,XMTSK) ; User chooses to join a group.
- +1 IF '$DATA(XMV)
- NEW XMV,XMDISPI,XMDUN,XMNOSEND,XMPRIV
- +2 KILL XMERR,^TMP("XMERR",$JOB)
- +3 DO XMDUZ^XMXPARM(.XMDUZ,.XMV)
- +4 IF $DATA(XMINSTR)
- DO XMINSTR(.XMINSTR)
- +5 DO JOIN^XMXGRP(XMDUZ,XMGROUP,.XMINSTR,.XMTSK)
- +6 QUIT
- DROP(XMDUZ,XMGROUP) ; User chooses to drop from a group.
- +1 IF '$DATA(XMV)
- NEW XMV,XMDISPI,XMDUN,XMNOSEND,XMPRIV
- +2 KILL XMERR,^TMP("XMERR",$JOB)
- +3 DO XMDUZ^XMXPARM(.XMDUZ,.XMV)
- IF $DATA(XMERR)
- QUIT
- +4 DO DROP^XMXGRP(XMDUZ,XMGROUP)
- +5 QUIT
- XMINSTR(XMINSTR) ;
- +1 IF $DATA(XMINSTR("SELF BSKT"))
- SET XMINSTR("SELF BSKT")=$$XMK^XMXPARM(XMDUZ,"XMINSTR(""SELF BSKT"")",XMINSTR("SELF BSKT"),1)
- +2 IF $DATA(XMINSTR("FLAGS"))
- DO XMFLAG^XMXPARM("XMINSTR(""FLAGS"")",XMINSTR("FLAGS"),"AF")
- +3 IF $DATA(XMINSTR("FDATE"))
- SET XMINSTR("FDATE")=$$XMDATE^XMXPARMB("XMINSTR(""FDATE"")",XMINSTR("FDATE"))
- +4 IF $DATA(XMINSTR("TDATE"))
- SET XMINSTR("TDATE")=$$XMDATE^XMXPARMB("XMINSTR(""TDATE"")",XMINSTR("TDATE"))
- +5 QUIT
- GOTLOCAL(XMGROUP,XMDAYS,XMMBRS) ; Function: Any active local members? (1=yes; 0=no)
- +1 ; XMDAYS (optional) add'l requirement that the member must have used
- +2 ; MailMan within the last XMDAYS days.
- +3 ; XMMBRS (optional) add'l requirement that this many local members must
- +4 ; be in the group. (default is 1)
- +5 NEW XMGIEN,XMSCREEN,XMLIST
- +6 KILL XMERR,^TMP("XMERR",$JOB)
- +7 SET XMGIEN=$$IEN(XMGROUP)
- IF $DATA(XMERR)
- QUIT 0
- +8 ; User must have access code and mailbox
- +9 SET XMSCREEN="N XM S XM=+^(0) I $L($P($G(^VA(200,XM,0)),U,3)),$D(^XMB(3.7,XM,2))"
- +10 IF $GET(XMDAYS)
- SET XMSCREEN=XMSCREEN_",$P($G(^(""L"")),U,2)'<"_$$FMADD^XLFDT(DT,-XMDAYS)
- +11 IF '$GET(XMMBRS)
- SET XMMBRS=1
- +12 DO LIST^DIC(3.81,","_XMGIEN_",","@","I",XMMBRS,"","","",XMSCREEN,"","XMLIST")
- +13 IF +XMLIST("DILIST",0)=XMMBRS
- QUIT 1
- +14 ; none found
- +15 IF $DATA(DIERR)
- KILL DIERR,^TMP("DIERR",$JOB)
- +16 NEW XMPARM,XMDIALOG
- +17 ;Mail group '|1|' has no active local members
- SET XMPARM(1)=$$NAME(XMGIEN)
- SET XMDIALOG=39503
- +18 ;Mail group '|1|' has no local members active since '|2|'
- IF $GET(XMDAYS)
- SET XMPARM(2)=$$FMTE^XLFDT($$FMADD^XLFDT(DT,-XMDAYS),5)
- SET XMDIALOG=39504
- +19 IF $GET(XMMBRS)
- SET XMPARM(3)=XMMBRS
- SET XMDIALOG=XMDIALOG+.1
- +20 ;39503.1-Mail group '|1|' does not have at least |3| active local members
- +21 ;39504.1-Mail group '|1|' does not have at least |3| local members who have been active since '|2|'.
- +22 DO ERRSET^XMXUTIL(XMDIALOG,.XMPARM)
- +23 QUIT 0
- IEN(XMGROUP) ; INTERNAL USE ONLY function, given group's ien or exact name, returns ien
- +1 IF +XMGROUP=XMGROUP
- Begin DoDot:1
- +2 IF $DATA(^XMB(3.8,XMGROUP,0))
- QUIT
- +3 ;Mail group IEN '|1|' not found.
- DO ERRSET^XMXUTIL(39502,XMGROUP)
- +4 SET XMGROUP=0
- End DoDot:1
- QUIT XMGROUP
- +5 NEW XMGIEN
- +6 SET XMGIEN=$ORDER(^XMB(3.8,"B",XMGROUP,0))
- IF XMGIEN
- QUIT XMGIEN
- +7 ;Mail group '|1|' not found.
- DO ERRSET^XMXUTIL(39501,XMGROUP)
- +8 QUIT 0
- NAME(XMGIEN) ; INTERNAL USE ONLY function, given group's ien, returns name
- +1 QUIT $PIECE($GET(^XMB(3.8,XMGIEN,0)),U,1)
- MEMBER(XMDUZ,XMGROUP,XMCHKSUB) ; Is user a member of the group?
- +1 ; XMCHKSUB - Check member groups, too? (0=no; 1=yes)
- +2 NEW XMGIEN,XMCHECKD
- +3 KILL XMERR,^TMP("XMERR",$JOB)
- +4 SET XMGIEN=$$IEN(XMGROUP)
- IF $DATA(XMERR)
- QUIT 0
- +5 IF '$GET(XMCHKSUB)
- QUIT $DATA(^XMB(3.8,XMGIEN,1,"B",XMDUZ))>0
- +6 QUIT $$SUBMBR(XMDUZ,XMGIEN)
- SUBMBR(XMDUZ,XMGIEN) ;
- +1 IF $DATA(^XMB(3.8,XMGIEN,1,"B",XMDUZ))
- QUIT 1
- +2 NEW XMI,XMMBR
- +3 SET XMCHECKD(XMGIEN)=""
- +4 SET XMI=0
- +5 FOR
- SET XMI=$ORDER(^XMB(3.8,XMGIEN,5,"B",XMI))
- IF 'XMI
- QUIT
- Begin DoDot:1
- +6 IF '$DATA(^XMB(3.8,XMI))
- QUIT
- +7 IF $DATA(XMCHECKD(XMI))
- QUIT
- +8 SET XMMBR=$$SUBMBR(XMDUZ,XMI)
- End DoDot:1
- IF $GET(XMMBR)
- QUIT
- +9 QUIT +$GET(XMMBR)