[论坛BUG修复]增强论坛后台消息发送功能,增加发送消息给全部用户功能 已处理

lianjin 6月前 36

修改 plugin/huux_notice/view/admin_notice_create.htm 页面代码为修改
<?php include _include(ADMIN_PATH.'view/htm/header.inc.htm');?>

<div class="row">
    <div class="col-lg-12">
        <div class="btn-group mb-3" role="group">
            <?php echo admin_tab_active($menu['notice']['tab'], 'post');?>
        </div>
        <div class="card">
            <div class="card-body">
                <form action="<?php echo url('notice-create'); ?>" method="post" id="form">
                    <div class="form-group row">
                        <label class="col-sm-2 form-control-label"><?php echo lang('notice_admin_send_notice_message')?>
                            :</label>
                        <div class="col-sm-10">
                            <?php echo $input['message']; ?>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-2 form-control-label"><?php echo lang('notice_admin_send_notice_uid')?>
                            :</label>
                        <div class="col-sm-10">
                            <?php echo $input['recvuid']; ?>
                            <input type="hidden" name="sendtype" id="sendtype" value="one">
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="inputPassword3" class="col-sm-2 form-control-label"></label>
                        <div class="col-sm-5">
                            <button type="submit" class="btn btn-primary btn-block" id="submit"
                                    data-loading-text="<?php echo lang('submiting');?>...">指定用户
                            </button>
                        </div>
                        <div class="col-sm-5">
                            <button type="button" class="btn btn-primary btn-block" id="submitAll"
                                    data-loading-text="<?php echo lang('submiting');?>...">发送给所有用户
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<?php include _include(ADMIN_PATH.'view/htm/footer.inc.htm');?>

<script>
    var jform = $('#form');
    var jsubmit = $('#submit');
    var jsubmitAll = $('#submitAll');
    jsubmitAll.on('click', function () {
        $("#sendtype").val('All');
        jform.reset();
        jsubmit.button('loading');
        jsubmitAll.button('loading');
        var postdata = jform.serialize();
        $.xpost(jform.attr('action'), postdata, function (code, message) {
            if (code == 0) {
                $.alert(message);
                jsubmitAll.text(message).delay(1000).button('reset').location('<?php echo url("notice-list"); ?>');
            } else if (code < 0) {
                $.alert(message);
                jsubmit.button('reset');
                jsubmitAll.button('reset');
            } else {
                jform.find('[name="' + code + '"]').alert(message).focus();
                jsubmit.button('reset');
                jsubmitAll.button('reset');
            }
        });
    });
    jform.on('submit', function () {
        $("#sendtype").val('One');
        jform.reset();
        jsubmit.button('loading');
        jsubmitAll.button('loading');
        var postdata = jform.serialize();
        $.xpost(jform.attr('action'), postdata, function (code, message) {
            if (code == 0) {
                $.alert(message);
                jsubmit.text(message).delay(1000).button('reset').location('<?php echo url("notice-list"); ?>');
            } else if (code < 0) {
                $.alert(message);
                jsubmit.button('reset');
                jsubmitAll.button('reset');
            } else {
                jform.find('[name="' + code + '"]').alert(message).focus();
                jsubmit.button('reset');
                jsubmitAll.button('reset');
            }
        });
        return false;
    });

    $('#nav li.nav-item-notice').addClass('active');

</script>
修改 plugin/huux_notice/route/notice.php 页面代码为
<?php

!defined('DEBUG') AND exit('Access Denied.');

// 管理后台-所有消息 发送通知
$action = param(1);

if ($action == 'create') {

    if ($method == 'GET') {

        $input = array();
        $input['recvuid'] = form_text('recvuid', '');
        $input['message'] = form_textarea('message', '', '100%', 100);

        $header['title'] = lang('notice_admin_send_notice');
        $header['mobile_title'] = lang('notice_admin_send_notice');

        include _include(APP_PATH . "plugin/huux_notice/view/htm/admin_notice_create.htm");

    } else {

        $message = param('message', '', FALSE);
        $recvuid = param('recvuid', 0);
        $sendtype = param('sendtype', 'One');

        // 检查内容和接收人是否为空
        empty($message) AND message('message', lang('notice_admin_send_notice_message_empty'));
        empty($recvuid) AND message('recvuid', lang('notice_admin_send_notice_recvuid_empty'));
        if ($sendtype == 'One') {
            // 检查接收人是否存在
            $recvuid_check = user__read($recvuid);
            $recvuid_check === FALSE AND message('recvuid', lang('notice_admin_send_notice_user_empty'));
            $nid = notice_send($uid, $recvuid, $message, 3); // 3:系统通知
            $nid === FALSE AND message(-1, lang('notice_admin_send_notice_failed'));
        } else {
            $userlist = user_find();
            foreach ($userlist as &$_user) {
                $nid = notice_send($uid, $_user['uid'], $message, 3); // 3:系统通知
            }
        }

        message(0, lang('notice_admin_send_notice_sucessfully'));
    }

} elseif ($action == 'delete') {

    // 单条删除
    $nid = param('nid');
    $r = notice_delete($nid);
    $r === FALSE AND message(-1, lang('notice_delete_notice_failed'));
    message(0, lang('notice_delete_notice_sucessfully'));

} elseif ($action == 'list') {

    $page = param(2, 1);
    $pagesize = 20;
    $active = 'default';
    $notices = notice_count(); //直接获取最新的
    $cond = array();
    $orderby = 'nid';

    $notice_menu = include _include(APP_PATH . 'plugin/huux_notice/conf/notice_menu.conf.php');
    $noticelist = notice_find($cond, $page, $pagesize);
    $pagination = pagination(url("notice-list-{page}"), $notices, $page, $pagesize);

    $header['title'] = lang('notice_admin_notice_list');
    $header['mobile_title'] = lang('notice_admin_notice_list');

    include _include(APP_PATH . "plugin/huux_notice/view/htm/admin_notice_list.htm");

} elseif ($action == 'read') {
    //ajax返回message 暂时不需要
}

?>
最后于 6月前 被lianjin编辑 ,原因:
最新回复 (0)
    • Deep♂Dark♂Fantastic
      2
        立即登录 立即注册 
返回