Search code examples
opencartadmindashboarduser-permissions

How to Set Permission for Dashboard in Opencart for certain users?


I am using Opencart 1.5.6.4 I am able to set Permissions to All other pages but I am not getting option to set permission to set permission for dashborad or common/home.

I am trying follow link http://forum.opencart.com/viewtopic.php?t=32561

But I am not able to get options to set permission.


Solution

  • I found the answer. To HIDE Dashboard from certain users following are the steps we need to take.

    Open admin\controller\user\user_permission.php

    FIND

    $ignore = array('common/home',
                      'common/startup',
                      'common/login',
                      'common/logout',
                      'common/forgotten',
                      'common/reset',                                             
                      'error/not_found',
                      'error/permission',
                      'common/footer',
                       'common/header'
                      );
    

    REMOVE 'common/home',

    Create XML file and add under vqmod xml folder.

    <modification>
    
                    <id>Add a permission check to the admin dashboard, and provide with an alternate forwarding target</id>
                    <version>1.0.0</version>
                    <vqmver>1.0.2</vqmver>
                    <author>ckonig</author>
    
                    <file name="admin/controller/user/user_permission.php">
    
            <operation>
                <search position="replace">
                                                                    <![CDATA['common/home',]]>
                                                    </search>
                <add>
                                                                    <![CDATA[]]>
                                                    </add>
            </operation>
                    </file>
    
                    <file name="admin/view/template/common/home.tpl">
    
            <operation>
                <search position="after">
                                                                    <![CDATA[<?php echo $header; ?>]]>
                                                    </search>
                <add>
                                                                    <![CDATA[
                                                                    <?php
                                                                    if(!$this->user->hasPermission('access','common/home')){
                                                                                    $this->redirect('index.php?token='.$token.'&route=catalog/product');
                                                                    }
                                                                    ?>
                                                                    ]]>
                                                    </add>
            </operation>
                    </file>
    </modification>
    

    NEXT SET Permission