-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
394 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="ISO-8859-15"?> | ||
<OX> | ||
<OXMENU id="NAVIGATION_ESHOPADMIN"> | ||
<MAINMENU id="mxuadmin"> | ||
<SUBMENU id="mxusers"> | ||
<TAB id="tbcluser_greetings" cl="oemt_admin_greeting" /> | ||
</SUBMENU> | ||
</MAINMENU> | ||
</OXMENU> | ||
</OX> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\ModuleTemplate\Greeting\Controller\Admin; | ||
|
||
use OxidEsales\ModuleTemplate\Core\Module as ModuleCore; | ||
use OxidEsales\Eshop\Application\Controller\Admin\AdminController; | ||
use OxidEsales\ModuleTemplate\Extension\Model\User as TemplateModelUser; | ||
use OxidEsales\ModuleTemplate\Greeting\Service\UserServiceInterface; | ||
|
||
class GreetingAdminController extends AdminController | ||
{ | ||
protected $_sThisTemplate = '@oe_moduletemplate/admin/user_greetings'; | ||
|
||
public function render() | ||
{ | ||
$userService = $this->getService(UserServiceInterface::class); | ||
if ($this->getEditObjectId()) { | ||
/** @var TemplateModelUser $oUser */ | ||
$oUser = $userService->getUserById($this->getEditObjectId()); | ||
$this->addTplParam(ModuleCore::OEMT_ADMIN_GREETING_TEMPLATE_VARNAME, $oUser->getPersonalGreeting()); | ||
} | ||
|
||
return parent::render(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\ModuleTemplate\Greeting\Infrastructure; | ||
|
||
use OxidEsales\Eshop\Application\Model\User; | ||
|
||
class UserModelFactory implements UserModelFactoryInterface | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function create(): User | ||
{ | ||
return oxNew(User::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
namespace OxidEsales\ModuleTemplate\Greeting\Infrastructure; | ||
|
||
use OxidEsales\Eshop\Application\Model\User; | ||
|
||
interface UserModelFactoryInterface | ||
{ | ||
/** | ||
* @return User | ||
*/ | ||
public function create(): User; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\ModuleTemplate\Greeting\Service; | ||
|
||
use OxidEsales\Eshop\Application\Model\User as EshopModelUser; | ||
use OxidEsales\ModuleTemplate\Greeting\Infrastructure\UserModelFactoryInterface; | ||
|
||
/** | ||
* @extendable-class | ||
*/ | ||
class UserService implements UserServiceInterface | ||
{ | ||
/** | ||
* @var UserModelFactoryInterface | ||
*/ | ||
private $userModelFactory; | ||
|
||
public function __construct( | ||
UserModelFactoryInterface $userModelFactory | ||
) { | ||
$this->userModelFactory = $userModelFactory; | ||
} | ||
|
||
public function getUserById(string $userId): EshopModelUser | ||
{ | ||
$userModel = $this->userModelFactory->create(); | ||
$userModel->load($userId); | ||
|
||
return $userModel; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\ModuleTemplate\Greeting\Service; | ||
|
||
use OxidEsales\Eshop\Application\Model\User as EshopModelUser; | ||
|
||
interface UserServiceInterface | ||
{ | ||
public function getUserById(string $userId): EshopModelUser; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\ModuleTemplate\Tests\Codeception\Acceptance\Admin; | ||
|
||
use OxidEsales\Codeception\Module\Translation\Translator; | ||
use OxidEsales\ModuleTemplate\Tests\Codeception\Support\AcceptanceTester; | ||
|
||
/** | ||
* @group oe_moduletemplate | ||
* @group oe_moduletemplate_admin | ||
*/ | ||
final class GreetingAdminCest | ||
{ | ||
public function _before(AcceptanceTester $I): void | ||
{ | ||
//ensure each test start from same environment | ||
$I->setGreetingModeGeneric(); | ||
$this->setUserPersonalGreeting($I, 'Hello there!'); | ||
} | ||
|
||
public function _after(AcceptanceTester $I): void | ||
{ | ||
//clean up after each test | ||
$I->setGreetingModeGeneric(); | ||
} | ||
|
||
/** @param AcceptanceTester $I */ | ||
public function seeGreetingOptionsForUser(AcceptanceTester $I): void | ||
{ | ||
$I->openAdmin(); | ||
$adminPage = $I->loginAdmin(); | ||
|
||
$userList = $adminPage->openUsers(); | ||
$userList->find("where[oxuser][oxusername]", $I->getDemoUserName()); | ||
|
||
$I->selectEditFrame(); | ||
$I->see(Translator::translate('OEMODULETEMPLATE_ALLOW_GREETING')); | ||
|
||
$I->selectListFrame(); | ||
$I->click(Translator::translate('tbcluser_greetings')); | ||
|
||
$I->selectEditFrame(); | ||
$I->see(Translator::translate('OEMODULETEMPLATE_GREETING_TITLE')); | ||
$I->see('Hello there!'); | ||
} | ||
|
||
private function setUserPersonalGreeting(AcceptanceTester $I, string $value = ''): void | ||
{ | ||
$I->updateInDatabase( | ||
'oxuser', | ||
[ | ||
'oemtgreeting' => $value, | ||
], | ||
[ | ||
'oxusername' => $I->getDemoUserName(), | ||
] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,9 @@ | |
'email' => '[email protected]', | ||
'password' => 'useruser', | ||
], | ||
'adminUser' => [ | ||
'OXID' => 'oxadminuser', | ||
'email' => '[email protected]', | ||
'password' => 'useruser', | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#Add default user | ||
REPLACE INTO `oxuser` (`OXID`, `OXACTIVE`, `OXRIGHTS`, `OXSHOPID`, `OXUSERNAME`, `OXPASSWORD`, `OXPASSSALT`, `OXCREATE`, `OXREGISTER`, `OXTIMESTAMP`, `OXBIRTHDATE`) VALUES | ||
('oxdefaultuser',1,'user',1,'[email protected]','$2y$10$ljaDXMPHOyC7ELlnC5ErK.3ET4B0oAN3WVr/Tk.RKlUfiuBcQEVVC','', '2003-01-01 00:00:00', '2003-01-01 00:00:00', '2003-01-01 00:00:00', '1985-01-01'); | ||
('oxdefaultuser',1,'user',1,'[email protected]','$2y$10$ljaDXMPHOyC7ELlnC5ErK.3ET4B0oAN3WVr/Tk.RKlUfiuBcQEVVC','', '2003-01-01 00:00:00', '2003-01-01 00:00:00', '2003-01-01 00:00:00', '1985-01-01'), | ||
('oxadminuser',1,'malladmin',1,'[email protected]','$2y$10$ljaDXMPHOyC7ELlnC5ErK.3ET4B0oAN3WVr/Tk.RKlUfiuBcQEVVC','', '2003-01-01 00:00:00', '2003-01-01 00:00:00', '2003-01-01 00:00:00', '1985-01-01'); |
Oops, something went wrong.