本文整理汇总了PHP中Gdn::Config方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn::Config方法的具体用法?PHP Gdn::Config怎么用?PHP Gdn::Config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn
的用法示例。
在下文中一共展示了Gdn::Config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PluginController_SingleSignOn_Create
public function PluginController_SingleSignOn_Create($Sender, $EventArguments)
{
$Sender->Head->Title('Single Sign-on');
$Sender->AddSideMenu('garden/plugin/singlesignon');
$Validation = new Gdn_Validation();
$ConfigurationModel = new Gdn_ConfigurationModel($Validation);
$ConfigurationModel->SetField(array('Garden.Authenticator.Type', 'Garden.Authenticator.Encoding', 'Garden.Authenticator.AuthenticateUrl', 'Garden.Authenticator.SignInUrl', 'Garden.Authenticator.SignOutUrl', 'Garden.Authenticator.RegisterUrl', 'Garden.Cookie.Path'));
// Set the model on the form.
$Sender->Form = new Gdn_Form();
$Sender->Form->SetModel($ConfigurationModel);
// If seeing the form for the first time...
if ($Sender->Form->AuthenticatedPostBack() === FALSE) {
// Apply the config settings to the form.
$Sender->Form->SetData($ConfigurationModel->Data);
$Sender->Form->SetValue('EnableSSO', Gdn::Config('Garden.Authenticator.Type') == 'Handshake' ? 'TRUE' : '');
} else {
// Make sure to force some values
$Sender->Form->SetFormValue('Garden.Authenticator.Type', $Sender->Form->GetFormValue('EnableSSO', '') == 'TRUE' ? 'Handshake' : 'Password');
$Sender->Form->SetFormValue('Garden.Authenticator.Encoding', 'ini');
$Sender->Form->SetFormValue('Garden.Cookie.Path', '/');
// <-- Make sure that Vanilla's cookies don't have a path
if ($Sender->Form->Save() !== FALSE) {
$Sender->StatusMessage = Translate("Your changes have been saved successfully.");
}
}
$Sender->Render(PATH_PLUGINS . DS . 'SingleSignOn' . DS . 'views' . DS . 'index.php');
}
示例2: ToString
public function ToString()
{
if (Gdn::Config('Vanilla.Categories.Use') == TRUE) {
return parent::ToString();
}
return '';
}
示例3: Index
public function Index($Offset = 0, $Limit = NULL)
{
$this->AddJsFile('/js/library/jquery.gardenmorepager.js');
$this->AddJsFile('search.js');
$this->Title(Translate('Search'));
if (!is_numeric($Limit)) {
$Limit = Gdn::Config('Garden.Search.PerPage', 20);
}
$Search = $this->Form->GetFormValue('Search');
$ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit);
$this->SetData('SearchResults', $ResultSet, TRUE);
$this->SetData('SearchTerm', Format::Text($Search), TRUE);
$NumResults = $ResultSet->NumRows();
if ($NumResults == $Offset + $Limit) {
$NumResults++;
}
// Build a pager
$PagerFactory = new PagerFactory();
$Pager = $PagerFactory->GetPager('MorePager', $this);
$Pager->MoreCode = 'More Results';
$Pager->LessCode = 'Previous Results';
$Pager->ClientID = 'Pager';
$Pager->Configure($Offset, $Limit, $NumResults, 'garden/search/%1$s/%2$s/?Search=' . Format::Url($Search));
$this->SetData('Pager', $Pager, TRUE);
$this->View = 'results';
$this->Render();
}
示例4: Index
public function Index($Offset = 0, $Limit = NULL)
{
$this->AddJsFile('/js/library/jquery.gardenmorepager.js');
$this->AddJsFile('search.js');
$this->Title(T('Search'));
if (!is_numeric($Limit)) {
$Limit = Gdn::Config('Garden.Search.PerPage', 20);
}
$Search = $this->Form->GetFormValue('Search');
$ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit);
$this->SetData('SearchResults', $ResultSet, TRUE);
$this->SetData('SearchTerm', Gdn_Format::Text($Search), TRUE);
if ($ResultSet) {
$NumResults = $ResultSet->NumRows();
} else {
$NumResults = 0;
}
if ($NumResults == $Offset + $Limit) {
$NumResults++;
}
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$Pager = $PagerFactory->GetPager('MorePager', $this);
$Pager->MoreCode = 'More Results';
$Pager->LessCode = 'Previous Results';
$Pager->ClientID = 'Pager';
$Pager->Configure($Offset, $Limit, $NumResults, 'dashboard/search/%1$s/%2$s/?Search=' . Gdn_Format::Url($Search));
$this->SetData('Pager', $Pager, TRUE);
if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
$this->SetJson('LessRow', $this->Pager->ToString('less'));
$this->SetJson('MoreRow', $this->Pager->ToString('more'));
$this->View = 'results';
}
$this->Render();
}
示例5: DiscussionsController_Participated_Create
public function DiscussionsController_Participated_Create(&$Sender, $Args)
{
$Sender->Permission('Garden.SignIn.Allow');
$Page = GetValue(0, $Args);
$Limit = GetValue(1, $Args);
list($Offset, $Limit) = OffsetLimit($Page, Gdn::Config('Vanilla.Discussions.PerPage', 30));
// Get Discussions
$DiscussionModel = new DiscussionModel();
$Sender->DiscussionData = $DiscussionModel->GetParticipated(Gdn::Session()->UserID, $Offset, $Limit);
$Sender->SetData('Discussions', $Sender->DiscussionData);
$CountDiscussions = $DiscussionModel->GetCountParticipated(Gdn::Session()->UserID);
$Sender->SetData('CountDiscussions', $CountDiscussions);
// Build a pager
$PagerFactory = new Gdn_PagerFactory();
$Sender->EventArguments['PagerType'] = 'Pager';
$Sender->FireEvent('BeforeBuildPager');
$Sender->Pager = $PagerFactory->GetPager($Sender->EventArguments['PagerType'], $Sender);
$Sender->Pager->ClientID = 'Pager';
$Sender->Pager->Configure($Offset, $Limit, $CountDiscussions, 'discussions/participated/%1$s');
$Sender->FireEvent('AfterBuildPager');
// Deliver JSON data if necessary
if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL) {
$Sender->SetJson('LessRow', $Sender->Pager->ToString('less'));
$Sender->SetJson('MoreRow', $Sender->Pager->ToString('more'));
$Sender->View = 'discussions';
}
// Add modules
$Sender->AddModule('NewDiscussionModule');
$Sender->AddModule('CategoriesModule');
$BookmarkedModule = new BookmarkedModule($Sender);
$BookmarkedModule->GetData();
$Sender->AddModule($BookmarkedModule);
$Sender->Render($this->GetView('participated.php'));
}
示例6: Folders
/**
* Returns an array of all folder names within the source folder or FALSE
* if SourceFolder does not exist.
*
* @param string $SourceFolder
* @todo Documentation and variable type is needed for $SourceFolder.
*/
public static function Folders($SourceFolders)
{
if (!is_array($SourceFolders)) {
$SourceFolders = array($SourceFolders);
}
$BlackList = Gdn::Config('Garden.FolderBlacklist');
if (!is_array($BlackList)) {
$BlackList = array('.', '..');
}
$Result = array();
foreach ($SourceFolders as $SourceFolder) {
if ($DirectoryHandle = opendir($SourceFolder)) {
while (($Item = readdir($DirectoryHandle)) !== FALSE) {
$SubFolder = CombinePaths(array($SourceFolder, $Item));
if (!in_array($Item, $BlackList) && is_dir($SubFolder)) {
$Result[] = $Item;
}
}
closedir($DirectoryHandle);
}
}
if (count($Result) == 0) {
return FALSE;
}
return $Result;
}
示例7: __construct
public function __construct()
{
$this->Dispatcher = new Gdn_Dispatcher();
$EnabledApplications = Gdn::Config('EnabledApplications');
$this->Dispatcher->EnabledApplicationFolders($EnabledApplications);
$this->Dispatcher->PassProperty('EnabledApplications', $EnabledApplications);
}
示例8: SetModuleSort
/**
* Function for quick modify sorting for modules in configuration file.
* See library/core/class.controller.php ~ L: 118
* If $PositionItem is False (default) $ModuleName will be added to the edn of the list.
* If $PositionItem is integer (positive or negative) ...
* If $PositionItem is string ...
*
* @param string $ModuleSortContainer, container name.
* @param string $AssetName, asset name.
* @param string $ModuleName, module name which need to add to config.
* @param mixed $PositionItem.
* @return bool. Return FALSE on failure.
*/
function SetModuleSort($ModuleSortContainer, $AssetName, $ModuleName, $PositionItem = False)
{
$ModuleSort = Gdn::Config('Modules');
$AssetSort = GetValueR("{$ModuleSortContainer}.{$AssetName}", $ModuleSort, array());
if (!is_array($AssetSort)) {
$AssetSort = array();
}
if ($PositionItem !== False) {
if (!is_numeric($PositionItem)) {
$Position = substr($PositionItem, 0, 1);
if (in_array($Position, array('-', '+'))) {
$PositionItem = substr($PositionItem, 1);
}
$PositionItem = array_search($PositionItem, $AssetSort);
if ($Position == '+') {
$PositionItem = (int) $PositionItem + 1;
}
}
$PositionItem = (int) $PositionItem;
array_splice($AssetSort, $PositionItem, 0, array($ModuleName));
} else {
array_push($AssetSort, $ModuleName);
}
$AssetSort = array_unique($AssetSort);
// Make sure that we put in config strings only.
$VarExport = create_function('$Value', 'return var_export(strval($Value), True);');
$ModuleList = implode(', ', array_map($VarExport, $AssetSort));
$PhpArrayCode = "\n\$Configuration['Modules']['{$ModuleSortContainer}']['{$AssetName}'] = array({$ModuleList});";
$ConfigFile = PATH_CONF . '/config.php';
$Result = file_put_contents($ConfigFile, $PhpArrayCode, FILE_APPEND | LOCK_EX);
return $Result !== False;
}
示例9: Get
/**
* Get messages by conversation.
*
* Events: BeforeGet.
*
* @since 2.0.0
* @access public
*
* @param int $ConversationID Unique ID of conversation being viewed.
* @param int $ViewingUserID Unique ID of current user.
* @param int $Offset Number to skip.
* @param int $Limit Maximum to return.
* @param array $Wheres SQL conditions.
* @return Gdn_DataSet SQL results.
*/
public function Get($ConversationID, $ViewingUserID, $Offset = '0', $Limit = '', $Wheres = '') {
if ($Limit == '')
$Limit = Gdn::Config('Conversations.Messages.PerPage', 50);
$Offset = !is_numeric($Offset) || $Offset < 0 ? 0 : $Offset;
if (is_array($Wheres))
$this->SQL->Where($Wheres);
$this->FireEvent('BeforeGet');
return $this->SQL
->Select('cm.*')
->Select('iu.Name', '', 'InsertName')
->Select('iu.Photo', '', 'InsertPhoto')
->From('ConversationMessage cm')
->Join('Conversation c', 'cm.ConversationID = c.ConversationID')
->Join('UserConversation uc', 'c.ConversationID = uc.ConversationID and uc.UserID = '.$ViewingUserID, 'left')
->Join('User iu', 'cm.InsertUserID = iu.UserID', 'left')
->BeginWhereGroup()
->Where('uc.DateCleared is null')
->OrWhere('uc.DateCleared <', 'cm.DateInserted', TRUE, FALSE) // Make sure that cleared conversations do not show up unless they have new messages added.
->EndWhereGroup()
->Where('cm.ConversationID', $ConversationID)
->OrderBy('cm.DateInserted', 'asc')
->Limit($Limit, $Offset)
->Get();
}
示例10: Base_Render_Before
public function Base_Render_Before(&$Sender)
{
$Session = Gdn::Session();
// Enable theme previewing
if ($Session->IsValid()) {
$PreviewThemeFolder = $Session->GetPreference('PreviewThemeFolder', '');
// echo 'test'.$PreviewThemeFolder;
if ($PreviewThemeFolder != '') {
$Sender->Theme = $PreviewThemeFolder;
$Sender->AddAsset('Content', $Sender->FetchView('previewtheme', 'settingscontroller', 'dashboard'));
$Sender->AddCssFile('previewtheme.css');
}
}
// Add Message Modules (if necessary)
$MessageCache = Gdn::Config('Garden.Messages.Cache', array());
$Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod;
if ($Sender->MasterView != 'empty' && in_array('Base', $MessageCache) || InArrayI($Location, $MessageCache)) {
$MessageModel = new MessageModel();
$MessageData = $MessageModel->GetMessagesForLocation($Location);
foreach ($MessageData as $Message) {
$MessageModule = new MessageModule($Sender, $Message);
$Sender->AddModule($MessageModule);
}
}
}
示例11: Advanced
public function Advanced()
{
$this->Permission('Vanilla.Settings.Manage');
$Validation = new Gdn_Validation();
$ConfigurationModel = new Gdn_ConfigurationModel($Validation);
$ConfigurationModel->SetField(array('Vanilla.Archive.Date', 'Vanilla.Archive.Exclude'));
// Set the model on the form.
$this->Form->SetModel($ConfigurationModel);
// If seeing the form for the first time...
if ($this->Form->AuthenticatedPostBack() === FALSE) {
// Apply the config settings to the form.
$this->Form->SetData($ConfigurationModel->Data);
} else {
$ConfigurationModel->Validation->ApplyRule('Vanilla.Archive.Date', 'Date');
// Grab old config values to check for an update.
$ArchiveDateBak = Gdn::Config('Vanilla.Archive.Date');
$ArchiveExcludeBak = (bool) Gdn::Config('Vanilla.Archive.Exclude');
$Saved = $this->Form->Save();
if ($Saved) {
$ArchiveDate = Gdn::Config('Vanilla.Archive.Date');
$ArchiveExclude = (bool) Gdn::Config('Vanilla.Archive.Exclude');
if ($ArchiveExclude != $ArchiveExcludeBak || $ArchiveExclude && $ArchiveDate != $ArchiveDateBak) {
$DiscussionModel = new Gdn_DiscussionModel();
$DiscussionModel->UpdateDiscussionCount('All');
}
$this->StatusMessage = Translate("Your changes have been saved.");
}
}
$this->AddSideMenu('vanilla/settings/advanced');
$this->AddJsFile('settings.js');
$this->Title(Translate('Advanced Forum Settings'));
$this->Render();
}
示例12: smarty_function_link
/**
* Takes a route and prepends the web root (expects "/controller/action/params" as $Path).
*
* @param array The parameters passed into the function.
* The parameters that can be passed to this function are as follows.
* - <b>path</b>: The relative path for the url. There are some special paths that can be used to return "intelligent" links:
* - <b>signinout</b>: This will return a signin/signout url that will toggle depending on whether or not the user is already signed in. When this path is given the text is automaticall set.
* - <b>withdomain</b>: Whether or not to add the domain to the url.
* - <b>text</b>: Html text to be put inside an anchor. If this value is set then an html <a></a> is returned rather than just a url.
* - <b>id, class, etc.></b>: When an anchor is generated then any other attributes are passed through and will be written in the resulting tag.
* @param Smarty The smarty object rendering the template.
* @return The url.
*/
function smarty_function_link($Params, &$Smarty)
{
$Path = GetValue('path', $Params, '', TRUE);
$WithDomain = GetValue('withdomain', $Params, FALSE, TRUE);
$RemoveSyndication = GetValue('removeSyndication', $Params, FALSE, TRUE);
$Text = GetValue('text', $Params, '', TRUE);
$NoTag = GetValue('notag', $Params, FALSE, TRUE);
$Class = GetValue('class', $Params, '', TRUE);
$Session = Gdn::Session();
$Authenticator = Gdn::Authenticator();
// Use some logic to expan special urls.
switch (strtolower($Path)) {
case "signinout":
// The destination is the signin/signout toggle link.
if ($Session->IsValid()) {
if (!$Text && !$NoTag) {
$Text = T('Sign Out');
}
$Path = $Authenticator->SignOutUrl();
$Class = ConcatSep(' ', $Class, 'SignOut');
} else {
if (!$Text && !$NoTag) {
$Text = T('Sign In');
}
$Attribs = array();
$Path = $Authenticator->SignInUrl('');
if (Gdn::Config('Garden.SignIn.Popup')) {
$Class = ConcatSep(' ', $Class, 'SignInPopup');
}
}
break;
}
$Url = Url($Path, $WithDomain, $RemoveSyndication);
$Url = str_replace('{Session_TransientKey}', $Session->TransientKey(), $Url);
if (!$Text) {
$NoTag = TRUE;
}
if ($NoTag) {
$Result = $Url;
} else {
$Result = '<a';
// Add the standard attrbutes to the anchor.
$ID = GetValue('id', $Params, '', TRUE);
if ($ID) {
$Result .= ' id="' . urlencode($ID) . '"';
}
$Result .= ' href="' . $Url . '"';
if ($Class) {
$Result .= ' class="' . urlencode($Class) . '"';
}
// Add anything that's left over.
foreach ($Params as $Key => $Value) {
$Result .= ' ' . $Key . '="' . urlencode($Value) . '"';
}
// Add the link text.
$Result .= '>' . $Text . '</a>';
}
return $Result;
}
示例13: Save
public function Save($FormPostValues)
{
$Session = Gdn::Session();
// Define the primary key in this model's table.
$this->DefineSchema();
// Add & apply any extra validation rules:
$this->Validation->ApplyRule('Body', 'Required');
$MaxCommentLength = Gdn::Config('Vanilla.Comment.MaxLength');
if (is_numeric($MaxCommentLength) && $MaxCommentLength > 0) {
$this->Validation->SetSchemaProperty('Body', 'Length', $MaxCommentLength);
$this->Validation->ApplyRule('Body', 'Length');
}
// Get the DraftID from the form so we know if we are inserting or updating.
$DraftID = ArrayValue('DraftID', $FormPostValues, '');
$Insert = $DraftID == '' ? TRUE : FALSE;
// Remove the discussionid from the form value collection if it's empty
if (array_key_exists('DiscussionID', $FormPostValues) && $FormPostValues['DiscussionID'] == '') {
unset($FormPostValues['DiscussionID']);
}
if ($Insert) {
// If no categoryid is defined, grab the first available.
if (ArrayValue('CategoryID', $FormPostValues) === FALSE) {
$FormPostValues['CategoryID'] = $this->SQL->Get('Category', '', '', 1)->FirstRow()->CategoryID;
}
}
// Add the update fields because this table's default sort is by DateUpdated (see $this->Get()).
$this->AddInsertFields($FormPostValues);
$this->AddUpdateFields($FormPostValues);
// Remove checkboxes from the fields if they were unchecked
if (ArrayValue('Announce', $FormPostValues, '') === FALSE) {
unset($FormPostValues['Announce']);
}
if (ArrayValue('Closed', $FormPostValues, '') === FALSE) {
unset($FormPostValues['Closed']);
}
if (ArrayValue('Sink', $FormPostValues, '') === FALSE) {
unset($FormPostValues['Sink']);
}
// Validate the form posted values
if ($this->Validate($FormPostValues, $Insert)) {
$Fields = $this->Validation->SchemaValidationFields();
// All fields on the form that relate to the schema
$DraftID = intval(ArrayValue('DraftID', $Fields, 0));
// If the post is new and it validates, make sure the user isn't spamming
if ($DraftID > 0) {
// Update the draft
$Fields = RemoveKeyFromArray($Fields, 'DraftID');
// Remove the primary key from the fields for saving
$this->SQL->Put($this->Name, $Fields, array($this->PrimaryKey => $DraftID));
} else {
// Insert the draft
unset($Fields['DraftID']);
$DraftID = $this->SQL->Insert($this->Name, $Fields);
$this->UpdateUser($Session->UserID);
}
}
return $DraftID;
}
示例14: Advanced
/**
* Advanced settings.
*
* Allows setting configuration values via form elements.
*
* @since 2.0.0
* @access public
*/
public function Advanced() {
// Check permission
$this->Permission('Vanilla.Settings.Manage');
// Load up config options we'll be setting
$Validation = new Gdn_Validation();
$ConfigurationModel = new Gdn_ConfigurationModel($Validation);
$ConfigurationModel->SetField(array(
'Vanilla.Discussions.PerPage',
'Vanilla.Comments.AutoRefresh',
'Vanilla.Comments.PerPage',
'Vanilla.Archive.Date',
'Vanilla.Archive.Exclude',
'Garden.EditContentTimeout'
));
// Set the model on the form.
$this->Form->SetModel($ConfigurationModel);
// If seeing the form for the first time...
if ($this->Form->AuthenticatedPostBack() === FALSE) {
// Apply the config settings to the form.
$this->Form->SetData($ConfigurationModel->Data);
} else {
// Define some validation rules for the fields being saved
$ConfigurationModel->Validation->ApplyRule('Vanilla.Discussions.PerPage', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Discussions.PerPage', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comments.AutoRefresh', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comments.PerPage', 'Required');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Comments.PerPage', 'Integer');
$ConfigurationModel->Validation->ApplyRule('Vanilla.Archive.Date', 'Date');
$ConfigurationModel->Validation->ApplyRule('Garden.EditContentTimeout', 'Integer');
// Grab old config values to check for an update.
$ArchiveDateBak = Gdn::Config('Vanilla.Archive.Date');
$ArchiveExcludeBak = (bool)Gdn::Config('Vanilla.Archive.Exclude');
// Save new settings
$Saved = $this->Form->Save();
if($Saved) {
$ArchiveDate = Gdn::Config('Vanilla.Archive.Date');
$ArchiveExclude = (bool)Gdn::Config('Vanilla.Archive.Exclude');
if($ArchiveExclude != $ArchiveExcludeBak || ($ArchiveExclude && $ArchiveDate != $ArchiveDateBak)) {
$DiscussionModel = new DiscussionModel();
$DiscussionModel->UpdateDiscussionCount('All');
}
$this->InformMessage(T("Your changes have been saved."));
}
}
$this->AddSideMenu('vanilla/settings/advanced');
$this->AddJsFile('settings.js');
$this->Title(T('Advanced Forum Settings'));
// Render default view (settings/advanced.php)
$this->Render();
}
示例15: CheckForSpam
/**
* Checks to see if the user is spamming. Returns TRUE if the user is spamming.
*/
public function CheckForSpam($Type)
{
$Spam = FALSE;
if (!in_array($Type, array('Comment', 'Discussion'))) {
trigger_error(ErrorMessage(sprintf('Spam check type unknown: %s', $Type), 'VanillaModel', 'CheckForSpam'), E_USER_ERROR);
}
$Session = Gdn::Session();
$CountSpamCheck = $Session->GetAttribute('Count' . $Type . 'SpamCheck', 0);
$DateSpamCheck = $Session->GetAttribute('Date' . $Type . 'SpamCheck', 0);
$SecondsSinceSpamCheck = time() - Format::ToTimestamp($DateSpamCheck);
$SpamCount = Gdn::Config('Vanilla.' . $Type . '.SpamCount');
if (!is_numeric($SpamCount) || $SpamCount < 2) {
$SpamCount = 2;
}
// 2 spam minimum
$SpamTime = Gdn::Config('Vanilla.' . $Type . '.SpamTime');
if (!is_numeric($SpamTime) || $SpamTime < 0) {
$SpamTime = 30;
}
// 30 second minimum spam span
$SpamLock = Gdn::Config('Vanilla.' . $Type . '.SpamLock');
if (!is_numeric($SpamLock) || $SpamLock < 30) {
$SpamLock = 30;
}
// 30 second minimum lockout
// Definition:
// Users cannot post more than $SpamCount comments within $SpamTime
// seconds or their account will be locked for $SpamLock seconds.
// Apply a spam lock if necessary
$Attributes = array();
if ($SecondsSinceSpamCheck < $SpamLock && $CountSpamCheck >= $SpamCount && $DateSpamCheck !== FALSE) {
// TODO: REMOVE DEBUGGING INFO AFTER THIS IS WORKING PROPERLY
/*
echo '<div>SecondsSinceSpamCheck: '.$SecondsSinceSpamCheck.'</div>';
echo '<div>SpamLock: '.$SpamLock.'</div>';
echo '<div>CountSpamCheck: '.$CountSpamCheck.'</div>';
echo '<div>SpamCount: '.$SpamCount.'</div>';
echo '<div>DateSpamCheck: '.$DateSpamCheck.'</div>';
echo '<div>SpamTime: '.$SpamTime.'</div>';
*/
$Spam = TRUE;
$this->Validation->AddValidationResult('Body', sprintf(T('You have posted %1$s times within %2$s seconds. A spam block is now in effect on your account. You must wait at least %3$s seconds before attempting to post again.'), $SpamCount, $SpamTime, $SpamLock));
// Update the 'waiting period' every time they try to post again
$Attributes['Date' . $Type . 'SpamCheck'] = Format::ToDateTime();
} else {
if ($SecondsSinceSpamCheck > $SpamTime) {
$Attributes['Count' . $Type . 'SpamCheck'] = 1;
$Attributes['Date' . $Type . 'SpamCheck'] = Format::ToDateTime();
} else {
$Attributes['Count' . $Type . 'SpamCheck'] = $CountSpamCheck + 1;
}
}
// Update the user profile after every comment
$UserModel = Gdn::UserModel();
$UserModel->SaveAttribute($Session->UserID, $Attributes);
return $Spam;
}