From cbbac4833300bc2713cca4752a73e4f5d527e541 Mon Sep 17 00:00:00 2001 From: Li Jianxuan Date: Wed, 24 Apr 2013 13:39:23 +0000 Subject: [PATCH] add doi action to authorcontroller --- .../admin/views/scripts/data/doi-add.phtml | 2 +- .../default/controllers/AuthorController.php | 109 ++ .../default/views/scripts/author/accept.phtml | 3 +- .../views/scripts/author/doi-add.phtml | 133 +++ .../default/views/scripts/author/doi.phtml | 80 ++ .../default/views/scripts/author/navi.phtml | 3 +- .../default/views/scripts/data/view.phtml | 1002 ++++++++--------- application/models/data/Author.php | 44 + application/models/data/Doi.php | 50 +- 9 files changed, 914 insertions(+), 512 deletions(-) create mode 100644 application/default/views/scripts/author/doi-add.phtml create mode 100644 application/default/views/scripts/author/doi.phtml create mode 100644 application/models/data/Author.php diff --git a/application/admin/views/scripts/data/doi-add.phtml b/application/admin/views/scripts/data/doi-add.phtml index 8161c9b1..f49326d9 100644 --- a/application/admin/views/scripts/data/doi-add.phtml +++ b/application/admin/views/scripts/data/doi-add.phtml @@ -33,7 +33,7 @@ $this->theme->AppendPlus($this,'colorbox');
- " /> + " />
diff --git a/application/default/controllers/AuthorController.php b/application/default/controllers/AuthorController.php index 8c4804b8..c2f69c08 100644 --- a/application/default/controllers/AuthorController.php +++ b/application/default/controllers/AuthorController.php @@ -3954,6 +3954,115 @@ class AuthorController extends Zend_Controller_Action }//mdfunddel }//fund + + public function doiAction() + { + //$this->_helper->layout->setLayout('administry'); + $ac = $this->_getParam('ac'); + $submit = $this->_getParam('submit'); + $uuid = $this->_getParam('uuid'); + + include_once("data/Doi.php"); + $doi = new Doi($this->db); + include_once("helper/view.php"); + + if( empty($ac) || $ac == "index") + { + $uid = view::User('id'); + if(empty($uuid)) + { + $rows = $doi->fetch($uid); + view::addPaginator($rows,$this->view,$this->_request); + }else{ + $this->_redirect('/author/doi/ac/edit/?uuid='.$uuid); + return true; + } + return true; + }//index + + if($ac == "edit") + { + $this->_helper->viewRenderer('doi-add'); + $id = $this->_getParam('id'); + if(empty($uuid) && empty($id)) + { + view::Msg('alert-error',"参数错误",-1); + return false; + } + + if(empty($submit)){ + if(!empty($uuid)) + { + $this->view->uuid = $uuid; + $this->view->data = $doi->view($uuid); + if(empty($this->view->data)) + { + include('data/Metadata.php'); + $md = new Metadata($this->db); + $metadata = $md->view($uuid); + $this->view->data = array( + 'uuid'=>$uuid, + 'title'=>$metadata['title'], + 'doi'=>$metadata['doi'], + 'url'=>"http://" . $_SERVER['HTTP_HOST'].'/data/'.$uuid, + 'publisher'=>view::User('realname'), + ); + }else{ + $this->view->data['info'] = $doi->data_process_out($this->view->data); + } + }else{ + $this->view->data = $doi->view($uuid); + $this->view->data['info'] = $doi->data_process_out($this->view->data); + } + }else{ + $data = $doi->_getParams($this->_request); + $this->view->data = $data; + $info = $doi->checkinfo($data['info']); + if(!is_array($info)){ + $this->view->error = view::Error('alert-error',$info,-1); + return true; + }else{ + $data['info'] = $info; + $data['info'] = $doi->sksort($data['info'],"order",SORT_DESC); + } + $uid = view::User('id'); + $state = $doi->update($data,$uuid,$uid); + if($state) + { + $this->view->msg = view::Msg('alert-success',"修改成功!",'/author/doi/uuid/'.$uuid); + return false; + }else{ + $this->view->error = view::Error('alert-error',"修改失败",-1); + return false; + } + } + }//edit + + if($ac == "del") + { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + $id = $this->_getParam('id'); + + if(empty($id)) + { + $this->jsonexit(array('error'=>'参数错误')); + return true; + } + + if($doi->delete($id) == true) + { + $this->jsonexit(array('success'=>$id)); + return true; + }else{ + $this->jsonexit(array('error'=>'删除失败')); + return true; + } + + }//del + + }//doi /* * jsonexit() 退出并返回json数据 diff --git a/application/default/views/scripts/author/accept.phtml b/application/default/views/scripts/author/accept.phtml index 488c7692..c8428907 100644 --- a/application/default/views/scripts/author/accept.phtml +++ b/application/default/views/scripts/author/accept.phtml @@ -48,7 +48,8 @@ $this->breadcrumb()->setSeparator(' > '); | 取消委托 | 邮件通知 | - 支持项目 + 支持项目 | + DOI diff --git a/application/default/views/scripts/author/doi-add.phtml b/application/default/views/scripts/author/doi-add.phtml new file mode 100644 index 00000000..6879c802 --- /dev/null +++ b/application/default/views/scripts/author/doi-add.phtml @@ -0,0 +1,133 @@ +headTitle($this->config->title->site); +$this->headTitle($this->config->title->author); +$this->headTitle()->setSeparator(' - '); +//$this->headLink()->appendStylesheet('/css/admin.css'); +$this->breadcrumb('首页'); +$this->breadcrumb('数据管理'); +$this->breadcrumb('DOI'); +$this->breadcrumb()->setSeparator(' > '); +$this->theme->AppendPlus($this,'colorbox'); +$this->headLink()->appendStylesheet('/css/author.css'); +?> +
+
+ partial('author/navi.phtml'); ?> +
+
+
+ +
+
+ error)) { ?> + error ?> + + msg)) { ?> + msg ?> + +
+
+ +
+ " /> +
+
+
+ +
+ " /> +
+
+
+ +
+ " /> +
+
+
+ +
+ " /> +
+
+
+ +
+ " /> +
+
+ data['info']) || !is_array($this->data['info'])) {?> +
+ +
+ + + +
+
+ + data['info'] as $k=>$v){ + $index ++; + ?> +
+ +
+ + + + 0){ ?> + -删除 + +
+
+ + +
+ +
+
+
+ + id)) { ?> + + + uuid)) { ?> + + + +
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/application/default/views/scripts/author/doi.phtml b/application/default/views/scripts/author/doi.phtml new file mode 100644 index 00000000..daad58d8 --- /dev/null +++ b/application/default/views/scripts/author/doi.phtml @@ -0,0 +1,80 @@ +headTitle($this->config->title->site); +$this->headTitle($this->config->title->author); +$this->headTitle()->setSeparator(' - '); +$this->breadcrumb('首页'); +$this->breadcrumb('数据管理'); +$this->headLink()->appendStylesheet('/css/author.css'); +$this->breadcrumb('DOI'); +$this->breadcrumb()->setSeparator(' > '); +$this->theme->AppendPlus($this,'colorbox'); +$this->theme->AppendPlus($this,'admin_plugin'); +?> + +
+
+ partial('author/navi.phtml'); ?> +
+
+
+ +
+
+
+
+ + +
+
+
+ error)) { ?> + error ?> + + msg)) { ?> + msg ?> + +
+ paginator)): ?> + + + + + + + + + + + paginator as $item): + $autoindex++;?> + + + + + + + + +
UUID元数据DOI操作
+ 编辑 + 删除 +
+ + +
+ +
+
+ + diff --git a/application/default/views/scripts/author/navi.phtml b/application/default/views/scripts/author/navi.phtml index 8e2e6cd4..97828358 100644 --- a/application/default/views/scripts/author/navi.phtml +++ b/application/default/views/scripts/author/navi.phtml @@ -10,7 +10,8 @@ - + + diff --git a/application/default/views/scripts/data/view.phtml b/application/default/views/scripts/data/view.phtml index 9779c1d0..13e5095d 100755 --- a/application/default/views/scripts/data/view.phtml +++ b/application/default/views/scripts/data/view.phtml @@ -1,501 +1,501 @@ -headTitle($this->config->title->site); - $this->headTitle($this->config->title->data); - $this->headTitle($this->metadata->title); - $this->headTitle()->setSeparator(' - '); - $this->breadcrumb('首页'); - $this->breadcrumb(''.$this->config->title->data.''); - $this->breadcrumb('查看元数据'); - $this->breadcrumb()->setSeparator(' > '); - $this->theme->AppendPlus($this,'google_map_v3'); - $this->theme->AppendPlus($this,'colorbox'); -?> - -metadata;if ($md):?> -

escape($md->title); -if ($md->title_en) echo '
'.$this->escape($md->title_en);?> -

-
-
-
-
- -

-

',$md->description);?> -

-
-
- citation) : ?> -
-

本数据引用方式数据引用帮助

-

escape($md->citation);?>

- - ref) : ?> -
-

建议参考文献

-
    - ref as $ref) : - if (empty($ref->link)) - echo '
  1. '.$ref->reference.'
  2. '; - else - echo '
  3. '.$ref->reference.' 下载
  4. '; - endforeach; - ?> -
- - userref) : ?> -
-

数据用户发表文献

-
    - userref as $ref) : - if (empty($ref->link)) - echo '
  1. '.$ref->reference.'
  2. '; - else - echo '
  3. '.$ref->reference.' 下载
  4. '; - endforeach; - ?> -
- -
-

数据使用声明

- uselimits) : - foreach($this->uselimits as $uselimit) : - echo '

'.str_replace(array("\r\n", "\n", "\r"),'

',$this->escape($uselimit->uselimit)).'

'; - endforeach; - ?> - -

为尊重知识产权、保障数据作者的权益、扩展数据中心的服务、评估数据的应用潜力,请数据使用者在使用数据所产生的研究成果中(包括公开发表的论文、论著、数据产品和未公开发表的研究报告、数据产品等成果),明确注明数据来源和数据作者。对于转载(二次或多次发布)的数据,作者还须注明原始数据来源。

