Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LQDN Adminsys
don
Commits
a899ac65
Commit
a899ac65
authored
Oct 19, 2019
by
Guinness
Browse files
Merge branch 'preprod' into 'master'
Merge Preprod into master See merge request
!120
parents
ca986a2f
b3af270d
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/controller/campaign.php
View file @
a899ac65
...
@@ -4,6 +4,7 @@ namespace Controller;
...
@@ -4,6 +4,7 @@ namespace Controller;
use
LQDN\Command\UserUpdateTotalCommand
;
use
LQDN\Command\UserUpdateTotalCommand
;
use
LQDN\Command\UserCreateCommand
;
use
LQDN\Command\UserCreateCommand
;
use
LQDN\Command\DonationCreateCommand
;
use
LQDN\Command\DonationCreateCommand
;
use
LQDN\Exception\InvalidEmailException
;
class
Campaign
extends
Controller
class
Campaign
extends
Controller
{
{
...
@@ -108,7 +109,7 @@ class Campaign extends Controller
...
@@ -108,7 +109,7 @@ class Campaign extends Controller
$user
=
$f3
->
get
(
'container'
)[
'user_finder'
]
->
findByEmail
(
\
Utils
::
asl
(
$email
));
$user
=
$f3
->
get
(
'container'
)[
'user_finder'
]
->
findByEmail
(
\
Utils
::
asl
(
$email
));
if
(
count
(
$user
)
>
0
&&
is_array
(
$user
))
{
if
(
is_array
(
$user
)
&&
count
(
$user
)
>
0
)
{
// We have an existing user, we should try to login with the provided password
// We have an existing user, we should try to login with the provided password
// or 403.
// or 403.
$mapper
=
new
\
DB\SQL\Mapper
(
$f3
->
get
(
'DB'
),
'users'
);
$mapper
=
new
\
DB\SQL\Mapper
(
$f3
->
get
(
'DB'
),
'users'
);
...
@@ -122,8 +123,13 @@ class Campaign extends Controller
...
@@ -122,8 +123,13 @@ class Campaign extends Controller
$cumul_id
=
$user
[
'cumul'
];
$cumul_id
=
$user
[
'cumul'
];
}
else
{
}
else
{
// The user does not exist, so let's create it
// The user does not exist, so let's create it
$result
=
$db
->
query
(
"INSERT INTO users (pseudo, email, hash)
try
{
VALUES ('"
.
$f3
->
get
(
'pseudo'
)
.
"', '
$email
', '
$hash
')"
);
$f3
->
get
(
'container'
)[
'command_handler'
]
->
handle
(
new
UserCreateCommand
(
$email
,
$hash
,
$f3
->
get
(
'pseudo'
),
0
,
0
));
}
catch
(
InvalidEmailException
$e
)
{
$f3
->
set
(
"error"
,
_
(
"Email Invalide"
));
$f3
->
error
(
"403"
);
}
$user_id
=
$db
->
lastInsertId
();
$user_id
=
$db
->
lastInsertId
();
}
}
}
}
...
...
db/migrations/20181025132655_add_commentaire.php
View file @
a899ac65
...
@@ -28,7 +28,7 @@ class AddCommentaire extends AbstractMigration
...
@@ -28,7 +28,7 @@ class AddCommentaire extends AbstractMigration
public
function
change
()
public
function
change
()
{
{
$table
=
$this
->
table
(
'contreparties'
);
$table
=
$this
->
table
(
'contreparties'
);
$table
->
addColumn
(
'commentaire'
,
'string'
)
$table
->
addColumn
(
'commentaire'
,
'string'
,
array
(
'default'
=>
''
)
)
->
update
();
->
update
();
}
}
}
}
db/migrations/20191003105908_code_postaux_alphanumeriques.php
0 → 100644
View file @
a899ac65
<?php
use
Phinx\Migration\AbstractMigration
;
class
CodePostauxAlphanumeriques
extends
AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* addCustomColumn
* renameColumn
* addIndex
* addForeignKey
*
* Any other destructive changes will result in an error when trying to
* rollback the migration.
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public
function
change
()
{
$adresses
=
$this
->
table
(
'adresses'
);
$adresses
->
changeColumn
(
'codepostal'
,
'string'
,
[
'limit'
=>
20
])
->
update
();
}
}
db/schema.sql
View file @
a899ac65
...
@@ -83,7 +83,7 @@ DROP TABLE IF EXISTS `contreparties`;
...
@@ -83,7 +83,7 @@ DROP TABLE IF EXISTS `contreparties`;
/*!40101 SET character_set_client = utf8 */
;
/*!40101 SET character_set_client = utf8 */
;
CREATE
TABLE
`contreparties`
(
CREATE
TABLE
`contreparties`
(
`id`
int
(
10
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`id`
int
(
10
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`datec`
datetime
NOT
NULL
,
`datec`
datetime
NOT
NULL
DEFAULT
'0000-00-00 00:00:00'
,
`user_id`
int
(
10
)
unsigned
NOT
NULL
,
`user_id`
int
(
10
)
unsigned
NOT
NULL
,
`quoi`
varchar
(
255
)
NOT
NULL
,
`quoi`
varchar
(
255
)
NOT
NULL
,
`taille`
int
(
10
)
unsigned
NOT
NULL
,
`taille`
int
(
10
)
unsigned
NOT
NULL
,
...
@@ -105,22 +105,22 @@ DROP TABLE IF EXISTS `dons`;
...
@@ -105,22 +105,22 @@ DROP TABLE IF EXISTS `dons`;
CREATE
TABLE
`dons`
(
CREATE
TABLE
`dons`
(
`id`
int
(
10
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`id`
int
(
10
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`status`
tinyint
(
3
)
unsigned
NOT
NULL
,
`status`
tinyint
(
3
)
unsigned
NOT
NULL
,
`datec`
datetime
NOT
NULL
,
`datec`
datetime
NOT
NULL
DEFAULT
'0000-00-00 00:00:00'
,
`somme`
int
(
10
)
unsigned
NOT
NULL
,
`somme`
int
(
10
)
unsigned
NOT
NULL
,
`lang`
varchar
(
5
)
CHARACTER
SET
latin1
NOT
NULL
DEFAULT
'en_US'
,
`lang`
varchar
(
5
)
CHARACTER
SET
latin1
NOT
NULL
DEFAULT
'en_US'
,
`cadeau`
tinyint
(
3
)
unsigned
NOT
NULL
,
`cadeau`
tinyint
(
3
)
unsigned
NOT
NULL
DEFAULT
0
,
`abo`
tinyint
(
4
)
NOT
NULL
,
`abo`
tinyint
(
4
)
NOT
NULL
DEFAULT
0
,
`taille`
int
(
10
)
unsigned
NOT
NULL
,
`taille`
int
(
10
)
unsigned
NOT
NULL
DEFAULT
0
,
`public`
int
(
10
)
unsigned
NOT
NULL
,
`public`
int
(
10
)
unsigned
NOT
NULL
DEFAULT
0
,
`pdf`
varchar
(
32
)
CHARACTER
SET
latin1
NOT
NULL
,
`pdf`
varchar
(
32
)
CHARACTER
SET
latin1
NOT
NULL
DEFAULT
''
,
`decimale`
int
(
10
)
unsigned
NOT
NULL
,
`decimale`
int
(
10
)
unsigned
NOT
NULL
DEFAULT
0
,
`datee`
datetime
NOT
NULL
,
`datee`
datetime
NOT
NULL
DEFAULT
'0000-00-00 00:00:00'
,
`mailsent`
tinyint
(
4
)
DEFAULT
'0'
,
`mailsent`
tinyint
(
4
)
DEFAULT
'0'
,
`color`
varchar
(
7
)
CHARACTER
SET
latin1
DEFAULT
NULL
,
`color`
varchar
(
7
)
CHARACTER
SET
latin1
DEFAULT
NULL
,
`pi_x`
int
(
11
)
DEFAULT
NULL
,
`pi_x`
int
(
11
)
DEFAULT
NULL
DEFAULT
0
,
`pi_y`
int
(
11
)
DEFAULT
NULL
,
`pi_y`
int
(
11
)
DEFAULT
NULL
DEFAULT
0
,
`hash`
varchar
(
64
)
DEFAULT
NULL
,
`hash`
varchar
(
64
)
DEFAULT
NULL
DEFAULT
""
,
`taille_h`
int
(
10
)
unsigned
NOT
NULL
,
`taille_h`
int
(
10
)
unsigned
NOT
NULL
DEFAULT
0
,
`fdnn_user`
bigint
(
20
)
NOT
NULL
DEFAULT
'0'
,
`fdnn_user`
bigint
(
20
)
NOT
NULL
DEFAULT
'0'
,
`color_2`
varchar
(
7
)
DEFAULT
''
,
`color_2`
varchar
(
7
)
DEFAULT
''
,
`cumul`
int
(
11
)
DEFAULT
'0'
,
`cumul`
int
(
11
)
DEFAULT
'0'
,
...
@@ -193,13 +193,13 @@ CREATE TABLE `users` (
...
@@ -193,13 +193,13 @@ CREATE TABLE `users` (
`id`
int
(
10
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`id`
int
(
10
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`email`
varchar
(
255
)
DEFAULT
NULL
,
`email`
varchar
(
255
)
DEFAULT
NULL
,
`hash`
varchar
(
64
)
CHARACTER
SET
latin1
NOT
NULL
,
`hash`
varchar
(
64
)
CHARACTER
SET
latin1
NOT
NULL
,
`total`
int
(
10
)
unsigned
NOT
NULL
,
`total`
int
(
10
)
unsigned
NOT
NULL
DEFAULT
0
,
`cumul`
int
(
10
)
unsigned
NOT
NULL
,
`cumul`
int
(
10
)
unsigned
NOT
NULL
DEFAULT
0
,
`pseudo`
varchar
(
255
)
NOT
NULL
,
`pseudo`
varchar
(
255
)
NOT
NULL
DEFAULT
""
,
`identifier`
varchar
(
50
)
DEFAULT
NULL
,
`identifier`
varchar
(
50
)
DEFAULT
NULL
,
`expiration`
datetime
DEFAULT
NULL
,
`expiration`
datetime
DEFAULT
NULL
,
`status`
int
(
11
)
DEFAULT
NULL
,
`status`
int
(
11
)
DEFAULT
NULL
,
`commentaire`
text
,
`commentaire`
text
DEFAULT
''
,
PRIMARY
KEY
(
`id`
),
PRIMARY
KEY
(
`id`
),
KEY
`email`
(
`email`
)
KEY
`email`
(
`email`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
15494
DEFAULT
CHARSET
=
utf8
COMMENT
=
'Les donateurs'
;
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
15494
DEFAULT
CHARSET
=
utf8
COMMENT
=
'Les donateurs'
;
...
...
src/LQDN/Exception/InvalidEmailException.php
0 → 100644
View file @
a899ac65
<?php
namespace
LQDN\Exception
;
class
InvalidEmailException
extends
\
RuntimeException
{
}
src/LQDN/Handler/UserHandler.php
View file @
a899ac65
...
@@ -8,6 +8,14 @@ use LQDN\Command\UserUpdateTotalCommand;
...
@@ -8,6 +8,14 @@ use LQDN\Command\UserUpdateTotalCommand;
use
LQDN\Command\UserUpdateCumulCommand
;
use
LQDN\Command\UserUpdateCumulCommand
;
use
LQDN\Command\UserCreateCommand
;
use
LQDN\Command\UserCreateCommand
;
use
LQDN\Command\AdminUpdateTotalUsersCommand
;
use
LQDN\Command\AdminUpdateTotalUsersCommand
;
use
LQDN\Exception\InvalidEmailException
;
function
checkEmail
(
$email
)
{
if
(
!
filter_var
(
$email
,
FILTER_VALIDATE_EMAIL
))
{
throw
new
InvalidEmailException
();
}
}
class
UserHandler
class
UserHandler
{
{
...
@@ -25,6 +33,7 @@ class UserHandler
...
@@ -25,6 +33,7 @@ class UserHandler
*/
*/
public
function
handleUserUpdateByAdminCommand
(
UserUpdateByAdminCommand
$command
)
public
function
handleUserUpdateByAdminCommand
(
UserUpdateByAdminCommand
$command
)
{
{
checkEmail
(
$command
->
getEmail
());
$this
->
connection
->
executeUpdate
(
'UPDATE users SET pseudo = :username, email = :email, commentaire = :comment, cumul = :cumul, total = :total WHERE id = :id'
,
[
$this
->
connection
->
executeUpdate
(
'UPDATE users SET pseudo = :username, email = :email, commentaire = :comment, cumul = :cumul, total = :total WHERE id = :id'
,
[
'username'
=>
$command
->
getUsername
(),
'username'
=>
$command
->
getUsername
(),
'email'
=>
$command
->
getEmail
(),
'email'
=>
$command
->
getEmail
(),
...
@@ -42,6 +51,7 @@ class UserHandler
...
@@ -42,6 +51,7 @@ class UserHandler
*/
*/
public
function
handleUserCreateCommand
(
UserCreateCommand
$command
)
public
function
handleUserCreateCommand
(
UserCreateCommand
$command
)
{
{
checkEmail
(
$command
->
getEmail
());
$this
->
connection
->
executeUpdate
(
'INSERT INTO users(email, hash, pseudo, total, cumul) VALUES (:email, :hash, :pseudo, :total, :cumul)'
,
[
$this
->
connection
->
executeUpdate
(
'INSERT INTO users(email, hash, pseudo, total, cumul) VALUES (:email, :hash, :pseudo, :total, :cumul)'
,
[
'email'
=>
$command
->
getEmail
(),
'email'
=>
$command
->
getEmail
(),
'hash'
=>
$command
->
getHash
(),
'hash'
=>
$command
->
getHash
(),
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment