Magazento_Ordersaccess - Version 1.0.1

Version Notes

1.0.1 Stable

Download this release

Release Info

Developer Dmitry Poddubny
Extension Magazento_Ordersaccess
Version 1.0.1
Comparing to
See all releases


Version 1.0.1

app/code/community/Magazento/Orderaccess/Admin/Model/Mysql4/Roles.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magazento_Orderaccess_Admin_Model_Mysql4_Roles extends Mage_Admin_Model_Mysql4_Roles
4
+ {
5
+ //app/code/core/Mage/Admin/Model/Mysql4/Roles.php _afterSave _afterLoad
6
+ protected function _afterSave(Mage_Core_Model_Abstract $role)
7
+ {
8
+ $this->_updateRoleUsersAcl($role);
9
+ Mage::app()->getCache()->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,
10
+ array(Mage_Adminhtml_Block_Page_Menu::CACHE_TAGS));
11
+
12
+ $condition = $this->_getWriteAdapter()->quoteInto('admin_role_id = ?', $role->getId());
13
+ $this->_getWriteAdapter()->delete('magazento_orderaccess_role_group', $condition);
14
+ print_r($role->getData('customer_group_ids')); exit();
15
+ foreach ($role->getData('customer_group_ids') as $customerGroupId) {
16
+ $customerGroupArray = array();
17
+ $customerGroupArray['admin_role_id'] = $role->getId();
18
+ $customerGroupArray['customer_group_id'] = $customerGroupId;
19
+ $this->_getWriteAdapter()->insert('magazento_orderaccess_role_group', $customerGroupArray);
20
+ }
21
+ return $this;
22
+ }
23
+
24
+ protected function _afterLoad(Mage_Core_Model_Abstract $role) {
25
+
26
+ $select = $this->_getReadAdapter()->select()
27
+ ->from(array('group' => 'customer_group'))
28
+ ->joinLeft(array(
29
+ 'role_group' => 'magazento_orderaccess_role_group'),
30
+ 'role_group.customer_group_id = group.customer_group_id',
31
+ array())
32
+ ->where('role_group.admin_role_id = ?', $role->getId());
33
+
34
+ if ($data = $this->_getReadAdapter()->fetchAll($select)) {
35
+ $customerGroupIdArray = array();
36
+ foreach ($data as $row) {
37
+ $customerGroupIdArray[] = $row['customer_group_id'];
38
+ }
39
+ $role->setData('customer_group_ids', $customerGroupIdArray);
40
+ }
41
+
42
+ return $this;
43
+ }
44
+
45
+ }
app/code/community/Magazento/Orderaccess/Admin/Model/Roles.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Admin
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ echo '<p>Magazento_Orderaccess_Admin_Model_Roles</p>';
28
+
29
+ class Magazento_Orderaccess_Admin_Model_Roles extends Mage_Admin_Model_Roles
30
+ {
31
+ /**
32
+ * @var string
33
+ */
34
+ protected $_eventPrefix = 'admin_roles';
35
+
36
+ protected function _construct()
37
+ {
38
+ $this->_init('admin/roles');
39
+ }
40
+
41
+ public function update()
42
+ {
43
+ $this->getResource()->update($this);
44
+ return $this;
45
+ }
46
+
47
+ public function getUsersCollection()
48
+ {
49
+ return Mage::getResourceModel('admin/roles_user_collection');
50
+ }
51
+
52
+ public function getResourcesTree()
53
+ {
54
+ return $this->_buildResourcesArray(null, null, null, null, true);
55
+ }
56
+
57
+ public function getResourcesList()
58
+ {
59
+ return $this->_buildResourcesArray();
60
+ }
61
+
62
+ public function getResourcesList2D()
63
+ {
64
+ return $this->_buildResourcesArray(null, null, null, true);
65
+ }
66
+
67
+ public function getRoleUsers()
68
+ {
69
+ return $this->getResource()->getRoleUsers($this);
70
+ }
71
+
72
+ protected function _buildResourcesArray(Varien_Simplexml_Element $resource=null, $parentName=null, $level=0, $represent2Darray=null, $rawNodes = false, $module = 'adminhtml')
73
+ {
74
+ static $result;
75
+ if (is_null($resource)) {
76
+ $resource = Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode('acl/resources');
77
+ $resourceName = null;
78
+ $level = -1;
79
+ } else {
80
+ $resourceName = $parentName;
81
+ if ($resource->getName()!='title' && $resource->getName()!='sort_order' && $resource->getName() != 'children') {
82
+ $resourceName = (is_null($parentName) ? '' : $parentName.'/').$resource->getName();
83
+
84
+ //assigning module for its' children nodes
85
+ if ($resource->getAttribute('module')) {
86
+ $module = (string)$resource->getAttribute('module');
87
+ }
88
+
89
+ if ($rawNodes) {
90
+ $resource->addAttribute("aclpath", $resourceName);
91
+ $resource->addAttribute("module_c", $module);
92
+ }
93
+
94
+ if ( is_null($represent2Darray) ) {
95
+ $result[$resourceName]['name'] = Mage::helper($module)->__((string)$resource->title);
96
+ $result[$resourceName]['level'] = $level;
97
+ } else {
98
+ $result[] = $resourceName;
99
+ }
100
+ }
101
+ }
102
+
103
+ $children = $resource->children();
104
+ if (empty($children)) {
105
+ if ($rawNodes) {
106
+ return $resource;
107
+ } else {
108
+ return $result;
109
+ }
110
+ }
111
+ foreach ($children as $child) {
112
+ $this->_buildResourcesArray($child, $resourceName, $level+1, $represent2Darray, $rawNodes, $module);
113
+ }
114
+ if ($rawNodes) {
115
+ return $resource;
116
+ } else {
117
+ return $result;
118
+ }
119
+ }
120
+
121
+ }
app/code/community/Magazento/Orderaccess/Adminhtml/Block/Permissions/Tab/Roleinfo.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magazento_Orderaccess_Adminhtml_Block_Permissions_Tab_Roleinfo extends Mage_Adminhtml_Block_Permissions_Tab_Roleinfo implements Mage_Adminhtml_Block_Widget_Tab_Interface {
4
+
5
+ protected function _initForm() {
6
+
7
+ $roleId = $this->getRequest()->getParam('rid');
8
+
9
+ $form = new Varien_Data_Form();
10
+
11
+ $fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('adminhtml')->__('Role Information')));
12
+
13
+ $fieldset->addField('role_name', 'text',
14
+ array(
15
+ 'name' => 'rolename',
16
+ 'label' => Mage::helper('adminhtml')->__('Role Name'),
17
+ 'id' => 'role_name',
18
+ 'class' => 'required-entry',
19
+ 'required' => true,
20
+ )
21
+ );
22
+ /*
23
+ $groups = Mage::getResourceModel('customer/group_collection')
24
+ ->addFieldToFilter('customer_group_id', array('gt'=> 0))
25
+ ->load()
26
+ ->toOptionHash();
27
+ $groups = array(0 => 'Not selected') + $groups;
28
+ $fieldset->addField('customer_group_id', 'select', array(
29
+ 'name' => 'customer_group_id',
30
+ 'label' => Mage::helper('adminhtml')->__('Customer group'),
31
+ 'required' => false,
32
+ 'values' => $groups,
33
+ ));
34
+ */
35
+ $groups = array();
36
+ //$groups = array(array('label' => 'All groups', 'value' => '0'));
37
+ $collection = Mage::getResourceModel('customer/group_collection');
38
+ foreach ($collection as $group) {
39
+ $groups[] = ( array(
40
+ 'label' => (string) $group->getCustomerGroupCode(),
41
+ 'value' => $group->getCustomerGroupId()
42
+ ));
43
+ }
44
+
45
+ $fieldset->addField('customer_group_ids', 'multiselect', array(
46
+ 'name' => 'customer_group_ids[]',
47
+ 'label' => Mage::helper('adminhtml')->__('Customer groups'),
48
+ 'title' => Mage::helper('adminhtml')->__('Customer groups'),
49
+ 'required' => false,
50
+ 'style' => 'height:150px',
51
+ 'values' => $groups
52
+ ));
53
+
54
+
55
+
56
+ $fieldset->addField('role_id', 'hidden',
57
+ array(
58
+ 'name' => 'role_id',
59
+ 'id' => 'role_id',
60
+ )
61
+ );
62
+
63
+ $fieldset->addField('in_role_user', 'hidden',
64
+ array(
65
+ 'name' => 'in_role_user',
66
+ 'id' => 'in_role_userz',
67
+ )
68
+ );
69
+
70
+ $fieldset->addField('in_role_user_old', 'hidden', array('name' => 'in_role_user_old'));
71
+
72
+ $form->setValues($this->getRole()->getData());
73
+ $this->setForm($form);
74
+ }
75
+
76
+ }
app/code/community/Magazento/Orderaccess/Adminhtml/Block/Sales/Order/Grid.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magazento_Orderaccess_Adminhtml_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid {
4
+
5
+ protected function _prepareCollection() {
6
+ if (Mage::getStoreConfig('orderaccess/options/enabled')) {
7
+ $user = Mage::getSingleton('admin/session')->getUser();
8
+ $roleId = implode('', $user->getRoles());
9
+ $customerGroupIds = Mage::getModel('admin/roles')->load($roleId)->getCustomerGroupIds();
10
+ $customers = Mage::getResourceModel('customer/customer_collection');
11
+ if (count($customerGroupIds)) {
12
+ $customers->addAttributeToFilter('group_id', array('in' => $customerGroupIds));
13
+ }
14
+ $customerIds = $customers->getAllIds();
15
+
16
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
17
+ $collection->addAttributeToFilter('customer_id', array('in' => $customerIds));
18
+ $this->setCollection($collection);
19
+ return $collection;
20
+ } else {
21
+ return parent::_prepareCollection();
22
+ }
23
+ }
24
+
25
+ }
app/code/community/Magazento/Orderaccess/Block/Developer.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magazento_Orderaccess_Block_Developer extends Mage_Adminhtml_Block_System_Config_Form_Fieldset {
4
+
5
+ public function render(Varien_Data_Form_Element_Abstract $element) {
6
+ $content = '<p></p>';
7
+ $content.= '<style>';
8
+ $content.= '.magazento {
9
+ background:#FAFAFA;
10
+ border: 1px solid #CCCCCC;
11
+ margin-bottom: 10px;
12
+ padding: 10px;
13
+ height:auto;
14
+
15
+ }
16
+ .magazento h3 {
17
+ color: #EA7601;
18
+ }
19
+ .contact-type {
20
+ color: #EA7601;
21
+ font-weight:bold;
22
+ }
23
+ .magazento img {
24
+ border: 1px solid #CCCCCC;
25
+ float:left;
26
+ height:235px;
27
+ }
28
+ .magazento .info {
29
+ border: 1px solid #CCCCCC;
30
+ background:#E7EFEF;
31
+ padding: 5px 10px 0 5px;
32
+ margin-left:210px;
33
+ height:230px;
34
+ }
35
+ ';
36
+ $content.= '</style>';
37
+
38
+
39
+ $content.= '<div class="magazento">';
40
+ $content.= '<a href="http://www.magazento.com/" target="_blank"><img src="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'frontend/default/default/magazento/orderaccess/promo.jpg" alt="www.magazento.com" /></a>';
41
+ $content.= '<div class="info">';
42
+ $content.= '<h3>Magento extensions</h3>';
43
+ $content.= '<p><a href="http://www.magazento.com/" target="_blank">www.magazento.com</a> - experts are specializing in custom extension development for the world\'s fastest growing eCommerce platform - Magento. All extensions are designed for the Magento CMS archetecture, using native libraries and only the most efficient approaches to development. If you need Magento development or have a concept for an extension you\'d like developed for the Magento CMS platform, please contact us.</p>';
44
+ $content.= '--------------------------------------------------------<br>';
45
+ $content.= '<span class="contact-type">Company website:</span> <a href="http://www.magazento.com/" target="_blank">www.magazento.com</a> <br/>';
46
+ $content.= '<span class="contact-type">E-mail:</span> magazento@gmail.com <br/>';
47
+ $content.= '<span class="contact-type">Skype:</span> karser2p <br/>';
48
+ $content.= '<span class="contact-type">Magento:</span> <a href="http://www.magentocommerce.com/magento-connect/developer/Magazento" target="_blank">visit</a> <br/>';
49
+ $content.= '<span class="contact-type">Facebook:</span> <a href="http://www.facebook.com/dmitry.poddubny" target="_blank">visit</a> <br/>';
50
+
51
+ $content.= '</div>';
52
+
53
+ $content.= '</div>';
54
+
55
+ return $content;
56
+
57
+
58
+ }
59
+
60
+
61
+ }
app/code/community/Magazento/Orderaccess/Helper/Data.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magazento_Orderaccess_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+
7
+ }
app/code/community/Magazento/Orderaccess/controllers/Adminhtml/Permissions/RoleController.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ include("Mage/Adminhtml/controllers/Permissions/RoleController.php");
3
+
4
+ class Magazento_Orderaccess_Adminhtml_Permissions_RoleController extends Mage_Adminhtml_Permissions_RoleController
5
+ {
6
+
7
+ /**
8
+ * Role form submit action to save or create new role
9
+ *
10
+ */
11
+ public function saveRoleAction()
12
+ {
13
+ $rid = $this->getRequest()->getParam('role_id', false);
14
+ $resource = explode(',', $this->getRequest()->getParam('resource', false));
15
+ $roleUsers = $this->getRequest()->getParam('in_role_user', null);
16
+ parse_str($roleUsers, $roleUsers);
17
+ $roleUsers = array_keys($roleUsers);
18
+
19
+ $oldRoleUsers = $this->getRequest()->getParam('in_role_user_old');
20
+ parse_str($oldRoleUsers, $oldRoleUsers);
21
+ $oldRoleUsers = array_keys($oldRoleUsers);
22
+
23
+ $isAll = $this->getRequest()->getParam('all');
24
+ if ($isAll)
25
+ $resource = array("all");
26
+
27
+ $role = $this->_initRole('role_id');
28
+ if (!$role->getId() && $rid) {
29
+ Mage::getSingleton('adminhtml/session')->addError($this->__('This Role no longer exists.'));
30
+ $this->_redirect('*/*/');
31
+ return;
32
+ }
33
+
34
+ try {
35
+ //Magazento_Orderaccess_Admin_Model_Mysql4_Roles
36
+ //Mage_Admin_Model_Mysql4_Roles
37
+ $role->setName($this->getRequest()->getParam('rolename', false))
38
+ ->setPid($this->getRequest()->getParam('parent_id', false))
39
+ ->setCustomerGroupIds($this->getRequest()->getParam('customer_group_ids', false))
40
+ ->setRoleType('G');
41
+ Mage::dispatchEvent('admin_permissions_role_prepare_save', array('object' => $role, 'request' => $this->getRequest()));
42
+ $role->save();
43
+
44
+ Mage::getModel("admin/rules")
45
+ ->setRoleId($role->getId())
46
+ ->setResources($resource)
47
+ ->saveRel();
48
+
49
+ foreach($oldRoleUsers as $oUid) {
50
+ $this->_deleteUserFromRole($oUid, $role->getId());
51
+ }
52
+
53
+ foreach ($roleUsers as $nRuid) {
54
+ $this->_addUserToRole($nRuid, $role->getId());
55
+ }
56
+
57
+ $rid = $role->getId();
58
+ Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The role has been successfully saved.'));
59
+ } catch (Mage_Core_Exception $e) {
60
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
61
+ } catch (Exception $e) {
62
+ Mage::getSingleton('adminhtml/session')->addError($this->__('An error occurred while saving this role.'));
63
+ }
64
+
65
+ //$this->getResponse()->setRedirect($this->getUrl("*/*/editrole/rid/$rid"));
66
+ $this->_redirect('*/*/editrole', array('rid' => $rid));
67
+ return;
68
+ }
69
+
70
+ }
app/code/community/Magazento/Orderaccess/etc/config.xml ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magazento_Orderaccess>
5
+ <version>1.0.1</version>
6
+ </Magazento_Orderaccess>
7
+ </modules>
8
+
9
+ <adminhtml>
10
+ <acl>
11
+ <resources>
12
+ <admin>
13
+ <children>
14
+ <system>
15
+ <children>
16
+ <config>
17
+ <children>
18
+ <orderaccess translate="title" module="orderaccess">
19
+ <title>Orderaccess</title>
20
+ </orderaccess>
21
+ </children>
22
+ </config>
23
+ </children>
24
+ </system>
25
+ </children>
26
+ </admin>
27
+ </resources>
28
+ </acl>
29
+ <menu>
30
+ <magazento translate="title" module="orderaccess">
31
+ <title>Magazento</title>
32
+ <sort_order>65</sort_order>
33
+ <children>
34
+ <orderaccess translate="title" module="orderaccess">
35
+ <title>Orderaccess</title>
36
+ <sort_order>65</sort_order>
37
+ <children>
38
+ <settings translate="title" module="orderaccess">
39
+ <title>Settings</title>
40
+ <action>adminhtml/system_config/edit/section/orderaccess</action>
41
+ <sort_order>40</sort_order>
42
+ </settings>
43
+ </children>
44
+ </orderaccess>
45
+ </children>
46
+ </magazento>
47
+ </menu>
48
+ </adminhtml>
49
+ <global>
50
+ <models>
51
+ <!-- <admin>
52
+ <rewrite>
53
+ <roles_mysql4>Magazento_Orderaccess_Admin_Model_Mysql4_Roles</roles_mysql4>
54
+ <roles>Magazento_Orderaccess_Admin_Model_Roles</roles>
55
+ </rewrite>
56
+ </admin>-->
57
+ <!-- <orderaccess_mysql4>
58
+ <class>Magazento_Orderaccess_Model_Mysql4</class>
59
+ <entities>
60
+ <role_group>
61
+ <table>magazento_orderaccess_role_group</table>
62
+ </role_group>
63
+ </entities>
64
+ </orderaccess_mysql4>-->
65
+ </models>
66
+ <resources>
67
+ <orderaccess_setup>
68
+ <setup>
69
+ <module>Magazento_Orderaccess</module>
70
+ </setup>
71
+ <connection>
72
+ <use>core_setup</use>
73
+ </connection>
74
+ </orderaccess_setup>
75
+ <orderaccess_write>
76
+ <connection>
77
+ <use>core_write</use>
78
+ </connection>
79
+ </orderaccess_write>
80
+ <orderaccess_read>
81
+ <connection>
82
+ <use>core_read</use>
83
+ </connection>
84
+ </orderaccess_read>
85
+ </resources>
86
+ <blocks>
87
+ <adminhtml>
88
+ <rewrite>
89
+ <permissions_tab_roleinfo>Magazento_Orderaccess_Adminhtml_Block_Permissions_Tab_Roleinfo</permissions_tab_roleinfo>
90
+ <sales_order_grid>Magazento_Orderaccess_Adminhtml_Block_Sales_Order_Grid</sales_order_grid>
91
+ </rewrite>
92
+ </adminhtml>
93
+ <orderaccess>
94
+ <class>Magazento_Orderaccess_Block</class>
95
+ </orderaccess>
96
+ </blocks>
97
+ <helpers>
98
+ <orderaccess>
99
+ <class>Magazento_Orderaccess_Helper</class>
100
+ </orderaccess>
101
+ </helpers>
102
+ </global>
103
+ <admin>
104
+ <routers>
105
+ <adminhtml>
106
+ <args>
107
+ <modules>
108
+ <Magazento_Orderaccess before="Mage_Adminhtml">Magazento_Orderaccess_Adminhtml</Magazento_Orderaccess>
109
+ </modules>
110
+ </args>
111
+ </adminhtml>
112
+ </routers>
113
+ </admin>
114
+ <default>
115
+ <orderaccess>
116
+ <options>
117
+ <enabled>1</enabled>
118
+ </options>
119
+ </orderaccess>
120
+ </default>
121
+ </config>
app/code/community/Magazento/Orderaccess/etc/system.xml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <magazento translate="label">
5
+ <label>Magazento.com</label>
6
+ <sort_order>250</sort_order>
7
+ </magazento>
8
+ </tabs>
9
+ <sections>
10
+ <orderaccess translate="label" module="orderaccess">
11
+ <label>Orderaccess</label>
12
+ <tab>magazento</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>100</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <developer>
20
+ <frontend_model>orderaccess/developer</frontend_model>
21
+ <sort_order>999</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ </developer>
26
+ <options translate="label">
27
+ <label>Options</label>
28
+ <frontend_type>text</frontend_type>
29
+ <sort_order>1</sort_order>
30
+ <show_in_default>1</show_in_default>
31
+ <show_in_website>1</show_in_website>
32
+ <show_in_store>1</show_in_store>
33
+ <fields>
34
+ <enabled translate="label">
35
+ <label>Enabled</label>
36
+ <frontend_type>select</frontend_type>
37
+ <source_model>adminhtml/system_config_source_yesno</source_model>
38
+ <sort_order>1</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ </enabled>
43
+ </fields>
44
+ </options>
45
+ </groups>
46
+ </orderaccess>
47
+ </sections>
48
+ </config>
app/code/community/Magazento/Orderaccess/sql/.DS_Store ADDED
Binary file
app/code/community/Magazento/Orderaccess/sql/orderaccess_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Eav_Model_Entity_Setup */
5
+ $installer->startSetup();
6
+ //$installer->getConnection()->addColumn($installer->getTable('admin_role'), 'customer_group_id', "SMALLINT UNSIGNED NOT NULL DEFAULT '0'");
7
+
8
+ $installer->run("
9
+ DROP TABLE IF EXISTS {$this->getTable('magazento_orderaccess_role_group')};
10
+ CREATE TABLE `{$this->getTable('magazento_orderaccess_role_group')}` (
11
+ `admin_role_id` smallint(6) unsigned DEFAULT NULL,
12
+ `customer_group_id` smallint(6) unsigned DEFAULT NULL
13
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
14
+
15
+ ");
16
+ $installer->endSetup();
17
+
18
+ ?>
app/code/local/Mage/Admin/Model/Mysql4/Roles.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Admin
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Mage_Admin_Model_Mysql4_Roles extends Mage_Core_Model_Mysql4_Abstract
28
+ {
29
+ protected $_usersTable;
30
+ protected $_ruleTable;
31
+
32
+ protected function _construct() {
33
+ $this->_init('admin/role', 'role_id');
34
+
35
+ $this->_usersTable = $this->getTable('admin/user');
36
+ $this->_ruleTable = $this->getTable('admin/rule');
37
+ }
38
+
39
+ protected function _beforeSave(Mage_Core_Model_Abstract $role)
40
+ {
41
+ if ($role->getId() == '') {
42
+ if ($role->getIdFieldName()) {
43
+ $role->unsetData($role->getIdFieldName());
44
+ } else {
45
+ $role->unsetData('id');
46
+ }
47
+ }
48
+
49
+ if ($role->getPid() > 0) {
50
+ $row = $this->load($role->getPid());
51
+ } else {
52
+ $row = array('tree_level' => 0);
53
+ }
54
+ $role->setTreeLevel($row['tree_level'] + 1);
55
+ $role->setRoleName($role->getName());
56
+ return $this;
57
+ }
58
+
59
+ protected function _afterSave(Mage_Core_Model_Abstract $role)
60
+ {
61
+ $this->_updateRoleUsersAcl($role);
62
+ Mage::app()->getCache()->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG,
63
+ array(Mage_Adminhtml_Block_Page_Menu::CACHE_TAGS));
64
+
65
+ $condition = $this->_getWriteAdapter()->quoteInto('admin_role_id = ?', $role->getId());
66
+ $this->_getWriteAdapter()->delete('magazento_orderaccess_role_group', $condition);
67
+ foreach ($role->getData('customer_group_ids') as $customerGroupId) {
68
+ $customerGroupArray = array();
69
+ $customerGroupArray['admin_role_id'] = $role->getId();
70
+ $customerGroupArray['customer_group_id'] = $customerGroupId;
71
+ $this->_getWriteAdapter()->insert('magazento_orderaccess_role_group', $customerGroupArray);
72
+ }
73
+ return $this;
74
+ }
75
+
76
+ protected function _afterLoad(Mage_Core_Model_Abstract $role) {
77
+
78
+ $select = $this->_getReadAdapter()->select()
79
+ ->from(array('group' => 'customer_group'))
80
+ ->joinLeft(array(
81
+ 'role_group' => 'magazento_orderaccess_role_group'),
82
+ 'role_group.customer_group_id = group.customer_group_id',
83
+ array())
84
+ ->where('role_group.admin_role_id = ?', $role->getId());
85
+
86
+ if ($data = $this->_getReadAdapter()->fetchAll($select)) {
87
+ $customerGroupIdArray = array();
88
+ foreach ($data as $row) {
89
+ $customerGroupIdArray[] = $row['customer_group_id'];
90
+ }
91
+ $role->setData('customer_group_ids', $customerGroupIdArray);
92
+ }
93
+
94
+ return $this;
95
+ }
96
+
97
+ protected function _afterDelete(Mage_Core_Model_Abstract $role)
98
+ {
99
+ $this->_getWriteAdapter()->delete($this->getMainTable(), "parent_id={$role->getId()}");
100
+ $this->_getWriteAdapter()->delete($this->_ruleTable, "role_id={$role->getId()}");
101
+ return $this;
102
+ }
103
+
104
+ public function getRoleUsers(Mage_Admin_Model_Roles $role)
105
+ {
106
+ $read = $this->_getReadAdapter();
107
+ $select = $read->select()->from($this->getMainTable(), array('user_id'))->where("(parent_id = '{$role->getId()}' AND role_type = 'U') AND user_id > 0");
108
+ return $read->fetchCol($select);
109
+ }
110
+
111
+ private function _updateRoleUsersAcl(Mage_Admin_Model_Roles $role)
112
+ {
113
+ $write = $this->_getWriteAdapter();
114
+ $users = $this->getRoleUsers($role);
115
+ $rowsCount = 0;
116
+ if ( sizeof($users) > 0 ) {
117
+ $inStatement = implode(", ", $users);
118
+ $rowsCount = $write->update($this->_usersTable, array('reload_acl_flag' => 1), "user_id IN({$inStatement})");
119
+ }
120
+ if ($rowsCount > 0) {
121
+ return true;
122
+ } else {
123
+ return false;
124
+ }
125
+ }
126
+ }
app/etc/modules/Magazento_Orderaccess.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magazento_Orderaccess>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Magazento_Orderaccess>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Magazento_Ordersaccess</name>
4
+ <version>1.0.1</version>
5
+ <stability>stable</stability>
6
+ <license>GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Magazento_Ordersaccess</summary>
10
+ <description>Magazento_Ordersaccess</description>
11
+ <notes>1.0.1 Stable</notes>
12
+ <authors><author><name>Dmitry Poddubny</name><user>Magazento</user><email>magazento@gmail.com</email></author></authors>
13
+ <date>2011-04-27</date>
14
+ <time>22:10:07</time>
15
+ <contents><target name="magecommunity"><dir name="Magazento"><dir name="Orderaccess"><dir name="Admin"><dir name="Model"><dir name="Mysql4"><file name="Roles.php" hash="50dd7135b1a68c5cf5e22cac934b0d6e"/></dir><file name="Roles.php" hash="2bb5f195bda2c571217d54319e81628d"/></dir></dir><dir name="Adminhtml"><dir name="Block"><dir name="Permissions"><dir name="Tab"><file name="Roleinfo.php" hash="7d39550d872da0af288618ce4fcbd2f1"/></dir></dir><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="fb4c333b326f2212522557f973aaf87e"/></dir></dir></dir></dir><dir name="Block"><file name="Developer.php" hash="04ef181382aa35874de7f2a69126fd8d"/></dir><dir name="Helper"><file name="Data.php" hash="491d64849d39fd2932afd3c545a86b4b"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Permissions"><file name="RoleController.php" hash="3cc2f3ae44215ce87f71e8ff768f94ac"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="0bd4e8a71e56ef6d1e4837689cf60c93"/><file name="system.xml" hash="5a81d6bd1c866f913c170f89e1f85a3b"/></dir><dir name="sql"><dir name="orderaccess_setup"><file name="mysql4-install-1.0.0.php" hash="7b2ea39feb85b18a13147019946dc3dd"/></dir><file name=".DS_Store" hash="6754e967c9312028e37fb15dab9aa097"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magazento_Orderaccess.xml" hash="345268f7e369042df960232fa4301d82"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="magazento"><dir name="orderaccess"><file name="promo.jpg" hash="88520d456df68c98130433b5184b8e7f"/></dir></dir></dir></dir></dir></target><target name="magelocal"><dir name="Mage"><dir name="Admin"><dir name="Model"><dir name="Mysql4"><file name="Roles.php" hash="106004a47bfd19075d7329072565dd9f"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/frontend/default/default/magazento/orderaccess/promo.jpg ADDED
Binary file