Skip to content

Commit

Permalink
Merge pull request afup#13 from Koin/master
Browse files Browse the repository at this point in the history
Finalisation de la partie membre
  • Loading branch information
ubermuda committed Feb 5, 2012
2 parents 9f93dce + 51ff814 commit 57194b1
Show file tree
Hide file tree
Showing 31 changed files with 15,713 additions and 1,769 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ deps.lock
.buildpath
.project
.settings/
*.*~
5 changes: 5 additions & 0 deletions app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
'Aperophp' => __DIR__.'/../src/'
));

// Utils
$app['utils'] = $app->share(function() use ($app) {
return new \Aperophp\Lib\Utils($app);
});

use Silex\Provider\SymfonyBridgesServiceProvider;
use Silex\Provider\UrlGeneratorServiceProvider;
use Silex\Provider\TwigServiceProvider;
Expand Down
5 changes: 4 additions & 1 deletion app/config.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ $app['db.options'] = array(
'user' => '',
'password' => '',
);
*/
*/

// Secret string
$app['secret'] = 'change_me_im_not_secret';
25 changes: 22 additions & 3 deletions data/sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,29 @@ CREATE TABLE IF NOT EXISTS `User` (
`id` INT NOT NULL AUTO_INCREMENT ,
`lastname` VARCHAR(80) NULL ,
`firstname` VARCHAR(80) NULL ,
`username` VARCHAR(80) NOT NULL ,
`password` VARCHAR(64) NOT NULL ,
`actived` TINYINT(1) NOT NULL ,
`email` VARCHAR(80) NOT NULL ,
`token` VARCHAR(64) NULL ,
`member_id` INT NULL ,
PRIMARY KEY (`id`) ,
INDEX `fk_User_Member` (`member_id` ASC) ,
CONSTRAINT `fk_User_Member`
FOREIGN KEY (`member_id` )
REFERENCES `Member` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `Member`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `Member` ;

CREATE TABLE IF NOT EXISTS `Member` (
`id` INT NOT NULL AUTO_INCREMENT ,
`username` VARCHAR(80) NOT NULL ,
`password` VARCHAR(80) NOT NULL ,
`active` TINYINT(1) NOT NULL DEFAULT '1' ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,21 @@
use Symfony\Component\Validator\Constraints;

/**
* Signup form.
* Edit member form.
*
* @author Koin <[email protected]>
* @since 22 janv. 2012
* @version 1.0 - 22 janv. 2012 - Koin <[email protected]>
* @since 4 févr. 2012
* @version 1.0 - 4 févr. 2012 - Koin <[email protected]>
*/
class Signup extends AbstractType
class EditMemberType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('lastname', 'text')
->add('firstname', 'text')
->add('username', 'text')
->add('lastname', 'text', array('label' => 'Nom', 'required' => false, 'attr' => array('placeholder' => 'Facultatif.')))
->add('firstname', 'text', array('label' => 'Prénom', 'required' => false, 'attr' => array('placeholder' => 'Facultatif.')))
->add('email', 'email')
->add('password', 'password');
->add('password', 'password', array('label' => 'Mot de passe', 'required' => false));
}

public function getDefaultOptions(array $options)
Expand All @@ -32,9 +31,11 @@ public function getDefaultOptions(array $options)
'fields' => array(
'lastname' => new Constraints\MaxLength(array('limit' => 80)),
'firstname' => new Constraints\MaxLength(array('limit' => 80)),
'username' => new Constraints\MaxLength(array('limit' => 80)),
'email' => new Constraints\Email(),
'password' => new Constraints\NotNull(),
'email' => array(
new Constraints\Email(),
new Constraints\NotNull(),
),
'password' => new Constraints\MaxLength(array('limit' => 80)),
),
'allowExtraFields' => false,
));
Expand Down
49 changes: 49 additions & 0 deletions src/Aperophp/Form/SigninType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Aperophp\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;

use Symfony\Component\Validator\Constraints;

/**
* Signin form.
*
* @author Koin <[email protected]>
* @since 4 févr. 2012
* @version 1.0 - 4 févr. 2012 - Koin <[email protected]>
*/
class SigninType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('username', 'text', array('label' => 'Identifiant'))
->add('password', 'password', array('label' => 'Mot de passe'));
}

public function getDefaultOptions(array $options)
{
$collectionConstraint = new Constraints\Collection(array(
'fields' => array(
'username' => array(
new Constraints\MaxLength(array('limit' => 80)),
new Constraints\NotNull(),
),
'password' => array(
new Constraints\MaxLength(array('limit' => 80)),
new Constraints\NotNull(),
),
),
'allowExtraFields' => false,
));

return array('validation_constraint' => $collectionConstraint);
}

public function getName()
{
return 'signin';
}
}
58 changes: 58 additions & 0 deletions src/Aperophp/Form/SignupType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace Aperophp\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;

use Symfony\Component\Validator\Constraints;

/**
* Signup form.
*
* @author Koin <[email protected]>
* @since 22 janv. 2012
* @version 1.0 - 22 janv. 2012 - Koin <[email protected]>
*/
class SignupType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('lastname', 'text', array('label' => 'Nom', 'required' => false, 'attr' => array('placeholder' => 'Facultatif.')))
->add('firstname', 'text', array('label' => 'Prénom', 'required' => false, 'attr' => array('placeholder' => 'Facultatif.')))
->add('username', 'text', array('label' => 'Identifiant'))
->add('email', 'email')
->add('password', 'password', array('label' => 'Mot de passe'));
}

public function getDefaultOptions(array $options)
{
$collectionConstraint = new Constraints\Collection(array(
'fields' => array(
'lastname' => new Constraints\MaxLength(array('limit' => 80)),
'firstname' => new Constraints\MaxLength(array('limit' => 80)),
'username' => array(
new Constraints\MaxLength(array('limit' => 80)),
new Constraints\NotNull(),
),
'email' => array(
new Constraints\Email(),
new Constraints\NotNull(),
),
'password' => array(
new Constraints\MaxLength(array('limit' => 80)),
new Constraints\NotNull(),
),
),
'allowExtraFields' => false,
));

return array('validation_constraint' => $collectionConstraint);
}

public function getName()
{
return 'signup';
}
}
37 changes: 37 additions & 0 deletions src/Aperophp/Lib/Utils.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Aperophp\Lib;

/**
* Aperophp utils.
*
* @author Koin <[email protected]>
* @since 4 févr. 2012
* @version 1.0 - 4 févr. 2012 - Koin <[email protected]>
*/
class Utils
{
protected
$app;

public function __construct($app)
{
$this->app = $app;
}

/**
* Hash my string.
*
* @author Koin <[email protected]>
* @since 4 févr. 2012
* @version 1.1 - 4 févr. 2012 - Koin <[email protected]>
* @param string $str
* @param string $salt
* @return string
*/
public function hash($str, $salt = null)
{
$salt = $salt ? $salt : $this->app['secret'];
return sha1($str.$salt);
}
}
Loading

0 comments on commit 57194b1

Please sign in to comment.