修改数据审核流程,支持用户自主审核,并分割用户审核邮件为三类,且每个邮件仅发送给一个用户。
This commit is contained in:
parent
0995216c3a
commit
67a2d1e70c
|
@ -44,40 +44,242 @@ class Admin_DownController extends Zend_Controller_Action
|
||||||
$this->db->query($sql,array($start));
|
$this->db->query($sql,array($start));
|
||||||
$sql="select * from offlineapp where id=?";
|
$sql="select * from offlineapp where id=?";
|
||||||
$row=$this->db->fetchRow($sql,array($start));
|
$row=$this->db->fetchRow($sql,array($start));
|
||||||
|
$username=$row['username'];
|
||||||
//发送用户邮件进行信息提示和说明
|
//发送用户邮件进行信息提示和说明
|
||||||
$mail = new WestdcMailer($this->view->config->smtp);
|
$mail = new WestdcMailer($this->view->config->smtp);
|
||||||
$datalist=str_replace(";","\n",$row['datalist']);
|
$datalist=str_replace(";","\n",$row['datalist']);
|
||||||
$mailtp=new EmailText($this->db,'offline-start',array('user'=>$row['username'],'datalist'=>$datalist));
|
$mailtp=new EmailText($this->db,'offline-start',array('user'=>$username,'datalist'=>$datalist));
|
||||||
$mail->setBodyText($mailtp->getBody());
|
$mail->setBodyText($mailtp->getBody());
|
||||||
$mail->setSubject($mailtp->getSubject());
|
$mail->setSubject($mailtp->getSubject());
|
||||||
$mail->addTo($row['email']);
|
$mail->addTo($row['email']);
|
||||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||||
$mail->send();
|
$mail->send();
|
||||||
|
|
||||||
unset($mail);
|
|
||||||
$mail = new WestdcMailer($this->view->config->smtp);
|
|
||||||
$mailtp=new EmailText($this->db,'offline-start-admin',array('user'=>$row['username'],'datalist'=>$datalist));
|
|
||||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
|
||||||
$sql="select distinct(res.email) from dataorder d left join role on d.uuid=role.uuid left join responsible res on role.resid=res.id where length(res.email)>4 and d.offlineappid=? and role.role in ('pointOfContact','resourceProvider')";
|
|
||||||
$rows=$this->db->fetchAll($this->db->quoteInto($sql,$start));
|
|
||||||
$addrs=array();
|
|
||||||
foreach($rows as $row)
|
|
||||||
{
|
|
||||||
$addrs[]=$row['email'];
|
|
||||||
}
|
|
||||||
//收件人邮箱
|
|
||||||
$addrs[] = 'nztong@lzb.ac.cn';
|
|
||||||
$addrs[] = 'wjian@lzb.ac.cn';
|
|
||||||
$addrs[] = 'lixin@lzb.ac.cn';
|
|
||||||
$mail->setBodyText($mailtp->getBody());
|
|
||||||
$mail->setSubject($mailtp->getSubject());
|
|
||||||
$mail->addTo($addrs);
|
|
||||||
$mail->addCc($this->view->config->service->email,'西部数据中心服务组');
|
|
||||||
$sql="select pdflink from offlineapp where id=?";
|
$sql="select pdflink from offlineapp where id=?";
|
||||||
$row=$this->db->fetchRow($sql,array($start));
|
$row=$this->db->fetchRow($sql,array($start));
|
||||||
$filecontent=file_get_contents($this->view->config->offline->savepath."/".$row['pdflink']);
|
$filecontent=file_get_contents($this->view->config->offline->savepath."/".$row['pdflink']);
|
||||||
$mail->createAttachment($filecontent,'application/octet-stream',Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'offlineapp.pdf');
|
|
||||||
$mail->send();
|
//对每条数据的管理员用户发送相应的邮件通知,同一用户的邮件需要合并
|
||||||
|
//需要取出对应数据的标题、uuid,以及对应的作者的email(一条数据可能有多个作者,一次申请可能有多条数据对应同一个作者)
|
||||||
|
//邮件中应提示用户可以选择是否委托给数据中心进行管理(这样以后就不接受相应的管理邮件,但用户仍然可以自主取消此选择)
|
||||||
|
|
||||||
|
// 1. 处理有数据作者且自行管理的数据
|
||||||
|
$sql="select u.email,m.title,d.uuid,a.activation from dataorder d left join mdstatus s on d.uuid=s.uuid left join users u on s.userid=u.id
|
||||||
|
left join metadata m on m.uuid=d.uuid left join mdauthor a on a.uuid=d.uuid where d.offlineappid=? and s.status=6 and a.userid=s.userid
|
||||||
|
order by u.email,m.title";
|
||||||
|
$rows=$this->db->fetchAll($this->db->quoteInto($sql,$start));
|
||||||
|
$tmp_email='';
|
||||||
|
$data='';
|
||||||
|
foreach($rows as $row)
|
||||||
|
{
|
||||||
|
if ($tmp_email!=$row['email'])
|
||||||
|
{
|
||||||
|
if (!empty($data))
|
||||||
|
{
|
||||||
|
//发送之前的用户申请审核邮件
|
||||||
|
unset($mail);
|
||||||
|
$mail = new WestdcMailer($this->view->config->smtp);
|
||||||
|
$mailtp=new EmailText($this->db,'offline-start-author',array('user'=>$username,'datalist'=>$data));
|
||||||
|
$mail->setBodyText($mailtp->getBody());
|
||||||
|
$mail->setSubject($mailtp->getSubject());
|
||||||
|
$mail->addTo($tmp_email);
|
||||||
|
$mail->addCc($this->view->config->service->email,'西部数据中心服务组');
|
||||||
|
$mail->createAttachment($filecontent,'application/octet-stream',Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'offlineapp.pdf');
|
||||||
|
$mail->send();
|
||||||
|
$data="";
|
||||||
|
}
|
||||||
|
$tmp_email=$row['email'];
|
||||||
|
}
|
||||||
|
$data.=" 数据名称:".$row['title']."\n";
|
||||||
|
$data.=" \t数据地址:http://westdc.westgis.ac.cn/data/".$row['uuid']."\n";
|
||||||
|
$data.=" \t如您不想收到此类数据申请审核的邮件,您可以将该数据委托给数据中心代为审核,委托后您也可以随时撤销此委托以便继续自行管理。\n";
|
||||||
|
$data.=" \t如想委托给数据中心,请访问此网址:http://westdc.westgis.ac.cn/author/delegate/uuid/".$row['uuid']."\n";
|
||||||
|
$data.=" \t撤销委托方法:进入数据中心->数据作者->我的数据,在该数据条上撤销委托。\n\n";
|
||||||
|
}
|
||||||
|
//发送最后一封邮件
|
||||||
|
if (!empty($data))
|
||||||
|
{
|
||||||
|
unset($mail);
|
||||||
|
$mail = new WestdcMailer($this->view->config->smtp);
|
||||||
|
$mailtp=new EmailText($this->db,'offline-start-author',array('user'=>$username,'datalist'=>$data));
|
||||||
|
$mail->setBodyText($mailtp->getBody());
|
||||||
|
$mail->setSubject($mailtp->getSubject());
|
||||||
|
$mail->addTo($tmp_email);
|
||||||
|
$mail->addCc($this->view->config->service->email,'西部数据中心服务组');
|
||||||
|
$mail->createAttachment($filecontent,'application/octet-stream',Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'offlineapp.pdf');
|
||||||
|
$mail->send();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 处理委托数据中心进行管理的数据
|
||||||
|
$sql="select m.title,d.uuid from dataorder d left join mdstatus s on d.uuid=s.uuid left join metadata m on m.uuid=d.uuid
|
||||||
|
where d.offlineappid=? and s.status=7 order by u.email,m.title";
|
||||||
|
$rows=$this->db->fetchAll($this->db->quoteInto($sql,$start));
|
||||||
|
$data="";
|
||||||
|
foreach($rows as $row)
|
||||||
|
{
|
||||||
|
$data.=" 数据名称:".$row['title']."\n";
|
||||||
|
$data.=" \t数据地址:http://westdc.westgis.ac.cn/data/".$row['uuid']."\n\n";
|
||||||
|
}
|
||||||
|
if (!empty($data))
|
||||||
|
{
|
||||||
|
unset($mail);
|
||||||
|
$mail = new WestdcMailer($this->view->config->smtp);
|
||||||
|
$mailtp=new EmailText($this->db,'offline-start-dcadmin',array('user'=>$username,'datalist'=>$data));
|
||||||
|
$mail->setBodyText($mailtp->getBody());
|
||||||
|
$mail->setSubject($mailtp->getSubject());
|
||||||
|
$addrs=array();
|
||||||
|
$addrs[] = 'nztong@lzb.ac.cn';
|
||||||
|
$addrs[] = 'wjian@lzb.ac.cn';
|
||||||
|
$addrs[] = 'lixin@lzb.ac.cn';
|
||||||
|
$mail->addTo($addrs);
|
||||||
|
$mail->addCc($this->view->config->service->email,'西部数据中心服务组');
|
||||||
|
$mail->createAttachment($filecontent,'application/octet-stream',Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'offlineapp.pdf');
|
||||||
|
$mail->send();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 未认证的数据,即无明确的数据管理者,从元数据提取对应管理者的email信息进行管理
|
||||||
|
//无数据作者的数据,根据元数据中的联系人信息发送相应的管理邮件,发送策略是多发还是少发?
|
||||||
|
//发送管理邮件同时建议用户认证为数据的作者,可以有更多的管理选择,同时邮件中应该有详细的说明为什么会收到此邮件
|
||||||
|
$sql="select res.email,d.uuid,m.title,role.role from dataorder d left join role on d.uuid=role.uuid left join responsible res on role.resid=res.id
|
||||||
|
left join metadata m on d.uuid=m.uuid where length(res.email)>4 and d.offlineappid=?
|
||||||
|
and role.role in ('pointOfContact','custodian','resourceProvider','owner','distributor','publisher','author')
|
||||||
|
order by m.title,res.email";
|
||||||
|
$rows=$this->db->fetchAll($this->db->quoteInto($sql,$start));
|
||||||
|
unset($addrs);
|
||||||
|
$md=array();
|
||||||
|
$tmp_title='';
|
||||||
|
$role=array();
|
||||||
|
$role['pointOfContact']=array();
|
||||||
|
$role['custodian']=array();
|
||||||
|
$role['resourceProvider']=array();
|
||||||
|
$role['owner']=array();
|
||||||
|
$role['distributor']=array();
|
||||||
|
$role['publisher']=array();
|
||||||
|
$role['author']=array();
|
||||||
|
$single=array();
|
||||||
|
foreach($rows as $row)
|
||||||
|
{
|
||||||
|
if ($tmp_title!=$row['title'])
|
||||||
|
{
|
||||||
|
if (count($role))
|
||||||
|
{
|
||||||
|
$single['role']=$role;
|
||||||
|
$md[]=$single;
|
||||||
|
}
|
||||||
|
|
||||||
|
$single['title']=$row['title'];
|
||||||
|
$single['uuid']=$row['uuid'];
|
||||||
|
|
||||||
|
$tmp_title=$row['title'];
|
||||||
|
$role=array();
|
||||||
|
$role['pointOfContact']=array();
|
||||||
|
$role['custodian']=array();
|
||||||
|
$role['resourceProvider']=array();
|
||||||
|
$role['owner']=array();
|
||||||
|
$role['distributor']=array();
|
||||||
|
$role['publisher']=array();
|
||||||
|
$role['author']=array();
|
||||||
|
}
|
||||||
|
if ($row['role']=='resourceProvider')
|
||||||
|
{
|
||||||
|
$role['resourceProvider'][]=$row['email'];
|
||||||
|
} elseif ($row['role']=='custodian') {
|
||||||
|
$role['custodian'][]=$row['email'];
|
||||||
|
} elseif ($row['role']=='pointOfContact') {
|
||||||
|
$role['pointOfContact'][]=$row['email'];
|
||||||
|
} elseif ($row['role']=='owner') {
|
||||||
|
$role['owner'][]=$row['email'];
|
||||||
|
} elseif ($row['role']=='distributor') {
|
||||||
|
$role['distributor'][]=$row['email'];
|
||||||
|
} elseif ($row['role']=='publisher') {
|
||||||
|
$role['publisher'][]=$row['email'];
|
||||||
|
} elseif ($row['role']=='author') {
|
||||||
|
$role['author'][]=$row['email'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($role))
|
||||||
|
{
|
||||||
|
$single['role']=$role;
|
||||||
|
$md[]=$single;
|
||||||
|
}
|
||||||
|
//再循环一次,提取最高权限email组,并发送管理邮件
|
||||||
|
$newmd=array();
|
||||||
|
$single=array();
|
||||||
|
foreach($md as $row)
|
||||||
|
{
|
||||||
|
if (count($row['role']))
|
||||||
|
{
|
||||||
|
$addrs=array();
|
||||||
|
if (count($row['role']['pointOfContact']))
|
||||||
|
{
|
||||||
|
$addrs=$row['role']['pointOfContact'];
|
||||||
|
} elseif (count($row['role']['custodian'])) {
|
||||||
|
$addrs=$row['role']['custodian'];
|
||||||
|
} elseif (count($row['role']['resourceProvider'])) {
|
||||||
|
$addrs=$row['role']['resourceProvider'];
|
||||||
|
} elseif (count($row['role']['owner'])) {
|
||||||
|
$addrs=$row['role']['owner'];
|
||||||
|
} elseif (count($row['role']['distributor'])) {
|
||||||
|
$addrs=$row['role']['distributor'];
|
||||||
|
} elseif (count($row['role']['publisher'])) {
|
||||||
|
$addrs=$row['role']['publisher'];
|
||||||
|
} elseif (count($row['role']['author'])) {
|
||||||
|
$addrs=$row['role']['author'];
|
||||||
|
}
|
||||||
|
$single['uuid']=$row['uuid'];
|
||||||
|
$single['title']=$row['title'];
|
||||||
|
foreach($addrs as $email)
|
||||||
|
{
|
||||||
|
$single['email']=$email;
|
||||||
|
//$newmd[]=$single;
|
||||||
|
$newmd['uuid'][]=$row['uuid'];
|
||||||
|
$newmd['title'][]=$row['title'];
|
||||||
|
$newmd['email'][]=$email;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//按照email排序
|
||||||
|
array_multisort($newmd['email'],$newmd['uuid'],$newmd['title']);
|
||||||
|
$tmp_email='';
|
||||||
|
$data='';
|
||||||
|
foreach($newmd['email'] as $k=>$row)
|
||||||
|
{
|
||||||
|
if ($tmp_email!=$row)
|
||||||
|
{
|
||||||
|
if (!empty($data))
|
||||||
|
{
|
||||||
|
unset($mail);
|
||||||
|
$mail = new WestdcMailer($this->view->config->smtp);
|
||||||
|
$mailtp=new EmailText($this->db,'offline-start-mdadmin',array('user'=>$username,'datalist'=>$data));
|
||||||
|
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||||
|
$mail->setBodyText($mailtp->getBody());
|
||||||
|
$mail->setSubject($mailtp->getSubject());
|
||||||
|
$mail->addTo($tmp_email);
|
||||||
|
$mail->addCc($this->view->config->service->email,'西部数据中心服务组');
|
||||||
|
$mail->createAttachment($filecontent,'application/octet-stream',Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'offlineapp.pdf');
|
||||||
|
$mail->send();
|
||||||
|
$data='';
|
||||||
|
}
|
||||||
|
$tmp_email=$row;
|
||||||
|
}
|
||||||
|
$data.=" 数据名称:".$row['title']."\n";
|
||||||
|
$data.=" \t数据地址:http://westdc.westgis.ac.cn/data/".$row['uuid']."\n";
|
||||||
|
$data.=" \t如您不想收到此类数据申请审核的邮件,您可以在按如下操作办法进行处理:1. 申请成为该数据作者;2. 将该数据委托给数据中心代为审核,委托后您也可以随时撤销此委托以便继续自行管理。\n";
|
||||||
|
$data.=" \t如要申请成为该数据作者:进入数据中心->数据作者->数据认证,查找到对应的数据后,在其下方点击申请认证即可。\n\n";
|
||||||
|
}
|
||||||
|
if (!empty($data))
|
||||||
|
{
|
||||||
|
unset($mail);
|
||||||
|
$mail = new WestdcMailer($this->view->config->smtp);
|
||||||
|
$mailtp=new EmailText($this->db,'offline-start-mdadmin',array('user'=>$username,'datalist'=>$data));
|
||||||
|
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||||
|
$mail->setBodyText($mailtp->getBody());
|
||||||
|
$mail->setSubject($mailtp->getSubject());
|
||||||
|
$mail->addTo($tmp_email);
|
||||||
|
$mail->addCc($this->view->config->service->email,'西部数据中心服务组');
|
||||||
|
$mail->createAttachment($filecontent,'application/octet-stream',Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'offlineapp.pdf');
|
||||||
|
$mail->send();
|
||||||
|
}
|
||||||
|
|
||||||
//提示信息
|
//提示信息
|
||||||
$this->messenger->addMessage('提示信息:该离线数据已经开始处理,并发送邮件给申请人以及数据管理委员会,请在处理完成后点击“完成”。');
|
$this->messenger->addMessage('提示信息:该离线数据已经开始处理,并发送邮件给申请人以及数据管理委员会,请在处理完成后点击“完成”。');
|
||||||
|
|
Loading…
Reference in New Issue