Permalink
Browse files

ID#255: added date of birth field for user.

  • Loading branch information...
Christian Achatz
Christian Achatz committed Jan 19, 2016
1 parent 39e7c66 commit dc74dbbede0c84a7c8b7324f2cb7edfb027481e3
@@ -21,6 +21,7 @@
namespace APF\modules\usermanagement\biz\model;
use APF\modules\usermanagement\biz\provider\UserFieldEncryptionProvider;
use DateTime;
/**
* This class represents the "APF\modules\usermanagement\biz\model\UmgtUser" domain object.
@@ -72,6 +73,22 @@ public function addRole(UmgtRole $role) {
$this->addRelatedObject('Role2User', $role);
}
/**
* @param DateTime $date The user's birth date.
*
* @return UmgtUser The domain object for further usage.
*/
public function setBirthday(DateTime $date) {
return parent::setDateOfBirth($date->format('Y-m-d'));
}
/**
* @return DateTime $date The user's birth date.
*/
public function getBirthday() {
return DateTime::createFromFormat('Y-m-d', parent::getDateOfBirth());
}
public function beforeSave() {
UserFieldEncryptionProvider::encryptProperties($this);
}
@@ -388,6 +388,33 @@ public function deleteDynamicSalt() {
return $this;
}
/**
* @return string The value for property "DateOfBirth".
*/
public function getDateOfBirth() {
return $this->getProperty('DateOfBirth');
}
/**
* @param string $value The value to set for property "DateOfBirth".
*
* @return UmgtUser The domain object for further usage.
*/
public function setDateOfBirth($value) {
$this->setProperty('DateOfBirth', $value);
return $this;
}
/**
* @return UmgtUser The domain object for further usage.
*/
public function deleteDateOfBirth() {
$this->deleteProperty('DateOfBirth');
return $this;
}
}
// DO NOT CHANGE THIS COMMENT! <*UmgtUserBase:end*>
@@ -21,6 +21,7 @@ CREATE TABLE IF NOT EXISTS `ent_user` (
`Username` VARCHAR(100) character set utf8 NOT NULL default '',
`Password` VARCHAR(100) character set utf8 NOT NULL default '',
`DynamicSalt` VARCHAR(50) character set utf8 NOT NULL default '',
`DateOfBirth` DATE NOT NULL default '0000-00-00',
`CreationTimestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
`ModificationTimestamp` timestamp NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`UserID`)
@@ -78,6 +78,10 @@
background-color: #eeeeee;
}

.umgt-content form #date-of-birth select {
width: 68px;
}

.umgt-content table.vis-def {
border: none;
width: 100%;
@@ -35,7 +35,7 @@ class GroupAddController extends UmgtBaseController {
public function transformContent() {
$form = & $this->getForm('GroupAdd');
if ($form->isSent() == true && $form->isValid() == true) {
if ($form->isSent() && $form->isValid()) {
$uM = & $this->getManager();
@@ -45,9 +45,9 @@ public function transformContent() {
$uM = & $this->getManager();
if ($form->isSent() == true) {
if ($form->isSent()) {
if ($form->isValid() == true) {
if ($form->isValid()) {
$group = new UmgtGroup();
$group->setObjectId($groupId);
@@ -38,7 +38,7 @@ public function transformContent() {
$form = & $this->getForm('PermissionAdd');
if ($form->isSent() == true && $form->isValid() == true) {
if ($form->isSent() && $form->isValid()) {
$displayName = $form->getFormElementByName('DisplayName');
$name = $form->getFormElementByName('Name');
@@ -48,9 +48,9 @@ public function transformContent() {
$uM = & $this->getManager();
if ($form->isSent() == true) {
if ($form->isSent()) {
if ($form->isValid() == true) {
if ($form->isValid()) {
$permission = new UmgtPermission();
$permission->setObjectId($permissionId);
@@ -50,7 +50,7 @@ public function transformContent() {
$permissionControl->addOption($roles[$i]->getDisplayName(), $roles[$i]->getObjectId());
}
if ($form->isSent() == true && $form->isValid() == true) {
if ($form->isSent() && $form->isValid()) {
$uM = & $this->getManager();
$role = new UmgtRole();
@@ -51,9 +51,9 @@ public function transformContent() {
// load selected roles to be able to highlight them within the select field
$role = $uM->loadRoleByID($roleId);
if ($form->isSent() == true) {
if ($form->isSent()) {
if ($form->isValid() == true) {
if ($form->isValid()) {
$displayName = & $form->getFormElementByName('DisplayName');
@@ -22,6 +22,7 @@
use APF\modules\usermanagement\biz\model\UmgtUser;
use APF\modules\usermanagement\pres\documentcontroller\UmgtBaseController;
use APF\tools\form\taglib\DateSelectorTag;
/**
* Implements the controller to add a user.
@@ -34,25 +35,28 @@ class UserAddController extends UmgtBaseController {
public function transformContent() {
$form = & $this->getForm('UserForm');
if ($form->isSent() == true && $form->isValid() == true) {
$form = &$this->getForm('UserForm');
if ($form->isSent() && $form->isValid()) {
$firstName = & $form->getFormElementByName('FirstName');
$lastName = & $form->getFormElementByName('LastName');
$streetName = & $form->getFormElementByName('StreetName');
$streetNumber = & $form->getFormElementByName('StreetNumber');
$zipCode = & $form->getFormElementByName('ZIPCode');
$city = & $form->getFormElementByName('City');
$email = & $form->getFormElementByName('EMail');
$mobile = & $form->getFormElementByName('Mobile');
$username = & $form->getFormElementByName('Username');
$password = & $form->getFormElementByName('Password');
$firstName = &$form->getFormElementByName('FirstName');
$lastName = &$form->getFormElementByName('LastName');
/* @var $birthday DateSelectorTag */
$birthday = &$form->getFormElementByName('Birthday');
$streetName = &$form->getFormElementByName('StreetName');
$streetNumber = &$form->getFormElementByName('StreetNumber');
$zipCode = &$form->getFormElementByName('ZIPCode');
$city = &$form->getFormElementByName('City');
$email = &$form->getFormElementByName('EMail');
$mobile = &$form->getFormElementByName('Mobile');
$username = &$form->getFormElementByName('Username');
$password = &$form->getFormElementByName('Password');
$uM = & $this->getManager();
$uM = &$this->getManager();
$user = new UmgtUser();
$user->setFirstName($firstName->getValue());
$user->setLastName($lastName->getValue());
$user->setBirthday($birthday->getValue());
$user->setStreetName($streetName->getValue());
$user->setStreetNumber($streetNumber->getValue());
$user->setZIPCode($zipCode->getValue());
@@ -23,6 +23,7 @@
use APF\modules\usermanagement\biz\model\UmgtUser;
use APF\modules\usermanagement\pres\documentcontroller\UmgtBaseController;
use APF\tools\form\taglib\AbstractFormControl;
use APF\tools\form\taglib\DateSelectorTag;
use APF\tools\form\validator\AbstractFormValidator;
/**
@@ -48,26 +49,28 @@ public function transformContent() {
$userId = $this->getRequest()->getParameter('userid');
// setup the form
$form = & $this->getForm('UserForm');
$fieldUserId = & $form->getFormElementByName('userid');
$form = &$this->getForm('UserForm');
$fieldUserId = &$form->getFormElementByName('userid');
$fieldUserId->setAttribute('value', $userId);
$firstName = & $form->getFormElementByName('FirstName');
$lastName = & $form->getFormElementByName('LastName');
$streetName = & $form->getFormElementByName('StreetName');
$streetNumber = & $form->getFormElementByName('StreetNumber');
$zipCode = & $form->getFormElementByName('ZIPCode');
$city = & $form->getFormElementByName('City');
$email = & $form->getFormElementByName('EMail');
$mobile = & $form->getFormElementByName('Mobile');
$username = & $form->getFormElementByName('Username');
$firstName = &$form->getFormElementByName('FirstName');
$lastName = &$form->getFormElementByName('LastName');
/* @var $birthday DateSelectorTag */
$birthday = &$form->getFormElementByName('Birthday');
$streetName = &$form->getFormElementByName('StreetName');
$streetNumber = &$form->getFormElementByName('StreetNumber');
$zipCode = &$form->getFormElementByName('ZIPCode');
$city = &$form->getFormElementByName('City');
$email = &$form->getFormElementByName('EMail');
$mobile = &$form->getFormElementByName('Mobile');
$username = &$form->getFormElementByName('Username');
// get the manager
$uM = & $this->getManager();
$uM = &$this->getManager();
if ($form->isSent() == true) {
if ($form->isSent()) {
if ($form->isValid() == true) {
if ($form->isValid()) {
// setup the domain object
$user = new UmgtUser();
@@ -76,6 +79,7 @@ public function transformContent() {
// read the "normal" fields
$user->setFirstName($firstName->getValue());
$user->setLastName($lastName->getValue());
$user->setBirthday($birthday->getValue());
$user->setStreetName($streetName->getValue());
$user->setStreetNumber($streetNumber->getValue());
$user->setZIPCode($zipCode->getValue());
@@ -85,8 +89,8 @@ public function transformContent() {
$user->setUsername($username->getValue());
// read the password field
$passField1 = & $form->getFormElementByName('Password');
$passField2 = & $form->getFormElementByName('Password2');
$passField1 = &$form->getFormElementByName('Password');
$passField2 = &$form->getFormElementByName('Password2');
$pass1 = $passField1->getAttribute('value');
$pass2 = $passField2->getAttribute('value');
@@ -125,15 +129,16 @@ public function transformContent() {
$user = $uM->loadUserByID($userId);
// pre-fill form
$firstName->setAttribute('value', $user->getFirstName());
$lastName->setAttribute('value', $user->getLastName());
$streetName->setAttribute('value', $user->getStreetName());
$streetNumber->setAttribute('value', $user->getStreetNumber());
$zipCode->setAttribute('value', $user->getZIPCode());
$city->setAttribute('value', $user->getCity());
$email->setAttribute('value', $user->getEMail());
$mobile->setAttribute('value', $user->getMobile());
$username->setAttribute('value', $user->getUsername());
$firstName->setValue($user->getFirstName());
$lastName->setValue($user->getLastName());
$birthday->setValue($user->getBirthday());
$streetName->setValue($user->getStreetName());
$streetNumber->setValue($user->getStreetNumber());
$zipCode->setValue($user->getZIPCode());
$city->setValue($user->getCity());
$email->setValue($user->getEMail());
$mobile->setValue($user->getMobile());
$username->setValue($user->getUsername());
$form->transformOnPlace();
@@ -146,6 +151,7 @@ private function getMarkerClass(AbstractFormControl &$control) {
if (empty($marker)) {
$marker = AbstractFormValidator::$DEFAULT_MARKER_CLASS;
}
return $marker;
}
@@ -16,6 +16,14 @@
</label>
<form:text name="LastName" maxlength="100"/>

<label>
<html:getstring
namespace="APF\modules\usermanagement\pres"
config="labels.ini"
entry="frontend.user.edit.form.birthday.label"/>
</label>
<form:date name="Birthday" id="date-of-birth" yearrange="1920-now"/>

<label>
<html:getstring
namespace="APF\modules\usermanagement\pres"

0 comments on commit dc74dbb

Please sign in to comment.