-

中文发表的成果参考以下规范注明: 数据来源于国家自然科学基金委员会"中国西部环境与生态科学数据中心"(http://westdc.westgis.ac.cn)

-

英文发表的成果依据以下规范注明: The data set is provided by Environmental and Ecological Science Data Center for West China,National Natural Science Foundation of China (http://westdc.westgis.ac.cn)

-

- - data_archives){ ?> -

数据相关新闻

-
    - data_archives as $v){?> -
  • - -
-
- - suppinfo || $this->fund) : ?> -

资助项目

- fund)) : ?> -
    - fund as $k=>$v) : ?> -
  • (项目编号:) [(No. )]
  • - -
- suppinfo)) : ?> - '.str_replace(array("\r\n", "\n", "\r"),'

',$this->escape($md->suppinfo)).'

';?> - -
- - resources) : ?> -

相关资源

- -
- -
-
- keys as $cg){ - if($cg['keytype']=="theme") - $keywords[]=$cg['keyword']; - } - $ev = join(" ",$keywords); - ?> -
- -
- - -
-
    -
    -
    - downhistory) : ?> -

    最近10条服务记录如下:

    -
      - downhistory as $v){ - echo '
    1. '.date("Y-m-d",strtotime($v->ts_created))." ".$v->unit." ".$v->realname; - if (!empty($v->offlineproject)) - echo ' 用途:'.$v->offlineproject; - elseif (!empty($v->onlineproject)) - echo ' 用途:'.$v->onlineproject; - echo '
    2. '; - } - ?> -
    - - 暂时没有服务记录,欢迎您下载使用! - -
    -
    - -
    -
    -
    -
    -
    - status>0 and $md->status<5) : ?> -

    此数据还在评审过程中,我们真切地邀请您参加此数据的评审,以便我们能尽快发布此数据!评审

    - -

    数据评论

    -
    -
    评论加载中
    -
    - hasIdentity()) - { - $user = $auth->getIdentity(); - $name = $user->realname; - $email = $user->email; - }else - { - $name = ""; - $email = ""; - } - ?> -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - e.g. http://westdc.westgis.ac.cn/ -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    -
    - - - 提交 -
    -
    -
    -
    - -
    -
    -
    -
    - - '学科','place'=>'地点','theme'=>'主题','temporal'=>'时间词','stratum'=>'地层'); -$kt=''; -$i=0; -foreach($this->keys as $cg) : - if ($kt==$cg['keytype']) : - $i+=1; - else : - if (!empty($kt)) echo ''; - $kt=$cg['keytype']; - $i=0; - endif; - if ($i==0) { - ?> - - doi) : ?> -
    • 数据DOI:doi; ?>
    - -
    -
    -

    数据细节文件列表

    -
      - fileformat) : ?> -
    • 格式:fileformat; ?>
    • - -
    • 大小:filesize; ?>MB
    • - downloaded>9) :?> -
    • 下载:downloaded; ?>次
    • - -
    • 浏览:viewed; ?>次
    • - - timebegin)) : ?> -
    • 数据时间范围:timebegin));if (!empty($md->timeend)) echo " 至 ".date('Y-m-d',strtotime($md->timeend)); ?>
    • - - doc)) : ?> - - - attachments) : ?> -
    • 相关文档: - attachments as $k=>$a) : ?> - - - -
    • - -
    • 数据共享方式:datatype) print "离线"; else print "在线(可直接下载)";?>
    • -
    -
    - status>0 and $md->status<5) : ?> - 数据评审 - datatype) : ?> - - 在线下载 - - - - 离线申请 - - -
    -
    -
    -

    空间位置

    -
    -
    -

    联系信息

    -
    -
      - '资源提供者','custodian'=>'维护者','owner'=>'拥有者','user'=>'用户','distributor'=>'数据服务联系人','originator'=>'创建者','pointOfContact'=>'联系人','principalInvestigator'=>'数据调查与处理者','processor'=>'处理者','publisher'=>'元数据发布者','author'=>'元数据作者'); - $r=''; - $i=0; - foreach($this->authors as $k=>$author) : - if ($author->role!=$r) - { - $r=$author->role; - $i=0; - if ($k>0) echo ''; - echo '
    • '.$party_zh[$author->role].':'; - } - if ($i>0) echo ','; - $i+=1; - if (!empty($author->email) && $r!='principalInvestigator') - echo ''; - echo ''; - if (!empty($author->individual)) - echo $author->individual; - else - echo $author->organisation; - echo ''; - if (!empty($author->email)) echo ''; - if ($k+1==count($this->authors)) echo '
    • '; - endforeach; - ?> -
    -
    -
      -
    • 元数据更新时间:ts_created)); ?>
    • -
    • 下载元数据: - Adobe PDF格式 - OpenOffice odt格式 - Word doc格式 - 查看XML源文件 -
    • - - version->c>0):?> -
    • 版本历史:version->c ?> 个
    • - -
    -
    - -
    -
    -
    分享到
    - -
    - - - - - - - - - -
    - -
    -
    -
    - - - -

    Cannot find the metadata.

    -

    没有找到对应的元数据。

    - - - +headTitle($this->config->title->site); + $this->headTitle($this->config->title->data); + $this->headTitle($this->metadata->title); + $this->headTitle()->setSeparator(' - '); + $this->breadcrumb('首页'); + $this->breadcrumb(''.$this->config->title->data.''); + $this->breadcrumb('查看元数据'); + $this->breadcrumb()->setSeparator(' > '); + $this->theme->AppendPlus($this,'google_map_v3'); + $this->theme->AppendPlus($this,'colorbox'); +?> + +metadata;if ($md):?> +

    escape($md->title); +if ($md->title_en) echo '
    '.$this->escape($md->title_en);?> +

    +
    +
    +
    +
    + +

    +

    ',$md->description);?> +

    +
    +
    + citation) : ?> +
    +

    本数据引用方式数据引用帮助

    +

    escape($md->citation);?>

    + + ref) : ?> +
    +

    建议参考文献

    +
      + ref as $ref) : + if (empty($ref->link)) + echo '
    1. '.$ref->reference.'
    2. '; + else + echo '
    3. '.$ref->reference.' 下载
    4. '; + endforeach; + ?> +
    + + userref) : ?> +
    +

    数据用户发表文献

    +
      + userref as $ref) : + if (empty($ref->link)) + echo '
    1. '.$ref->reference.'
    2. '; + else + echo '
    3. '.$ref->reference.' 下载
    4. '; + endforeach; + ?> +
    + +
    +

    数据使用声明

    + uselimits) : + foreach($this->uselimits as $uselimit) : + echo '

    '.str_replace(array("\r\n", "\n", "\r"),'

    ',$this->escape($uselimit->uselimit)).'

    '; + endforeach; + ?> + +

    为尊重知识产权、保障数据作者的权益、扩展数据中心的服务、评估数据的应用潜力,请数据使用者在使用数据所产生的研究成果中(包括公开发表的论文、论著、数据产品和未公开发表的研究报告、数据产品等成果),明确注明数据来源和数据作者。对于转载(二次或多次发布)的数据,作者还须注明原始数据来源。

    +

    中文发表的成果参考以下规范注明: 数据来源于国家自然科学基金委员会"中国西部环境与生态科学数据中心"(http://westdc.westgis.ac.cn)

    +

    英文发表的成果依据以下规范注明: The data set is provided by Environmental and Ecological Science Data Center for West China,National Natural Science Foundation of China (http://westdc.westgis.ac.cn)

    +

    + + data_archives){ ?> +

    数据相关新闻

    +
      + data_archives as $v){?> +
    • + +
    +
    + + suppinfo || $this->fund) : ?> +

    资助项目

    + fund)) : ?> +
      + fund as $k=>$v) : ?> +
    • (项目编号:) [(No. )]
    • + +
    + suppinfo)) : ?> + '.str_replace(array("\r\n", "\n", "\r"),'

    ',$this->escape($md->suppinfo)).'

    ';?> + +
    + + resources) : ?> +

    相关资源

    + +
    + +
    +
    + keys as $cg){ + if($cg['keytype']=="theme") + $keywords[]=$cg['keyword']; + } + $ev = join(" ",$keywords); + ?> +
    + +
    + + +
    +
      +
      +
      + downhistory) : ?> +

      最近10条服务记录如下:

      +
        + downhistory as $v){ + echo '
      1. '.date("Y-m-d",strtotime($v->ts_created))." ".$v->unit." ".$v->realname; + if (!empty($v->offlineproject)) + echo ' 用途:'.$v->offlineproject; + elseif (!empty($v->onlineproject)) + echo ' 用途:'.$v->onlineproject; + echo '
      2. '; + } + ?> +
      + + 暂时没有服务记录,欢迎您下载使用! + +
      +
      + +
      +
      +
      +
      +
      + status>0 and $md->status<5) : ?> +

      此数据还在评审过程中,我们真切地邀请您参加此数据的评审,以便我们能尽快发布此数据!评审

      + +

      数据评论

      +
      +
      评论加载中
      +
      + hasIdentity()) + { + $user = $auth->getIdentity(); + $name = $user->realname; + $email = $user->email; + }else + { + $name = ""; + $email = ""; + } + ?> +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + e.g. http://westdc.westgis.ac.cn/ +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      +
      + + + 提交 +
      +
      +
      +
      + +
      +
      +
      +
      + + '学科','place'=>'地点','theme'=>'主题','temporal'=>'时间词','stratum'=>'地层'); +$kt=''; +$i=0; +foreach($this->keys as $cg) : + if ($kt==$cg['keytype']) : + $i+=1; + else : + if (!empty($kt)) echo ''; + $kt=$cg['keytype']; + $i=0; + endif; + if ($i==0) { + ?> + + doi) : ?> +
      • 数据DOI:doi; ?>
      + +
      +
      +

      数据细节文件列表

      +
        + fileformat) : ?> +
      • 格式:fileformat; ?>
      • + +
      • 大小:filesize; ?>MB
      • + downloaded>9) :?> +
      • 下载:downloaded; ?>次
      • + +
      • 浏览:viewed; ?>次
      • + + timebegin)) : ?> +
      • 数据时间范围:timebegin));if (!empty($md->timeend)) echo " 至 ".date('Y-m-d',strtotime($md->timeend)); ?>
      • + + doc)) : ?> + + + attachments) : ?> +
      • 相关文档: + attachments as $k=>$a) : ?> + + + +
      • + +
      • 数据共享方式:datatype) print "离线"; else print "在线(可直接下载)";?>
      • +
      +
      + status>0 and $md->status<5) : ?> + 数据评审 + datatype) : ?> + + 在线下载 + + + + 离线申请 + + +
      +
      +
      +

      空间位置

      +
      +
      +

      联系信息

      +
      +
        + '资源提供者','custodian'=>'维护者','owner'=>'拥有者','user'=>'用户','distributor'=>'数据服务联系人','originator'=>'创建者','pointOfContact'=>'联系人','principalInvestigator'=>'数据调查与处理者','processor'=>'处理者','publisher'=>'元数据发布者','author'=>'元数据作者'); + $r=''; + $i=0; + foreach($this->authors as $k=>$author) : + if ($author->role!=$r) + { + $r=$author->role; + $i=0; + if ($k>0) echo ''; + echo '
      • '.$party_zh[$author->role].':'; + } + if ($i>0) echo ','; + $i+=1; + if (!empty($author->email) && $r!='principalInvestigator') + echo ''; + echo ''; + if (!empty($author->individual)) + echo $author->individual; + else + echo $author->organisation; + echo ''; + if (!empty($author->email)) echo ''; + if ($k+1==count($this->authors)) echo '
      • '; + endforeach; + ?> +
      +
      +
        +
      • 元数据更新时间:ts_created)); ?>
      • +
      • 下载元数据: + Adobe PDF格式 + OpenOffice odt格式 + Word doc格式 + 查看XML源文件 +
      • + + version->c>0):?> +
      • 版本历史:version->c ?> 个
      • + +
      +
      + +
      +
      +
      分享到
      + +
      + + + + + + + + + +
      + +
      +
      +
      + + + +

      Cannot find the metadata.

      +

      没有找到对应的元数据。

      + + + diff --git a/application/models/data/Author.php b/application/models/data/Author.php new file mode 100644 index 00000000..150a8bc2 --- /dev/null +++ b/application/models/data/Author.php @@ -0,0 +1,44 @@ +db = $db; + } + + //检查前台用户对某条数据的权限 + function checkAuthor($uuid,$uid=0) + { + if(empty($uid)) + { + $auth = Zend_Auth::getInstance(); + if($auth->hasIdentity()) + { + $user = $auth->getIdentity(); + $uid = $user->id; + } + } + if(!empty($uid)) + { + $sql = "SELECT * FROM ".$this->tbl_author." WHERE uuid='$uuid' AND userid=$uid"; + }else{ + return false; + } + + $rs = $this->db->query($sql); + $row = $rs->fetch(PDO::FETCH_BOTH); + if($row['status']>0) + { + return true; + }else{ + return false; + } + } +} diff --git a/application/models/data/Doi.php b/application/models/data/Doi.php index b7216b5f..c53f5ef5 100644 --- a/application/models/data/Doi.php +++ b/application/models/data/Doi.php @@ -12,9 +12,18 @@ class Doi extends Zend_Controller_Plugin_Abstract $this->db = $db; } - function fetch() + function fetch($uid=0) { - $sql = "SELECT * FROM ".$this->tbl_doi." ORDER BY id DESC"; + if(empty($uid)) + { + $sql = "SELECT * FROM ".$this->tbl_doi." ORDER BY id DESC"; + }else{ + $sql = "SELECT doi.* FROM ".$this->tbl_doi." doi + LEFT JOIN mdauthor a ON doi.uuid=a.uuid + WHERE a.userid=".$uid." AND a.status>0 + ORDER BY id DESC + "; + } $rs = $this->db->query($sql); $rows = $rs->fetchAll(); return $rows; @@ -29,7 +38,13 @@ class Doi extends Zend_Controller_Plugin_Abstract return $dbh->insert($this->tbl_doi,$data); } - function update($data,$uuid){ + function update($data,$uuid,$uid=0){ + include_once("data/Author.php"); + $author = new Author($this->db); + if($author->checkAuthor($uuid,$uid)==false) + { + return "您没有权限"; + } $doi_info = $this->view($uuid); if($doi_info == false) { @@ -85,7 +100,7 @@ class Doi extends Zend_Controller_Plugin_Abstract $info[$k] = array( 'author'=>$authors[$k], 'organization'=>$orgs[$k], - 'order'=>0 + 'order'=> 5*count($authors)-($k*5) ); } //include_once("helper/view.php"); @@ -106,14 +121,33 @@ class Doi extends Zend_Controller_Plugin_Abstract return $row; } - function delete($id){ + function delete($id,$uid=0){ if(!is_numeric($id)) { return "参数错误"; } - $condition = " id=$id "; - $sql = "DELETE FROM ".$this->tbl_doi." WHERE $condition"; - return $this->db->exec($sql); + if($uid != 0){ + $sql = "SELECT uuid FROM ".$this->tbl_doi." WHERE id=$id"; + $rs = $this->db->query($sql); + $row = $rs->fetch(); + if(isset($row['uuid']) && !empty($row['uuid'])){ + include_once("data/Author.php"); + $author = new Author($this->db); + if($author->checkAuthor($row['uuid'],$uid)==false) + { + return "您没有权限"; + } + $condition = " id=$id "; + $sql = "DELETE FROM ".$this->tbl_doi." WHERE $condition"; + return $this->db->exec($sql); + }else{ + return "该记录不存在"; + } + }else{ + $condition = " id=$id "; + $sql = "DELETE FROM ".$this->tbl_doi." WHERE $condition"; + return $this->db->exec($sql); + } } function _getParams(Zend_Controller_Request_Abstract $request)