예제 #1
0
        /// <summary>
        /// 发送email通知
        /// </summary>
        /// <returns></returns>
        public string SendEmail()
        {
            if (Signature != GetParam("sig").ToString())
            {
                ErrorCode = (int)ErrorType.API_EC_SIGNATURE;
                return("");
            }

            //如果是桌面程序则需要验证用户身份
            if (this.App.ApplicationType == (int)ApplicationType.DESKTOP)
            {
                if (Uid < 1)
                {
                    ErrorCode = (int)ErrorType.API_EC_SESSIONKEY;
                    return("");
                }
                if (Discuz.Forum.UserGroups.GetUserGroupInfo(Discuz.Forum.Users.GetShortUserInfo(Uid).Groupid).Radminid != 1)
                {
                    ErrorCode = (int)ErrorType.API_EC_PERMISSION_DENIED;
                    return("");
                }
            }

            if (CallId <= LastCallId)
            {
                ErrorCode = (int)ErrorType.API_EC_CALLID;
                return("");
            }

            //	 recipients subject
            if (!CheckRequiredParams("recipients,subject,text"))
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return("");
            }

            if (!Utils.IsNumericArray(GetParam("recipients").ToString().Split(',')))
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return("");
            }

            //需要过滤部分html标签,待开发
            //得到了 用逗号分隔的ids 和 subject,先通过ids得到所有人的用户名
            string uids = Discuz.Forum.Emails.SendMailToUsers(GetParam("recipients").ToString(), GetParam("subject").ToString(), GetParam("text").ToString());

            if (Format == FormatType.JSON)
            {
                return(string.Format("\"{0}\"", uids));
            }


            NotificationSendEmailResponse nser = new NotificationSendEmailResponse();

            nser.Recipients = uids;
            return(SerializationHelper.Serialize(nser));
        }
예제 #2
0
        public override bool Run(CommandParameter commandParam, ref string result)
        {
            //如果是桌面程序则需要验证用户身份
            if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP)
            {
                if (commandParam.LocalUid < 1)
                {
                    result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList);
                    return(false);
                }
                //如果当前用户不是管理员
                if (Discuz.Forum.UserGroups.GetUserGroupInfo(Discuz.Forum.Users.GetShortUserInfo(commandParam.LocalUid).Groupid).Radminid != 1)
                {
                    result = Util.CreateErrorMessage(ErrorType.API_EC_PERMISSION_DENIED, commandParam.ParamList);
                    return(false);
                }
            }

            //	 recipients subject
            if (!commandParam.CheckRequiredParams("recipients,subject,text"))
            {
                result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList);
                return(false);
            }

            string recipients = commandParam.GetDNTParam("recipients").ToString();

            if (!Utils.IsNumericList(recipients))
            {
                result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList);
                return(false);
            }

            //需要过滤部分html标签,待开发
            //得到了 用逗号分隔的ids 和 subject,先通过ids得到所有人的用户名
            string uids = Discuz.Forum.Emails.SendMailToUsers(recipients, commandParam.GetDNTParam("subject").ToString(), commandParam.GetDNTParam("text").ToString());

            if (commandParam.Format == FormatType.JSON)
            {
                result = string.Format("\"{0}\"", uids);
            }
            else
            {
                NotificationSendEmailResponse nser = new NotificationSendEmailResponse();
                nser.Recipients = uids;
                result          = SerializationHelper.Serialize(nser);
            }
            return(true);
        }
예제 #3
0
        /// <summary>
        /// 发送email通知
        /// </summary>
        /// <returns></returns>
        public string SendEmail()
        {
            if (Signature != GetParam("sig").ToString())
            {
                ErrorCode = (int)ErrorType.API_EC_SIGNATURE;
                return "";
            }

            //如果是桌面程序则需要验证用户身份
            if (this.App.ApplicationType == (int)ApplicationType.DESKTOP)
            {
                if (Uid < 1)
                {
                    ErrorCode = (int)ErrorType.API_EC_SESSIONKEY;
                    return "";
                }
                if (Discuz.Forum.UserGroups.GetUserGroupInfo(Discuz.Forum.Users.GetShortUserInfo(Uid).Groupid).Radminid != 1)
                {
                    ErrorCode = (int)ErrorType.API_EC_PERMISSION_DENIED;
                    return "";
                }
            }

            if (CallId <= LastCallId)
            {
                ErrorCode = (int)ErrorType.API_EC_CALLID;
                return "";
            }

            //	 recipients subject 
            if (!CheckRequiredParams("recipients,subject,text"))
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return "";
            }

            if (!Utils.IsNumericArray(GetParam("recipients").ToString().Split(',')))
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return "";
            }

            //需要过滤部分html标签,待开发
            //得到了 用逗号分隔的ids 和 subject,先通过ids得到所有人的用户名
            string uids = Discuz.Forum.Emails.SendMailToUsers(GetParam("recipients").ToString(), GetParam("subject").ToString(), GetParam("text").ToString());

            if (Format == FormatType.JSON)
                return string.Format("\"{0}\"", uids);


            NotificationSendEmailResponse nser = new NotificationSendEmailResponse();
            nser.Recipients = uids;
            return SerializationHelper.Serialize(nser);
        }
예제 #4
0
        public override bool Run(CommandParameter commandParam, ref string result)
        {
            //如果是桌面程序则需要验证用户身份
            if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP)
            {
                if (commandParam.LocalUid < 1)
                {
                    result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList);
                    return false;
                }
                //如果当前用户不是管理员
                if (Discuz.Forum.UserGroups.GetUserGroupInfo(Discuz.Forum.Users.GetShortUserInfo(commandParam.LocalUid).Groupid).Radminid != 1)
                {
                    result = Util.CreateErrorMessage(ErrorType.API_EC_PERMISSION_DENIED, commandParam.ParamList);
                    return false;
                }
            }

            //	 recipients subject 
            if (!commandParam.CheckRequiredParams("recipients,subject,text"))
            {
                result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList);
                return false;
            }

            string recipients = commandParam.GetDNTParam("recipients").ToString();

            if (!Utils.IsNumericList(recipients))
            {
                result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList);
                return false;
            }

            //需要过滤部分html标签,待开发
            //得到了 用逗号分隔的ids 和 subject,先通过ids得到所有人的用户名
            string uids = Discuz.Forum.Emails.SendMailToUsers(recipients, commandParam.GetDNTParam("subject").ToString(), commandParam.GetDNTParam("text").ToString());

            if (commandParam.Format == FormatType.JSON)
                result = string.Format("\"{0}\"", uids);
            else
            {
                NotificationSendEmailResponse nser = new NotificationSendEmailResponse();
                nser.Recipients = uids;
                result = SerializationHelper.Serialize(nser);
            }
            return true;
        }