// work with session data in our module context echo '<h2>Session demo</h2><h4>Toggle a session variable</h4>'; $sessionHelper = new Session(); if ($sessionHelper) { $var = $sessionHelper->get('fred'); if ($var) { echo sprintf('Clearing session variable value of "%s"', $var) . '<br />'; $sessionHelper->destroy(); } else { $var = date('Y-m-d H:i:s'); echo sprintf('Session variable not set. Setting as: %s', $var) . '<br />'; $sessionHelper->set('fred', $var); } } echo '<h2>Permission demo</h2>'; $permissionHelper = new Permission(); if ($permissionHelper) { // this is the name and item we are going to work with $permissionName = 'fred'; $permissionItemId = 1; // if this is a post operation get the input and save it if ('POST' === Request::getMethod()) { echo $xoops->alert('success', 'Permission updated'); // save the data $name = $permissionHelper->defaultFieldName($permissionName, $permissionItemId); $groups = Request::getVar($name, array(), 'POST'); $permissionHelper->savePermissionForItem($permissionName, $permissionItemId, $groups); } // build a form for our permission $form = new Xoops\Form\ThemeForm("Permission Form (for the permission named '{$permissionName}')", 'form', '', 'POST'); $groupElement = $permissionHelper->getGroupSelectFormForItem($permissionName, $permissionItemId, "Groups with '{$permissionName}' permission", null, true);
*/ /** * @copyright XOOPS Project (http://xoops.org) * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) * @package debugbar * @since * @author XOOPS Development Team */ use Xoops\Core\Request; use Xmf\Module\Helper; use Xmf\Module\Permission; include_once __DIR__ . '/admin_header.php'; $moduleAdmin = new \Xoops\Module\Admin(); $moduleAdmin->displayNavigation('permissions.php'); $helper = Helper::getHelper('monolog'); $permHelper = new Permission(); if ($permHelper) { // this is the name and item we are going to work with $gperm_name = 'use_monolog'; $gperm_itemid = 0; // if this is a post operation get our variables if ('POST' === Request::getMethod()) { $name = $permHelper->defaultFieldName($gperm_name, $gperm_itemid); $groups = Request::getVar($name, array(), 'POST'); $permHelper->savePermissionForItem($gperm_name, $gperm_itemid, $groups); echo $xoops->alert('success', _MA_MONOLOG_FORM_PROCESSED, _MA_MONOLOG_PERMISSION_FORM); } $form = new \Xoops\Form\ThemeForm(_MA_MONOLOG_PERMISSION_FORM, 'form', '', 'POST'); $permElement = $permHelper->getGroupSelectFormForItem($gperm_name, $gperm_itemid, _MA_MONOLOG_PERMISSION_GROUPS, null, true); $form->addElement($permElement); $form->addElement(new \Xoops\Form\Button('', 'submit', _MA_MONOLOG_FORM_SUBMIT, 'submit'));