本文整理汇总了PHP中Gdn_Controller::Permission方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Controller::Permission方法的具体用法?PHP Gdn_Controller::Permission怎么用?PHP Gdn_Controller::Permission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn_Controller
的用法示例。
在下文中一共展示了Gdn_Controller::Permission方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SettingsController_CustomizeText_Create
/**
* Add the customize text page to the dashboard.
*
* @param Gdn_Controller $Sender
*/
public function SettingsController_CustomizeText_Create($Sender)
{
$Sender->Permission('Garden.Settings.Manage');
$Sender->AddSideMenu('settings/customizetext');
$Sender->AddJsFile('jquery.autogrow.js');
$Sender->Title('Customize Text');
$Directive = GetValue(0, $Sender->RequestArgs, '');
$View = 'customizetext';
if ($Directive == 'rebuild') {
$View = 'rebuild';
} elseif ($Directive == 'rebuildcomplete') {
$View = 'rebuildcomplete';
}
$Method = 'none';
if ($Sender->Form->IsPostback()) {
$Method = 'search';
if ($Sender->Form->GetValue('Save_All')) {
$Method = 'save';
}
}
$Matches = array();
$Keywords = NULL;
switch ($Method) {
case 'none':
break;
case 'search':
case 'save':
$Keywords = strtolower($Sender->Form->GetValue('Keywords'));
if ($Method == 'search') {
$Sender->Form->ClearInputs();
$Sender->Form->SetFormValue('Keywords', $Keywords);
}
$Definitions = Gdn::Locale()->GetDeveloperDefinitions();
$CountDefinitions = sizeof($Definitions);
$Sender->SetData('CountDefinitions', $CountDefinitions);
$Changed = FALSE;
foreach ($Definitions as $Key => $BaseDefinition) {
$KeyHash = md5($Key);
$ElementName = "def_{$KeyHash}";
// Look for matches
$k = strtolower($Key);
$d = strtolower($BaseDefinition);
// If this key doesn't match, skip it
if ($Keywords != '*' && !(strlen($Keywords) > 0 && (strpos($k, $Keywords) !== FALSE || strpos($d, $Keywords) !== FALSE))) {
continue;
}
$Modified = FALSE;
// Found a definition, look it up in the real locale first, to see if it has been overridden
$CurrentDefinition = Gdn::Locale()->Translate($Key, FALSE);
if ($CurrentDefinition !== FALSE && $CurrentDefinition != $BaseDefinition) {
$Modified = TRUE;
} else {
$CurrentDefinition = $BaseDefinition;
}
$Matches[$Key] = array('def' => $CurrentDefinition, 'mod' => $Modified);
if ($CurrentDefinition[0] == "\r\n") {
$CurrentDefinition = "\r\n{$CurrentDefinition}";
} else {
if ($CurrentDefinition[0] == "\r") {
$CurrentDefinition = "\r{$CurrentDefinition}";
} else {
if ($CurrentDefinition[0] == "\n") {
$CurrentDefinition = "\n{$CurrentDefinition}";
}
}
}
if ($Method == 'save') {
$SuppliedDefinition = $Sender->Form->GetValue($ElementName);
// Has this field been changed?
if ($SuppliedDefinition != FALSE && $SuppliedDefinition != $CurrentDefinition) {
// Changed from what it was, but is it a change from the *base* value?
$SaveDefinition = $SuppliedDefinition != $BaseDefinition ? $SuppliedDefinition : NULL;
if (!is_null($SaveDefinition)) {
$CurrentDefinition = $SaveDefinition;
$SaveDefinition = str_replace("\r\n", "\n", $SaveDefinition);
}
Gdn::Locale()->SetTranslation($Key, $SaveDefinition, array('Save' => TRUE, 'RemoveEmpty' => TRUE));
$Matches[$Key] = array('def' => $SuppliedDefinition, 'mod' => !is_null($SaveDefinition));
$Changed = TRUE;
}
}
$Sender->Form->SetFormValue($ElementName, $CurrentDefinition);
}
if ($Changed) {
$Sender->InformMessage("Locale changes have been saved!");
}
break;
}
$Sender->SetData('Matches', $Matches);
$CountMatches = sizeof($Matches);
$Sender->SetData('CountMatches', $CountMatches);
$Sender->Render($View, '', 'plugins/CustomizeText');
}
示例2: Controller_Delete
/**
* Delete a Tag
*
* @param Gdn_Controller $Sender
*/
public function Controller_Delete($Sender)
{
$Sender->Permission('Garden.Settings.Manage');
$TagID = GetValue(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');
}
示例3: SettingsController_Tagging_Create
/**
* Tag management (let admins rename tags, remove tags, etc).
* TODO: manage the Plugins.Tagging.Required boolean setting that makes tagging required or not.
* @param Gdn_Controller $Sender
*/
public function SettingsController_Tagging_Create($Sender, $Args) {
$Sender->Permission('Garden.Settings.Manage');
$Sender->Title('Tagging');
$Sender->AddSideMenu('settings/tagging');
$Sender->AddCSSFile('plugins/Tagging/design/tagadmin.css');
$Sender->AddJSFile('plugins/Tagging/admin.js');
$SQL = Gdn::SQL();
list($Offset, $Limit) = OffsetLimit($Sender->Request->Get('Page'), 100);
$Sender->SetData('_Limit', $Limit);
$Sender->SetData('Tags', $SQL
->Select('t.*')
->From('Tag t')
->OrderBy('t.Name', 'asc')
->OrderBy('t.CountDiscussions', 'desc')
->Limit($Limit, $Offset)
->Get()->ResultArray());
$Sender->SetData('RecordCount', $SQL->GetCount('Tag'));
$Sender->Render('Tagging', '', 'plugins/Tagging');
}