Jump to content

phpvms admin - addons


Mickey

Recommended Posts

  • Moderators

There is not any way to add a new permission based on the modules you have installed on your phpVMS system. In most cases, as a developer and wherever I believe it's useful, I have developed a build in permissions system on my modules. My Pilot Academy module has that system. Here are some solutions I can suggest to you:

Open your admin/templates/core_navigation.tpl file and find this:

<li style="padding: 0; margin: 0;"><a class="menu" href="#">
<img src="<?php echo  SITE_URL?>/admin/lib/layout/images/settings_icon.gif" />Addons</a>
<ul style="padding: 0; margin: 0;">
<?php echo $MODULE_NAV_INC; ?>
</ul>
</li>

This is the part of codes which shown the addon's section of your phpVMS system. You can put it in an if statement if you wish to show the addon's section to the admin's who have a specific permission. Below, I am giving you an example which will give access only to those who has the FULL_ADMIN permission:

<?php
if(PilotGroups::group_has_perm(Auth::$usergroups, FULL_ADMIN)) {
?>
<li style="padding: 0; margin: 0;"><a class="menu" href="#">
<img src="<?php echo  SITE_URL?>/admin/lib/layout/images/settings_icon.gif" />Addons</a>
<ul style="padding: 0; margin: 0;">
<?php echo $MODULE_NAV_INC; ?>
</ul>
</li>
<?php } ?>

Of course, you can replace FULL_ADMIN with any permission you can see on the list where you administrate your groups permissions. This solution will limit the whole addon's section of your system. As an alternative, you can do the following. Let's take as an example the Frequently Asked Questions module. You will have to open the admin/modules/Faq/Faq.php file and find this:

public function NavBar() {
    echo '<li><a href="'.SITE_URL.'/admin/index.php/FAQ">FAQ</a></li>';
   }

What you can do is add the echo in an if statement. Something like this:

public function NavBar() {
    if(PilotGroups::group_has_perm(Auth::$usergroups, EDIT_PAGES)) {
		  echo '<li><a href="'.SITE_URL.'/admin/index.php/FAQ">FAQ</a></li>';
   }
   }

The part of code above allows only those who have the EDIT_PAGES permission to access the FAQ. Again, you can change the EDIT_PAGES to anything you wish. Please bare in mind that this does not limit the access to the module, this just hides the module link from the addon's section. If any admin wants to access the module, he will be able to do so if he types the link directly (for example phpvms domain/admin/index.php/Faq).

  • Like 1
Link to comment
Share on other sites

It's actually quite easy to limit what your staff see by their Group membership. Below is a quick write up I did for doing this. It works great . Like the code above this just hides the links but it works.

As you install new modules sometimes the creator of the module doesn't add permission settings for the module link. What happens is, pilot groups that you don't want to see the module can. To fix this we have to add the specific group that you want to have access.

I'll use the Charter Module as an example. For this module I only want admins and the custom pilot group called "Scheduling Manager" to have access.

1. Go to the admin site

2. Navigate to Pilots & Groups --> Pilot Groups

3. Take note of the "Group ID" of the pilot group you want to allow permission. In our example it would be Group ID 6.

4. Login to FTP

5. Go to admin/modules/MODULE NAME (CharterCenter in our example)

6. Locate CharterCenter.php and back it up first

7. After you have backed it up, open the file in a text editor (NOT WORD)

8. Locate the following line

public function NavBar()
{
 echo '<li><a href="'.SITE_URL.'/admin/index.php/CharterCenter">Charter Center</a></li>';
}

The above code has no permission settings so any one that has access to the admin will have full rights to this.

9. We now need to add the permissions line.

public function NavBar()
{
if(PilotGroups::CheckUserInGroup(Auth::$userinfo->pilotid, 1) || PilotGroups::CheckUserInGroup(Auth::$userinfo->pilotid, 6)) {
echo '<li><a href="'.SITE_URL.'/admin/index.php/CharterCenter">Charter Center</a></li>';
}
}

If there is a module that you only want admins to have access to just remove this code from the above.

|| PilotGroups::CheckUserInGroup(Auth::$userinfo->pilotid, 6)

You can have more than just one other group on the modules. The below code allows Admins, Schedule Managers, and HR Manager.

public function NavBar()
{
if(PilotGroups::CheckUserInGroup(Auth::$userinfo->pilotid, 1) || PilotGroups::CheckUserInGroup(Auth::$userinfo->pilotid, 6) || PilotGroups::CheckUserInGroup(Auth::$userinfo->pilotid, 4)) {
echo '<li><a href="'.SITE_URL.'/admin/index.php/CharterCenter">Charter Center</a></li>';
}
}

  • Like 2
Link to comment
Share on other sites

Brilliant! Thank you for both reply's that has sorted the problem out..

Also if i wanted to not have for example - in my addons tab I have Charter Center can i change that to a different tab like Airline Operations? Because when I install modules it automatically puts them in addons.

Link to comment
Share on other sites

  • 1 year later...
On 11/01/2016 at 7:05 PM, TennShadow said:

Na verdade, é bastante fácil limitar o que sua equipe vê pela associação do grupo. Abaixo está uma rápida escrita que fiz para fazer isso. Isso funciona muito bem. Como o código acima, isso apenas esconde os links, mas funciona.

À medida que você instala novos módulos às vezes, o criador do módulo não adiciona configurações de permissão para o link do módulo. O que acontece é que grupos de pilotos que você não quer ver o módulo podem. Para corrigir isso, temos que adicionar o grupo específico que você deseja ter acesso.

Vou usar o Módulo de Carta como um exemplo. Para este módulo, eu só quero administradores e o grupo piloto personalizado chamado "Scheduling Manager" para ter acesso.

1. Vá para o site de administração

2. Navegue para Pilotos e Grupos -> Grupos de Pilotos

3. Tome nota da "ID do grupo" do grupo piloto que deseja permitir a permissão. No nosso exemplo, seria o Grupo ID 6.

4. Faça login no FTP

5. Vá para admin / modules / MODULE NAME (CharterCenter no nosso exemplo)

6. Localize CharterCenter.php e faça o backup primeiro

7. Depois de fazer backup, abra o arquivo em um editor de texto (NOT WORD)

8. Localize a seguinte linha



 

O código acima não tem configurações de permissão para que qualquer um que tenha acesso ao administrador terá direitos completos sobre isso.

9. Agora precisamos adicionar a linha de permissões.

 



 

 

Se houver um módulo que você só deseja que os administradores tenham acesso para simplesmente remover este código do acima.


 

Você pode ter mais do que apenas um outro grupo nos módulos. O código abaixo permite Admins, Schedule Managers e HR Manager.

 



 

Hello!
I made the release process for the group that by coincidence is also ID 6, it includes the same in the bar, but does not appear for the pilot of group 06 only for me pous sou full adm

can you help me!?

 

class Events_admin extends CodonModule
{
    public function HTMLHead()
    {
        $this->set('sidebar', 'events/sidebar_events.php');
    }

    public function NavBar()
    {
    if(PilotGroups::CheckUserInGroup(Auth::$userinfo->pilotid, 1) || PilotGroups::CheckUserInGroup(Auth::$userinfo->pilotid, 6)) {
        echo '<li><a href="'.SITE_URL.'/admin/index.php/events_admin">Events</a></li>';
    }
    }

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...