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); $form->addElement($groupElement); $form->addElement(new Xoops\Form\Button('', 'submit', 'Save', 'submit')); echo $form->render(); // check it the current user has the permission if ($permissionHelper->checkPermission($permissionName, $permissionItemId)) { echo "<p>You have the <strong>'{$permissionName}'</strong> permission for the 'codex' module.</p>";
foreach ($keys as $k) { $optArray[$k] = $commands[$k]['name']; } return $optArray; } echo <<<EOT <script> setTimeout(function () { window.location.href = "index.php"; }, 900000); //will redirect after 900 secs - security token expires </script> EOT; $basicOpt = getOptArray($basicgroup, $commands); $showOpt = getOptArray($showgroup, $commands); $utilOpt = getOptArray($utilgroup, $commands); $method = Request::getMethod(); $form = new Xoops\Form\ThemeForm('', 'composer', 'composertool.php', 'post', true, 'horizontal'); $selected = Request::getCmd('composer_command', ''); $select_optgroup = new Xoops\Form\Select('Composer Command', 'composer_command', $selected, 1, false); $select_optgroup->addOptionGroup('Basics', getOptArray($basicgroup, $commands)); $select_optgroup->addOptionGroup('Informational', getOptArray($showgroup, $commands)); $select_optgroup->addOptionGroup('Utility', getOptArray($utilgroup, $commands)); //$select_optgroup->setDescription('Description Select Optgroup'); $select_optgroup->setClass('span3'); $form->addElement($select_optgroup, true); $testtray = new Xoops\Form\ElementTray(''); $pkg = new Xoops\Form\Text('Package', 'package', 32, 128, '', 'vendor/package'); //$pkg->setDescription('Description code'); //$pkg->setPattern('^.{3,}$', 'You need at least 3 characters'); //$pkg->setDatalist(array('list 1','list 2','list 3')); $testtray->addElement($pkg);