Checks that the user has the specified permissions. If the user does not, they are redirected to the DefaultPermission route.
public permission ( mixed $Permission, boolean $FullMatch = true, string $JunctionTable = '', integer $JunctionID = '' ) | ||
$Permission | mixed | A permission or array of permission names required to access this resource. |
$FullMatch | boolean | If $Permission is an array, $FullMatch indicates if all permissions specified are required. If false, the user only needs one of the specified permissions. |
$JunctionTable | string | The name of the junction table for a junction permission. |
$JunctionID | integer | The ID of the junction permission. |
/** * The settings page for vanillicon. * * @param Gdn_Controller $sender */ public function settingsController_vanillicon_create($sender) { $sender->permission('Garden.Settings.Manage'); $cf = new ConfigurationModule($sender); $items = array('v1' => 'Vanillicon 1', 'v2' => 'Vanillicon 2'); $cf->initialize(array('Plugins.Vanillicon.Type' => array('LabelCode' => 'Vanillicon Set', 'Control' => 'radiolist', 'Description' => 'Which vanillicon set do you want to use?', 'Items' => $items, 'Options' => array('display' => 'after'), 'Default' => 'v1'))); $sender->setData('Title', sprintf(t('%s Settings'), 'Vanillicon')); $cf->renderAll(); }
/** * Delete a Tag * * @param Gdn_Controller $Sender */ public function controller_delete($Sender) { $Sender->permission('Garden.Settings.Manage'); $TagID = val(1, $Sender->RequestArgs); $TagModel = new TagModel(); $Tag = $TagModel->getID($TagID, DATASET_TYPE_ARRAY); if ($Sender->Form->authenticatedPostBack()) { // Delete tag & tag relations. $SQL = Gdn::sql(); $SQL->delete('TagDiscussion', array('TagID' => $TagID)); $SQL->delete('Tag', array('TagID' => $TagID)); $Sender->informMessage(formatString(t('<b>{Name}</b> deleted.'), $Tag)); $Sender->jsonTarget("#Tag_{$Tag['TagID']}", null, 'Remove'); } $Sender->setData('Title', t('Delete Tag')); $Sender->render('delete', '', 'plugins/Tagging'); }
/** * The settings page for vanillicon. * * @param Gdn_Controller $sender */ public function settingsController_vanillicon_create($sender) { $sender->permission('Garden.Settings.Manage'); $cf = new ConfigurationModule($sender); $items = array('v1' => 'Vanillicon 1', 'v2' => 'Vanillicon 2 (beta)'); $cachePath = self::getCachePath(); $writable = is_writable($cachePath); $txtNotWritable = '<p style="color: #c00;">' . T('<b>Warning:</b> the cache directory is not writable. If you want to use the cache mechanism, you have to enable write permissions for') . '</p><code>' . $cachePath . '</code><br><br><br>'; $txtProxyActive = '<p style="color: #090;">' . T('<b>Congratulations: The privacy of your users is respected!</b> All requests to vanillicon.com are made by your server and not by your users.') . '</p><br>'; $cf->initialize(array('Plugins.Vanillicon.Type' => array('LabelCode' => 'Vanillicon Proxy', 'Control' => 'radiolist', 'Description' => $txtProxyActive . ($writable ? '' : $txtNotWritable) . ' ' . T('Which vanillicon set do you want to use?'), 'Items' => $items, 'Options' => array('list' => true, 'listclass' => 'icon-list', 'display' => 'after'), 'Default' => 'v1'))); $sender->addSideMenu(); $sender->setData('Title', sprintf(t('%s Settings'), 'Vanillicon')); $cf->renderAll(); }