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(); }
protected function getActivationMailMessage(sfObjectGuardUser $user, $activation, $password) { return Swift_Message::newInstance()->setFrom(sfConfig::get('app_robot_mail_address'))->setTo($user->getEmail())->setSubject($this->getPartial('mailNotificationSubject'))->setBody($this->getPartial('mailNotificationBody', array('user' => $user, 'key' => $activation, 'password' => $password))); }
/** * Removes user from all groups in model * * @param sfObjectGuardUser $user user instance * @return void */ public function removeUser(sfObjectGuardUser $user) { if ($this->_options['onlyOwnable']) { throw new Exception(sprintf('Model "%s" is only Ownable', $this->_table->getComponentName())); } Doctrine_Query::create()->delete($this->_plugin->getTable()->getComponentName())->where('object_id = ?', $this->getInvoker()->getId())->andWhere('user_id = ?', $user->getId())->execute(); }
<?php include dirname(__FILE__) . '/../bootstrap/doctrine.php'; $t = new lime_test(20, new lime_output_color()); $user = new sfObjectGuardUser(); $user->setEmail('*****@*****.**'); $user->save(); $uId = $user->getId(); $t->isnt($uId, null, 'User "is saved"'); $activationKey = new sfObjectGuardActivationKey(); $activationKey->setKeyType(Doctrine::getTable('sfObjectGuardActivationKeyType')->findOneByName('register')); $activationKey->setUser($user); $activationKey->save(); $t->is($user->getActivationKeys()->getKeyType()->getName(), 'register', 'Activation key type of the user is "register"'); $t->is($activationKey->getUserId(), $user->getId(), 'Activation key "connected with user"'); $user->setPassword('testerPaSss'); $user->save(); $user = Doctrine::getTable('sfObjectGuardUser')->findOneByEmail('*****@*****.**'); $t->is($user->getId(), $uId, 'User "retrieved"'); $t->ok($user->checkPassword('testerPaSss'), 'Password "is right"'); $t->ok(!$user->checkPassword('testerPasss'), 'Password with "wrong case" is not right'); $t->ok(!$user->checkPassword('ABC'), 'Password is "totally wrong"'); $t->ok(!$user->getIsActive(), 'New user is "not active"'); $user->setActiveWithKey($activationKey); $user->save(); $activationKey->delete(); $t->ok($user->getIsActive(), 'User is now "active"'); $t->is($user->getKeyType()->getName(), 'register', 'User activated with "keyType = register"'); $t->is($user->getInviterId(), null, 'User does not have inviter'); $user2 = Doctrine::getTable('sfObjectGuardUser')->findOneByEmail('*****@*****.**'); $t->is($user2->getEmail(), '*****@*****.**', 'User 2 "email is everzet@gmail.com"');