Supervisor Manager

PHP

Plesk extension for managing Supervisor processes and workers with monitoring, process control, service management, and deployment automation.

Stars
16
Forks
1
Downloads
N/A
Open Issues
0
Files main

Repository Files

Loading file structure...
plib/hooks/CustomButtons.php
<?php

require_once pm_Context::getPlibDir() . '/library/SupervisorManager/Permissions.php';

class Modules_SupervisorManager_CustomButtons extends pm_Hook_CustomButtons
{
    public function getButtons()
    {
        $icon = pm_Context::getBaseUrl() . 'images/icon.svg';
        $link = pm_Context::getBaseUrl() . 'index.php/index/index';
        $domainLink = pm_Context::getBaseUrl() . 'index.php/index/domain';
        $isAdmin = SupervisorManager_Permissions::isAdmin();
        $hasAccess = $isAdmin || SupervisorManager_Permissions::canAny(SupervisorManager_Permissions::ACCESS);

        $buttons = array();
        if ($isAdmin) {
            $buttons[] = array(
                'place' => self::PLACE_ADMIN_NAVIGATION,
                'section' => self::SECTION_NAV_SERVER_MANAGEMENT,
                'title' => 'Supervisor',
                'description' => 'Manage Supervisor programs',
                'icon' => $icon,
                'link' => $link,
                'newWindow' => false,
            );
        }

        if (!$hasAccess) {
            return $buttons;
        }

        if (!$isAdmin) {
            $buttons[] = array(
                'place' => self::PLACE_RESELLER_NAVIGATION,
                'section' => self::SECTION_NAV_ADDITIONAL,
                'title' => 'Supervisor',
                'description' => 'Manage assigned Supervisor programs',
                'icon' => $icon,
                'link' => $link,
                'newWindow' => false,
            );
        }

        $buttons[] = array(
            'place' => self::PLACE_CUSTOMER_HOME,
            'title' => 'Supervisor',
            'description' => 'Manage assigned Supervisor programs',
            'icon' => $icon,
            'link' => $link,
            'newWindow' => false,
        );
        $buttons[] = array(
            'place' => self::PLACE_DOMAIN,
            'title' => 'Supervisor',
            'description' => 'Manage domain Supervisor programs',
            'icon' => $icon,
            'link' => $domainLink,
            'newWindow' => false,
            'contextParams' => true,
        );

        if (
            defined('pm_Hook_CustomButtons::PLACE_DOMAIN_PROPERTIES_DYNAMIC') &&
            defined('pm_Hook_CustomButtons::SECTION_DOMAIN_PROPS_DYNAMIC_DEV_TOOLS')
        ) {
            $buttons[] = array(
                'place' => constant('pm_Hook_CustomButtons::PLACE_DOMAIN_PROPERTIES_DYNAMIC'),
                'section' => constant('pm_Hook_CustomButtons::SECTION_DOMAIN_PROPS_DYNAMIC_DEV_TOOLS'),
                'title' => 'Supervisor',
                'description' => 'Manage Supervisor programs',
                'icon' => $icon,
                'link' => $domainLink,
                'newWindow' => false,
                'contextParams' => true,
            );
        }

        return $buttons;
    }
}