Created
February 16, 2011 15:02
-
-
Save dmclark/829515 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class myUser extends sfGuardSecurityUser | |
{ | |
public function getCenter() { | |
return parent::getGuardUser()->getStaff()->getCenter() : null; | |
} | |
public function getCenterId() { | |
return $this->user ? $this->getStaff()->getCenter()->getId() : null; | |
} | |
public function getName() { | |
return $this->user ? $this->getStaff()->getName() : null; | |
} | |
public function getStaffCenter() | |
{ | |
if ($this->user && $this->getCenterId() != 1) { | |
$q = Doctrine_Query::create() | |
->From('Staff s') | |
->where('s.center_id = ?', $this->getCenterId()); | |
} else { | |
$q = Doctrine_Query::create() | |
->From('Staff s'); | |
} | |
return $this->user ? Doctrine_Core::getTable('Staff')->getStaff($q) : null; | |
} | |
public function getClientCenter() | |
{ | |
if ($this->user && $this->getCenterId() != 1) { | |
$q = Doctrine_Query::create() | |
->From('Client c') | |
->where('c.center_id = ?', $this->getCenterId()); | |
} else { | |
$q = Doctrine_Query::create() | |
->From('Client c'); | |
} | |
return Doctrine_Core::getTable('Client')->getClient($q); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment