public function BuildCategorySiteMap($UrlCode, &$Urls) { $Category = CategoryModel::Categories($UrlCode); if (!$Category) { throw NotFoundException(); } // Get the min/max dates for the sitemap. $Row = Gdn::SQL()->Select('DateInserted', 'min', 'MinDate')->Select('DateInserted', 'max', 'MaxDate')->From('Discussion')->Where('CategoryID', $Category['CategoryID'])->Get()->FirstRow(DATASET_TYPE_ARRAY); if ($Row) { $From = strtotime('first day of this month 00:00:00', strtotime($Row['MaxDate'])); $To = strtotime('first day of this month 00:00:00', strtotime($Row['MinDate'])); if (!$From || !$To) { $From = -1; $To = 0; } } else { $From = -1; $To = 0; } $Now = time(); for ($i = $From; $i >= $To; $i = strtotime('-1 month', $i)) { $Url = array('Loc' => Url('/categories/archives/' . rawurlencode($Category['UrlCode'] ? $Category['UrlCode'] : $Category['CategoryID']) . '/' . gmdate('Y-m', $i), TRUE), 'LastMod' => '', 'ChangeFreq' => ''); $LastMod = strtotime('last day of this month', $i); if ($LastMod > $Now) { $LastMod = $Now; } $Url['LastMod'] = gmdate('c', $LastMod); $Urls[] = $Url; } // If there are no links then just link to the category. if (count($Urls) === 0) { $Url = array('Loc' => CategoryUrl($Category), 'LastMode' => '', 'ChangeFreq' => ''); $Urls[] = $Url; } }
private function _GenerateConfContent($Template) { $SQLSock = ''; if ('' != trim(ini_get('mysql.default_socket'))) { $SQLSock = 'sql_sock = ' . ini_get('mysql.default_socket'); } //Check to see if grabing any of the tags ///@todo fix this stopgap solution with something more robust //Get list of tags $SQL = Gdn::SQL(); if (Gdn::Structure()->TableExists('TagDiscussion')) { $Tags = TRUE; } else { $Tags = FALSE; } $DBPrefix = C('Database.Name') . '.' . C('Database.DatabasePrefix', 'GDN_'); //join these 2 $Search = array('{sql_sock}' => $SQLSock, '{sql_host}' => $this->Settings['Install']->Host, '{sql_user}' => C('Database.User'), '{sql_pass}' => C('Database.Password'), '{sql_db}' => C('Database.Name'), '{charset_type}' => C('Garden.Charset', 'utf-8'), '{charset_type_mysql}' => C('Database.CharacterEncoding', 'utf8'), '{install_path}' => $this->Settings['Install']->InstallPath, '{assests_path}' => PATH_PLUGINS . DS . 'SphinxSearchLite' . DS . 'assests' . DS, '{searchd_port}' => $this->Settings['Install']->Port, '{log_path}' => $this->Settings['Install']->LogPath, '{query_path}' => $this->Settings['Install']->QueryPath, '{PID_path}' => $this->Settings['Install']->PIDPath, '{data_path}' => $this->Settings['Install']->DataPath, '{db_prefix}' => $DBPrefix, '{ss_prefix}' => $this->Settings['Install']->Prefix); /* '{tag_select}' => $Tags == TRUE ? '(SELECT td.TagID as TagName\ FROM '.$DBPrefix.'TagDiscussion td\ WHERE pic.GDN_Comment.DiscussionID = td.DiscussionID),\\' : '\\',*/ $ReWritedContent = str_replace(array_keys($Search), $Search, $Template); //echo nl2br($ReWritedContent); die; return $ReWritedContent; }
public function GetAll($ForeignType, $ForeignIDs = array()) { if (count($ForeignIDs) == 0) { return new Gdn_DataSet(array()); } return Gdn::SQL()->Select('*')->From('Regarding')->Where('ForeignType', $ForeignType)->WhereIn('ForeignID', $ForeignIDs)->Get(); }
protected function _CacheOnlineUserss(&$Sender) { //logic taken from Who's Online plugin $SQL = Gdn::SQL(); // $this->_OnlineUsers = $SQL // insert or update entry into table $Session = Gdn::Session(); $Invisible = $Invisible ? 1 : 0; if ($Session->UserID) { $SQL->Replace('Whosonline', array('UserID' => $Session->UserID, 'Timestamp' => Gdn_Format::ToDateTime(), 'Invisible' => $Invisible), array('UserID' => $Session->UserID)); } $Frequency = C('WhosOnline.Frequency', 4); $History = time() - $Frequency; $SQL->Select('u.UserID, u.Name, w.Timestamp, w.Invisible')->From('Whosonline w')->Join('User u', 'w.UserID = u.UserID')->Where('w.Timestamp >=', date('Y-m-d H:i:s', $History))->OrderBy('u.Name'); if (!$Session->CheckPermission('Plugins.WhosOnline.ViewHidden')) { $SQL->Where('w.Invisible', 0); } $OnlineUsers = $SQL->Get(); $arrOnline = array(); if ($OnlineUsers->NumRows() > 0) { foreach ($OnlineUsers->Result() as $User) { $arrOnline[] = $User->UserID; } } $Sender->SetData('Plugin-OnlineUsers-Marker', $arrOnline); }
public function GetData($Limit = 10) { $this->Data = FALSE; if (Gdn::Session()->IsValid() && C('Vanilla.Modules.ShowBookmarkedModule', TRUE)) { $BookmarkIDs = Gdn::SQL() ->Select('DiscussionID') ->From('UserDiscussion') ->Where('UserID', Gdn::Session()->UserID) ->Where('Bookmarked', 1) ->Get()->ResultArray(); $BookmarkIDs = ConsolidateArrayValuesByKey($BookmarkIDs, 'DiscussionID'); if (count($BookmarkIDs)) { $DiscussionModel = new DiscussionModel(); DiscussionModel::CategoryPermissions(); $DiscussionModel->SQL->WhereIn('d.DiscussionID', $BookmarkIDs); $this->Data = $DiscussionModel->Get( 0, $Limit ); } else { $this->Data = FALSE; } } }
public function GetData($FingerprintUserID, $Fingerprint) { if (!Gdn::Session()->CheckPermission('Garden.Users.Edit')) { return; } $this->_Data = Gdn::SQL()->Select()->From('User')->Where('Fingerprint', $Fingerprint)->Where('UserID <>', $FingerprintUserID)->Get(); }
public function GetData() { $TagQuery = Gdn::SQL(); $this->AutoContext(); $TagCacheKey = "TagModule-{$this->ParentType}-{$this->ParentID}"; switch ($this->ParentType) { case 'Discussion': $Tags = TagModel::instance()->getDiscussionTags($this->ParentID, false); break; case 'Category': $TagQuery->Join('TagDiscussion td', 't.TagID = td.TagID')->Select('COUNT(DISTINCT td.TagID)', '', 'NumTags')->Where('td.CategoryID', $this->ParentID)->GroupBy('td.TagID')->Cache($TagCacheKey, 'get', array(Gdn_Cache::FEATURE_EXPIRY => 120)); break; case 'Global': $TagCacheKey = 'TagModule-Global'; $TagQuery->Where('t.CountDiscussions >', 0, FALSE)->Cache($TagCacheKey, 'get', array(Gdn_Cache::FEATURE_EXPIRY => 120)); if ($this->CategorySearch) { $TagQuery->Where('t.CategoryID', '-1'); } break; } if (isset($Tags)) { $this->_TagData = new Gdn_DataSet($Tags, DATASET_TYPE_ARRAY); } else { $this->_TagData = $TagQuery->Select('t.*')->From('Tag t')->OrderBy('t.CountDiscussions', 'desc')->Limit(25)->Get(); } $this->_TagData->DatasetType(DATASET_TYPE_ARRAY); }
public function Expire() { $ExpireBans = Gdn::SQL()->Select('Count(UserID)')->From('User')->Where(array('Banned' => TRUE, 'BanExpire<' => Gdn_Format::ToDateTime()))->Get()->Result(); if ($ExpireBans) { Gdn::SQL()->Put('User', array('Banned' => FALSE, 'BanExpire' => NULL), array('Banned' => TRUE, 'BanExpire<' => Gdn_Format::ToDateTime())); } }
public function GetData($DiscussionID = '') { $SQL = Gdn::SQL(); if (is_numeric($DiscussionID) && $DiscussionID > 0) { $this->_DiscussionID = $DiscussionID; $SQL->Join('TagDiscussion td', 't.TagID = td.TagID')->Where('td.DiscussionID', $DiscussionID); } $this->_TagData = $SQL->Select('t.*')->From('Tag t')->Where('t.CountDiscussions >', 0, FALSE)->OrderBy('t.CountDiscussions', 'desc')->Limit(25)->Get(); }
public function Structure() { // Get a user for operations. $UserID = Gdn::SQL()->GetWhere('User', array('Name' => 'Mollom', 'Admin' => 2))->Value('UserID'); if (!$UserID) { $UserID = Gdn::SQL()->Insert('User', array('Name' => 'Mollom', 'Password' => RandomString('20'), 'HashMethod' => 'Random', 'Email' => '*****@*****.**', 'DateInserted' => Gdn_Format::ToDateTime(), 'Admin' => '2')); } SaveToConfig('Plugins.Mollom.UserID', $UserID); }
public static function DeleteRoute($URI, $RequestUri = Null) { $SQL = Gdn::SQL(); $Where = array(); if ($RequestUri !== Null) { $Where['RequestUri'] = $RequestUri; } else { $Where = array('URI' => $URI); } $SQL->Delete('Route', $Where); }
public function Award($Sender, $User, $Criteria) { $Target = $Criteria->Target; $TargetDate = date(DATE_ISO8601, strtotime($Criteria->Duration . ' ' . $Criteria->Period . ' ago')); $SQL = Gdn::SQL(); $Count = $SQL->Select('count(CommentID) as Count')->From('Comment')->Where('InsertUserID', $User->UserID)->Where('DateInserted >=', $TargetDate)->Get()->FirstRow(); if ($Count->Count >= $Target) { return TRUE; } else { return FALSE; } }
public function DiscussionModel_GetCountParticipated_Create(&$Sender) { $UserID = GetValue(0, $Sender->EventArguments); if (is_null($UserID)) { if (!Gdn::Session()->IsValid()) { throw new Exception(T("Could not get participated discussions for non logged-in user.")); } $UserID = Gdn::Session()->UserID; } $Count = Gdn::SQL()->Select('c.DiscussionID', 'DISTINCT', 'NumDiscussions')->From('Comment c')->Where('c.InsertUserID', $UserID)->GroupBy('c.DiscussionID')->Get(); return $Count instanceof Gdn_Dataset ? $Count->NumRows() : FALSE; }
public function GetProviderByScheme($AuthenticationSchemeAlias, $UserID = NULL) { $ProviderQuery = Gdn::SQL()->Select('uap.*')->From('UserAuthenticationProvider uap')->Where('uap.AuthenticationSchemeAlias', $AuthenticationSchemeAlias); if (!is_null($UserID) && $UserID) { $ProviderQuery->Join('UserAuthentication ua', 'ua.ProviderKey = uap.AuthenticationKey', 'left')->Where('ua.UserID', $UserID); } $ProviderData = $ProviderQuery->Get(); if ($ProviderData->NumRows()) { return $ProviderData->FirstRow(DATASET_TYPE_ARRAY); } return FALSE; }
/** * @param Gdn_Controller $Sender * @param array $Args */ public function EntryController_Render_Before($Sender, $Args) { if ($Sender->RequestMethod != 'passwordreset') { return; } if (isset($Sender->Data['User'])) { // Get all of the users with the same email. $Email = $Sender->Data('User.Email'); $Users = Gdn::SQL()->Select('Name')->From('User')->Where('Email', $Email)->Get()->ResultArray(); $Names = array_column($Users, 'Name'); SetValue('Name', $Sender->Data['User'], implode(', ', $Names)); } }
public function GetData() { $SQL = Gdn::SQL(); $Limit = Gdn::Config('LatestComment.Limit'); $LatestOrMost = Gdn::Config('LatestComment.LatestOrMost'); $Limit = !$Limit || $Limit == 0 ? 10 : $Limit; $Session = Gdn::Session(); if ($LatestOrMost == "YES") { $this->_LatestComments = $SQL->Query('SELECT DiscussionID, CategoryID, Name, Body, DateLastComment, LastCommentUserID, CountComments From ' . $SQL->Database->DatabasePrefix . 'Discussion order by DateLastComment desc LIMIT ' . $Limit); } else { $this->_LatestComments = $SQL->Query('SELECT DiscussionID, CategoryID, Name, Body, DateLastComment, LastCommentUserID, CountComments From ' . $SQL->Database->DatabasePrefix . 'Discussion order by DateLastComment desc LIMIT ' . $Limit); } }
public function SaveMetaData($RowID, $OtherTable, $Values) { $TableName = $this->Name . $OtherTable; $OtherField = $OtherTable . 'ID'; $Where = array($this->PrimaryKey => $RowID); $SQL = Gdn::SQL(); $DataInsert = array(); foreach ($Values as $Value) { $DataInsert[] = array_merge($Where, array($OtherField => $Value)); } $this->SQL->Where($Where)->Delete($TableName); return $SQL->Insert($TableName, $DataInsert); }
protected function GetCount($Table) { // Try and get the count from the cache. $Key = "{$Table}.CountRows"; $Count = Gdn::Cache()->Get($Key); if ($Count !== Gdn_Cache::CACHEOP_FAILURE) { return $Count; } // The count wasn't in the cache so grab it from the table. $Count = Gdn::SQL()->Select($Table . 'ID', 'count', 'CountRows')->From($Table)->Get()->Value('CountRows'); // Save the value to the cache. Gdn::Cache()->Store($Key, $Count, array(Gdn_Cache::FEATURE_EXPIRY => 5 * 60 + mt_rand(0, 30))); return $Count; }
protected function PrepareClassic($Matches) { // print_r($Matches); die; $SQL = clone Gdn::SQL(); $SQL->Reset(); $SQL = Gdn::SQL(); $WhereIn = $this->WhereIn('c.CommentID', $Matches['Comment']); //only retrieving comments and the title of the discussion $Comment = $SQL->Select('c.DiscussionID, c.InsertUserID, c.Body, c.DateInserted, c.CommentID as CommentID, 1 as IsComment')->Select('d.CountComments, d.CountViews, d.Name as Title,d.Body as DiscussionBody')->Select('u.Name as UserName, u.Photo as UserPhoto, u.UserID')->Select('cat.Name as CatName, cat.UrlCode as CatUrlCode')->From('Comment as c')->Join('Discussion as d', 'c.DiscussionID = d.DiscussionID')->Join('User as u', 'c.InsertUserID = u.UserID')->Join('Category as cat', 'd.CategoryID = cat.CategoryID')->WhereIn('c.CommentID', $Matches['Comment'])->Get()->Result(); $SQL = clone Gdn::SQL(); $SQL->Reset(); $Discussion = $SQL->Select('d.DiscussionID, d.InsertUserID, d.Body, d.DateInserted, d.LastCommentUserID, d.DiscussionID as CommentID, 0 as IsComment')->Select('d.CountComments, d.CountViews, d.Name as Title, d.Body as DiscussionBody')->Select('u.Name as UserName, u.Photo as UserPhoto, u.UserID')->Select('cat.Name as CatName, cat.UrlCode as CatUrlCode')->From('Discussion as d')->Join('User as u', 'd.InsertUserID = u.UserID')->Join('Category as cat', 'd.CategoryID = cat.CategoryID')->WhereIn('d.DiscussionID', $Matches['Discussion'])->Get()->Result(); return $this->SortTableResults($Matches, $Comment, $Discussion); }
function GetData() { $SQL = Gdn::SQL(); $id = $this->ID; $this->_PollData = $SQL->Select('t.*')->From('Poll t')->Where('discussion_id', $id)->Get()->FirstRow(); if (!empty($this->_PollData)) { $poll_id = $this->_PollData->id; $this->_PollAnswers = $SQL->Select('t.*')->From('PollAnswers t')->Where('poll_id', $poll_id)->OrderBy('id', 'asc')->Get(); foreach ($this->_PollAnswers->Result() as $Answer) { $this->_PollVotes += $Answer->votes; } } # }
public function GetFacebookIDs($Datas, $UserIDColumn) { $UserIDs = array(); foreach ($Datas as $Data) { if ($UserID = GetValue($UserIDColumn, $Data)) { $UserIDs[] = $UserID; } else { $IDs = ConsolidateArrayValuesByKey($Data, $UserIDColumn); $UserIDs = array_merge($UserIDs, $IDs); } } $FbIDs = Gdn::SQL()->WhereIn('UserID', array_unique($UserIDs))->GetWhere('UserAuthentication', array('ProviderKey' => 'facebook'))->ResultArray(); $Result = ConsolidateArrayValuesByKey($FbIDs, 'UserID', 'ForeignUserKey'); return $Result; }
public function GetData($DiscussionID = '') { $SQL = Gdn::SQL(); if (!$DiscussionID) { $SQL->Cache('TagModule', 'get', array(Gdn_Cache::FEATURE_EXPIRY => 120)); } if (is_numeric($DiscussionID) && $DiscussionID > 0) { $this->_DiscussionID = $DiscussionID; $SQL->Join('TagDiscussion td', 't.TagID = td.TagID')->Where('td.DiscussionID', $DiscussionID); } else { $SQL->Where('t.CountDiscussions >', 0, FALSE); } $this->_TagData = $SQL->Select('t.*')->From('Tag t')->OrderBy('t.CountDiscussions', 'desc')->Limit(25)->Get(); $this->_TagData->DatasetType(DATASET_TYPE_ARRAY); }
public function GetData($time_threshold = false) { $SQL = Gdn::SQL(); $Session = Gdn::Session(); // insert or update into table if ($Session->UserID) { $SQL->Replace('CountriesOnline', array('UserID' => $Session->UserID, 'CountryCode' => $this->user_country, 'Timestamp' => $this->time_now), array('UserID' => $Session->UserID)); // How many minutes back to display country stats? Default is 5 $this->time_threshold = !$time_threshold ? C('Plugin.CountriesOnline.TimeThreshold') : $time_threshold; $threshold_candidates = $this->time_now - $this->time_threshold; // Grab relevant data, then pass to grouping method $SQL->Select('CountryCode, Timestamp')->From('CountriesOnline')->Where('Timestamp >=', $threshold_candidates); $this->db_data = $SQL->Get(); $this->grouped_data = $this->groupCountryData(); } }
public function GetData() { if (Gdn::Session()->IsValid()) { $BookmarkIDs = Gdn::SQL()->Select('DiscussionID')->From('UserDiscussion')->Where('UserID', Gdn::Session()->UserID)->Where('Bookmarked', 1)->Get()->ResultArray(); $BookmarkIDs = ConsolidateArrayValuesByKey($BookmarkIDs, 'DiscussionID'); if (count($BookmarkIDs)) { $DiscussionModel = new DiscussionModel(); DiscussionModel::CategoryPermissions(); $DiscussionModel->SQL->WhereIn('d.DiscussionID', $BookmarkIDs); $Bookmarks = $DiscussionModel->Get(0, $this->Limit, array('w.Bookmarked' => '1')); $this->SetData('Bookmarks', $Bookmarks); } else { $this->SetData('Bookmarks', new Gdn_DataSet()); } } }
/** * Delete all of the Vanilla related information for a specific user. * @param int $UserID The ID of the user to delete. * @param array $Options An array of options: * - DeleteMethod: One of delete, wipe, or NULL * @since 2.1 */ public function DeleteUserData($UserID, $Options = array(), &$Data = NULL) { $SQL = Gdn::SQL(); // Remove discussion watch records and drafts. $SQL->Delete('UserDiscussion', array('UserID' => $UserID)); Gdn::UserModel()->GetDelete('Draft', array('InsertUserID' => $UserID), $Data); // Comment deletion depends on method selected $DeleteMethod = GetValue('DeleteMethod', $Options, 'delete'); if ($DeleteMethod == 'delete') { // Clear out the last posts to the categories. $SQL->Update('Category c')->Join('Discussion d', 'd.DiscussionID = c.LastDiscussionID')->Where('d.InsertUserID', $UserID)->Set('c.LastDiscussionID', NULL)->Set('c.LastCommentID', NULL)->Put(); $SQL->Update('Category c')->Join('Comment d', 'd.CommentID = c.LastCommentID')->Where('d.InsertUserID', $UserID)->Set('c.LastDiscussionID', NULL)->Set('c.LastCommentID', NULL)->Put(); // Grab all of the discussions that the user has engaged in. $DiscussionIDs = $SQL->Select('DiscussionID')->From('Comment')->Where('InsertUserID', $UserID)->GroupBy('DiscussionID')->Get()->ResultArray(); $DiscussionIDs = ConsolidateArrayValuesByKey($DiscussionIDs, 'DiscussionID'); Gdn::UserModel()->GetDelete('Comment', array('InsertUserID' => $UserID), $Data); // Update the comment counts. $CommentCounts = $SQL->Select('DiscussionID')->Select('CommentID', 'count', 'CountComments')->Select('CommentID', 'max', 'LastCommentID')->WhereIn('DiscussionID', $DiscussionIDs)->GroupBy('DiscussionID')->Get('Comment')->ResultArray(); foreach ($CommentCounts as $Row) { $SQL->Put('Discussion', array('CountComments' => $Row['CountComments'] + 1, 'LastCommentID' => $Row['LastCommentID']), array('DiscussionID' => $Row['DiscussionID'])); } // Update the last user IDs. $SQL->Update('Discussion d')->Join('Comment c', 'd.LastCommentID = c.CommentID', 'left')->Set('d.LastCommentUserID', 'c.InsertUserID', FALSE, FALSE)->Set('d.DateLastComment', 'c.DateInserted', FALSE, FALSE)->WhereIn('d.DiscussionID', $DiscussionIDs)->Put(); // Update the last posts. $Discussions = $SQL->WhereIn('DiscussionID', $DiscussionIDs)->Where('LastCommentUserID', $UserID)->Get('Discussion'); // Delete the user's dicussions Gdn::UserModel()->GetDelete('Discussion', array('InsertUserID' => $UserID), $Data); // Update the appropriat recent posts in the categories. $CategoryModel = new CategoryModel(); $Categories = $CategoryModel->GetWhere(array('LastDiscussionID' => NULL))->ResultArray(); foreach ($Categories as $Category) { $CategoryModel->SetRecentPost($Category['CategoryID']); } } else { if ($DeleteMethod == 'wipe') { // Erase the user's dicussions $SQL->Update('Discussion')->Set('Body', T('The user and all related content has been deleted.'))->Set('Format', 'Deleted')->Where('InsertUserID', $UserID)->Put(); // Erase the user's comments $SQL->From('Comment')->Join('Discussion d', 'c.DiscussionID = d.DiscussionID')->Delete('Comment c', array('d.InsertUserID' => $UserID)); $SQL->Update('Comment')->Set('Body', T('The user and all related content has been deleted.'))->Set('Format', 'Deleted')->Where('InsertUserID', $UserID)->Put(); } else { // Leave comments } } // Remove the user's profile information related to this application $SQL->Update('User')->Set(array('CountDiscussions' => 0, 'CountUnreadDiscussions' => 0, 'CountComments' => 0, 'CountDrafts' => 0, 'CountBookmarks' => 0))->Where('UserID', $UserID)->Put(); }
public function SettingsController_RefreshTagCounts_Create($Sender) { $Sender->Permission('Garden.Settings.Manage'); $Px = $Sender->Database->DatabasePrefix; $SqlDriver = Gdn::SQL(); // Delete all the orphaned tagdiscussion records $Sql = 'delete td.* ' . "from {$Px}TagDiscussion as td " . "left join {$Px}Discussion as d ON td.DiscussionID = d.DiscussionID " . 'where d.DiscussionID is null'; $SqlDriver->Reset(); $SqlDriver->Query($Sql); // refresh the countdiscussions on all tags $Sql = "update {$Px}Tag as t " . 'set CountDiscussions = ( ' . 'select count(td.TagID) ' . "from {$Px}TagDiscussion as td " . 'where td.TagID = t.TagID group by t.TagID)'; $SqlDriver->Reset(); $SqlDriver->Query($Sql); // stash the inform message for later Gdn::Session()->Stash('RefreshCountsMessage', T('RefreshCounts.TagComplete')); Redirect('/settings/tagging'); }
public function DiscussionController_BeforeDiscussionRender_Handler($Sender, $Args) { if (!isset($_GET['noiseless'])) { return; } $Discussion = $Sender->Data('Discussion'); $Sql = Gdn::SQL(); $Sql->Select('*')->From('Comment c')->Where('c.DiscussionID', $Discussion->DiscussionID, TRUE, FALSE)->Where('c.InsertUserID', $Discussion->InsertUserID, TRUE, FALSE)->OrderBy('c.DateInserted', 'asc'); $Result = $Sql->Get(); Gdn::UserModel()->JoinUsers($Result, array('InsertUserID', 'UpdateUserID')); if (self::checkVersion('2.0')) { $Sender->SetData('CommentData', $Result, TRUE); } $Sender->SetData('Comments', $Result); $Sender->Pager->Configure(0, 0, 0, '', TRUE); $Sender->Offset = 0; }
public function GetData($Invisible = FALSE) { $SQL = Gdn::SQL(); // $this->_OnlineUsers = $SQL // insert or update entry into table $Session = Gdn::Session(); $Invisible = $Invisible ? 1 : 0; if ($Session->UserID) { $SQL->Replace('Whosonline', array('UserID' => $Session->UserID, 'Timestamp' => Gdn_Format::ToDateTime(), 'Invisible' => $Invisible), array('UserID' => $Session->UserID)); } $Frequency = C('WhosOnline.Frequency', 4); $History = time() - $Frequency; $SQL->Select('u.UserID, u.Name, w.Timestamp, w.Invisible')->From('Whosonline w')->Join('User u', 'w.UserID = u.UserID')->Where('w.Timestamp >=', date('Y-m-d H:i:s', $History))->OrderBy('u.Name'); if (!$Session->CheckPermission('Plugins.WhosOnline.ViewHidden')) { $SQL->Where('w.Invisible', 0); } $this->_OnlineUsers = $SQL->Get(); }
/** * Fetches the schema for the requested table. If it does not exist yet, it * will connect to the database and define it. * * @param string The name of the table schema to fetch from the database (or cache?). * @param Gdn_Database * @return array */ public function Fetch($Table = FALSE, $Database = NULL) { if ($Table !== FALSE) { $this->CurrentTable = $Table; } if (!is_array($this->_Schema)) { $this->_Schema = array(); } if (!array_key_exists($this->CurrentTable, $this->_Schema)) { if ($Database !== NULL) { $SQL = $Database->SQL(); } else { $SQL = Gdn::SQL(); } $this->_Schema[$this->CurrentTable] = $SQL->FetchTableSchema($this->CurrentTable); } return $this->_Schema[$this->CurrentTable]; }
public function GetData() { $SQL = Gdn::SQL(); $Limit = Gdn::Config('TopPosters.Limit'); $Limit = !$Limit || $Limit == 0 ? 10 : $Limit; $Session = Gdn::Session(); /* $SQL ->Select('u.Name, u.CountComments, u.CountDiscussions') ->From('User u') ->Where('u.CountComments >','0') ->Where('u.CountComments is not null') ->OrderBy('u.CountComments','desc') ->Limit($Limit); */ $arrExcludedUsers = Gdn::Config('TopPosters.Excluded'); $usersExcluded = is_array($arrExcludedUsers) ? ' AND UserID not in (' . Implode(',', $arrExcludedUsers) . ')' : ""; $this->_TopPosters = $SQL->Query('SELECT UserID, Name, if(CountDiscussions is NULL,0,CountDiscussions) + if(CountComments is NULL,0,CountComments) as AllPosted FROM ' . $SQL->Database->DatabasePrefix . 'User WHERE 1 ' . $usersExcluded . ' HAVING AllPosted > 0 order by AllPosted desc, Name asc LIMIT ' . $Limit); }