Skip to content

Commit d8e5ef1

Browse files
author
Kopylova,Olga(okopylova)
committed
Merge pull request magento#123 from magento-ogre/develop
[Ogre's] Sprint 24 Contribution
2 parents 3ab5b37 + b10f2fb commit d8e5ef1

File tree

431 files changed

+34072
-32881
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

431 files changed

+34072
-32881
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\AdminNotification\Setup;
8+
9+
use Magento\Framework\Setup\InstallSchemaInterface;
10+
use Magento\Framework\Setup\ModuleContextInterface;
11+
use Magento\Framework\Setup\SchemaSetupInterface;
12+
13+
/**
14+
* @codeCoverageIgnore
15+
*/
16+
class InstallSchema implements InstallSchemaInterface
17+
{
18+
/**
19+
* {@inheritdoc}
20+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
21+
*/
22+
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
23+
{
24+
$installer = $setup;
25+
26+
$installer->startSetup();
27+
/**
28+
* Create table 'adminnotification_inbox'
29+
*/
30+
$table = $installer->getConnection()->newTable(
31+
$installer->getTable('adminnotification_inbox')
32+
)->addColumn(
33+
'notification_id',
34+
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
35+
null,
36+
['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
37+
'Notification id'
38+
)->addColumn(
39+
'severity',
40+
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
41+
null,
42+
['unsigned' => true, 'nullable' => false, 'default' => '0'],
43+
'Problem type'
44+
)->addColumn(
45+
'date_added',
46+
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
47+
null,
48+
['nullable' => false],
49+
'Create date'
50+
)->addColumn(
51+
'title',
52+
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
53+
255,
54+
['nullable' => false],
55+
'Title'
56+
)->addColumn(
57+
'description',
58+
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
59+
'64k',
60+
[],
61+
'Description'
62+
)->addColumn(
63+
'url',
64+
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
65+
255,
66+
[],
67+
'Url'
68+
)->addColumn(
69+
'is_read',
70+
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
71+
null,
72+
['unsigned' => true, 'nullable' => false, 'default' => '0'],
73+
'Flag if notification read'
74+
)->addColumn(
75+
'is_remove',
76+
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
77+
null,
78+
['unsigned' => true, 'nullable' => false, 'default' => '0'],
79+
'Flag if notification might be removed'
80+
)->addIndex(
81+
$installer->getIdxName('adminnotification_inbox', ['severity']),
82+
['severity']
83+
)->addIndex(
84+
$installer->getIdxName('adminnotification_inbox', ['is_read']),
85+
['is_read']
86+
)->addIndex(
87+
$installer->getIdxName('adminnotification_inbox', ['is_remove']),
88+
['is_remove']
89+
)->setComment(
90+
'Adminnotification Inbox'
91+
);
92+
$installer->getConnection()->createTable($table);
93+
94+
/**
95+
* Create table 'admin_system_messages'
96+
*/
97+
$table = $installer->getConnection()->newTable(
98+
$installer->getTable('admin_system_messages')
99+
)->addColumn(
100+
'identity',
101+
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
102+
100,
103+
['nullable' => false, 'primary' => true],
104+
'Message id'
105+
)->addColumn(
106+
'severity',
107+
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
108+
null,
109+
['unsigned' => true, 'nullable' => false, 'default' => '0'],
110+
'Problem type'
111+
)->addColumn(
112+
'created_at',
113+
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
114+
null,
115+
['nullable' => false],
116+
'Create date'
117+
)->setComment(
118+
'Admin System Messages'
119+
);
120+
$installer->getConnection()->createTable($table);
121+
122+
$installer->endSetup();
123+
124+
}
125+
}

app/code/Magento/AdminNotification/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
9-
<module name="Magento_AdminNotification" schema_version="2.0.0">
9+
<module name="Magento_AdminNotification" setup_version="2.0.0">
1010
<sequence>
1111
<module name="Magento_Core"/>
1212
<module name="Magento_Store"/>

app/code/Magento/AdminNotification/sql/adminnotification_setup/install-2.0.0.php

Lines changed: 0 additions & 112 deletions
This file was deleted.

app/code/Magento/Authorization/Model/Resource/Setup.php renamed to app/code/Magento/Authorization/Setup/AuthorizationFactory.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
* Copyright © 2015 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\Authorization\Model\Resource;
6+
namespace Magento\Authorization\Setup;
77

88
/**
99
* Resource Setup Model
1010
*
11-
* @SuppressWarnings(PHPMD.LongVariable)
12-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
11+
* @codeCoverageIgnore
1312
*/
14-
class Setup extends \Magento\Framework\Module\DataSetup
13+
class AuthorizationFactory
1514
{
1615
/**
1716
* Role model factory
@@ -42,30 +41,23 @@ class Setup extends \Magento\Framework\Module\DataSetup
4241
protected $_rulesFactory;
4342

4443
/**
45-
* @param \Magento\Framework\Module\Setup\Context $context
46-
* @param string $resourceName
44+
* Init
45+
*
4746
* @param \Magento\Authorization\Model\Resource\Role\CollectionFactory $roleCollectionFactory
4847
* @param \Magento\Authorization\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory
4948
* @param \Magento\Authorization\Model\RoleFactory $roleFactory
5049
* @param \Magento\Authorization\Model\RulesFactory $rulesFactory
51-
* @param string $moduleName
52-
* @param string $connectionName
5350
*/
5451
public function __construct(
55-
\Magento\Framework\Module\Setup\Context $context,
56-
$resourceName,
5752
\Magento\Authorization\Model\Resource\Role\CollectionFactory $roleCollectionFactory,
5853
\Magento\Authorization\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory,
5954
\Magento\Authorization\Model\RoleFactory $roleFactory,
60-
\Magento\Authorization\Model\RulesFactory $rulesFactory,
61-
$moduleName = 'Magento_Authorization',
62-
$connectionName = \Magento\Framework\Module\Updater\SetupInterface::DEFAULT_SETUP_CONNECTION
55+
\Magento\Authorization\Model\RulesFactory $rulesFactory
6356
) {
6457
$this->_roleCollectionFactory = $roleCollectionFactory;
6558
$this->_rulesCollectionFactory = $rulesCollectionFactory;
6659
$this->_roleFactory = $roleFactory;
6760
$this->_rulesFactory = $rulesFactory;
68-
parent::__construct($context, $resourceName, $moduleName, $connectionName);
6961
}
7062

7163
/**
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Authorization\Setup;
8+
9+
use Magento\Framework\Setup\InstallDataInterface;
10+
use Magento\Framework\Setup\ModuleContextInterface;
11+
use Magento\Framework\Setup\ModuleDataSetupInterface;
12+
use Magento\Authorization\Model\Acl\Role\Group as RoleGroup;
13+
use Magento\Authorization\Model\UserContextInterface;
14+
15+
/**
16+
* @codeCoverageIgnore
17+
*/
18+
class InstallData implements InstallDataInterface
19+
{
20+
/**
21+
* Authorization factory
22+
*
23+
* @var AuthorizationFactory
24+
*/
25+
private $authFactory;
26+
27+
/**
28+
* Init
29+
*
30+
* @param AuthorizationFactory $authFactory
31+
*/
32+
public function __construct(AuthorizationFactory $authFactory)
33+
{
34+
$this->authFactory = $authFactory;
35+
}
36+
37+
/**
38+
* {@inheritdoc}
39+
*/
40+
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
41+
{
42+
$roleCollection = $this->authFactory->createRoleCollection()
43+
->addFieldToFilter('parent_id', 0)
44+
->addFieldToFilter('tree_level', 1)
45+
->addFieldToFilter('role_type', RoleGroup::ROLE_TYPE)
46+
->addFieldToFilter('user_id', 0)
47+
->addFieldToFilter('user_type', UserContextInterface::USER_TYPE_ADMIN)
48+
->addFieldToFilter('role_name', 'Administrators');
49+
50+
if ($roleCollection->count() == 0) {
51+
$admGroupRole = $this->authFactory->createRole()->setData(
52+
[
53+
'parent_id' => 0,
54+
'tree_level' => 1,
55+
'sort_order' => 1,
56+
'role_type' => RoleGroup::ROLE_TYPE,
57+
'user_id' => 0,
58+
'user_type' => UserContextInterface::USER_TYPE_ADMIN,
59+
'role_name' => 'Administrators',
60+
]
61+
)->save();
62+
} else {
63+
foreach ($roleCollection as $item) {
64+
$admGroupRole = $item;
65+
break;
66+
}
67+
}
68+
69+
$rulesCollection = $this->authFactory->createRulesCollection()
70+
->addFieldToFilter('role_id', $admGroupRole->getId())
71+
->addFieldToFilter('resource_id', 'all');
72+
73+
if ($rulesCollection->count() == 0) {
74+
$this->authFactory->createRules()->setData(
75+
[
76+
'role_id' => $admGroupRole->getId(),
77+
'resource_id' => 'Magento_Backend::all',
78+
'privileges' => null,
79+
'permission' => 'allow',
80+
]
81+
)->save();
82+
} else {
83+
/** @var \Magento\Authorization\Model\Rules $rule */
84+
foreach ($rulesCollection as $rule) {
85+
$rule->setData('resource_id', 'Magento_Backend::all')->save();
86+
}
87+
}
88+
}
89+
}

0 commit comments

Comments
 (0)