Skip to content

Instantly share code, notes, and snippets.

@dmclark
Created February 16, 2011 15:02
Show Gist options
  • Save dmclark/829515 to your computer and use it in GitHub Desktop.
Save dmclark/829515 to your computer and use it in GitHub Desktop.
<?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