當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Model\User類代碼示例

本文整理匯總了PHP中Model\User的典型用法代碼示例。如果您正苦於以下問題:PHP User類的具體用法?PHP User怎麽用?PHP User使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了User類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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' => 'a@b.c', '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":["a@b.c"],"from":"a.b.c"}', 'subject' => 'Email task')));
     // Project not found
     $this->assertFalse($w->receiveEmail(array('envelope' => '{"to":["a@b.c"],"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


注:本文中的Model\User類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。