<?php

class PG_Controller_Plugin_Authontication
extends Zend_Controller_Plugin_Abstract
{
	public function Auth(){
		$auth = Zend_Auth::getInstance();
		if (!$auth -> hasIdentity()) {
			$this -> _redirect('/login/');
		}
		
				

		setcookie('FootPrintApp', 'FootPrintApp', time() + 86400, '/');
		$user = $auth -> getIdentity();
		
		if ($user-> UnionType > 2) {

			if ($user -> Administrator == 1) {
			} else {
				$author = $db -> getRow($user -> author);
				if ($author["UnionType"] < 3) {
					$this -> _redirect('/union/first');
				} else {
					$this -> _redirect('/union/');
				}
			}
		}
		if ($user -> Status < 0) {
			$this -> _redirect('/first');
		}
		return $user;
	}
}
	