本文整理汇总了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;