function getUsersCountInGroup(sfObjectGuardUser $user1, sfObjectGuardGroup $group, sfObjectGuardTest $com) { return Doctrine_Query::create()->from('sfObjectGuardTestGuardable')->where('object_id = ?', $com->getId())->andWhere('user_id = ?', $user1->getId())->andWhere('group_id = ?', $group->getId())->execute()->count(); }
/** * Checks if user is in group of model * * @param sfObjectGuardUser $user user instance * @param sfObjectGuardGroup $group user group * @return boolean true if user in group, false in other way */ public function isUserInGroup(sfObjectGuardUser $user, sfObjectGuardGroup $group) { if ($this->_options['onlyOwnable']) { throw new Exception(sprintf('Model "%s" is only Ownable', $this->_table->getComponentName())); } return Doctrine_Query::create()->from($this->_plugin->getTable()->getComponentName())->where('object_id = ?', $this->getInvoker()->getId())->andWhere('user_id = ?', $user->getId())->andWhere('group_id = ?', $group->getId())->execute()->count() > 0; }