<?php

class myUser extends sfBasicSecurityUser {
    public function signIn($form_values) {
        $katao_user =/*(KataoUser)*/ KataoUserPeer::getUserByLoginAndPassword($form_values['login'], $form_values['password']);
        setlocale(LC_TIME, 'fr');
        $this->setInstance($katao_user);
        // Credentials and authentication:
        $this->addCredentials($katao_user->getCredentials());
        $this->setAuthenticated(true);
        $this->setCulture('fr');
    }

    public function signOut() {
        $this->setAuthenticated(false);
        $this->clearCredentials();
        $this->getAttributeHolder()->removeNamespace();
    }

    public function setInstance(KataoUser $user) {
        return $this->setAttribute('user', $user);
    }
    public function getInstance() {
        return $this->getAttribute('user', null);
    }

    public function isJustDelegate() {
        return !$this->hasCredential('admin') && !$this->hasCredential('seo') && !$this->hasCredential('supplier') && $this->hasCredential('delegate') && !$this->hasCredential('referer');
    }
    public function isJustReferer() {
        return !$this->hasCredential('admin') && !$this->hasCredential('seo') && !$this->hasCredential('supplier') && !$this->hasCredential('delegate') && $this->hasCredential('referer');
    }
    public function isJustSupplier() {
        return !$this->hasCredential('admin') && !$this->hasCredential('seo') && $this->hasCredential('supplier') && !$this->hasCredential('delegate') && !$this->hasCredential('referer');
    }
}