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'); }
public function ToString() { if (Gdn::Config('Vanilla.Categories.Use') == TRUE) { return parent::ToString(); } return ''; }
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(); }
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(); }
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')); }
/** * 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; }
public function __construct() { $this->Dispatcher = new Gdn_Dispatcher(); $EnabledApplications = Gdn::Config('EnabledApplications'); $this->Dispatcher->EnabledApplicationFolders($EnabledApplications); $this->Dispatcher->PassProperty('EnabledApplications', $EnabledApplications); }
/** * 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; }
/** * 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(); }
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); } } }
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(); }
/** * 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; }
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; }
/** * 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(); }
/** * 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; }
public function Base_Render_Before(&$Sender) { $MetaDescriptionlimit = 40; // should not be more than 50 $Description = Gdn::Config('Meta.Description'); $Keywords = Gdn::Config('Meta.Keywords'); $Sender->Head->AddTag('meta', array('name' => 'description', 'content' => $Description)); $Sender->Head->AddTag('meta', array('name' => 'keywords', 'content' => $Keywords)); }
/** * Load discussions for a specific tag. */ public function DiscussionsController_Tagged_Create($Sender) { $Offset = GetValue('1', $Sender->RequestArgs, 'p1'); list($Offset, $Limit) = OffsetLimit($Offset, Gdn::Config('Vanilla.Discussions.PerPage', 30)); $Sender->Tag = GetValue('0', $Sender->RequestArgs, ''); $Sender->Title(T('Tagged with ') . $Sender->Tag); $Sender->Head->Title($Sender->Head->Title()); $Sender->CanonicalUrl(Url(ConcatSep('/', 'discussions/tagged/' . $Sender->Tag, PageNumber($Offset, $Limit, TRUE)), TRUE)); if ($Sender->Head) { $Sender->AddJsFile('discussions.js'); $Sender->AddJsFile('bookmark.js'); $Sender->AddJsFile('js/library/jquery.menu.js'); $Sender->AddJsFile('options.js'); $Sender->Head->AddRss($Sender->SelfUrl . '/feed.rss', $Sender->Head->Title()); } if (!is_numeric($Offset) || $Offset < 0) { $Offset = 0; } // Add Modules $Sender->AddModule('NewDiscussionModule'); $BookmarkedModule = new BookmarkedModule($Sender); $BookmarkedModule->GetData(); $Sender->AddModule($BookmarkedModule); $Sender->SetData('Category', FALSE, TRUE); $DiscussionModel = new DiscussionModel(); $Tag = $DiscussionModel->SQL->Select()->From('Tag')->Where('Name', $Sender->Tag)->Get()->FirstRow(); $TagID = $Tag ? $Tag->TagID : 0; $CountDiscussions = $Tag ? $Tag->CountDiscussions : 0; $Sender->SetData('CountDiscussions', $CountDiscussions); $Sender->AnnounceData = FALSE; $Sender->SetData('Announcements', array(), TRUE); $DiscussionModel->FilterToTagID = $TagID; $Sender->DiscussionData = $DiscussionModel->Get($Offset, $Limit); $Sender->SetData('Discussions', $Sender->DiscussionData, TRUE); $Sender->SetJson('Loading', $Offset . ' to ' . $Limit); // Build a pager. $PagerFactory = new Gdn_PagerFactory(); $Sender->Pager = $PagerFactory->GetPager('Pager', $Sender); $Sender->Pager->ClientID = 'Pager'; $Sender->Pager->Configure($Offset, $Limit, $CountDiscussions, 'discussions/tagged/' . $Sender->Tag . '/%1$s'); // 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'; } // Set a definition of the user's current timezone from the db. jQuery // will pick this up, compare to the browser, and update the user's // timezone if necessary. $CurrentUser = Gdn::Session()->User; if (is_object($CurrentUser)) { $ClientHour = $CurrentUser->HourOffset + date('G', time()); $Sender->AddDefinition('SetClientHour', $ClientHour); } // Render the controller $Sender->Render(PATH_PLUGINS . '/Tagging/views/taggeddiscussions.php'); }
public function __construct() { // This authenticator gets its data directly from the request object, always $this->_DataSourceType = Gdn_Authenticator::DATA_NONE; // Which cookie signals the presence of an authentication package? $this->_CookieName = Gdn::Config('Garden.Authenticators.proxy.CookieName', 'VanillaProxy'); // Initialize built-in authenticator functionality parent::__construct(); }
public function SaveStep($Step) { if (Gdn::Config($Step, '') != '1') { SaveToConfig($Step, '1'); } // If all of the steps are now completed, disable this plugin if (Gdn::Config('Plugins.GettingStarted.Registration', '0') == '1' && Gdn::Config('Plugins.GettingStarted.Plugins', '0') == '1' && Gdn::Config('Plugins.GettingStarted.Categories', '0') == '1' && Gdn::Config('Plugins.GettingStarted.Profile', '0') == '1' && Gdn::Config('Plugins.GettingStarted.Discussion', '0') == '1') { Gdn::PluginManager()->DisablePlugin('GettingStarted'); } }
public function Base_Render_Before(&$Sender) { $Controller = $Sender->ControllerName; $Application = $Sender->ApplicationFolder; if ($Controller == "discussioncontroller") { $Session = Gdn::Session(); $Sender->AddJsFile('/plugins/MaxImageSize/maximagesize.js'); $Width = Gdn::Config('MaxImageSize.Width', 660); $Sender->AddDefinition('MaxImageSizeWidth', $Width); } }
public function ActivityController_Render_Before(&$Sender) { $Session = Gdn::Session(); if (!$Session->CheckPermission('Plugins.Privacy.Activity')) { if (!$Session->IsValid()) { Redirect(Gdn::Authenticator()->SignInUrl(Gdn_Url::Request())); } else { Redirect(Gdn::Config('Routes.DefaultPermission')); } } }
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); } return $this->SQL->Select('cm.*')->Select('iu.Name', '', 'InsertName')->Select('iup.Name', '', 'InsertPhoto')->From('ConversationMessage cm')->Join('Conversation c', 'cm.ConversationID = c.ConversationID')->Join('UserConversation uc', 'c.ConversationID = uc.ConversationID and uc.UserID = ' . $ViewingUserID)->Join('User iu', 'cm.InsertUserID = iu.UserID')->Join('Photo iup', 'iu.PhotoID = iup.PhotoID', 'left')->BeginWhereGroup()->Where('uc.DateCleared is null')->OrWhere('uc.DateCleared <', 'cm.DateInserted', TRUE, FALSE)->EndWhereGroup()->Where('cm.ConversationID', $ConversationID)->OrderBy('cm.DateInserted', 'asc')->Limit($Limit, $Offset)->Get(); }
public function Get($ViewingUserID, $Offset = '0', $Limit = '', $Wheres = '') { if ($Limit == '') { $Limit = Gdn::Config('Conversations.Conversations.PerPage', 50); } $Offset = !is_numeric($Offset) || $Offset < 0 ? 0 : $Offset; $this->ConversationQuery($ViewingUserID); if (is_array($Wheres)) { $this->SQL->Where($Wheres); } return $this->SQL->OrderBy('c.DateUpdated', 'desc')->Limit($Limit, $Offset)->Get(); }
public function Base_Render_Before($Sender) { if (InSection('Dashboard')) { return; } //GET THE CONFIGURATION VALUES $TOS = t('TermsOfService'); $TOSUrl = Gdn::Config('Garden.TermsOfService', '#'); // ADD CONTENT TO ASSET $Content = '<div><center><a id="TermsOfService" class="Popup" target="terms" href="' . $TOSUrl . '">' . $TOS . '</a></center></div>'; $Sender->addAsset('Foot', $Content, 'TermsOfServiceLink'); }
public function __construct(&$Sender = '') { // Load categories $this->Data = FALSE; if (Gdn::Config('Vanilla.Categories.Use') == TRUE) { if (!property_exists($Sender, 'CategoryModel') || !is_object($Sender->CategoryModel)) { $Sender->CategoryModel = new CategoryModel(); } $this->Data = $Sender->CategoryModel->GetFull(); } parent::__construct($Sender); }
public function Index($Offset = 0, $Limit = NULL) { $this->AddJsFile('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'); $Mode = $this->Form->GetFormValue('Mode'); if ($Mode) $this->SearchModel->ForceSearchMode = $Mode; try { $ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit); } catch (Gdn_UserException $Ex) { $this->Form->AddError($Ex); $ResultSet = array(); } catch (Exception $Ex) { $ResultSet = array(); } $this->SetData('SearchResults', $ResultSet, TRUE); $this->SetData('SearchTerm', Gdn_Format::Text($Search), TRUE); if($ResultSet) $NumResults = count($ResultSet); else $NumResults = 0; if ($NumResults == $Offset + $Limit) $NumResults++; // Build a pager $PagerFactory = new Gdn_PagerFactory(); $this->Pager = $PagerFactory->GetPager('MorePager', $this); $this->Pager->MoreCode = 'More Results'; $this->Pager->LessCode = 'Previous Results'; $this->Pager->ClientID = 'Pager'; $this->Pager->Configure( $Offset, $Limit, $NumResults, 'dashboard/search/%1$s/%2$s/?Search='.Gdn_Format::Url($Search) ); if ($this->_DeliveryType != DELIVERY_TYPE_ALL) { $this->SetJson('LessRow', $this->Pager->ToString('less')); $this->SetJson('MoreRow', $this->Pager->ToString('more')); $this->View = 'results'; } $this->CanonicalUrl(Url('search', TRUE)); $this->Render(); }
public function ToString() { $String = ''; $Session = Gdn::Session(); ob_start(); //Hide the top poster box id there's no post greater than 0 if ($this->_TopPosters->NumRows() > 0) { ?> <div id="TopPosters" class="Box"> <h4><?php echo Gdn::Translate("Top Posters"); ?> </h4> <ul class="PanelInfo"> <?php $i = 1; foreach ($this->_TopPosters->Result() as $User) { ?> <li> <?php echo $User->AllPosted; ?> <?php if (Gdn::Config('TopPosters.Show.Medal') == "both" || Gdn::Config('TopPosters.Show.Medal') == "side") { ?> <img src="<?php echo str_replace("index.php?p=", "", Url('/plugins/TopPosters/badges/' . (file_exists('plugins/TopPosters/badges/' . $i . '.png') ? $i . '.png' : 'medal-icon.png'))); ?> "> <?php } ?> <strong> <?php echo UserAnchor($User); ?> </strong> </li> <?php $i++; } ?> </ul> </div> <?php } $String = ob_get_contents(); @ob_end_clean(); return $String; }
public function DiscussionController_Render_Before(&$Sender) { $Session = Gdn::Session(); if ($Session->UserID == 0) { // we enable this feature only for logged in users and only on discussion page return; } $Sender->AddJsFile($this->GetResource('quoteselection.js', FALSE, FALSE)); $Sender->AddCssFile($this->GetResource('quoteselection.css', FALSE, FALSE)); $Sender->AddDefinition('qsInputFormatter', strtolower(Gdn::Config('Garden.InputFormatter'))); $Sender->AddDefinition("qsQuote", T('Quote')); $Sender->AddDefinition("qsQuoteText", T('%s said')); }
public function Check($Type = '', $Name = '') { if ($Type != '' && $Name != '') { $this->AddItem($Type, $Name); } if (count($this->_Items) > 0) { // TODO: Use garden update check url instead of this: $UpdateUrl = Url('/lussumo/update', TRUE, TRUE); $Host = Gdn_Url::Host(); $Path = CombinePaths(array(Gdn_Url::WebRoot(), 'lussumo', 'update'), '/'); $Port = 80; /* $UpdateUrl = Gdn::Config('Garden.UpdateCheckUrl', ''); $UpdateUrl = parse_url($UpdateUrl); $Host = ArrayValue('host', $UpdateUrl, 'www.lussumo.com'); $Path = ArrayValue('path', $UpdateUrl, '/'); $Port = ArrayValue('port', $UpdateUrl, '80'); */ $Path .= '?Check=' . urlencode(Format::Serialize($this->_Items)); $Locale = Gdn::Config('Garden.Locale', 'Undefined'); $Referer = Gdn_Url::WebRoot(TRUE); if ($Referer === FALSE) { $Referer = 'Undefined'; } $Timeout = 10; $Response = ''; // Connect to the update server. $Pointer = @fsockopen($Host, '80', $ErrorNumber, $Error, $Timeout); if (!$Pointer) { throw new Exception(sprintf(Gdn::Translate('Encountered an error when attempting to connect to the update server (%1$s): [%2$s] %3$s'), $UpdateUrl, $ErrorNumber, $Error)); } else { // send the necessary headers to get the file fputs($Pointer, "GET {$Path} HTTP/1.0\r\n" . "Host: {$Host}\r\n" . "User-Agent: Lussumo Garden/1.0\r\n" . "Accept: */*\r\n" . "Accept-Language: " . $Locale . "\r\n" . "Accept-Charset: utf-8;\r\n" . "Keep-Alive: 300\r\n" . "Connection: keep-alive\r\n" . "Referer: {$Referer}\r\n\r\n"); // Retrieve the response from the remote server while ($Line = fread($Pointer, 4096)) { $Response .= $Line; } fclose($Pointer); // Remove response headers $Response = substr($Response, strpos($Response, "\r\n\r\n") + 4); } $Result = Format::Unserialize($Response); // print_r($Result); if (is_array($Result)) { $this->_Items = $Result; } else { $Result = FALSE; } return $Result; } }
public function __construct($Config) { if (is_string($Config)) { $Config = Gdn::Config($Config); } $this->AuthenticateUrl = ArrayValue('AuthenticateUrl', $Config); $this->_RegisterUrl = ArrayValue('RegisterUrl', $Config); $this->_SignInUrl = ArrayValue('SignInUrl', $Config); $this->_SignOutUrl = ArrayValue('SignOutUrl', $Config); $this->Encoding = ArrayValue('Encoding', $Config, 'ini'); $this->_Identity = Gdn::Factory('Identity'); $this->_Identity->Init(); parent::__construct(); }