#301 修改了数据作者申请流程
This commit is contained in:
parent
61ba7b166f
commit
b85bb408d6
|
@ -10,6 +10,7 @@
|
||||||
@update 2012-3-1 15:06 李建轩
|
@update 2012-3-1 15:06 李建轩
|
||||||
@update 2012-3-9 17:01 李建轩
|
@update 2012-3-9 17:01 李建轩
|
||||||
@update 2012-3-12 16:16 李建轩
|
@update 2012-3-12 16:16 李建轩
|
||||||
|
@update 2012-3-14 18:01 李建轩
|
||||||
|
|
||||||
*/
|
*/
|
||||||
class AuthorController extends Zend_Controller_Action
|
class AuthorController extends Zend_Controller_Action
|
||||||
|
@ -377,6 +378,7 @@ class AuthorController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
}// search
|
}// search
|
||||||
|
|
||||||
|
//激活数据作者
|
||||||
if($ac == "active")
|
if($ac == "active")
|
||||||
{
|
{
|
||||||
$this->_helper->viewRenderer('accept-active');
|
$this->_helper->viewRenderer('accept-active');
|
||||||
|
@ -387,15 +389,15 @@ class AuthorController extends Zend_Controller_Action
|
||||||
$sql = "SELECT a.id,a.activation,a.ts_created,a.ts_activated,md.title,a.uuid,u.realname,u.email FROM mdauthor a
|
$sql = "SELECT a.id,a.activation,a.ts_created,a.ts_activated,md.title,a.uuid,u.realname,u.email FROM mdauthor a
|
||||||
LEFT JOIN metadata md ON a.uuid=md.uuid
|
LEFT JOIN metadata md ON a.uuid=md.uuid
|
||||||
LEFT JOIN users u ON a.userid=u.id
|
LEFT JOIN users u ON a.userid=u.id
|
||||||
WHERE a.activation=? and a.userid=?";
|
WHERE a.activation=?";
|
||||||
|
|
||||||
$sth = $this->db->prepare($sql);
|
$sth = $this->db->prepare($sql);
|
||||||
$sth->execute(array($vdcode,$u_id));
|
$sth->execute(array($vdcode));
|
||||||
$row = $sth->fetch();
|
$row = $sth->fetch();
|
||||||
|
|
||||||
if(empty($row['id']) || time() - strtotime($row['ts_created'])>3600* 72)
|
if(empty($row['id']))
|
||||||
{
|
{
|
||||||
$this->view->info='此激活码无效,或者已经过期,请重新申请<br /><a href="/author/accept">点击这里</a>进入我的数据页面查看';
|
$this->view->info='此激活码无效';
|
||||||
}else{
|
}else{
|
||||||
if(empty($row['ts_activated']))
|
if(empty($row['ts_activated']))
|
||||||
{
|
{
|
||||||
|
@ -409,7 +411,7 @@ class AuthorController extends Zend_Controller_Action
|
||||||
include_once("EmailText.php");
|
include_once("EmailText.php");
|
||||||
$mail=new WestdcMailer($this->view->config->smtp);
|
$mail=new WestdcMailer($this->view->config->smtp);
|
||||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||||
$mailtp=new EmailText($this->db,"md-author-newmember",array(
|
$mailtp=new EmailText($this->db,"author-newmember",array(
|
||||||
'user' => $row['realname'],
|
'user' => $row['realname'],
|
||||||
'uuid' => $row['uuid'],
|
'uuid' => $row['uuid'],
|
||||||
'title'=> $row['title'],
|
'title'=> $row['title'],
|
||||||
|
@ -420,18 +422,13 @@ class AuthorController extends Zend_Controller_Action
|
||||||
if($this->debug==0)
|
if($this->debug==0)
|
||||||
{
|
{
|
||||||
//获得元数据作者email
|
//获得元数据作者email
|
||||||
$sql="select p.email,md.title from role r
|
|
||||||
left join responsible p on r.resid=p.id
|
|
||||||
left join metadata md on md.uuid=r.uuid
|
|
||||||
where r.uuid=? order by r.role,r.id";
|
|
||||||
$sth = $this->db->prepare($sql);
|
|
||||||
$sth->execute(array($uuid));
|
|
||||||
$rows = $sth->fetchAll();
|
|
||||||
|
|
||||||
$address = array();
|
$info = $this->getEmail($uuid,1);
|
||||||
foreach($rows as $v)
|
|
||||||
|
$address = $info['addrs'];
|
||||||
|
foreach($address as $v)
|
||||||
{
|
{
|
||||||
$mail->addTo($v['email']);
|
$mail->addTo($v);
|
||||||
}
|
}
|
||||||
$mail->addTo($row['email']);
|
$mail->addTo($row['email']);
|
||||||
$mail->addCc($this->view->config->service->email); //管理员
|
$mail->addCc($this->view->config->service->email); //管理员
|
||||||
|
@ -446,7 +443,7 @@ class AuthorController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
$this->view->info='此激活码已经失效,请重新申请<br /><a href="/author/accept">点击这里</a>进入我的数据页面查看';
|
$this->view->info='此激活码已经失效';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -460,11 +457,206 @@ class AuthorController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}//激活数据作者
|
||||||
|
|
||||||
|
//否认激活
|
||||||
|
if($ac == "lock")
|
||||||
|
{
|
||||||
|
$this->_helper->viewRenderer('accept-active');
|
||||||
|
$vdcode = $this->_request->getParam('v');
|
||||||
|
$this->view->v = $vdcode;
|
||||||
|
|
||||||
|
try{
|
||||||
|
$sql = "SELECT a.id,a.activation,a.ts_created,a.ts_activated,md.title,a.uuid,u.realname,u.email FROM mdauthor a
|
||||||
|
LEFT JOIN metadata md ON a.uuid=md.uuid
|
||||||
|
LEFT JOIN users u ON a.userid=u.id
|
||||||
|
WHERE a.activation=?";
|
||||||
|
|
||||||
|
$sth = $this->db->prepare($sql);
|
||||||
|
$sth->execute(array($vdcode));
|
||||||
|
$row = $sth->fetch();
|
||||||
|
|
||||||
|
if(empty($row['id']))
|
||||||
|
{
|
||||||
|
$this->view->info='此激活码无效';
|
||||||
|
}else{
|
||||||
|
if(empty($row['ts_activated']))
|
||||||
|
{
|
||||||
|
$sql = "UPDATE mdauthor SET ts_activated=?,status=? WHERE activation=?";
|
||||||
|
|
||||||
|
$sth = $this->db->prepare($sql);
|
||||||
|
$ex = $sth->execute(array('now()',-1,$vdcode));
|
||||||
|
|
||||||
|
if($ex)
|
||||||
|
{
|
||||||
|
include_once("EmailText.php");
|
||||||
|
$mail=new WestdcMailer($this->view->config->smtp);
|
||||||
|
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||||
|
$mailtp=new EmailText($this->db,"author-deny",array(
|
||||||
|
'user' => $row['realname'],
|
||||||
|
'uuid' => $row['uuid'],
|
||||||
|
'title'=> $row['title'],
|
||||||
|
'email'=> $row['email'],
|
||||||
|
));
|
||||||
|
/*
|
||||||
|
mail=>元数据有新作者加入
|
||||||
|
id=>author-newmember
|
||||||
|
body=>
|
||||||
|
您好:
|
||||||
|
您申请成为数据《{title}》遭到数据拥有者的否认,如果有疑问请联系数据中心
|
||||||
|
中国西部环境与生态科学数据中心
|
||||||
|
*/
|
||||||
|
$mail->setBodyText($mailtp->getBody());
|
||||||
|
$mail->setSubject($mailtp->getSubject());
|
||||||
|
if($this->debug==0)
|
||||||
|
{
|
||||||
|
$mail->addTo($row['email']);
|
||||||
|
}else{
|
||||||
|
$mail->addTo($this->debug_email);
|
||||||
|
}
|
||||||
|
$mail->send();
|
||||||
|
$this->view->info = '该申请已被拒绝,<a href="/author/accept">点击这里</a>进入我的数据页面查看';
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
$this->view->info = "激活中遇到问题,请重试";
|
||||||
|
}
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
$this->view->info='此激活码已经失效';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch(Exception $e){
|
||||||
|
if($this->debug==0)
|
||||||
|
{
|
||||||
|
$this->view->info = "处理中遇到错误,请重新尝试";
|
||||||
|
}else{
|
||||||
|
$this->view->info = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}//否认激活
|
||||||
|
|
||||||
}//acceptAction() 我的数据
|
}//acceptAction() 我的数据
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* getEmail() 获取数据所有者电子邮箱地址
|
||||||
|
*
|
||||||
|
* param string $uuid //UUID
|
||||||
|
* param int $level //输出信息等级
|
||||||
|
* 0 => 输出所有Email地址
|
||||||
|
* 1 => 输出数据权限等级最高的Email地址 (def)
|
||||||
|
*
|
||||||
|
* return array()
|
||||||
|
*/
|
||||||
|
function getEmail($uuid,$level=1)
|
||||||
|
{
|
||||||
|
//需要定义角色,防止程序流程出错
|
||||||
|
$addrs = array();
|
||||||
|
$addrs['resourceProvider'] = array();
|
||||||
|
$addrs['owner'] = array();
|
||||||
|
$addrs['pointOfContact'] = array();
|
||||||
|
$addrs['author'] = array();
|
||||||
|
$addrs["publisher"] = array();
|
||||||
|
|
||||||
|
$sql = 'select r.uuid,p.email,md.title,r.role from metadata md
|
||||||
|
LEFT JOIN role r ON md.uuid=r.uuid
|
||||||
|
left join responsible p on r.resid=p.id
|
||||||
|
WHERE r.uuid=? AND p.email IS NOT NULL AND p.email!=?
|
||||||
|
GROUP BY r.uuid,p.email,md.title,r.role';
|
||||||
|
$sth = $this->db->prepare($sql);
|
||||||
|
$sth->execute(array($uuid,''));
|
||||||
|
$rows = $sth->fetchAll();
|
||||||
|
|
||||||
|
$addrs['title'] = $rows[0]['title'];
|
||||||
|
|
||||||
|
foreach($rows as $k=>$v)
|
||||||
|
{
|
||||||
|
//数据资源提供者resourceProvider
|
||||||
|
if($v['role']=='resourceProvider')
|
||||||
|
{
|
||||||
|
$addrs['resourceProvider'][]=$v['email'];
|
||||||
|
}
|
||||||
|
|
||||||
|
//数据资源所有者owner
|
||||||
|
if($v['role']=='owner')
|
||||||
|
{
|
||||||
|
$addrs['owner'][]=$v['email'];
|
||||||
|
}
|
||||||
|
|
||||||
|
//数据联系人pointOfContact
|
||||||
|
if($v['role']=='pointOfContact')
|
||||||
|
{
|
||||||
|
$addrs['pointOfContact'][]=$v['email'];
|
||||||
|
}
|
||||||
|
|
||||||
|
//元数据作者author
|
||||||
|
if($v['role']== 'author' )
|
||||||
|
{
|
||||||
|
$addrs['author'][] = $v['email'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if($v["role"] =="")
|
||||||
|
{
|
||||||
|
$addrs["publisher"][] = $v['email'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//输出所哟email (多维数组)
|
||||||
|
/*
|
||||||
|
$addrs['resourceProvider']
|
||||||
|
$addrs['owner']
|
||||||
|
$addrs['pointOfContact']
|
||||||
|
$addrs['author']
|
||||||
|
*/
|
||||||
|
if($level == 0)
|
||||||
|
{
|
||||||
|
return $addrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//输出最高优先级的Email
|
||||||
|
//$addrs['addrs']
|
||||||
|
if($level == 1)
|
||||||
|
{
|
||||||
|
//如果有 数据资源提供者 resourceProvider 就输出他的地址 以此类推
|
||||||
|
if(count($addrs['resourceProvider'])>0)
|
||||||
|
{
|
||||||
|
$addrs['addrs'][] = $addrs['resourceProvider'];
|
||||||
|
return $addrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count($addrs['owner'])>0)
|
||||||
|
{
|
||||||
|
$addrs['addrs'][] = $addrs['owner'];
|
||||||
|
return $addrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count($addrs['pointOfContact'])>0)
|
||||||
|
{
|
||||||
|
$addrs['addrs'][] = $addrs['pointOfContact'];
|
||||||
|
return $addrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count($addrs['author'])>0)
|
||||||
|
{
|
||||||
|
$addrs['addrs'][] = $addrs['author'];
|
||||||
|
return $addrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count($addrs["publisher"])>0)
|
||||||
|
{
|
||||||
|
$addrs['addrs'][] = $addrs["publisher"];
|
||||||
|
return $addrs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}//getEmail 获取数据作者email地址
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* applyAction() 申请成为元数据作者
|
* applyAction() 申请成为元数据作者
|
||||||
|
@ -618,12 +810,20 @@ class AuthorController extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
$data = array("error"=>"您目前已经是该数据作者,不需要再申请");
|
$data = array("error"=>"您目前已经是该数据作者,不需要再申请");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//如果已经遭到明确拒绝,则不允许用户再次申请
|
||||||
|
if(!empty($row['id']) && $row['status']==-1)
|
||||||
|
{
|
||||||
|
$data = array("error"=>"您的申请已经遭到拒绝,不能再申请,有疑问请联系数据中心");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//如果已经存在申请,但是没有激活的,返回激活信息
|
//如果已经存在申请,但是没有激活的,返回激活信息
|
||||||
if($row['status']==0){
|
if($row['status']==0){
|
||||||
if(!empty($row['id']) && empty($m))
|
if(!empty($row['id']) && empty($m))
|
||||||
{
|
{
|
||||||
$data = array(
|
$data = array(
|
||||||
"error"=>'您已经申请过了,请在<我的数据>中进行激活操作',
|
"error"=>'您已经申请过了,如果长时间没有收到回应请联系数据中心',
|
||||||
"post"=>"activa",
|
"post"=>"activa",
|
||||||
"uid"=>$u_id,
|
"uid"=>$u_id,
|
||||||
"uemail"=>$u_email,
|
"uemail"=>$u_email,
|
||||||
|
@ -633,22 +833,11 @@ class AuthorController extends Zend_Controller_Action
|
||||||
|
|
||||||
else{
|
else{
|
||||||
|
|
||||||
//获得元数据作者email
|
$info = $this->getEmail($uuid,1);
|
||||||
$sql="select p.email,md.title from role r
|
|
||||||
left join responsible p on r.resid=p.id
|
|
||||||
left join metadata md on md.uuid=r.uuid
|
|
||||||
where r.uuid=? order by r.role,r.id";
|
|
||||||
$sth = $this->db->prepare($sql);
|
|
||||||
$sth->execute(array($uuid));
|
|
||||||
$rows = $sth->fetchAll();
|
|
||||||
|
|
||||||
$address = array();
|
$address = $info['addrs'];
|
||||||
foreach($rows as $v)
|
|
||||||
{
|
|
||||||
$address[] = $v['email'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$mdtitle = $rows[0]['title'];
|
$mdtitle = $info['title'];
|
||||||
|
|
||||||
//如果当前用户的email包含在元数据作者email列表中,则直接使其成为元数据作者
|
//如果当前用户的email包含在元数据作者email列表中,则直接使其成为元数据作者
|
||||||
if(in_array($u_email,$address))
|
if(in_array($u_email,$address))
|
||||||
|
@ -672,7 +861,7 @@ class AuthorController extends Zend_Controller_Action
|
||||||
$mail->setSubject($mailtp->getSubject());
|
$mail->setSubject($mailtp->getSubject());
|
||||||
/*
|
/*
|
||||||
mail=>元数据有新作者加入
|
mail=>元数据有新作者加入
|
||||||
id=>md-author-newmember
|
id=>author-newmember
|
||||||
body=>
|
body=>
|
||||||
您好:
|
您好:
|
||||||
{user} ({email}) 已经申请成为元数据《{title}》的作者,如果有疑问请联系该作者或者数据中心服务组
|
{user} ({email}) 已经申请成为元数据《{title}》的作者,如果有疑问请联系该作者或者数据中心服务组
|
||||||
|
@ -696,6 +885,7 @@ body=>
|
||||||
}
|
}
|
||||||
|
|
||||||
//如果不包含在当前元数据作者的email列表中
|
//如果不包含在当前元数据作者的email列表中
|
||||||
|
//给数据拥有者发送邮件,使其决定是否同意新加入作者
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//生成激活码
|
//生成激活码
|
||||||
|
@ -718,23 +908,30 @@ body=>
|
||||||
if($ex)
|
if($ex)
|
||||||
{
|
{
|
||||||
|
|
||||||
//给新申请的用户发送邮件
|
//给拥有者发送邮件
|
||||||
include_once("EmailText.php");
|
include_once("EmailText.php");
|
||||||
@$mail=new WestdcMailer($this->view->config->smtp);
|
@$mail=new WestdcMailer($this->view->config->smtp);
|
||||||
@$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
@$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||||
@$mailtp=new EmailText($this->db,"author-apply",array(
|
@$mailtp=new EmailText($this->db,"author-apply",array(
|
||||||
'user' => $user->username,
|
'user' => $user->username,
|
||||||
'uuid' => $uuid,
|
'uuid' => $uuid,
|
||||||
|
//元数据标题
|
||||||
'title'=> $mdtitle,
|
'title'=> $mdtitle,
|
||||||
'vdcode' => $vdcode,
|
|
||||||
'link'=>"http://".$_SERVER['SERVER_NAME']."/author/accept/?ac=active&v=$vdcode",
|
|
||||||
));
|
));
|
||||||
@$mail->setBodyText($mailtp->getBody());
|
@$mail->setBodyText($mailtp->getBody());
|
||||||
@$mail->setSubject($mailtp->getSubject());
|
/*
|
||||||
|
mail=>申请成为数据作者
|
||||||
|
id=>author-apply
|
||||||
|
body=>
|
||||||
|
您好:
|
||||||
|
您申请成为元数据《{title}》的作者,目前已经提交申请,请等待专家审核
|
||||||
|
|
||||||
|
中国西部环境与生态科学数据中心
|
||||||
|
*/
|
||||||
|
@$mail->setSubject($mailtp->getSubject());
|
||||||
if($this->debug==0)
|
if($this->debug==0)
|
||||||
{
|
{
|
||||||
@$mail->addTo($u_email);
|
@$mail->addTo($user->email);
|
||||||
}else{
|
}else{
|
||||||
@$mail->addTo($this->debug_email);
|
@$mail->addTo($this->debug_email);
|
||||||
}
|
}
|
||||||
|
@ -752,15 +949,30 @@ body=>
|
||||||
'email'=> $u_email,
|
'email'=> $u_email,
|
||||||
'title'=> $mdtitle,
|
'title'=> $mdtitle,
|
||||||
'link'=>"http://".$_SERVER['SERVER_NAME']."/data/$uuid",
|
'link'=>"http://".$_SERVER['SERVER_NAME']."/data/$uuid",
|
||||||
|
|
||||||
|
//验证码
|
||||||
|
'vdcode' => $vdcode,
|
||||||
|
|
||||||
|
//激活链接
|
||||||
|
'active'=>"http://".$_SERVER['SERVER_NAME']."/author/accept/?ac=active&v=$vdcode",
|
||||||
|
|
||||||
|
//不同意激活的链接
|
||||||
|
'lock'=>"http://".$_SERVER['SERVER_NAME']."/author/accept/?ac=lock&v=$vdcode",
|
||||||
));
|
));
|
||||||
@$mail->setBodyText($mailtp->getBody());
|
@$mail->setBodyText($mailtp->getBody());
|
||||||
@$mail->setSubject($mailtp->getSubject());
|
@$mail->setSubject($mailtp->getSubject());
|
||||||
/*
|
/*
|
||||||
mail=>元数据作者激活
|
mail=>元数据作者激活
|
||||||
id=>md-author-apply-confirm
|
id=>author-apply-confirm
|
||||||
body=>
|
body=>
|
||||||
您好:
|
您好:
|
||||||
元数据《{title}》有新用户 {user} (Email:{email})申请成为作者,如果有疑问请联系该用户或者数据中心服务组.
|
元数据《{title}》有新用户 {user} (Email:{email})申请成为作者。
|
||||||
|
如果同意该申请,请点击这条链接
|
||||||
|
{active}
|
||||||
|
|
||||||
|
如果不同意该申请,请点击这条链接
|
||||||
|
{lock}
|
||||||
|
|
||||||
元数据访问地址:{link}
|
元数据访问地址:{link}
|
||||||
中国西部环境与生态科学数据中心
|
中国西部环境与生态科学数据中心
|
||||||
*/
|
*/
|
||||||
|
@ -768,13 +980,15 @@ body=>
|
||||||
{
|
{
|
||||||
foreach ($address as $dist)
|
foreach ($address as $dist)
|
||||||
{$mail->addTo($dist);} //元数据作者
|
{$mail->addTo($dist);} //元数据作者
|
||||||
$mail->addCc($this->view->config->service->email); //管理员
|
//$mail->addCc($this->view->config->service->email); //管理员
|
||||||
}else{
|
}else{
|
||||||
@$mail->addTo($this->debug_email);
|
@$mail->addTo($this->debug_email);
|
||||||
}
|
}
|
||||||
|
|
||||||
@$mail->send();
|
@$mail->send();
|
||||||
|
|
||||||
$data = array("error"=>"我们给您的邮箱中发送了激活链接,请按邮件提示进行激活操作。");
|
$data = array("error"=>"您的申请已收到,请耐心等待回应");
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
$data = array("error"=>"服务器可能在忙,请重试。");
|
$data = array("error"=>"服务器可能在忙,请重试。");
|
||||||
}//激活码记录
|
}//激活码记录
|
||||||
|
@ -817,9 +1031,11 @@ body=>
|
||||||
/*
|
/*
|
||||||
* authoredAction() 数据反馈
|
* authoredAction() 数据反馈
|
||||||
*
|
*
|
||||||
|
* param string $ac 动作
|
||||||
* param string $uuid 元数据UUID
|
* param string $uuid 元数据UUID
|
||||||
* param int $page 页数
|
* param int $page 页数
|
||||||
*
|
*
|
||||||
|
* return view
|
||||||
*/
|
*/
|
||||||
function authoredAction()
|
function authoredAction()
|
||||||
{
|
{
|
||||||
|
@ -830,7 +1046,6 @@ body=>
|
||||||
{
|
{
|
||||||
$user = $auth->getIdentity();
|
$user = $auth->getIdentity();
|
||||||
$u_id = $user->id;
|
$u_id = $user->id;
|
||||||
$u_email = $user->email;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($ac)|| $ac=='list')
|
if(empty($ac)|| $ac=='list')
|
||||||
|
@ -905,5 +1120,67 @@ body=>
|
||||||
}// authoredAction() 数据反馈
|
}// authoredAction() 数据反馈
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* newsAction() 数据新闻
|
||||||
|
*
|
||||||
|
* param string $ac
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function newsAction(){
|
||||||
|
|
||||||
|
$ac = $this->_request->getParam('ac');
|
||||||
|
|
||||||
|
$auth = Zend_Auth::getInstance();
|
||||||
|
if($auth->hasIdentity())
|
||||||
|
{
|
||||||
|
$user = $auth->getIdentity();
|
||||||
|
$u_id = $user->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
//新闻发布
|
||||||
|
if($ac == "add")
|
||||||
|
{
|
||||||
|
$this->_helper->viewRenderer('news-add');
|
||||||
|
}// $ac == add
|
||||||
|
|
||||||
|
//新闻发布的ajax动作
|
||||||
|
if($ac =="addnews")
|
||||||
|
{
|
||||||
|
$this->_helper->layout->disableLayout();
|
||||||
|
$this->_helper->viewRenderer->setNoRender();
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
|
||||||
|
$data['title'] = $this->_request->getParam('title');
|
||||||
|
$data['keyword'] = $this->_request->getParam('keyword');
|
||||||
|
$data['body'] = $this->_request->getParam('body');
|
||||||
|
|
||||||
|
foreach($data as $k=>$v)
|
||||||
|
{
|
||||||
|
$data[$k]=preg_replace("#<a([^>]*)>(.*)</a>#i","",$v);
|
||||||
|
$data[$k]=preg_replace("#<script([^>]*)>(.*)</script>#i","",$v);
|
||||||
|
$data[$k]=preg_replace("#<iframe([^>]*)>(.*)</iframe>#i","",$v);
|
||||||
|
}
|
||||||
|
|
||||||
|
$msg = array();
|
||||||
|
|
||||||
|
if(mb_strlen($data['title'],"utf-8")<=6)
|
||||||
|
{
|
||||||
|
$msg['status'] == 0;
|
||||||
|
$msg['error'] == '标题太短,请重新填写';
|
||||||
|
$this ->getResponse()
|
||||||
|
->setHeader('Content-Type', 'application/json')
|
||||||
|
->appendBody(Zend_Json::encode($msg));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}//newsAction() 数据新闻
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue