本文整理匯總了PHP中DiscussionModel::FilterForm方法的典型用法代碼示例。如果您正苦於以下問題:PHP DiscussionModel::FilterForm方法的具體用法?PHP DiscussionModel::FilterForm怎麽用?PHP DiscussionModel::FilterForm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DiscussionModel
的用法示例。
在下文中一共展示了DiscussionModel::FilterForm方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Discussion
//.........這裏部分代碼省略.........
// Permission to add
$this->Permission('Vanilla.Discussions.Add');
$this->Title(T('New Discussion'));
}
TouchValue('Type', $this->Data, 'Discussion');
// See if we should hide the category dropdown.
$AllowedCategories = CategoryModel::GetByPermission('Discussions.Add', $this->Form->GetValue('CategoryID', $this->CategoryID), array('Archived' => 0, 'AllowDiscussions' => 1), array('AllowedDiscussionTypes' => $this->Data['Type']));
if (count($AllowedCategories) == 1) {
$AllowedCategory = array_pop($AllowedCategories);
$this->ShowCategorySelector = FALSE;
$this->Form->AddHidden('CategoryID', $AllowedCategory['CategoryID']);
if ($this->Form->IsPostBack() && !$this->Form->GetFormValue('CategoryID')) {
$this->Form->SetFormValue('CategoryID', $AllowedCategory['CategoryID']);
}
}
// Set the model on the form
$this->Form->SetModel($this->DiscussionModel);
if ($this->Form->IsPostBack() == FALSE) {
// Prep form with current data for editing
if (isset($this->Discussion)) {
$this->Form->SetData($this->Discussion);
} elseif (isset($this->Draft)) {
$this->Form->SetData($this->Draft);
} else {
if ($this->Category !== NULL) {
$this->Form->SetData(array('CategoryID' => $this->Category->CategoryID));
}
$this->PopulateForm($this->Form);
}
} else {
// Form was submitted
// Save as a draft?
$FormValues = $this->Form->FormValues();
$FormValues = $this->DiscussionModel->FilterForm($FormValues);
$this->DeliveryType(GetIncomingValue('DeliveryType', $this->_DeliveryType));
if ($DraftID == 0) {
$DraftID = $this->Form->GetFormValue('DraftID', 0);
}
$Draft = $this->Form->ButtonExists('Save Draft') ? TRUE : FALSE;
$Preview = $this->Form->ButtonExists('Preview') ? TRUE : FALSE;
if (!$Preview) {
if (!is_object($this->Category) && is_array($CategoryData) && isset($FormValues['CategoryID'])) {
$this->Category = GetValue($FormValues['CategoryID'], $CategoryData);
}
if (is_object($this->Category)) {
// Check category permissions.
if ($this->Form->GetFormValue('Announce', '') && !$Session->CheckPermission('Vanilla.Discussions.Announce', TRUE, 'Category', $this->Category->PermissionCategoryID)) {
$this->Form->AddError('You do not have permission to announce in this category', 'Announce');
}
if ($this->Form->GetFormValue('Close', '') && !$Session->CheckPermission('Vanilla.Discussions.Close', TRUE, 'Category', $this->Category->PermissionCategoryID)) {
$this->Form->AddError('You do not have permission to close in this category', 'Close');
}
if ($this->Form->GetFormValue('Sink', '') && !$Session->CheckPermission('Vanilla.Discussions.Sink', TRUE, 'Category', $this->Category->PermissionCategoryID)) {
$this->Form->AddError('You do not have permission to sink in this category', 'Sink');
}
if (!isset($this->Discussion) && (!$Session->CheckPermission('Vanilla.Discussions.Add', TRUE, 'Category', $this->Category->PermissionCategoryID) || !$this->Category->AllowDiscussions)) {
$this->Form->AddError('You do not have permission to start discussions in this category', 'CategoryID');
}
}
// Make sure that the title will not be invisible after rendering
$Name = trim($this->Form->GetFormValue('Name', ''));
if ($Name != '' && Gdn_Format::Text($Name) == '') {
$this->Form->AddError(T('You have entered an invalid discussion title'), 'Name');
} else {
// Trim the name.
$FormValues['Name'] = $Name;