45 lines
856 B
PHP
45 lines
856 B
PHP
<?php
|
|
class Author extends Zend_Controller_Plugin_Abstract
|
|
{
|
|
private $db; //传入PDO对象.
|
|
private $auth = NULL; //Zend_Auth 对象
|
|
|
|
//使用到的公共变量
|
|
public $tbl_metadata = "metadata"; //元数据
|
|
public $tbl_author = "mdauthor"; //数据作者表
|
|
|
|
function __construct($db)
|
|
{
|
|
$this->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;
|
|
}
|
|
}
|
|
}
|