Fix user options bugs that caused bad display. Fixes #213

This commit is contained in:
Matthew Ross 2015-11-08 17:31:05 -05:00
parent 4bb79a83f6
commit f2530601cc
4 changed files with 30 additions and 17 deletions

View File

@ -26,6 +26,7 @@ function exceptionHandler($exception) {
set_exception_handler('exceptionHandler');
R::setup('sqlite:'.__DIR__.'/taskboard.db');
R::setAutoResolve(TRUE);
createInitialUser();
$app->notFound(function() use ($app, $jsonResponse) {

View File

@ -380,7 +380,7 @@ function createInitialUser() {
$options->showAnimations = true;
$options->showAssignee = true;
$admin->ownOptions[] = $options;
$admin->xownOptionList[] = $options;
R::store($admin);
}

View File

@ -138,7 +138,7 @@ $app->get('/users/current', function() use($app, $jsonResponse) {
if (validateToken()) {
$user = getUser();
if (null != $user) {
$userOptions = R::exportAll($user->ownOption);
$userOptions = R::exportAll($user->xownOptionList);
$options = [
'tasksOrder' => $userOptions[0]['tasks_order'],
'showAssignee' => $userOptions[0]['show_assignee'] == 1,
@ -163,9 +163,9 @@ $app->post('/users/current/options', function() use ($app, $jsonResponse) {
if (validateToken()) {
$user = getUser();
$user->ownOption[1]->tasksOrder = $data->tasksOrder;
$user->ownOption[1]->showAssignee = $data->showAssignee;
$user->ownOption[1]->showAnimations = $data->showAnimations;
$user->xownOptionList[0]->tasksOrder = $data->tasksOrder;
$user->xownOptionList[0]->showAssignee = $data->showAssignee;
$user->xownOptionList[0]->showAnimations = $data->showAnimations;
R::store($user);
$jsonResponse->data = $data;
@ -198,13 +198,16 @@ $app->post('/users', function() use($app, $jsonResponse) {
$user->defaultBoard = $data->defaultBoard;
$user->salt = password_hash($data->username . time(), PASSWORD_BCRYPT);
$user->password = password_hash($data->password, PASSWORD_BCRYPT, array('salt' => $user->salt));
$options = R::dispense('option');
$options->newTaskPosition = 0; // Bottom of column (1 == top of column)
$options->animate = true;
$user->ownOptions = $options;
$options->tasksOrder = 0; // Bottom of column (1 == top of column)
$options->showAnimations = true;
$options->showAssignee = true;
$user->xownOptionList[] = $options;
R::store($user);
addUserToBoard($data->defaultBoard, $user);
if (property_exists($data, 'boardAccess') && is_array($data->boardAccess)) {
foreach($data->boardAccess as $board) {
addUserToBoard($board, $user);

27
composer.lock generated
View File

@ -1,10 +1,11 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "bcd0d77c65d6fda9ece3a2600d80347c",
"content-hash": "99f3562842898771c354cfc411491902",
"packages": [
{
"name": "firebase/php-jwt",
@ -135,16 +136,16 @@
},
{
"name": "phpmailer/phpmailer",
"version": "v5.2.9",
"version": "v5.2.14",
"source": {
"type": "git",
"url": "https://github.com/PHPMailer/PHPMailer.git",
"reference": "73b61679809615850706f1dbf88e6df2ddc05745"
"reference": "e774bc9152de85547336e22b8926189e582ece95"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/73b61679809615850706f1dbf88e6df2ddc05745",
"reference": "73b61679809615850706f1dbf88e6df2ddc05745",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/e774bc9152de85547336e22b8926189e582ece95",
"reference": "e774bc9152de85547336e22b8926189e582ece95",
"shasum": ""
},
"require": {
@ -152,17 +153,25 @@
},
"require-dev": {
"phpdocumentor/phpdocumentor": "*",
"phpunit/phpunit": "4.1.*"
"phpunit/phpunit": "4.7.*"
},
"suggest": {
"league/oauth2-client": "Needed for XOAUTH2 authentication",
"league/oauth2-google": "Needed for Gmail XOAUTH2"
},
"type": "library",
"autoload": {
"classmap": [
"class.phpmailer.php",
"class.phpmaileroauth.php",
"class.phpmaileroauthgoogle.php",
"class.smtp.php",
"class.pop3.php",
"class.smtp.php"
"extras/EasyPeasyICS.php",
"extras/ntlm_sasl_client.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"notification-url": "http://packagist.org/downloads/",
"license": [
"LGPL-2.1"
],
@ -184,7 +193,7 @@
}
],
"description": "PHPMailer is a full-featured email creation and transfer class for PHP",
"time": "2014-09-26 18:33:30"
"time": "2015-11-01 10:15:28"
},
{
"name": "slim/slim",