Plesk SDK API gives you the ability to integrate with Plesk service
plans by adding and checking custom permissions and limits to service
plans, resellers and subscriptions, and also by registering
extension-related plan items in Plesk.
Adding and checking custom permissions and limits
Two following hooks are used:
-
pm_Hook_Permissions
- for managing permissions. -
pm_Hook_Limits
- for managing limits.
Permissions and limits have string IDs like “manage_git” and
“max_repos”. These IDs must be unique for individual extensions, but the
same ID name can be used in different extensions. IDs are stored with
native permissions, limits, and other plan items’ data in the Plesk
database, in the TmplData
table. To prevent IDs from clashing, we
add an extension name prefix to each ID. For example, the “git”
extension adds custom limit named “max_repos”, so within the Plesk
context it becomes “git_max_repos”, but in the extension code
“max_repos” is used.
Note: ID names can contain only numbers, letters, and the underscore
symbol. All other symbols are not allowed.
A new class Service Plan wrapper
(pm_Plan)
was added. Objects are constructed by service plan ID. There are
getters:
getId()
and
getName().
The methods hasPermission($name)
and getLimit($name)
provide
access to custom permissions and limits, correspondingly. These methods
are available for domains
(pm_Domain)
and service plans
(pm_Plan).
The method pm_Client::hasPermission($name,
$domain)
checks if the client has access to the domain’s functionality restricted
by permission.
Examples
Permissions
…