Skip to content

Commit

Permalink
Merge pull request magento#123 from magento-ogre/develop
Browse files Browse the repository at this point in the history
[Ogre's] Sprint 24 Contribution
  • Loading branch information
Kopylova,Olga(okopylova) committed Mar 5, 2015
2 parents 3ab5b37 + b10f2fb commit d8e5ef1
Show file tree
Hide file tree
Showing 431 changed files with 34,072 additions and 32,881 deletions.
125 changes: 125 additions & 0 deletions app/code/Magento/AdminNotification/Setup/InstallSchema.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\AdminNotification\Setup;

use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;

/**
* @codeCoverageIgnore
*/
class InstallSchema implements InstallSchemaInterface
{
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$installer = $setup;

$installer->startSetup();
/**
* Create table 'adminnotification_inbox'
*/
$table = $installer->getConnection()->newTable(
$installer->getTable('adminnotification_inbox')
)->addColumn(
'notification_id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
'Notification id'
)->addColumn(
'severity',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '0'],
'Problem type'
)->addColumn(
'date_added',
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
null,
['nullable' => false],
'Create date'
)->addColumn(
'title',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
255,
['nullable' => false],
'Title'
)->addColumn(
'description',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'64k',
[],
'Description'
)->addColumn(
'url',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
255,
[],
'Url'
)->addColumn(
'is_read',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '0'],
'Flag if notification read'
)->addColumn(
'is_remove',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '0'],
'Flag if notification might be removed'
)->addIndex(
$installer->getIdxName('adminnotification_inbox', ['severity']),
['severity']
)->addIndex(
$installer->getIdxName('adminnotification_inbox', ['is_read']),
['is_read']
)->addIndex(
$installer->getIdxName('adminnotification_inbox', ['is_remove']),
['is_remove']
)->setComment(
'Adminnotification Inbox'
);
$installer->getConnection()->createTable($table);

/**
* Create table 'admin_system_messages'
*/
$table = $installer->getConnection()->newTable(
$installer->getTable('admin_system_messages')
)->addColumn(
'identity',
\Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
100,
['nullable' => false, 'primary' => true],
'Message id'
)->addColumn(
'severity',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '0'],
'Problem type'
)->addColumn(
'created_at',
\Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
null,
['nullable' => false],
'Create date'
)->setComment(
'Admin System Messages'
);
$installer->getConnection()->createTable($table);

$installer->endSetup();

}
}
2 changes: 1 addition & 1 deletion app/code/Magento/AdminNotification/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Magento_AdminNotification" schema_version="2.0.0">
<module name="Magento_AdminNotification" setup_version="2.0.0">
<sequence>
<module name="Magento_Core"/>
<module name="Magento_Store"/>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Authorization\Model\Resource;
namespace Magento\Authorization\Setup;

/**
* Resource Setup Model
*
* @SuppressWarnings(PHPMD.LongVariable)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @codeCoverageIgnore
*/
class Setup extends \Magento\Framework\Module\DataSetup
class AuthorizationFactory
{
/**
* Role model factory
Expand Down Expand Up @@ -42,30 +41,23 @@ class Setup extends \Magento\Framework\Module\DataSetup
protected $_rulesFactory;

/**
* @param \Magento\Framework\Module\Setup\Context $context
* @param string $resourceName
* Init
*
* @param \Magento\Authorization\Model\Resource\Role\CollectionFactory $roleCollectionFactory
* @param \Magento\Authorization\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory
* @param \Magento\Authorization\Model\RoleFactory $roleFactory
* @param \Magento\Authorization\Model\RulesFactory $rulesFactory
* @param string $moduleName
* @param string $connectionName
*/
public function __construct(
\Magento\Framework\Module\Setup\Context $context,
$resourceName,
\Magento\Authorization\Model\Resource\Role\CollectionFactory $roleCollectionFactory,
\Magento\Authorization\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory,
\Magento\Authorization\Model\RoleFactory $roleFactory,
\Magento\Authorization\Model\RulesFactory $rulesFactory,
$moduleName = 'Magento_Authorization',
$connectionName = \Magento\Framework\Module\Updater\SetupInterface::DEFAULT_SETUP_CONNECTION
\Magento\Authorization\Model\RulesFactory $rulesFactory
) {
$this->_roleCollectionFactory = $roleCollectionFactory;
$this->_rulesCollectionFactory = $rulesCollectionFactory;
$this->_roleFactory = $roleFactory;
$this->_rulesFactory = $rulesFactory;
parent::__construct($context, $resourceName, $moduleName, $connectionName);
}

/**
Expand Down
89 changes: 89 additions & 0 deletions app/code/Magento/Authorization/Setup/InstallData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Authorization\Setup;

use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Authorization\Model\Acl\Role\Group as RoleGroup;
use Magento\Authorization\Model\UserContextInterface;

/**
* @codeCoverageIgnore
*/
class InstallData implements InstallDataInterface
{
/**
* Authorization factory
*
* @var AuthorizationFactory
*/
private $authFactory;

/**
* Init
*
* @param AuthorizationFactory $authFactory
*/
public function __construct(AuthorizationFactory $authFactory)
{
$this->authFactory = $authFactory;
}

/**
* {@inheritdoc}
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$roleCollection = $this->authFactory->createRoleCollection()
->addFieldToFilter('parent_id', 0)
->addFieldToFilter('tree_level', 1)
->addFieldToFilter('role_type', RoleGroup::ROLE_TYPE)
->addFieldToFilter('user_id', 0)
->addFieldToFilter('user_type', UserContextInterface::USER_TYPE_ADMIN)
->addFieldToFilter('role_name', 'Administrators');

if ($roleCollection->count() == 0) {
$admGroupRole = $this->authFactory->createRole()->setData(
[
'parent_id' => 0,
'tree_level' => 1,
'sort_order' => 1,
'role_type' => RoleGroup::ROLE_TYPE,
'user_id' => 0,
'user_type' => UserContextInterface::USER_TYPE_ADMIN,
'role_name' => 'Administrators',
]
)->save();
} else {
foreach ($roleCollection as $item) {
$admGroupRole = $item;
break;
}
}

$rulesCollection = $this->authFactory->createRulesCollection()
->addFieldToFilter('role_id', $admGroupRole->getId())
->addFieldToFilter('resource_id', 'all');

if ($rulesCollection->count() == 0) {
$this->authFactory->createRules()->setData(
[
'role_id' => $admGroupRole->getId(),
'resource_id' => 'Magento_Backend::all',
'privileges' => null,
'permission' => 'allow',
]
)->save();
} else {
/** @var \Magento\Authorization\Model\Rules $rule */
foreach ($rulesCollection as $rule) {
$rule->setData('resource_id', 'Magento_Backend::all')->save();
}
}
}
}
Loading

0 comments on commit d8e5ef1

Please sign in to comment.