add gender and sex

This commit is contained in:
Dennis Eichhorn 2020-09-19 21:22:51 +02:00
parent b9e2b43997
commit e0d8f9e776
6 changed files with 160 additions and 11 deletions

View File

@ -20,6 +20,14 @@
"gdpr": true
}
},
"profile_account_gender": {
"name": "profile_account_gender",
"type": "INT"
},
"profile_account_sex": {
"name": "profile_account_sex",
"type": "INT"
},
"profile_account_birthday": {
"name": "profile_account_birthday",
"type": "DATETIME",

34
Models/GenderType.php Normal file
View File

@ -0,0 +1,34 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Profile\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Profile\Models;
use phpOMS\Stdlib\Base\Enum;
/**
* Gender type enum.
*
* @package Modules\Profile\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
abstract class GenderType extends Enum
{
public const OTHER = 1;
public const MALE = 2;
public const FEMALE = 3;
}

View File

@ -19,6 +19,7 @@ use Modules\Admin\Models\NullAccount;
use Modules\Media\Models\Media;
use Modules\Media\Models\NullMedia;
use phpOMS\Stdlib\Base\Location;
use phpOMS\Stdlib\Base\Exception\InvalidEnumValue;
/**
* Profile class.
@ -78,6 +79,22 @@ class Profile implements \JsonSerializable
*/
protected array $contactElements = [];
/**
* Gender.
*
* @var int
* @since 1.0.0
*/
protected int $gender = GenderType::OTHER;
/**
* Sex.
*
* @var int
* @since 1.0.0
*/
protected int $sex = SexType::OTHER;
/**
* Constructor.
*
@ -104,6 +121,70 @@ class Profile implements \JsonSerializable
return $this->id;
}
/**
* Get gender.
*
* @return int Returns the gender (GenderType)
*
* @since 1.0.0
*/
public function getGender() : int
{
return $this->gender;
}
/**
* Get gender.
*
* @param int $gender Gender
*
* @return void
*
* @throws InvalidEnumValue This exception is thrown if a invalid gender is used
*
* @since 1.0.0
*/
public function setGender(int $gender) : void
{
if (!GenderType::isValidValue($gender)) {
throw new InvalidEnumValue($gender);
}
$this->gender = $gender;
}
/**
* Get sex.
*
* @return int Returns the sex (SexType)
*
* @since 1.0.0
*/
public function getSex() : int
{
return $this->sex;
}
/**
* Get sex.
*
* @param int $sex Sex
*
* @return void
*
* @throws InvalidEnumValue This exception is thrown if a invalid sex is used
*
* @since 1.0.0
*/
public function setSex(int $sex) : void
{
if (!SexType::isValidValue($sex)) {
throw new InvalidEnumValue($sex);
}
$this->sex = $sex;
}
/**
* Get account locations.
*

View File

@ -39,6 +39,8 @@ final class ProfileMapper extends DataMapperAbstract
'profile_account_id' => ['name' => 'profile_account_id', 'type' => 'int', 'internal' => 'id'],
'profile_account_image' => ['name' => 'profile_account_image', 'type' => 'int', 'internal' => 'image', 'annotations' => ['gdpr' => true]],
'profile_account_birthday' => ['name' => 'profile_account_birthday', 'type' => 'DateTime', 'internal' => 'birthday', 'annotations' => ['gdpr' => true]],
'profile_account_gender' => ['name' => 'profile_account_gender', 'type' => 'int', 'internal' => 'gender', 'annotations' => ['gdpr' => true]],
'profile_account_sex' => ['name' => 'profile_account_sex', 'type' => 'int', 'internal' => 'sex', 'annotations' => ['gdpr' => true]],
'profile_account_account' => ['name' => 'profile_account_account', 'type' => 'int', 'internal' => 'account'],
];

34
Models/SexType.php Normal file
View File

@ -0,0 +1,34 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Profile\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Profile\Models;
use phpOMS\Stdlib\Base\Enum;
/**
* Sex type enum.
*
* @package Modules\Profile\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
abstract class SexType extends Enum
{
public const OTHER = 1;
public const MALE = 2;
public const FEMALE = 3;
}

View File

@ -53,7 +53,7 @@ echo $this->getData('nav')->render();
<input type="radio" id="c-tab-1" name="tabular-2"<?= $this->request->getUri()->getFragment() === 'c-tab-1' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6">
<div class="col-xs-12">
<div class="portlet" itemscope itemtype="http://schema.org/Person" itemtype="http://schema.org/Organization">
<div class="portlet-head">
<?php if (!empty($account->getName3()) || !empty($account->getName2())) : ?>
@ -144,16 +144,6 @@ echo $this->getData('nav')->render();
</div>
</div>
<div class="col-xs-12 col-md-6">
<div class="portlet">
<div class="portlet-head"><?= $this->getHtml('Visibility'); ?></div>
<div class="portlet-body">
<p>Define which users and user groups can see your profile</p>
<?= $this->getData('accGrpSelector')->render('iVisibility', 'visibility', true); ?>
</div>
</div>
</div>
<div class="col-xs-12">
<?= $this->getData('medialist')->render($media); ?>
</div>