westdc-zf1/application/module/Open/Handler/ClientHandler.php

84 lines
1.7 KiB
PHP
Raw Permalink Normal View History

<?php
namespace Open\Handler;
use \Helpers\View as view;
use \Helpers\dbh;
use \Helpers\Table;
use \Files\Files;
use \stdClass;
use \Users\Users;
class ClientHandler implements \Open\Event\ClientEvent
{
private $db; //传入PDO对象误
private $config; //全局配置
public $table;
public $tbl_maillog = ""; //邮件日志表
function __construct($db = NULL)
{
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
$this->table = new Table();
}
//获得Handlertype必须与 \Open\Source中同步否则会出现错误
//
public function getHandler($type,$data)
{
if($type == 'escience')
{
return new \Open\Handler\ClientTokenHandler\Escience($data);
}
if($type == 'sina')
{
return new \Open\Handler\ClientTokenHandler\Sina($data);
}
return false;
}
//存储token信息
public function tokenAndDataStorage(\Zend_EventManager_Event $e)
{
$type = $e->getParam('type');
$data = $e->getParam('token');
$handler = $this->getHandler($type,$data);
if($status = $handler->doit() === true)
{
return true;
}else{
return $status;
}
}
//检查用户账户是否存在
//存在就返回用户信息不存在返回false
//通用事件,通过各个 TokenHandler中内置Listener直接挂载不需要引入整个ClientListener
public function userCheck(\Zend_EventManager_Event $e)
{
$email = $e->getParam('email');
$user = new Users();
$current = $user->userExists($email);
if($current === false)
{
return false;
}
return $current;
}
}