DzzOffice 新闻插件修复当编辑文章后会出现不按发布范围来通知成员

问题描述:

当对已发布的文章进行二次编辑后再进行发布时会出现不按发布范围来通知成员,例如通知全体成员。

修复方法:

文件:\dzz\news\class\table\table_news.php

原代码:

if($return=parent::update($arr['newid'],$arr)){
    if($data['attachs']){
         $attachs=explode(',',$data['attachs']);
         C::t('attachment')->addcopy_by_aid($attachs,-1);
    }
    if(isset($arr['attachs'])){
         $attachs=explode(',',$arr['attachs']);
         C::t('attachment')->addcopy_by_aid($attachs,1);
    }
    //新添加的范围重新发送通知
    $orgids=$uids=array();
    if($arr['orgids']!=$data['orgids']){
        $norgids=$arr['orgids']?explode(',',$arr['orgids']):array();
        $oorgids=$data['orgids']?explode(',',$data['orgids']):array();
        $orgids=array_diff($norgids,$oorigids);
    }
    if($arr['uids']!=$data['uids']){
        $nuids=$arr['uids']?explode(',',$arr['uids']):array();
        $ouids=$data['uids']?explode(',',$data['uids']):array();
        $uids=array_diff($nuids,$ouids);
    }
    $new_uids=getUidsByOrgid($orgids,$uids);
    $appid=C::t('app_market')->fetch_appid_by_mod('{dzzscript}?mod=news',0);
    foreach($new_uids as $uid){
        if($uid!=getglobal('uid')){
            //发送通知
            $notevars=array(
                            'from_id'=>$appid,
                            'from_idtype'=>'app',
                            'url'=>DZZSCRIPT.'?mod=news&op=view&newid='.$data['newid'],
                            'author'=>getglobal('username'),
                            'authorid'=>getglobal('uid'),
                            'subject'=>$data['subject'],
                            'dataline'=>dgmdate(TIMESTAMP),
                            );
            
                $action='news_publish';
                $type='news_publish_'.$uid;
            
            dzz_notification::notification_add($uid, $type, $action, $notevars, 0,'dzz/news');
        }
    }
    
}

修改后的代码:

if($return=parent::update($arr['newid'],$arr)){
    if($data['attachs']){
         $attachs=explode(',',$data['attachs']);
         C::t('attachment')->addcopy_by_aid($attachs,-1);
    }
    if(isset($arr['attachs'])){
         $attachs=explode(',',$arr['attachs']);
         C::t('attachment')->addcopy_by_aid($attachs,1);
    }
    //新添加的范围重新发送通知
    $orgids=$uids=array();
    if($arr['orgids']!=$data['orgids']){
        $norgids=$arr['orgids']?explode(',',$arr['orgids']):array();
        $oorigids=$data['orgids']?explode(',',$data['orgids']):array();
        $orgids=implode(',', array_diff($norgids,$oorigids));
    }
    if($arr['uids']!=$data['uids']){
        $nuids=$arr['uids']?explode(',',$arr['uids']):array();
        $ouids=$data['uids']?explode(',',$data['uids']):array();
        $uids=implode(',', array_diff($nuids,$ouids));
    }
    if(!$orgids && $arr['orgids'] || !$uids && $arr['uids']){
    }else{
        $new_uids=getUidsByOrgid($orgids,$uids);
        $appid=C::t('app_market')->fetch_appid_by_mod('{dzzscript}?mod=news',0);
        foreach($new_uids as $uid){
            if($uid!=getglobal('uid')){
                //发送通知
                $notevars=array(
                                'from_id'=>$appid,
                                'from_idtype'=>'app',
                                'url'=>DZZSCRIPT.'?mod=news&op=view&newid='.$data['newid'],
                                'author'=>getglobal('username'),
                                'authorid'=>getglobal('uid'),
                                'subject'=>$arr['subject'],
                                'dataline'=>dgmdate(TIMESTAMP),
                                );
                
                    $action='news_publish';
                    $type='news_publish_'.$uid;
                
                dzz_notification::notification_add($uid, $type, $action, $notevars, 0,'dzz/news');
            }
        }
    }
}

  • 6
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小胡2024

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值