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

XMBGRP.m

Go to the documentation of this file.
  1. XMBGRP ;ISC-SF/GMB - Mail Group APIs ;04/17/2002 07:44
  1. ;;8.0;MailMan;**47**;Jun 28, 2002;Build 6
  1. ; Was (WASH ISC)/JL,CAP
  1. ;
  1. ; Entry points (DBIA 1146):
  1. ; $$DM Delete local members from a mail group.
  1. ; $$MG Create a mail group or add members to an existing mail group.
  1. MG(XMGROUP,XMTYPE,XMORG,XMSELF,XMY,XMDESC,XMQUIET) ; Create group or add members to existing group
  1. ;Example:
  1. ;S X=$$MG^XMBGRP(XMGROUP,XMTYPE,XMORG,XMSELF,.XMY,.XMDESC,XMQUIET)
  1. ;
  1. ;XMGROUP =group name if creating a new group;
  1. ; =group name or pointer to ^XMB(3.8,
  1. ; if adding members to an existing group.
  1. ;XMTYPE type of group - used only for creation
  1. ; 0=public (default)
  1. ; 1=private
  1. ;XMORG group organizer - used only for creation
  1. ; pointer to ^VA(200, (default=DUZ)
  1. ;XMSELF allow self enrollment - used only for creation
  1. ; 0=no
  1. ; 1=yes (default)
  1. ;XMY local group members (Array - Pass by reference)
  1. ; XMY(member DUZ)=""
  1. ;XMDESC description (Array - Pass by reference)
  1. ; - used only for creation
  1. ; Must be appropriate for FM word processing field.
  1. ;XMQUIET silent flag
  1. ; 0=interactive
  1. ; 1=silent (default)
  1. N XMABORT,XMGIEN,XMGNAME
  1. S XMABORT=0
  1. D MGINIT(XMGROUP,.XMGIEN,.XMGNAME,.XMTYPE,.XMORG,.XMSELF,.XMY,.XMDESC,.XMQUIET,.XMABORT)
  1. I XMABORT K XMY Q 0
  1. I '$D(XMGIEN) D
  1. . D CREATE(XMGNAME,.XMGIEN,XMTYPE,XMORG,XMSELF,.XMDESC,XMQUIET,.XMABORT) Q:XMABORT
  1. . Q:'$O(XMY(""))
  1. . D ADD(XMGIEN,.XMY,.XMABORT) Q:XMABORT
  1. . D NOTIFY("Members have been added to the "_XMGNAME_" Mail Group.",XMQUIET)
  1. E D
  1. . D ADD(XMGIEN,.XMY,.XMABORT)
  1. K XMY
  1. Q $S(XMABORT:0,1:XMGIEN)
  1. MGINIT(XMGROUP,XMGIEN,XMGNAME,XMTYPE,XMORG,XMSELF,XMY,XMDESC,XMQUIET,XMABORT) ;
  1. D CHKGROUP(XMGROUP,.XMGIEN,.XMGNAME,.XMABORT) Q:XMABORT
  1. I $D(XMGIEN),'$O(XMY("")) D Q
  1. . D NOTIFY("E907 No members specified to add to Mail Group "_XMGNAME,XMQUIET)
  1. . S XMABORT=1
  1. D CHKVAL(.XMTYPE,"XMTYPE",2,0,.XMABORT) Q:XMABORT
  1. S:$G(XMORG)="" XMORG=DUZ
  1. S:XMORG<1 XMORG=.5
  1. I '$D(^VA(200,XMORG,0)) D Q
  1. . D NOTIFY("E904 "_XMORG_" is not a user to use as an organizer of a mail group.",XMQUIET)
  1. . S XMABORT=1
  1. D CHKVAL(.XMSELF,"XMSELF",4,1,.XMABORT) Q:XMABORT
  1. D CHKVAL(.XMQUIET,"XMQUIET",7,1,.XMABORT) Q:XMABORT
  1. S:$D(ZTQUEUED) XMQUIET=1
  1. Q
  1. CHKGROUP(XMGROUP,XMGIEN,XMGNAME,XMABORT) ;
  1. I +XMGROUP=XMGROUP D Q
  1. . S XMGIEN=XMGROUP
  1. . S XMGNAME=$P($G(^XMB(3.8,XMGIEN,0)),U,1)
  1. . I XMGNAME="" D
  1. . . D NOTIFY("E910 Mail Group "_XMGROUP_" could not be found !",XMQUIET)
  1. . . S XMABORT=1
  1. S XMGNAME=XMGROUP
  1. I $L(XMGNAME)<3 D Q
  1. . D NOTIFY("E901 "_XMGNAME_" is not valid -- it is shorter than 3 characters",XMQUIET)
  1. . S XMABORT=1
  1. I $L(XMGNAME)>30 D Q
  1. . D NOTIFY("E902 "_XMGNAME_" is not valid -- it is longer than 30 characters",XMQUIET)
  1. . S XMABORT=1
  1. I $D(^XMB(3.8,"B",XMGNAME)) S XMGIEN=$O(^(XMGNAME,0))
  1. Q
  1. CHKVAL(XMVAL,XMVNAME,XMPOSN,XMDEFALT,XMABORT) ;
  1. S:$G(XMVAL)="" XMVAL=XMDEFALT
  1. I XMVAL=0!(XMVAL=1) Q
  1. D NOTIFY("E903 Parameter "_XMPOSN_"="_XMVAL_" (not valid, must be 0 or 1).",XMQUIET)
  1. S XMABORT=1
  1. Q
  1. CREATE(XMGNAME,XMGIEN,XMTYPE,XMORG,XMSELF,XMDESC,XMQUIET,XMABORT) ;
  1. N DIC,Y,DA,DO,DD,X
  1. S X=XMGNAME
  1. S DIC="^XMB(3.8,",DIC(0)="FZMN"_$S(XMQUIET:"",1:"E")
  1. ;** XM*8.0*47 Modified the DIR("DR") array to use a four slash stuff for the organizer field to prevent Fileman from reading four digit DUZ's as last four of SSN **
  1. S DIC("DR")="4///"_$S(XMTYPE=0:"PU",1:"PR")_";5////"_XMORG_";10///0;7///"_$S(XMSELF:"y",1:"n")
  1. D FILE^DICN
  1. I Y<0 D Q
  1. . D NOTIFY("Mail Group ("_XMGNAME_") creation failed!",XMQUIET)
  1. . S XMABORT=1
  1. S XMGIEN=+Y
  1. ;Add descriptive text
  1. I $O(XMDESC(""))'="" D
  1. . D WP^DIE(3.8,XMGIEN_",",3,"","XMDESC")
  1. . K XMDESC
  1. D NOTIFY("Mail Group "_XMGROUP_" created.",XMQUIET)
  1. Q
  1. ADD(XMGIEN,XMY,XMABORT) ; Add local members
  1. L +^XMB(3.8,XMGIEN):9 E D Q
  1. . D NOTIFY("E906 "_XMGROUP_" File could not be locked - Did not add members.",XMQUIET)
  1. . S XMABORT=1
  1. N XMUSER,XMFDA,XMADDCNT
  1. S XMUSER="",XMADDCNT=0
  1. F S XMUSER=$O(XMY(XMUSER)) Q:XMUSER="" D
  1. . I '$D(^VA(200,XMUSER,0))!'$D(^XMB(3.7,XMUSER,0)) D Q
  1. . . D NOTIFY("E908 Invalid member ("_XMUSER_") - NOT pointer to ^VA(200",XMQUIET)
  1. . Q:$D(^XMB(3.8,XMGIEN,1,"B",XMUSER)) ; already a member
  1. . S XMFDA(3.81,"+1,"_XMGIEN_",",.01)=XMUSER
  1. . D UPDATE^DIE("","XMFDA")
  1. . S XMADDCNT=XMADDCNT+1
  1. L -^XMB(3.8,XMGIEN)
  1. K XMY
  1. S:'XMADDCNT XMABORT=1 ; No members added
  1. Q
  1. DM(XMGROUP,XMY,XMQUIET) ; Delete members
  1. ;XMGROUP Mail Group Name or entry number
  1. ;XMY Array of members to remove
  1. ; XMY(local member DUZ)=""
  1. ;XMQUIET Silent Flag
  1. N XMGIEN,XMUSER,DIK,DA,XMABORT
  1. S XMABORT=0
  1. D DMINIT(XMGROUP,.XMGIEN,.XMY,.XMQUIET,.XMABORT)
  1. I XMABORT K XMY Q 0
  1. L +^XMB(3.8,XMGIEN):9 E D Q 0
  1. . D NOTIFY("E906 "_XMGROUP_" File could not be locked - Did not delete members.",XMQUIET)
  1. . S XMABORT=1
  1. S DA(1)=XMGIEN,DIK="^XMB(3.8,"_XMGIEN_",1,"
  1. S XMUSER=""
  1. F S XMUSER=$O(XMY(XMUSER)) Q:XMUSER="" D
  1. . S DA=$O(^XMB(3.8,XMGIEN,1,"B",XMUSER,0)) Q:'DA
  1. . D ^DIK
  1. K XMY
  1. L -^XMB(3.8,XMGIEN)
  1. Q 1
  1. DMINIT(XMGROUP,XMGIEN,XMY,XMQUIET,XMABORT) ;
  1. N XMGNAME
  1. D CHKGROUP(XMGROUP,.XMGIEN,.XMGNAME,.XMABORT) Q:XMABORT
  1. I '$D(XMGIEN) D Q
  1. . D NOTIFY("E910 Mail Group "_XMGROUP_" could not be found !",XMQUIET)
  1. . S XMABORT=1
  1. D CHKVAL(.XMQUIET,"XMQUIET",3,1,.XMABORT) Q:XMABORT
  1. S:$D(ZTQUEUED) XMQUIET=1
  1. I '$O(XMY("")) D Q
  1. . D NOTIFY("E909 Member delete attempted with no members specified.",XMQUIET)
  1. . S XMABORT=1
  1. Q
  1. NOTIFY(XMMSG,XMQUIET) ; Notification
  1. N I,XMTEXT
  1. S XMTEXT(1)="There was a call to the Mail Group Applications Programmer"
  1. S XMTEXT(2)="Interface (API) that required notification to the user:"
  1. S XMTEXT(3)=""
  1. S XMTEXT(4)=XMMSG
  1. I XMQUIET D SENDMSG(.XMTEXT) Q
  1. F I=1:1:4 W !,XMTEXT(I)
  1. W !,$C(7)
  1. Q
  1. SENDMSG(XMTEXT) ;
  1. N XMY,XMDUZ,XMSUB
  1. S XMY(.5)="",XMY(DUZ)="",XMTEXT="XMTEXT("
  1. S XMDUZ=.5,XMSUB="MAIL GROUP API"
  1. D ^XMD
  1. Q