本文整理汇总了PHP中Model\User类的典型用法代码示例。如果您正苦于以下问题:PHP User类的具体用法?PHP User怎么用?PHP User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testHandlePayload
public function testHandlePayload()
{
$w = new MailgunWebhook($this->container);
$p = new Project($this->container);
$pp = new ProjectPermission($this->container);
$u = new User($this->container);
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$this->assertEquals(2, $u->create(array('name' => 'me', 'email' => 'me@localhost')));
$this->assertEquals(1, $p->create(array('name' => 'test1')));
$this->assertEquals(2, $p->create(array('name' => 'test2', 'identifier' => 'TEST1')));
// Empty payload
$this->assertFalse($w->parsePayload(array()));
// Unknown user
$this->assertFalse($w->parsePayload(array('sender' => '[email protected]', 'subject' => 'Email task', 'recipient' => 'foobar', 'stripped-text' => 'boo')));
// Project not found
$this->assertFalse($w->parsePayload(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test@localhost', 'stripped-text' => 'boo')));
// User is not member
$this->assertFalse($w->parsePayload(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-text' => 'boo')));
$this->assertTrue($pp->addMember(2, 2));
// The task must be created
$this->assertTrue($w->parsePayload(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-text' => 'boo')));
$task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(2, $task['project_id']);
$this->assertEquals('Email task', $task['title']);
$this->assertEquals('boo', $task['description']);
$this->assertEquals(2, $task['creator_id']);
}
开发者ID:rbertani,项目名称:kanboard,代码行数:29,代码来源:MailgunWebhookTest.php
示例2: testHtml2Markdown
public function testHtml2Markdown()
{
$w = new Postmark($this->container);
$p = new Project($this->container);
$pp = new ProjectPermission($this->container);
$u = new User($this->container);
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$this->assertEquals(2, $u->create(array('username' => 'me', 'email' => 'me@localhost')));
$this->assertEquals(1, $p->create(array('name' => 'test2', 'identifier' => 'TEST1')));
$this->assertTrue($pp->addMember(1, 2));
$this->assertTrue($w->receiveEmail(array('From' => 'me@localhost', 'Subject' => 'Email task', 'MailboxHash' => 'test1', 'TextBody' => 'boo', 'HtmlBody' => '<p><strong>boo</strong></p>')));
$task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(1, $task['project_id']);
$this->assertEquals('Email task', $task['title']);
$this->assertEquals('**boo**', $task['description']);
$this->assertEquals(2, $task['creator_id']);
$this->assertTrue($w->receiveEmail(array('From' => 'me@localhost', 'Subject' => 'Email task', 'MailboxHash' => 'test1', 'TextBody' => '**boo**', 'HtmlBody' => '')));
$task = $tf->getById(2);
$this->assertNotEmpty($task);
$this->assertEquals(1, $task['project_id']);
$this->assertEquals('Email task', $task['title']);
$this->assertEquals('**boo**', $task['description']);
$this->assertEquals(2, $task['creator_id']);
}
开发者ID:0xff-fanatic,项目名称:kanboard,代码行数:26,代码来源:PostmarkTest.php
示例3: run
public function run()
{
$iAccountID = $this->get('id');
$oAccount = new m\Account();
$aDetail = $oAccount->getAccountDetail($iAccountID);
if (empty($aDetail)) {
c\Router::redirect(c\Router::genURL('Home'));
}
$aFields = $oAccount->getAccountFields($iAccountID);
$oUser = new m\User();
$aDefaultPassword = $oUser->getDefaultPassword();
$aEmails = $oUser->getEmails();
foreach ($aFields as $k => $v) {
$aFields[$k]['display'] = u\Str::partCover($v['value'], 2, 1);
}
sort($aFields);
$aFieldNames = array_map(function ($v) {
foreach ($v as $key => $value) {
if ($key !== 'name') {
unset($v[$key]);
}
}
return $v;
}, $aFields);
$aAccountAll = $oAccount->getAllAccount();
$aSiteList = [];
foreach ($aAccountAll as $aAccountDetail) {
$aSiteList[] = ['name' => 'link:' . $aAccountDetail['name']];
}
$aData = ['page_title' => 'Open Sesame - ' . $aDetail['name'], 'app' => $aDetail, 'fields' => $aFields, 'form_action_add' => c\Router::genURL('AddField'), 'form_action_del' => c\Router::genURL('DeleteField'), 'form_action_updatefield' => c\Router::genURL('UpdateField'), 'form_action_updateaccount' => c\Router::genURL('UpdateAccount'), 'site_list' => json_encode($aSiteList), 'field_names' => json_encode($aFieldNames), 'default_password' => $aDefaultPassword['data'], 'emails' => $aEmails['data']];
return $aData;
}
开发者ID:sdgdsffdsfff,项目名称:open-sesame,代码行数:32,代码来源:Detail.php
示例4: testCloneProjectWithUsers
public function testCloneProjectWithUsers()
{
$p = new Project($this->container);
$c = new Category($this->container);
$pp = new ProjectPermission($this->container);
$u = new User($this->container);
$this->assertEquals(2, $u->create(array('username' => 'unittest1', 'password' => 'unittest')));
$this->assertEquals(3, $u->create(array('username' => 'unittest2', 'password' => 'unittest')));
$this->assertEquals(4, $u->create(array('username' => 'unittest3', 'password' => 'unittest')));
$this->assertEquals(1, $p->create(array('name' => 'P1')));
$this->assertTrue($pp->addMember(1, 2));
$this->assertTrue($pp->addMember(1, 4));
$this->assertTrue($pp->addManager(1, 3));
$this->assertTrue($pp->isMember(1, 2));
$this->assertTrue($pp->isMember(1, 3));
$this->assertTrue($pp->isMember(1, 4));
$this->assertFalse($pp->isManager(1, 2));
$this->assertTrue($pp->isManager(1, 3));
$this->assertFalse($pp->isManager(1, 4));
$this->assertEquals(2, $p->duplicate(1));
$project = $p->getById(2);
$this->assertNotEmpty($project);
$this->assertEquals('P1 (Clone)', $project['name']);
$this->assertEquals(3, count($pp->getMembers(2)));
$this->assertTrue($pp->isMember(2, 2));
$this->assertTrue($pp->isMember(2, 3));
$this->assertTrue($pp->isMember(2, 4));
$this->assertFalse($pp->isManager(2, 2));
$this->assertTrue($pp->isManager(2, 3));
$this->assertFalse($pp->isManager(2, 4));
}
开发者ID:jasonmoofang,项目名称:kanboard,代码行数:31,代码来源:ProjectDuplicateTest.php
示例5: saveNewUser
public function saveNewUser(\model\User $newUser)
{
$newUser->getUserName();
$file = fopen("data/" . $newUser->getUserName() . ".txt", "w");
fwrite($file, $newUser->getPassword());
fclose($file);
}
开发者ID:js223kz,项目名称:1dv608_register,代码行数:7,代码来源:RegisterDAL.php
示例6: SaveLoginOnClient
public function SaveLoginOnClient(\model\User $user)
{
// Prepare values
$cookieValues = implode(':', array($user->GetUserName(), $user->GetToken(), $user->GetSignature()));
// Save values in cookie (expires in 30 days)
return setcookie(self::$COOKIE_ID, $cookieValues, time() + 60 * 60 * 24 * self::$COOKIE_VALID_DAYS);
}
开发者ID:johnnypesola,项目名称:1dv608-php-project,代码行数:7,代码来源:LoginView.php
示例7: testGetAll
public function testGetAll()
{
$u = new User($this->container);
$p = new Project($this->container);
$cf = new CustomFilter($this->container);
$this->assertEquals(1, $p->create(array('name' => 'UnitTest 1')));
$this->assertEquals(2, $p->create(array('name' => 'UnitTest 2')));
$this->assertEquals(2, $u->create(array('username' => 'user 2')));
$this->assertEquals(1, $cf->create(array('name' => 'My filter 1', 'filter' => 'color:blue', 'project_id' => 1, 'user_id' => 1)));
$this->assertEquals(2, $cf->create(array('name' => 'My filter 2', 'filter' => 'color:red', 'project_id' => 1, 'user_id' => 1, 'is_shared' => 1)));
$this->assertEquals(3, $cf->create(array('name' => 'My filter 3', 'filter' => 'color:green', 'project_id' => 1, 'user_id' => 2, 'is_shared' => 1)));
$this->assertEquals(4, $cf->create(array('name' => 'My filter 4', 'filter' => 'color:brown', 'project_id' => 1, 'user_id' => 2, 'is_shared' => 0)));
$this->assertEquals(5, $cf->create(array('name' => 'My filter 5', 'filter' => 'color:grey', 'project_id' => 2, 'user_id' => 2)));
// Get filters for the project 1 and user 1
$filters = $cf->getAll(1, 1);
$this->assertCount(3, $filters);
$this->assertEquals(1, $filters[0]['id']);
$this->assertEquals('My filter 1', $filters[0]['name']);
$this->assertEquals('color:blue', $filters[0]['filter']);
$this->assertEquals(1, $filters[0]['project_id']);
$this->assertEquals(1, $filters[0]['user_id']);
$this->assertEquals(0, $filters[0]['is_shared']);
$this->assertEquals('', $filters[0]['owner_name']);
$this->assertEquals('admin', $filters[0]['owner_username']);
$this->assertEquals(2, $filters[1]['id']);
$this->assertEquals('My filter 2', $filters[1]['name']);
$this->assertEquals('color:red', $filters[1]['filter']);
$this->assertEquals(1, $filters[1]['project_id']);
$this->assertEquals(1, $filters[1]['user_id']);
$this->assertEquals(1, $filters[1]['is_shared']);
$this->assertEquals('', $filters[1]['owner_name']);
$this->assertEquals('admin', $filters[1]['owner_username']);
$this->assertEquals(3, $filters[2]['id']);
$this->assertEquals('My filter 3', $filters[2]['name']);
$this->assertEquals('color:green', $filters[2]['filter']);
$this->assertEquals(1, $filters[2]['project_id']);
$this->assertEquals(2, $filters[2]['user_id']);
$this->assertEquals(1, $filters[2]['is_shared']);
$this->assertEquals('', $filters[2]['owner_name']);
$this->assertEquals('user 2', $filters[2]['owner_username']);
// Get filters for the project 1 and user 2
$filters = $cf->getAll(1, 2);
$this->assertCount(3, $filters);
$this->assertEquals(2, $filters[0]['id']);
$this->assertEquals('My filter 2', $filters[0]['name']);
$this->assertEquals(3, $filters[1]['id']);
$this->assertEquals('My filter 3', $filters[1]['name']);
$this->assertEquals(4, $filters[2]['id']);
$this->assertEquals('My filter 4', $filters[2]['name']);
// Get filters for the project 2 and user 1
$filters = $cf->getAll(2, 1);
$this->assertCount(0, $filters);
// Get filters for the project 2 and user 2
$filters = $cf->getAll(2, 2);
$this->assertCount(1, $filters);
$this->assertEquals(5, $filters[0]['id']);
$this->assertEquals('My filter 5', $filters[0]['name']);
$this->assertEquals(0, $filters[0]['is_shared']);
}
开发者ID:praveencs87,项目名称:kanboard,代码行数:59,代码来源:CustomFilterTest.php
示例8: mapToDataObject
/**
* @param User $user
* @return UserDataObject
*/
public function mapToDataObject(User $user)
{
$userDataObject = new UserDataObject();
$userDataObject->id = $user->getId();
$userDataObject->name = $user->getName();
$userDataObject->passwordHash = $user->getPasswordHash();
return $userDataObject;
}
开发者ID:flonology,项目名称:UrlKeeper,代码行数:12,代码来源:UserDataObjectMapper.php
示例9: doUserExist
public function doUserExist(User $user)
{
$this->database->prepare('SELECT * FROM users WHERE username = :username');
$this->database->bindValue(':username', $user->getUsername());
$this->database->fetchAll();
if ($this->database->rowCount() > 0) {
throw new exception\UserAlreadyExistException();
}
}
开发者ID:OskarKlintrotSkolarbeteWP14,项目名称:1dv608-Project,代码行数:9,代码来源:RegistrationDAL.php
示例10: testHandleFailedLogin
public function testHandleFailedLogin()
{
$u = new User($this->container);
$a = new Authentication($this->container);
$this->assertFalse($u->isLocked('admin'));
for ($i = 0; $i <= 6; $i++) {
$a->handleFailedLogin('admin');
}
$this->assertTrue($u->isLocked('admin'));
}
开发者ID:redarrow,项目名称:kanboard,代码行数:10,代码来源:AuthenticationTest.php
示例11: removeFollowee
/**
* Used when the person who is currently logged in wants to stop following another user
* @param User $user, person who is already following
* @param $followee, a person who is being followed
* @return bool
*/
public function removeFollowee(\model\User $user, $followee)
{
$follower = $user->getUsername();
try {
DB::getInstance()->deleteFollowee($follower, $followee);
return true;
} catch (\Exception $e) {
return false;
}
}
开发者ID:Janste,项目名称:PHP_MVC_Simple_Social_Network,代码行数:16,代码来源:Followers.php
示例12: testSuccessfulAuthentication
public function testSuccessfulAuthentication()
{
$_SERVER[REVERSE_PROXY_USER_HEADER] = 'my_user';
$a = new ReverseProxy($this->container);
$u = new User($this->container);
$this->assertTrue($a->authenticate());
$user = $u->getByUsername('my_user');
$this->assertNotEmpty($user);
$this->assertEquals(0, $user['is_admin']);
$this->assertEquals(1, $user['is_ldap_user']);
$this->assertEquals(1, $user['disable_login_form']);
}
开发者ID:redarrow,项目名称:kanboard,代码行数:12,代码来源:ReverseProxyTest.php
示例13: registerUser
public function registerUser()
{
$user = new User();
$user->setEmail($this->request_body->email);
$user->setPassword(md5($this->request_body->password));
$user->save();
$token = new AccessToken();
$token->setTokenContent(uniqid());
$token->setUser($user);
$token->save();
return array('user' => $user->toArray(), 'token' => $token->toArray());
}
开发者ID:hackathon-5,项目名称:power-ragers-repo,代码行数:12,代码来源:UserController.php
示例14: testHandlePayload
public function testHandlePayload()
{
$w = new Sendgrid($this->container);
$p = new Project($this->container);
$pp = new ProjectPermission($this->container);
$u = new User($this->container);
$tc = new TaskCreation($this->container);
$tf = new TaskFinder($this->container);
$this->assertEquals(2, $u->create(array('username' => 'me', 'email' => 'me@localhost')));
$this->assertEquals(1, $p->create(array('name' => 'test1')));
$this->assertEquals(2, $p->create(array('name' => 'test2', 'identifier' => 'TEST1')));
// Empty payload
$this->assertFalse($w->receiveEmail(array()));
// Unknown user
$this->assertFalse($w->receiveEmail(array('envelope' => '{"to":["[email protected]"],"from":"a.b.c"}', 'subject' => 'Email task')));
// Project not found
$this->assertFalse($w->receiveEmail(array('envelope' => '{"to":["[email protected]"],"from":"me@localhost"}', 'subject' => 'Email task')));
// User is not member
$this->assertFalse($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task')));
$this->assertTrue($pp->addMember(2, 2));
// The task must be created
$this->assertTrue($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task')));
$task = $tf->getById(1);
$this->assertNotEmpty($task);
$this->assertEquals(2, $task['project_id']);
$this->assertEquals('Email task', $task['title']);
$this->assertEquals('', $task['description']);
$this->assertEquals(2, $task['creator_id']);
// Html content
$this->assertTrue($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task', 'html' => '<strong>bold</strong> text')));
$task = $tf->getById(2);
$this->assertNotEmpty($task);
$this->assertEquals(2, $task['project_id']);
$this->assertEquals('Email task', $task['title']);
$this->assertEquals('**bold** text', $task['description']);
$this->assertEquals(2, $task['creator_id']);
// Text content
$this->assertTrue($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task', 'text' => '**bold** text')));
$task = $tf->getById(3);
$this->assertNotEmpty($task);
$this->assertEquals(2, $task['project_id']);
$this->assertEquals('Email task', $task['title']);
$this->assertEquals('**bold** text', $task['description']);
$this->assertEquals(2, $task['creator_id']);
// Text + html content
$this->assertTrue($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task', 'html' => '<strong>bold</strong> html', 'text' => '**bold** text')));
$task = $tf->getById(4);
$this->assertNotEmpty($task);
$this->assertEquals(2, $task['project_id']);
$this->assertEquals('Email task', $task['title']);
$this->assertEquals('**bold** html', $task['description']);
$this->assertEquals(2, $task['creator_id']);
}
开发者ID:redarrow,项目名称:kanboard,代码行数:53,代码来源:SendgridTest.php
示例15: makeHistoryChanges
/**
* Write changes into history
*
* @param \Model\User $oldUser
* @param \Model\User $newUser
*/
protected function makeHistoryChanges(\Model\User $oldUser, \Model\User $newUser)
{
try {
$history = new \Model\UsersHistory();
$history->user_id = $oldUser->id;
$history->was = $oldUser->toJson();
$history->setted = $newUser->toJson();
$history->save();
} catch (\Exception $e) {
// write err log
}
}
开发者ID:40min,项目名称:testreg,代码行数:18,代码来源:User.php
示例16: validate
public function validate()
{
unset($this->message);
$this->message = array();
$username = $this->getUsername();
$password = $this->getPassword();
$repeatedPassword = $this->getPasswordRepeat();
$validateUser = new User($username, $password);
try {
$validateUser->testValidUsername();
} catch (InvalidUsernameException $e) {
$this->message[] = "Username contains invalid characters.";
} catch (\Exception $e) {
$this->message[] = $e;
}
try {
$validateUser->testValidPassword();
} catch (InvalidPasswordException $e) {
$this->message[] = "Password contains invalid characters.";
} catch (\Exception $e) {
$this->message[] = $e;
}
try {
$validateUser->testUsernameLength();
} catch (ToShortUsernameException $e) {
$this->message[] = "Username has too few characters, at least 3 characters.";
} catch (\Exception $e) {
$this->message[] = $e;
}
try {
$validateUser->testPasswordLength();
} catch (ToShortPasswordException $e) {
$this->message[] = "Password has too few characters, at least 6 characters.";
} catch (\Exception $e) {
$this->message[] = $e;
}
if ($password != $repeatedPassword) {
$this->message[] = "Passwords do not match.";
}
try {
$this->dal->doUserExist($validateUser);
} catch (UserAlreadyExistException $e) {
$this->message[] = "User exists, pick another username.";
} catch (\Exception $e) {
$this->message[] = $e;
}
if (empty($this->message)) {
return true;
} else {
return false;
}
}
开发者ID:OskarKlintrotSkolarbeteWP14,项目名称:1dv608-Project,代码行数:52,代码来源:RegistrationView.php
示例17: testSendWithoutEmailAddress
public function testSendWithoutEmailAddress()
{
$en = new EmailNotification($this->container);
$p = new Project($this->container);
$tf = new TaskFinder($this->container);
$tc = new TaskCreation($this->container);
$u = new User($this->container);
$this->assertEquals(1, $p->create(array('name' => 'test')));
$this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));
$this->container['emailClient'] = $this->getMockBuilder('\\Core\\EmailClient')->setConstructorArgs(array($this->container))->setMethods(array('send'))->getMock();
$this->container['emailClient']->expects($this->never())->method('send');
$en->send($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
}
开发者ID:hj3938,项目名称:kanboard,代码行数:13,代码来源:EmailNotificationTest.php
示例18: addNewStatus
public function addNewStatus(\model\User $user, $content)
{
if (strlen($content) > 255) {
return false;
}
try {
$username = $user->getUsername();
DB::getInstance()->addStatusToDB($username, $content);
return true;
} catch (\Exception $e) {
return false;
}
}
开发者ID:Janste,项目名称:PHP_MVC_Simple_Social_Network,代码行数:13,代码来源:StatusHandler.php
示例19: save
public function save(\model\User $user)
{
if ($this->doExists($user->getUsername())) {
throw new \Exception();
}
$stmt = $this->database->prepare("INSERT INTO `lab4` (`username` , `password`) VALUES (?, ?)");
if ($stmt === FALSE) {
throw new \Exception($this->database->error);
}
$username = $user->getUsername();
$password = $user->getPassword();
$stmt->bind_param('ss', $username, $password);
$stmt->execute();
}
开发者ID:rs222kn,项目名称:1DV608_Login,代码行数:14,代码来源:UserDAL.php
示例20: helloMathis
public static function helloMathis($app)
{
$ajout = false;
$username = 'mathis';
$user = User::find($username);
// Si $user n'est pas set, c'est qu'il n'y a rien et on ajoute donc en base !
if (!isset($user)) {
$user = new User();
$user->name = $username;
$user->save();
$ajout = true;
}
$app->render('user.html.twig', array('ajout' => $ajout, 'autre' => 'ahah !', 'name' => $user->name));
}
开发者ID:schleft,项目名称:RuneAPI,代码行数:14,代码来源:Test.php
注:本文中的Model\User类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论