本文整理汇总了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']);
}
示例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']);
}
示例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;
}
示例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));
}
示例5: saveNewUser
public function saveNewUser(\model\User $newUser)
{
$newUser->getUserName();
$file = fopen("data/" . $newUser->getUserName() . ".txt", "w");
fwrite($file, $newUser->getPassword());
fclose($file);
}
示例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);
}
示例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']);
}
示例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;
}
示例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();
}
}
示例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'));
}
示例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;
}
}
示例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']);
}
示例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());
}
示例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']);
}
示例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
}
}