westdc-zf1/application/models/data/Author.php

45 lines
856 B
PHP
Raw Normal View History

2013-04-24 13:39:23 +00:00
<?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;
}
}
}