| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/business/pms/modules/ctools/plugins/access/ |
Upload File : |
<?php
/**
* @file
* Plugin to provide access control/visibility based on existence of a specified context
*/
$plugin = array(
'title' => t("Context exists"),
'description' => t('Control access by whether or not a context exists and contains data.'),
'callback' => 'ctools_context_exists_ctools_access_check',
'settings form' => 'ctools_context_exists_ctools_access_settings',
'summary' => 'ctools_context_exists_ctools_access_summary',
'required context' => new ctools_context_required(t('Context'), 'any'),
'defaults' => array('exists' => TRUE),
);
/**
* Settings form
*/
function ctools_context_exists_ctools_access_settings(&$form, &$form_state, $conf) {
$form['settings']['exists'] = array(
'#type' => 'radios',
'#description' => t("Check to see if the context exists (contains data) or does not exist (contains no data). For example, if a context is optional and the path does not contain an argument for that context, it will not exist."),
'#options' => array(TRUE => t('Exists'), FALSE => t("Doesn't exist")),
'#default_value' => $conf['exists'],
);
}
/**
* Check for access
*/
function ctools_context_exists_ctools_access_check($conf, $context) {
// xor returns false if the two bools are the same, and true if they are not.
// i.e, if we asked for context_exists and it does, return true.
// If we asked for context does not exist and it does, return false.
return (empty($context->data) xor !empty($conf['exists']));
}
/**
* Provide a summary description based upon the specified context
*/
function ctools_context_exists_ctools_access_summary($conf, $context) {
if (!empty($conf['exists'])) {
return t('@identifier exists', array('@identifier' => $context->identifier));
}
else {
return t('@identifier does not exist', array('@identifier' => $context->identifier));
}
}