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

2024-06-05 12:39 更新

问题描述:

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

修复方法:

文件:\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');
					}
				}
			}
		}


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号