diff --git a/Admin/Install/db.json b/Admin/Install/db.json index fa7df64..dce64a4 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -160,58 +160,13 @@ "name": "profile_contact_element_content", "type": "VARCHAR(255)", "null": false - } - } - }, - "profile_contact_elementrel": { - "name": "profile_contact_elementrel", - "fields": { - "profile_contact_elementrel_id": { - "name": "profile_contact_elementrel_id", - "type": "INT", - "null": false, - "primary": true, - "autoincrement": true }, - "profile_contact_elementrel_contact": { - "name": "profile_contact_elementrel_contact", + "profile_contact_element_contact": { + "name": "profile_contact_element_contact", "type": "INT", "null": false, "foreignTable": "profile_contact", "foreignKey": "profile_contact_id" - }, - "profile_contact_elementrel_element": { - "name": "profile_contact_elementrel_element", - "type": "INT", - "null": false, - "foreignTable": "profile_contact_element", - "foreignKey": "profile_contact_element_id" - } - } - }, - "profile_contactelementrel": { - "name": "profile_contactelementrel", - "fields": { - "profile_contactelementrel_id": { - "name": "profile_contactelementrel_id", - "type": "INT", - "null": false, - "primary": true, - "autoincrement": true - }, - "profile_contactelementrel_profile": { - "name": "profile_contactelementrel_profile", - "type": "INT", - "null": false, - "foreignTable": "profile_account", - "foreignKey": "profile_account_id" - }, - "profile_contactelementrel_element": { - "name": "profile_contactelementrel_element", - "type": "INT", - "null": false, - "foreignTable": "profile_contact_element", - "foreignKey": "profile_contact_element_id" } } }, @@ -240,37 +195,5 @@ "foreignKey": "address_id" } } - }, - "profile_addressrel": { - "name": "profile_addressrel", - "fields": { - "profile_addressrel_id": { - "name": "profile_addressrel_id", - "type": "INT", - "null": false, - "primary": true, - "autoincrement": true - }, - "profile_addressrel_profile": { - "name": "profile_addressrel_profile", - "type": "INT", - "null": false, - "foreignTable": "profile_account", - "foreignKey": "profile_account_id" - }, - "profile_addressrel_public": { - "name": "profile_addressrel_public", - "type": "TINYINT", - "default": 1, - "null": false - }, - "profile_addressrel_address": { - "name": "profile_addressrel_address", - "type": "INT", - "null": false, - "foreignTable": "address", - "foreignKey": "address_id" - } - } } } \ No newline at end of file diff --git a/Admin/Routes/Web/Api.php b/Admin/Routes/Web/Api.php index 1939120..37f0bf5 100755 --- a/Admin/Routes/Web/Api.php +++ b/Admin/Routes/Web/Api.php @@ -20,7 +20,7 @@ use phpOMS\Account\PermissionType; use phpOMS\Router\RouteVerb; return [ - '^.*/profile.*$' => [ + '^.*/profile$' => [ [ 'dest' => '\Modules\Profile\Controller\ApiController:apiProfileCreate', 'verb' => RouteVerb::PUT, @@ -43,6 +43,17 @@ return [ ], ], ], + '^.*/profile/settings/password(\?.*|$)' => [ + [ + 'dest' => '\Modules\Admin\Controller\ApiController:apiSettingsAccountPasswordSet', + 'verb' => RouteVerb::SET, + 'permission' => [ + 'module' => AdminApiController::NAME, + 'type' => PermissionType::MODIFY, + 'state' => AdminPermissionCategory::ACCOUNT_SETTINGS, + ], + ], + ], '^.*/profile/settings/image(\?.*|$)' => [ [ 'dest' => '\Modules\Profile\Controller\ApiController:apiSettingsAccountImageSet', diff --git a/Models/PermissionCategory.php b/Models/PermissionCategory.php index 0435305..410adcd 100755 --- a/Models/PermissionCategory.php +++ b/Models/PermissionCategory.php @@ -29,4 +29,6 @@ abstract class PermissionCategory extends Enum public const PROFILE = 1; public const PROFILE_SETTINGS = 2; + + public const LOGIN = 3; } diff --git a/Models/Profile.php b/Models/Profile.php index 691098d..d18fda8 100755 --- a/Models/Profile.php +++ b/Models/Profile.php @@ -63,22 +63,6 @@ class Profile implements \JsonSerializable */ public Account $account; - /** - * Location data. - * - * @var Location[] - * @since 1.0.0 - */ - protected array $location = []; - - /** - * Contact data. - * - * @var ContactElement[] - * @since 1.0.0 - */ - protected array $contactElements = []; - /** * Gender. * @@ -95,6 +79,14 @@ class Profile implements \JsonSerializable */ protected int $sex = SexType::OTHER; + /** + * Confirmation key. + * + * @var string + * @since 1.0.0 + */ + public string $confirmation = ''; + /** * Constructor. * @@ -104,8 +96,8 @@ class Profile implements \JsonSerializable */ public function __construct(Account $account = null) { - $this->image = new NullMedia(); - $this->account = $account ?? new NullAccount(); + $this->image = new NullMedia(); + $this->account = $account ?? new NullAccount(); } /** @@ -184,58 +176,6 @@ class Profile implements \JsonSerializable $this->sex = $sex; } - /** - * Get account locations. - * - * @return Location[] - * - * @since 1.0.0 - */ - public function getLocation() : array - { - return $this->location; - } - - /** - * Add location. - * - * @param Location $location Location - * - * @return void - * - * @since 1.0.0 - */ - public function addLocation(Location $location) : void - { - $this->location[] = $location; - } - - /** - * Get account contact element. - * - * @return ContactElement[] - * - * @since 1.0.0 - */ - public function getContactElements() : array - { - return $this->contactElements; - } - - /** - * Add contact element. - * - * @param ContactElement $contactElement Contact Element - * - * @return void - * - * @since 1.0.0 - */ - public function addContactElement(ContactElement $contactElement) : void - { - $this->contactElements[] = $contactElement; - } - /** * {@inheritdoc} */ @@ -248,8 +188,6 @@ class Profile implements \JsonSerializable 'account' => $this->account, 'image' => $this->image, 'birthday' => $this->birthday, - 'locations' => $this->location, - 'contactelements' => $this->contactElements, ]; } diff --git a/Models/ProfileMapper.php b/Models/ProfileMapper.php index 4507a54..5f6d9b8 100755 --- a/Models/ProfileMapper.php +++ b/Models/ProfileMapper.php @@ -70,27 +70,6 @@ final class ProfileMapper extends DataMapperFactory ], ]; - /** - * Has many relation. - * - * @var array - * @since 1.0.0 - */ - public const HAS_MANY = [ - 'location' => [ - 'mapper' => AddressMapper::class, - 'table' => 'profile_addressrel', - 'external' => 'profile_addressrel_address', - 'self' => 'profile_addressrel_profile', - ], - 'contactElements' => [ - 'mapper' => ContactElementMapper::class, - 'table' => 'profile_contactelementrel', - 'self' => 'profile_contactelementrel_profile', - 'external' => 'profile_contactelementrel_element', - ], - ]; - /** * Model to use by the mapper. * diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 395f274..f2fc96c 100755 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -48,6 +48,10 @@ return ['Profile' => [ 'Long' => 'Long', 'Medium' => 'Medium', 'Name' => 'Name', + 'OldPassword' => 'Old Password', + 'NewPassword' => 'New Password', + 'RepeatPassword' => 'Repeat Password', + 'Password' => 'Password', 'NoAddressSpecified' => 'No address specified', 'NoContactSpecified' => 'No contact specified', 'Numberformat' => 'Numberformat', diff --git a/Theme/Backend/profile-single.tpl.php b/Theme/Backend/profile-single.tpl.php index 4d6e934..10012bb 100755 --- a/Theme/Backend/profile-single.tpl.php +++ b/Theme/Backend/profile-single.tpl.php @@ -44,9 +44,10 @@ echo $this->getData('nav')->render();
@@ -165,7 +166,9 @@ echo $this->getData('nav')->render();
- request->header->account === $account->getId()) : + request->header->account === $account->getId()) : $countryCodes = ISO3166TwoEnum::getConstants(); $countries = ISO3166NameEnum::getConstants(); $timezones = TimeZoneEnumArray::getConstants(); @@ -598,6 +601,39 @@ echo $this->getData('nav')->render(); + + + request->uri->fragment === 'c-tab-3' ? ' checked' : ''; ?>> +
+
+
+
+
+
getHtml('Password'); ?>
+
+
+ + +
+ +
+ + +
+ +
+ + +
+
+
+ +
+
+
+
+
+
diff --git a/tests/Controller/ApiControllerTest.php b/tests/Controller/ApiControllerTest.php index 3595fe5..22f0edb 100755 --- a/tests/Controller/ApiControllerTest.php +++ b/tests/Controller/ApiControllerTest.php @@ -60,7 +60,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase }; $this->app->dbPool = $GLOBALS['dbpool']; - $this->app->orgId = 1; + $this->app->unitId = 1; $this->app->accountManager = new AccountManager($GLOBALS['session']); $this->app->appSettings = new CoreSettings(); $this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../Modules/');