Post by iloveopencart » Sat Apr 11, 2009 11:16 pm

So you created a new user group and hate having to scroll down and check every single box individually for view and modify permissions. While you won't necessarily want all groups to have all permissions, odds are, it will still be quicker to "uncheck" individual permissions. Make these simple changes and you'll have a "check all" box to hasten the process. This works on OpenCart v1.2.6 and should work backwards to OpenCart v1.1.8. You only need to edit 3 files:

/admin/controller/user/user_group.php

In the getForm() function, INSERT after $this->data['entry_modify'] = $this->language->get('entry_modify');

Code: Select all

$this->data['entry_check_all'] = $this->language->get('entry_check_all'); // INSERTED for permission check all enhancement

/admin/language/english/user/user_group.php *

INSERT after $_['entry_modify'] = 'Modify Permission:';

Code: Select all

$_['entry_check_all'] = 'Check All'; // INSERTED for permission check all enhancement
* Repeat for each langauage file with correct translation


/admin/view/template/user/user_group_form.php

REPLACE line <td><?php echo $entry_access; ?></td>

Code: Select all

<!-- MODIFIED for permission check all enhancement -->
<td>
<?php echo $entry_access; ?><br />
<?php echo $entry_check_all; ?><input type="checkbox" onclick="$('input[name*=\'permission[access]\']').attr('checked', this.checked);" />
</td>
<!-- END permission check all enhancement -->
REPLACE line <td><?php echo $entry_modify; ?></td>

Code: Select all

<!-- MODIFIED for permission check all enhancement -->
<td>
<?php echo $entry_modify; ?><br />
<?php echo $entry_check_all; ?><input type="checkbox" onclick="$('input[name*=\'permission[modify]\']').attr('checked', this.checked);" />
</td>
<!-- END permission check all enhancement -->
That's it!

User avatar
Global Moderator

Posts

Joined
Thu Mar 05, 2009 11:15 pm
Location - Phoenix, AZ

Post by Lestat » Thu Sep 10, 2009 4:59 am

Right on man. Thanks for the snippets!

www.beginnercode.com


Newbie

Posts

Joined
Thu Sep 10, 2009 4:55 am


Post by Qphoria » Thu Sep 10, 2009 5:16 am

I think just not needing to add permissions for the main admin would be easier:

1. EDIT: system/helper/user.php (system/library/user.php on old versions)
2. FIND (in the hasPermission function):

Code: Select all

if (isset($this->permission[$key])) {
3. BEFORE, ADD:

Code: Select all

if ($this->user_id == '1') { return true; }
Done. Never have to add permissions again for the master admin account

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 2 guests