From e6be33f1f2cd196acfb010eddc53e7c931fed428 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 8 Feb 2025 23:00:52 +0100 Subject: [PATCH] Fixes --- src/new/composer.lock | 24 +++++----- .../Controller/Backend/EditController.php | 20 ++++---- .../Form/Backend/General/AccountType.php | 11 +++++ .../core_account_create_and_edit.de.yml | 4 +- .../views/backend/edit/create.html.twig | 5 +- .../views/backend/edit/edit.html.twig | 3 ++ .../Controller/Backend/EditController.php | 5 -- .../Shop/CmsBundle/Form/Backend/CmsType.php | 14 ------ .../views/backend/edit/create.html.twig | 14 ------ .../views/backend/edit/edit.html.twig | 14 ------ .../PSC/Shop/EntityBundle/Document/Cms.php | 11 ----- .../PSC/Shop/EntityBundle/Entity/Account.php | 2 +- .../src/PSC/Shop/EntityBundle/Entity/Cms.php | 10 ---- .../application/data/models/AccountCms.php | 40 ++++++++++++++++ .../data/models/generated/BaseAccount.php | 15 ++++-- .../data/models/generated/BaseAccountCms.php | 47 +++++++++++++++++++ .../data/models/generated/BaseCms.php | 14 ++++-- src/old/application/helpers/Cms.php | 27 ++++++----- .../default/controllers/CmsController.php | 24 ++++++++-- 19 files changed, 187 insertions(+), 117 deletions(-) create mode 100644 src/old/application/data/models/AccountCms.php create mode 100644 src/old/application/data/models/generated/BaseAccountCms.php diff --git a/src/new/composer.lock b/src/new/composer.lock index 0f317cbd1..f5e44bdc7 100755 --- a/src/new/composer.lock +++ b/src/new/composer.lock @@ -6645,20 +6645,20 @@ }, { "name": "phpoffice/phpspreadsheet", - "version": "1.29.9", + "version": "1.29.10", "source": { "type": "git", "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", - "reference": "ffb47b639649fc9c8a6fa67977a27b756592ed85" + "reference": "c80041b1628c4f18030407134fe88303661d4e4e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/ffb47b639649fc9c8a6fa67977a27b756592ed85", - "reference": "ffb47b639649fc9c8a6fa67977a27b756592ed85", + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/c80041b1628c4f18030407134fe88303661d4e4e", + "reference": "c80041b1628c4f18030407134fe88303661d4e4e", "shasum": "" }, "require": { - "composer/pcre": "^3.3", + "composer/pcre": "^1||^2||^3", "ext-ctype": "*", "ext-dom": "*", "ext-fileinfo": "*", @@ -6745,9 +6745,9 @@ ], "support": { "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues", - "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.29.9" + "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.29.10" }, - "time": "2025-01-26T04:55:00+00:00" + "time": "2025-02-08T02:56:14+00:00" }, { "name": "phpstan/phpdoc-parser", @@ -15724,16 +15724,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.16", + "version": "1.12.17", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "e0bb5cb78545aae631220735aa706eac633a6be9" + "reference": "7027b3b0270bf392de0cfba12825979768d728bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e0bb5cb78545aae631220735aa706eac633a6be9", - "reference": "e0bb5cb78545aae631220735aa706eac633a6be9", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/7027b3b0270bf392de0cfba12825979768d728bf", + "reference": "7027b3b0270bf392de0cfba12825979768d728bf", "shasum": "" }, "require": { @@ -15778,7 +15778,7 @@ "type": "github" } ], - "time": "2025-01-21T14:50:05+00:00" + "time": "2025-02-07T15:01:57+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/src/new/src/PSC/Shop/AccountBundle/Controller/Backend/EditController.php b/src/new/src/PSC/Shop/AccountBundle/Controller/Backend/EditController.php index e211c4766..81c40200d 100755 --- a/src/new/src/PSC/Shop/AccountBundle/Controller/Backend/EditController.php +++ b/src/new/src/PSC/Shop/AccountBundle/Controller/Backend/EditController.php @@ -83,10 +83,10 @@ class EditController extends AbstractController $customFields = $fieldService->getFields(\PSC\System\PluginBundle\Form\Interfaces\Field::Account); $customGroups = $fieldService->getGroups(\PSC\System\PluginBundle\Form\Interfaces\Field::Account); $selectedShop = $shopService->getSelectedShop(); -/** @var Account $account */ + /** @var Account $account */ $account = new Account(); $account->shops[] = $selectedShop; -/** @var \PSC\Shop\EntityBundle\Document\Account $accountDoc */ + /** @var \PSC\Shop\EntityBundle\Document\Account $accountDoc */ $accountDoc = $documentManager ->getRepository('PSC\Shop\EntityBundle\Document\Account') ->findOneBy(array('uid' => (string)$account->getId())); @@ -158,11 +158,11 @@ class EditController extends AbstractController $customFields = $fieldService->getFields(\PSC\System\PluginBundle\Form\Interfaces\Field::Account); $customGroups = $fieldService->getGroups(\PSC\System\PluginBundle\Form\Interfaces\Field::Account); $selectedShop = $shopService->getSelectedShop(); -/** @var Account $account */ + /** @var Account $account */ $account = $entityManager ->getRepository('PSC\Shop\EntityBundle\Entity\Account') ->findOneBy(array('uid' => $uuid)); -/** @var \PSC\Shop\EntityBundle\Document\Account $accountDoc */ + /** @var \PSC\Shop\EntityBundle\Document\Account $accountDoc */ $accountDoc = $documentManager ->getRepository('PSC\Shop\EntityBundle\Document\Account') ->findOneBy(array('uid' => (string)$account->getId())); @@ -184,7 +184,9 @@ class EditController extends AbstractController $documentManager->flush(); } - $form = $this->createForm(AccountType::class, $account); + $form = $this->createForm(AccountType::class, $account, [ + 'cms' => $account->cms + ]); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $account->setProducts($this->merge([$account->getProductsOrg(), $account->getProductsSub()])); @@ -218,9 +220,9 @@ class EditController extends AbstractController private function merge($arrayCollections) { $returnCollection = new ArrayCollection(); -/** - * @var ArrayCollection $arrayCollection - */ + /** + * @var ArrayCollection $arrayCollection + */ foreach ($arrayCollections as $arrayCollection) { if ($returnCollection->count() === 0) { $returnCollection = $arrayCollection; @@ -228,7 +230,7 @@ class EditController extends AbstractController $arrayCollection->map(function ($element) use (&$returnCollection) { if (!$returnCollection->contains($element)) { - $returnCollection->add($element); + $returnCollection->add($element); } }); } diff --git a/src/new/src/PSC/Shop/AccountBundle/Form/Backend/General/AccountType.php b/src/new/src/PSC/Shop/AccountBundle/Form/Backend/General/AccountType.php index 1a7d51662..91ed86b98 100755 --- a/src/new/src/PSC/Shop/AccountBundle/Form/Backend/General/AccountType.php +++ b/src/new/src/PSC/Shop/AccountBundle/Form/Backend/General/AccountType.php @@ -50,12 +50,18 @@ class AccountType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { + $tempCms = [1]; + foreach ($options['cms'] as $cms) { + $tempCms[] = $cms->getUid(); + } + $builder ->add('title', TextType::class, ['label' => 'Name']) ->add('payments', EntityType::class, array( 'class' => 'PSC\Shop\EntityBundle\Entity\Payment', 'choice_label' => 'title', 'choice_value' => 'uid', + 'required' => false, 'multiple' => true, 'query_builder' => function (EntityRepository $er) { @@ -67,6 +73,7 @@ class AccountType extends AbstractType 'class' => 'PSC\Shop\EntityBundle\Entity\Shipping', 'choice_label' => 'title', 'choice_value' => 'uid', + 'required' => false, 'multiple' => true, 'query_builder' => function (EntityRepository $er) { @@ -85,6 +92,7 @@ class AccountType extends AbstractType } }, 'choice_value' => 'uid', + 'required' => false, 'multiple' => true, 'query_builder' => function (EntityRepository $er) { @@ -109,6 +117,7 @@ class AccountType extends AbstractType 'class' => 'PSC\Shop\EntityBundle\Entity\Product', 'choice_label' => 'nrTitle', 'multiple' => true, + 'required' => false, 'query_builder' => function (EntityRepository $er) { return $er->createQueryBuilder('u') @@ -118,6 +127,7 @@ class AccountType extends AbstractType ->add('productsSub', EntityType::class, array( 'class' => 'PSC\Shop\EntityBundle\Entity\Product', 'choice_label' => 'nrTitle', + 'required' => false, 'multiple' => true, 'query_builder' => function (EntityRepository $er) { @@ -227,6 +237,7 @@ class AccountType extends AbstractType { $resolver->setDefaults(array( 'data_class' => 'PSC\Shop\EntityBundle\Entity\Account', + 'cms' => [], 'translation_domain' => 'core_account_create_and_edit' )); } diff --git a/src/new/src/PSC/Shop/AccountBundle/Resources/translations/core_account_create_and_edit.de.yml b/src/new/src/PSC/Shop/AccountBundle/Resources/translations/core_account_create_and_edit.de.yml index 15d0acbd7..ae1b466fa 100755 --- a/src/new/src/PSC/Shop/AccountBundle/Resources/translations/core_account_create_and_edit.de.yml +++ b/src/new/src/PSC/Shop/AccountBundle/Resources/translations/core_account_create_and_edit.de.yml @@ -6,7 +6,7 @@ price: Preis Branding: Info & Branding bankdetails: Bankdaten advanced: Erweitert - +cms: CMS back: Zurück save: Speichern @@ -87,4 +87,4 @@ firsname1: Vorname 1 lastname1: Nachname 1 firsname12: Vorname 2 lastname2: Nachname 2 -extrasettings: Extra Einstellungen \ No newline at end of file +extrasettings: Extra Einstellungen diff --git a/src/new/src/PSC/Shop/AccountBundle/Resources/views/backend/edit/create.html.twig b/src/new/src/PSC/Shop/AccountBundle/Resources/views/backend/edit/create.html.twig index 9b6de587c..798899f81 100755 --- a/src/new/src/PSC/Shop/AccountBundle/Resources/views/backend/edit/create.html.twig +++ b/src/new/src/PSC/Shop/AccountBundle/Resources/views/backend/edit/create.html.twig @@ -367,6 +367,9 @@
+
{{'cms'|trans}}
+ {{ form_widget(form.cms) }} +
{{'paymentmethods'|trans}}
{{ form_widget(form.payments) }}
@@ -704,4 +707,4 @@
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/src/new/src/PSC/Shop/AccountBundle/Resources/views/backend/edit/edit.html.twig b/src/new/src/PSC/Shop/AccountBundle/Resources/views/backend/edit/edit.html.twig index 015fe00dc..b60537362 100755 --- a/src/new/src/PSC/Shop/AccountBundle/Resources/views/backend/edit/edit.html.twig +++ b/src/new/src/PSC/Shop/AccountBundle/Resources/views/backend/edit/edit.html.twig @@ -367,6 +367,9 @@
+
{{'cms'|trans}}
+ {{ form_widget(form.cms) }} +
{{'paymentmethods'|trans}}
{{ form_widget(form.payments) }}
diff --git a/src/new/src/PSC/Shop/CmsBundle/Controller/Backend/EditController.php b/src/new/src/PSC/Shop/CmsBundle/Controller/Backend/EditController.php index c1301d04f..3537d0cd5 100755 --- a/src/new/src/PSC/Shop/CmsBundle/Controller/Backend/EditController.php +++ b/src/new/src/PSC/Shop/CmsBundle/Controller/Backend/EditController.php @@ -108,8 +108,6 @@ class EditController extends AbstractController $cmsDoc->setExtraSettings($cms->getExtraSettings()); $cmsDoc->setPluginSettings($cms->getPluginSettings()); $cmsDoc->setNoIndex($cms->isNoIndex()); - $cmsDoc->setAccounts($cms->getAccounts()); - $documentManager->persist($cmsDoc); $documentManager->flush(); @@ -166,14 +164,12 @@ class EditController extends AbstractController if (!$request->isMethod('POST') && $cmsDoc) { $cms->setExtraSettings($cmsDoc->getExtraSettings()); $cms->setPluginSettings($cmsDoc->getPluginSettings()); - $cms->setAccounts($cmsDoc->getAccounts()); $cms->setNoIndex($cmsDoc->isNoIndex()); } elseif (!$cmsDoc) { $cmsDoc = new \PSC\Shop\EntityBundle\Document\Cms(); $cmsDoc->setUid($cms->getUid()); $cmsDoc->setExtraSettings($cms->getExtraSettings()); $cmsDoc->setNoIndex($cms->isNoIndex()); - $cmsDoc->setAccounts($cms->getAccounts()); $documentManager->persist($cmsDoc); $documentManager->flush(); } @@ -188,7 +184,6 @@ class EditController extends AbstractController $cmsDoc->setPluginSettings($cms->getPluginSettings()); $cmsDoc->setExtraSettings($cms->getExtraSettings()); $cmsDoc->setNoIndex($cms->isNoIndex()); - $cmsDoc->setAccounts($cms->getAccounts()); $this->historyService->createHistoryEntry(new PSCHistory((string)$cms->getUid()), $cms, $cmsDoc); $entityManager->persist($cms); diff --git a/src/new/src/PSC/Shop/CmsBundle/Form/Backend/CmsType.php b/src/new/src/PSC/Shop/CmsBundle/Form/Backend/CmsType.php index af2b2b1ea..6b1a459e4 100755 --- a/src/new/src/PSC/Shop/CmsBundle/Form/Backend/CmsType.php +++ b/src/new/src/PSC/Shop/CmsBundle/Form/Backend/CmsType.php @@ -84,14 +84,6 @@ class CmsType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { - $accounts = $this->entityManager->getRepository(Account::class)->createQueryBuilder('u') - ->join('u.shops', 's') - ->where('s.uid = :shop')->setParameter('shop', $this->shop->getSelectedShop()->getId())->getQuery()->execute(); - $defaultAccounts = []; - foreach ($accounts as $account) { - $defaultAccounts[$account->getTitle()] = $account->getUid(); - } - dump($defaultAccounts); $tmp = $this->buildCmsTree(['Oberste Ebene' => 0]); $builder ->add('title', TextType::class, ['label' => 'psc_shop_cms.Name', 'required' => false]) @@ -135,12 +127,6 @@ class CmsType extends AbstractType 'choices' => $this->language->getLanguageArrayForContent(), 'required' => true, )) - ->add('accounts', ChoiceType::class, array( - 'label' => 'psc_shop_cms.Accounts', - 'choices' => $defaultAccounts, - 'multiple' => true, - 'required' => false, - )) ->add('metaOgDescription', TextAreaType::class, ['label' => 'psc_shop_cms.OGDescription', 'required' => false]); /** @var \PSC\System\PluginBundle\Form\Interfaces\Field $field */ foreach ($this->fields->getFields(\PSC\System\PluginBundle\Form\Interfaces\Field::Cms) as $field) { diff --git a/src/new/src/PSC/Shop/CmsBundle/Resources/views/backend/edit/create.html.twig b/src/new/src/PSC/Shop/CmsBundle/Resources/views/backend/edit/create.html.twig index b215e1070..18b53b036 100755 --- a/src/new/src/PSC/Shop/CmsBundle/Resources/views/backend/edit/create.html.twig +++ b/src/new/src/PSC/Shop/CmsBundle/Resources/views/backend/edit/create.html.twig @@ -37,9 +37,6 @@ - {% for customGroup in customGroups %}
- {% for customGroup in customGroups %} -
- -
- {{ form_widget(form.accounts) }} -
- {{ form_errors(form.accounts) }} -
- {% for customGroup in customGroups %}
{% for customField in customFields %} diff --git a/src/new/src/PSC/Shop/CmsBundle/Resources/views/backend/edit/edit.html.twig b/src/new/src/PSC/Shop/CmsBundle/Resources/views/backend/edit/edit.html.twig index a614246d5..dd0388ddf 100755 --- a/src/new/src/PSC/Shop/CmsBundle/Resources/views/backend/edit/edit.html.twig +++ b/src/new/src/PSC/Shop/CmsBundle/Resources/views/backend/edit/edit.html.twig @@ -37,9 +37,6 @@ -
@@ -239,17 +236,6 @@
-
-
- -
- {{ form_widget(form.accounts) }} -
- {{ form_errors(form.accounts) }} -
-
diff --git a/src/new/src/PSC/Shop/EntityBundle/Document/Cms.php b/src/new/src/PSC/Shop/EntityBundle/Document/Cms.php index 0c36dcc49..c1ecfd1a7 100755 --- a/src/new/src/PSC/Shop/EntityBundle/Document/Cms.php +++ b/src/new/src/PSC/Shop/EntityBundle/Document/Cms.php @@ -29,8 +29,6 @@ class Cms #[Field(type: 'boolean')] protected bool $noIndex = false; - #[Field(type: 'hash')] - protected array $accounts = []; #[Field(type: 'hash')] protected $pluginSettings = []; @@ -120,13 +118,4 @@ class Cms { $this->noIndex = $noIndex; } - public function getAccounts(): array - { - return (array)$this->accounts; - } - - public function setAccounts(array $var): void - { - $this->accounts = $var; - } } diff --git a/src/new/src/PSC/Shop/EntityBundle/Entity/Account.php b/src/new/src/PSC/Shop/EntityBundle/Entity/Account.php index 6a03f033f..b051cc195 100755 --- a/src/new/src/PSC/Shop/EntityBundle/Entity/Account.php +++ b/src/new/src/PSC/Shop/EntityBundle/Entity/Account.php @@ -446,7 +446,7 @@ class Account #[ORM\JoinTable(name: 'account_cms')] #[ORM\JoinColumn(name: 'account_id', referencedColumnName: 'id')] - #[ORM\InverseJoinColumn(name: 'account_id', referencedColumnName: 'id')] + #[ORM\InverseJoinColumn(name: 'cms_id', referencedColumnName: 'id')] #[ORM\ManyToMany(targetEntity: 'Cms', inversedBy: 'accounts')] public $cms; diff --git a/src/new/src/PSC/Shop/EntityBundle/Entity/Cms.php b/src/new/src/PSC/Shop/EntityBundle/Entity/Cms.php index d9240d7db..0f2713cd9 100755 --- a/src/new/src/PSC/Shop/EntityBundle/Entity/Cms.php +++ b/src/new/src/PSC/Shop/EntityBundle/Entity/Cms.php @@ -29,7 +29,6 @@ class Cms { protected $extraSettings; - protected $accounts = []; protected $noIndex = false; protected $pluginSettings = []; @@ -694,13 +693,4 @@ class Cms { $this->noIndex = $noIndex; } - public function getAccounts(): array - { - return (array)$this->accounts; - } - - public function setAccounts(array $var): void - { - $this->accounts = $var; - } } diff --git a/src/old/application/data/models/AccountCms.php b/src/old/application/data/models/AccountCms.php new file mode 100644 index 000000000..64a403bcf --- /dev/null +++ b/src/old/application/data/models/AccountCms.php @@ -0,0 +1,40 @@ + + * @copyright 1997-2009 Thomas Peterson + * @license Not Public + * @version SVN: $Id: ContactPaymenttype.php 5162 2010-11-06 01:42:44Z boonkerz $ + * @link http://www.printshopcreator.de + */ + +/** + * ContactCms Modelclass + * + * ContactCms Modelsuperclass + * + * PHP versions 4 and 5 + * + * @category Data + * @package Model + * @subpackage Supermodel + * @author Thomas petersomn + * @copyright 1997-2009 Thomas Peterson + * @license Not Public + * @version Release: $Id: ContactPaymenttype.php 5162 2010-11-06 01:42:44Z boonkerz $ + * @link http://www.printshopcreator.de + */ + +class AccountCms extends BaseAccountCms +{ +} + diff --git a/src/old/application/data/models/generated/BaseAccount.php b/src/old/application/data/models/generated/BaseAccount.php index ec12eeb96..454c8621a 100755 --- a/src/old/application/data/models/generated/BaseAccount.php +++ b/src/old/application/data/models/generated/BaseAccount.php @@ -50,8 +50,8 @@ */ abstract class BaseAccount extends Doctrine_Record { - - public function setTableDefinition() { + public function setTableDefinition() + { $this->setTableName('account'); $this->hasColumn('id', 'integer', 8, array( 'primary' => true, @@ -230,7 +230,8 @@ abstract class BaseAccount extends Doctrine_Record $this->hasColumn('lastname2', 'string', 255); } - public function setUp() { + public function setUp() + { parent::setUp(); $this->hasOne('Install', array( 'local' => 'install_id', @@ -284,6 +285,12 @@ abstract class BaseAccount extends Doctrine_Record $this->hasMany('Motiv', array( 'local' => 'id', 'foreign' => 'account_id')); + + $this->hasMany('AccountCms', array( + 'local' => 'id', + 'foreign' => 'account_id')); + } -} \ No newline at end of file +} + diff --git a/src/old/application/data/models/generated/BaseAccountCms.php b/src/old/application/data/models/generated/BaseAccountCms.php new file mode 100644 index 000000000..501b1da4c --- /dev/null +++ b/src/old/application/data/models/generated/BaseAccountCms.php @@ -0,0 +1,47 @@ + + * @version SVN: $Id: BaseContactPaymenttype.php 5162 2010-11-06 01:42:44Z boonkerz $ + */ +abstract class BaseAccountCms extends Doctrine_Record +{ + public function setTableDefinition() + { + $this->setTableName('account_cms'); + $this->hasColumn('account_id', 'integer', 8, array( + 'type' => 'integer', + 'primary' => true, + 'length' => '8', + )); + $this->hasColumn('cms_id', 'integer', 8, array( + 'type' => 'integer', + 'primary' => true, + 'length' => '8', + )); + } + + public function setUp() + { + parent::setUp(); + $this->hasOne('Cms', array( + 'local' => 'cms_id', + 'foreign' => 'id')); + + $this->hasOne('Account', array( + 'local' => 'account_id', + 'foreign' => 'id')); + } +} + diff --git a/src/old/application/data/models/generated/BaseCms.php b/src/old/application/data/models/generated/BaseCms.php index 172b3e3f1..03f239bae 100755 --- a/src/old/application/data/models/generated/BaseCms.php +++ b/src/old/application/data/models/generated/BaseCms.php @@ -32,8 +32,8 @@ */ abstract class BaseCms extends Doctrine_Record { - - public function setTableDefinition() { + public function setTableDefinition() + { $this->setTableName('cms'); $this->hasColumn('id', 'integer', 8, array( 'primary' => true, @@ -128,7 +128,8 @@ abstract class BaseCms extends Doctrine_Record $this->hasColumn('enable', 'boolean'); } - public function setUp() { + public function setUp() + { parent::setUp(); $this->hasOne('Install', array( 'local' => 'install_id', @@ -149,6 +150,10 @@ abstract class BaseCms extends Doctrine_Record $this->hasMany('ContactCms', array( 'local' => 'id', 'foreign' => 'cms_id')); + $this->hasMany('AccountCms', array( + 'local' => 'id', + 'foreign' => 'cms_id')); + $sluggable0 = new Doctrine_Template_Sluggable(array( 'unique' => true, @@ -165,4 +170,5 @@ abstract class BaseCms extends Doctrine_Record $this->actAs($sluggable0); } -} \ No newline at end of file +} + diff --git a/src/old/application/helpers/Cms.php b/src/old/application/helpers/Cms.php index 8cf48e482..839f932e4 100755 --- a/src/old/application/helpers/Cms.php +++ b/src/old/application/helpers/Cms.php @@ -29,24 +29,29 @@ class TP_View_Helper_Cms $tmp = []; + foreach ($cms as $row) { + $tmp[] = $row; + } + if (Zend_Auth::getInstance()->hasIdentity()) { - $accountId = Zend_Auth::getInstance()->getIdentity()['account_id']; + $user = Zend_Auth::getInstance()->getIdentity(); + + $cms = Doctrine_Query::create()->from('Cms c')->leftJoin('c.ContactCms a')->where('c.private = 1 AND c.enable = 1 AND a.contact_id = ? AND c.shop_id = ? AND + (c.language = ? OR language = \'all\')', array($user['id'], $shop ['id'], Zend_Registry::get('locale')))->orderBy('c.sor ASC')->execute(); foreach ($cms as $row) { - $accounts = $row->getAccounts(); - if (count($accounts) === 0 || in_array($accountId, $accounts)) { - $tmp[] = $row; - } + $tmp[] = $row; + } + + $cms = Doctrine_Query::create()->from('Cms c')->leftJoin('c.AccountCms a')->where('c.private = 1 AND c.enable = 1 AND a.account_id = ? AND c.shop_id = ? AND + (c.language = ? OR language = \'all\')', array($user['account_id'], $shop ['id'], Zend_Registry::get('locale')))->orderBy('c.sor ASC')->execute(); + + foreach ($cms as $row) { + $tmp[] = $row; } return $tmp; } - foreach ($cms as $row) { - $accounts = $row->getAccounts(); - if (count($accounts) === 0) { - $tmp[] = $row; - } - } return $tmp; diff --git a/src/old/application/modules/default/controllers/CmsController.php b/src/old/application/modules/default/controllers/CmsController.php index b46fe6453..5950c7a1b 100755 --- a/src/old/application/modules/default/controllers/CmsController.php +++ b/src/old/application/modules/default/controllers/CmsController.php @@ -35,8 +35,8 @@ */ class CmsController extends TP_Controller_Action { - - public function preDispatch() { + public function preDispatch() + { //self::preDispatch(); } @@ -48,7 +48,8 @@ class CmsController extends TP_Controller_Action * @param string $page * @return void */ - public function indexAction($page = 'Overview') { + public function indexAction($page = 'Overview') + { $this->view->actmenu[] = $this->_request->getParam('page'); @@ -86,7 +87,20 @@ class CmsController extends TP_Controller_Action return; } - if ($page->display_only_logged_in && !Zend_Auth::getInstance()->hasIdentity()) { + + if ($page->private && Zend_Auth::getInstance()->hasIdentity()) { + $user = Zend_Auth::getInstance()->getIdentity(); + $count = 0; + $cms += Doctrine_Query::create()->from('ContactCms c')->where('c.contact_id = ? AND c.cms_id = ?', array($user['id'], $page->id))->execute()->count(); + + $cms += Doctrine_Query::create()->from('AccountCms a')->where('a.account_id = ? AND a.cms_id = ?', array($user['account_id'], $page->id))->execute()->count(); + + if ($cms === 0) { + $this->_redirect('/user/login'); + } + } + + if (($page->private || $page->display_only_logged_in) && !Zend_Auth::getInstance()->hasIdentity()) { $this->_redirect('/user/login'); } @@ -181,7 +195,7 @@ class CmsController extends TP_Controller_Action if ($this->shop->private && !Zend_Auth::getInstance()->hasIdentity()) { $this->_helper->layout->setLayout('private'); } - if($this->view->page->template != "") { + if ($this->view->page->template != "") { $this->render($this->view->page->template); } if ($this->_getParam('help')) {