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

66 lines
1.2 KiB
PHP

<?php
namespace open;
interface openbase
{
public function __construct($db = NULL,$auth = NULL);
}
interface openextend extends openbase
{
public function load();
}
abstract class open extends \Zend_Controller_Plugin_Abstract implements openextend
{
public $db;
public $auth = NULL;
public $user;
public $checkFiled = array('phone','realname','unit','address');
public function load($db = NULL,$auth = NULL){
$this->config = \Zend_Registry::get('config');
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
if(empty($auth))
{
$this->auth = \Zend_Auth::getInstance();
if($this->auth->hasIdentity())
{
$this->user = $this->auth->getIdentity();
}
}else{
$this->auth = false;
}
}
//检查用户资料完整性
public function checkinfo()
{
if($this->auth === false)
{
return "未登陆";
}
include_once("Users.php");
$user = new \Users($this->db);
$info = $user->getUserInfo($this->user->id);
foreach($this->checkFiled as $v)
{
if(empty($info[$v]))
{
return "请完善个人信息";
}
}
return true;
}
}