本文整理汇总了PHP中Gdn_Format::ToTimestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Format::ToTimestamp方法的具体用法?PHP Gdn_Format::ToTimestamp怎么用?PHP Gdn_Format::ToTimestamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn_Format
的用法示例。
在下文中一共展示了Gdn_Format::ToTimestamp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SetWatch
public function SetWatch($Discussion, $Limit, $Offset, $TotalComments)
{
// Record the user's watch data
$Session = Gdn::Session();
if ($Session->UserID > 0) {
$CountWatch = $Limit + $Offset;
if ($CountWatch > $TotalComments) {
$CountWatch = $TotalComments;
}
if (is_numeric($Discussion->CountCommentWatch)) {
// Update the watch data
if ($CountWatch != $Discussion->CountCommentWatch && $CountWatch > $Discussion->CountCommentWatch) {
// Only update the watch if there are new comments.
$this->SQL->Put('UserDiscussion', array('CountComments' => $CountWatch, 'DateLastViewed' => Gdn_Format::ToDateTime()), array('UserID' => $Session->UserID, 'DiscussionID' => $Discussion->DiscussionID));
}
} else {
// Make sure the discussion isn't archived.
$ArchiveDate = Gdn::Config('Vanilla.Archive.Date');
if (!$ArchiveDate || Gdn_Format::ToTimestamp($Discussion->DateLastComment) > Gdn_Format::ToTimestamp($ArchiveDate)) {
// Insert watch data
$this->SQL->Insert('UserDiscussion', array('UserID' => $Session->UserID, 'DiscussionID' => $Discussion->DiscussionID, 'CountComments' => $CountWatch, 'DateLastViewed' => Gdn_Format::ToDateTime()));
}
}
}
}
示例2: DiscussionModel_AfterAddColumns_Handler
/**
* Modify CountUnreadComments to account for DateAllViewed
*
* Required in DiscussionModel->Get() just before the return:
* $this->EventArguments['Data'] = $Data;
* $this->FireEvent('AfterAddColumns');
* @link http://vanillaforums.org/discussion/13227
*/
function DiscussionModel_AfterAddColumns_Handler(&$Sender)
{
if (!C('Plugins.AllViewed.Enabled')) {
return;
}
// Only for members
$Session = Gdn::Session();
if (!$Session->IsValid()) {
return;
}
// Recalculate New count with user's DateAllViewed
$Sender->Data = GetValue('Data', $Sender->EventArguments, '');
$Result =& $Sender->Data->Result();
foreach ($Result as &$Discussion) {
if (Gdn_Format::ToTimestamp($Discussion->DateLastComment) <= Gdn_Format::ToTimestamp($Session->User->DateAllViewed)) {
$Discussion->CountUnreadComments = 0;
// Covered by AllViewed
} elseif ($Discussion->CountCommentWatch == 0) {
// AllViewed used, but new comments since then
$Discussion->CountCommentWatch = -1;
// hack around "incomplete comment count" logic in WriteDiscussion
$Discussion->CountUnreadComments = $Discussion->CountComments;
}
}
}
示例3: 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() - Gdn_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'] = Gdn_Format::ToDateTime();
} else {
if ($SecondsSinceSpamCheck > $SpamTime) {
$Attributes['Count' . $Type . 'SpamCheck'] = 1;
$Attributes['Date' . $Type . 'SpamCheck'] = Gdn_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;
}
示例4: DiscussionModel_AfterAddColumns_Handler
/**
* Modify CountUnreadComments to account for DateAllViewed
*
* Required in DiscussionModel->Get() just before the return:
* $this->EventArguments['Data'] = $Data;
* $this->FireEvent('AfterAddColumns');
* @link http://vanillaforums.org/discussion/13227
*/
function DiscussionModel_AfterAddColumns_Handler(&$Sender) {
if (!C('Plugins.AllViewed.Enabled')) return;
// Only for members
$Session = Gdn::Session();
if(!$Session->IsValid()) return;
// Recalculate New count with user's DateAllViewed
$Sender->Data = GetValue('Data', $Sender->EventArguments, '');
$Result = &$Sender->Data->Result();
$DateAllViewed = Gdn_Format::ToTimestamp($Session->User->DateAllViewed);
foreach($Result as &$Discussion) {
if ($DateAllViewed != 0) { // Only if they've used AllViewed
if (Gdn_Format::ToTimestamp($Discussion->DateLastComment) <= $DateAllViewed)
$Discussion->CountUnreadComments = 0; // Covered by AllViewed
elseif ($Discussion->DateLastViewed == $DateAllViewed) // AllViewed used since last "real" view, but new comments since then
$Discussion->CountUnreadComments = $this->GetCommentCountSince($Discussion->DiscussionID, $DateAllViewed);
}
}
}
示例5: DrawEdited
protected function DrawEdited($Sender)
{
$Record = $Sender->Data('Discussion');
if (!$Record) {
$Record = $Sender->Data('Record');
}
if (!$Record) {
return;
}
$PermissionCategoryID = GetValue('PermissionCategoryID', $Record);
$Data = $Record;
$RecordType = 'discussion';
$RecordID = GetValue('DiscussionID', $Data);
// But override if comment
if (isset($Sender->EventArguments['Comment']) || GetValue('RecordType', $Record) == 'comment') {
$Data = $Sender->EventArguments['Comment'];
$RecordType = 'comment';
$RecordID = GetValue('CommentID', $Data);
}
$UserCanEdit = Gdn::Session()->CheckPermission('Vanilla.' . ucfirst($RecordType) . 's.Edit', TRUE, 'Category', $PermissionCategoryID);
if (is_null($Data->DateUpdated)) {
return;
}
if (Gdn_Format::ToTimestamp($Data->DateUpdated) <= Gdn_Format::ToTimestamp($Data->DateInserted)) {
return;
}
$SourceUserID = $Data->InsertUserID;
$UpdatedUserID = $Data->UpdateUserID;
$UserData = Gdn::UserModel()->GetID($UpdatedUserID);
$Edited = array('EditUser' => GetValue('Name', $UserData, T('Unknown User')), 'EditDate' => Gdn_Format::Date($Data->DateUpdated, 'html'), 'EditLogUrl' => Url("/log/record/{$RecordType}/{$RecordID}"), 'EditWord' => 'at');
$DateUpdateTime = Gdn_Format::ToTimestamp($Data->DateUpdated);
if (date('ymd', $DateUpdateTime) != date('ymd')) {
$Edited['EditWord'] = 'on';
}
$Format = T('PostEdited.Plain', 'Post edited by {EditUser} {EditWord} {EditDate}');
if ($UserCanEdit) {
$Format = T('PostEdited.Log', 'Post edited by {EditUser} {EditWord} {EditDate} (<a href="{EditLogUrl}">log</a>)');
}
$Display = '<div class="PostEdited">' . FormatString($Format, $Edited) . '</div>';
echo $Display;
}
示例6: Activity
public function Activity($UserReference = '', $Username = '', $UserID = '')
{
$this->Permission('Garden.Profiles.View');
$this->GetUserInfo($UserReference, $Username, $UserID);
$this->SetTabView('Activity');
$this->ActivityModel = new ActivityModel();
$Session = Gdn::Session();
$Comment = $this->Form->GetFormValue('Comment');
if ($Session->UserID > 0 && $this->Form->AuthenticatedPostBack() && !StringIsNullOrEmpty($Comment)) {
$Comment = substr($Comment, 0, 1000);
// Limit to 1000 characters...
// Update About if necessary
$ActivityType = 'WallComment';
$SendNotification = TRUE;
if ($Session->UserID == $this->User->UserID) {
$SendNotification = FALSE;
$this->UserModel->SaveAbout($Session->UserID, $Comment);
$this->User->About = $Comment;
$this->SetJson('UserData', $this->FetchView('user'));
$ActivityType = 'AboutUpdate';
}
$NewActivityID = $this->ActivityModel->Add($Session->UserID, $ActivityType, $Comment, $this->User->UserID, '', '/profile/' . $this->User->UserID . '/' . Gdn_Format::Url($this->User->Name), $SendNotification);
if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
Redirect('dashboard/profile/' . $UserReference);
} else {
// Load just the single new comment
$this->HideActivity = TRUE;
$this->ActivityData = $this->ActivityModel->GetWhere('ActivityID', $NewActivityID);
$this->View = 'activities';
$this->ControllerName = 'activity';
}
} else {
$this->ProfileUserID = $this->User->UserID;
$this->ActivityData = $this->ActivityModel->Get($this->User->UserID);
if ($this->ActivityData->NumRows() > 0) {
$ActivityData = $this->ActivityData->Result();
$ActivityIDs = ConsolidateArrayValuesByKey($ActivityData, 'ActivityID');
$LastActivity = $this->ActivityData->FirstRow();
$LastModifiedDate = Gdn_Format::ToTimestamp($this->User->DateUpdated);
$LastActivityDate = Gdn_Format::ToTimestamp($LastActivity->DateInserted);
if ($LastModifiedDate < $LastActivityDate) {
$LastModifiedDate = $LastActivityDate;
}
// Make sure to only query this page if the user has no new activity since the requesting browser last saw it.
$this->SetLastModified($LastModifiedDate);
$this->CommentData = $this->ActivityModel->GetComments($ActivityIDs);
} else {
$this->CommentData = FALSE;
}
}
// Set the canonical Url.
if (is_numeric($this->User->Name) || Gdn_Format::Url($this->User->Name) != strtolower($this->User->Name)) {
$this->CanonicalUrl(Url('profile/' . $this->User->UserID . '/' . Gdn_Format::Url($this->User->Name), TRUE));
} else {
$this->CanonicalUrl(Url('profile/' . strtolower($this->User->Name), TRUE));
}
$this->Render();
}
示例7: Start
/**
* Authenticates the user with the provided Authenticator class.
*
* @param int $UserID The UserID to start the session with.
* @param bool $SetIdentity Whether or not to set the identity (cookie) or make this a one request session.
*/
public function Start($UserID = FALSE, $SetIdentity = TRUE)
{
if (!Gdn::Config('Garden.Installed')) {
return;
}
// Retrieve the authenticated UserID from the Authenticator module.
$UserModel = Gdn::Authenticator()->GetUserModel();
$this->UserID = $UserID ? $UserID : Gdn::Authenticator()->GetIdentity();
$this->User = FALSE;
// Now retrieve user information
if ($this->UserID > 0) {
// Instantiate a UserModel to get session info
$this->User = $UserModel->GetSession($this->UserID);
if ($this->User) {
if ($UserID && $SetIdentity) {
Gdn::Authenticator()->SetIdentity($UserID);
}
if (Gdn::Authenticator()->ReturningUser($this->User)) {
$UserModel->UpdateLastVisit($this->UserID, $this->User->Attributes, $this->User->Attributes['HourOffset']);
}
$UserModel->EventArguments['User'] =& $this->User;
$UserModel->FireEvent('AfterGetSession');
$this->_Permissions = Gdn_Format::Unserialize($this->User->Permissions);
$this->_Preferences = Gdn_Format::Unserialize($this->User->Preferences);
$this->_Attributes = Gdn_Format::Unserialize($this->User->Attributes);
$this->_TransientKey = is_array($this->_Attributes) ? ArrayValue('TransientKey', $this->_Attributes) : FALSE;
if ($this->_TransientKey === FALSE) {
$this->_TransientKey = $UserModel->SetTransientKey($this->UserID);
}
// If the user hasn't been active in the session-time, update their date last active
$SessionLength = Gdn::Config('Garden.Session.Length', '15 minutes');
if (Gdn_Format::ToTimestamp($this->User->DateLastActive) < strtotime($SessionLength . ' ago')) {
$UserModel->Save(array('UserID' => $this->UserID, 'DateLastActive' => Gdn_Format::ToDateTime()));
}
} else {
$this->UserID = 0;
$this->User = FALSE;
if ($SetIdentity) {
Gdn::Authenticator()->SetIdentity(NULL);
}
}
}
// Load guest permissions if necessary
if ($this->UserID == 0) {
$this->_Permissions = Gdn_Format::Unserialize($UserModel->DefinePermissions(0));
}
}
示例8: GetID
public function GetID($DiscussionID)
{
$Session = Gdn::Session();
$this->FireEvent('BeforeGetID');
$Data = $this->SQL->Select('d.*')->Select('ca.Name', '', 'Category')->Select('ca.UrlCode', '', 'CategoryUrlCode')->Select('w.DateLastViewed, w.Dismissed, w.Bookmarked')->Select('w.CountComments', '', 'CountCommentWatch')->Select('d.DateLastComment', '', 'LastDate')->Select('d.LastCommentUserID', '', 'LastUserID')->Select('lcu.Name', '', 'LastName')->Select('iu.Name', '', 'InsertName')->Select('iup.Name', '', 'InsertPhoto')->From('Discussion d')->Join('Category ca', 'd.CategoryID = ca.CategoryID', 'left')->Join('UserDiscussion w', 'd.DiscussionID = w.DiscussionID and w.UserID = ' . $Session->UserID, 'left')->Join('User iu', 'd.InsertUserID = iu.UserID', 'left')->Join('Photo iup', 'iu.PhotoID = iup.PhotoID', 'left')->Join('Comment lc', 'd.LastCommentID = lc.CommentID', 'left')->Join('User lcu', 'lc.InsertUserID = lcu.UserID', 'left')->Where('d.DiscussionID', $DiscussionID)->Get()->FirstRow();
if ($Data && Gdn_Format::ToTimestamp($Data->DateLastComment) <= Gdn_Format::ToTimestamp(Gdn::Config('Vanilla.Archive.Date', 0))) {
$Data->Closed = '1';
}
return $Data;
}
示例9: SetWatch
/**
* Record the user's watch data.
*
* @since 2.0.0
* @access public
*
* @param object $Discussion Discussion being watched.
* @param int $Limit Max number to get.
* @param int $Offset Number to skip.
* @param int $TotalComments Total in entire discussion (hard limit).
*/
public function SetWatch($Discussion, $Limit, $Offset, $TotalComments)
{
$NewComment = FALSE;
$Session = Gdn::Session();
if ($Session->UserID > 0) {
$CountWatch = $Limit + $Offset + 1;
// Include the first comment (in the discussion table) in the count.
if ($CountWatch > $TotalComments) {
$CountWatch = $TotalComments;
$NewComment = TRUE;
}
if (is_numeric($Discussion->CountCommentWatch)) {
if (isset($Discussion->DateLastViewed)) {
$NewComment |= Gdn_Format::ToTimestamp($Discussion->DateLastComment) > Gdn_Format::ToTimestamp($Discussion->DateLastViewed);
}
// Update the watch data.
if ($NewComment || $CountWatch > $Discussion->CountCommentWatch) {
// Only update the watch if there are new comments.
$this->SQL->Put('UserDiscussion', array('CountComments' => $CountWatch, 'DateLastViewed' => Gdn_Format::ToDateTime()), array('UserID' => $Session->UserID, 'DiscussionID' => $Discussion->DiscussionID));
}
} else {
// Make sure the discussion isn't archived.
$ArchiveDate = Gdn::Config('Vanilla.Archive.Date');
if (!$ArchiveDate || Gdn_Format::ToTimestamp($Discussion->DateLastComment) > Gdn_Format::ToTimestamp($ArchiveDate)) {
// Insert watch data
$this->SQL->Insert('UserDiscussion', array('UserID' => $Session->UserID, 'DiscussionID' => $Discussion->DiscussionID, 'CountComments' => $CountWatch, 'DateLastViewed' => Gdn_Format::ToDateTime()));
}
}
}
}
示例10: Anchor
?>
<li id="<?php
echo 'Bookmark_' . $Discussion->DiscussionID;
?>
">
<strong><?php
echo Anchor($Discussion->Name, '/discussion/' . $Discussion->DiscussionID . '/' . Gdn_Format::Url($Discussion->Name) . ($Discussion->CountCommentWatch > 0 ? '/#Item_' . $Discussion->CountCommentWatch : ''), 'DiscussionLink');
?>
</strong>
<div class="Meta">
<?php
echo '<span>' . $Discussion->CountComments . '</span>';
$CountUnreadComments = $Discussion->CountComments - $Discussion->CountCommentWatch;
// Logic for incomplete comment count.
if ($Discussion->CountCommentWatch == 0 && ($DateLastViewed = GetValue('DateLastViewed', $Discussion))) {
if (Gdn_Format::ToTimestamp($DateLastViewed) >= Gdn_Format::ToTimestamp($Discussion->LastDate)) {
$CountUnreadComments = 0;
$Discussion->CountCommentWatch = $Discussion->CountComments;
} else {
$CountUnreadComments = '';
}
}
if ($CountUnreadComments > 0 || $CountUnreadComments === '') {
echo '<strong>' . trim(sprintf('%s new', $CountUnreadComments)) . '</strong>';
}
$Last = new stdClass();
$Last->UserID = $Discussion->LastUserID;
$Last->Name = $Discussion->LastName;
echo '<span>' . Gdn_Format::Date($Discussion->LastDate) . ' ' . UserAnchor($Last) . '</span>';
?>
</div>
示例11: Activity
/**
* Show activity feed for this user.
*
* @since 2.0.0
* @access public
* @param mixed $UserReference Unique identifier, possible ID or username.
* @param string $Username Username.
* @param int $UserID Unique ID.
* @param int $Offset How many to skip (for paging).
*/
public function Activity($UserReference = '', $Username = '', $UserID = '', $Page = '')
{
$this->Permission('Garden.Profiles.View');
$this->EditMode(FALSE);
// Object setup
$Session = Gdn::Session();
$this->ActivityModel = new ActivityModel();
// Calculate offset.
list($Offset, $Limit) = OffsetLimit($Page, 30);
// Get user, tab, and comment
$this->GetUserInfo($UserReference, $Username, $UserID);
$UserID = $this->User->UserID;
$Username = $this->User->Name;
$this->_SetBreadcrumbs(T('Activity'), UserUrl($this->User, '', 'activity'));
$this->SetTabView('Activity');
$Comment = $this->Form->GetFormValue('Comment');
// Load data to display
$this->ProfileUserID = $this->User->UserID;
$Limit = 30;
$NotifyUserIDs = array(ActivityModel::NOTIFY_PUBLIC);
if (Gdn::Session()->CheckPermission('Garden.Moderation.Manage')) {
$NotifyUserIDs[] = ActivityModel::NOTIFY_MODS;
}
$Activities = $this->ActivityModel->GetWhere(array('ActivityUserID' => $UserID, 'NotifyUserID' => $NotifyUserIDs), $Offset, $Limit)->ResultArray();
$this->ActivityModel->JoinComments($Activities);
$this->SetData('Activities', $Activities);
if (count($Activities) > 0) {
$LastActivity = $Activities[0];
$LastModifiedDate = Gdn_Format::ToTimestamp($this->User->DateUpdated);
$LastActivityDate = Gdn_Format::ToTimestamp($LastActivity['DateInserted']);
if ($LastModifiedDate < $LastActivityDate) {
$LastModifiedDate = $LastActivityDate;
}
// Make sure to only query this page if the user has no new activity since the requesting browser last saw it.
$this->SetLastModified($LastModifiedDate);
}
// Set the canonical Url.
if (is_numeric($this->User->Name) || Gdn_Format::Url($this->User->Name) != strtolower($this->User->Name)) {
$this->CanonicalUrl(Url('profile/' . $this->User->UserID . '/' . Gdn_Format::Url($this->User->Name), TRUE));
} else {
$this->CanonicalUrl(Url('profile/' . strtolower($this->User->Name), TRUE));
}
$this->Render();
}
示例12: UserInfoModule_OnBasicInfo_Handler
/**
* Display custom fields on Profile.
*/
public function UserInfoModule_OnBasicInfo_Handler($Sender)
{
try {
// Get the custom fields
$ProfileFields = Gdn::UserModel()->GetMeta($Sender->User->UserID, 'Profile.%', 'Profile.');
// Import from CustomProfileFields if available
if (!count($ProfileFields) && is_object($Sender->User) && C('Plugins.CustomProfileFields.SuggestedFields', FALSE)) {
$ProfileFields = Gdn::UserModel()->GetAttribute($Sender->User->UserID, 'CustomProfileFields', FALSE);
if ($ProfileFields) {
// Migrate to UserMeta & delete original
Gdn::UserModel()->SetMeta($Sender->User->UserID, $ProfileFields, 'Profile.');
Gdn::UserModel()->SaveAttribute($Sender->User->UserID, 'CustomProfileFields', FALSE);
}
}
// Send them off for magic formatting
$ProfileFields = $this->ParseSpecialFields($ProfileFields);
// Get all field data, error check
$AllFields = $this->GetProfileFields();
if (!is_array($AllFields) || !is_array($ProfileFields)) {
return;
}
// DateOfBirth is special case that core won't handle
// Hack it in here instead
if (C('ProfileExtender.Fields.DateOfBirth.OnProfile')) {
// Do not use Gdn_Format::Date because it shifts to local timezone
$ProfileFields['DateOfBirth'] = date(T('Birthday Format', 'F j, Y'), Gdn_Format::ToTimestamp($Sender->User->DateOfBirth));
$AllFields['DateOfBirth'] = array('Label' => T('Birthday'), 'OnProfile' => TRUE);
}
// Display all non-hidden fields
$ProfileFields = array_reverse($ProfileFields);
foreach ($ProfileFields as $Name => $Value) {
if (!$Value) {
continue;
}
if (!GetValue('OnProfile', $AllFields[$Name])) {
continue;
}
// Non-magic fields must be plain text, but we'll auto-link
if (!in_array($Name, $this->MagicLabels)) {
$Value = Gdn_Format::Links(Gdn_Format::Text($Value));
}
echo ' <dt class="ProfileExtend Profile' . Gdn_Format::AlphaNumeric($Name) . '">' . Gdn_Format::Text($AllFields[$Name]['Label']) . '</dt> ';
echo ' <dd class="ProfileExtend Profile' . Gdn_Format::AlphaNumeric($Name) . '">' . Gdn_Format::Html($Value) . '</dd> ';
}
} catch (Exception $ex) {
// No errors
}
}
示例13: CalculateData
protected static function CalculateData(&$Data) {
foreach ($Data as &$Category) {
$Category['CountAllDiscussions'] = $Category['CountDiscussions'];
$Category['CountAllComments'] = $Category['CountComments'];
$Category['Url'] = '/categories/'.rawurlencode($Category['UrlCode']);
// Calculate the following field.
$Following = !((bool)GetValue('Archived', $Category) || (bool)GetValue('Unfollow', $Category));
$Category['Following'] = $Following;
// Calculate the read field.
if (isset($Category['DateLastComment'])) {
$DateMarkedRead = GetValue('UserDateMarkedRead', $Category);
if (!$DateMarkedRead)
$DateMarkedRead = GetValue('DateMarkedRead', $Category);
if ($DateMarkedRead || !GetValue('DateLastComment', $Category))
$Category['Read'] = Gdn_Format::ToTimestamp($DateMarkedRead) >= Gdn_Format::ToTimestamp($Category['DateLastComment']);
else
$Category['Read'] = FALSE;
}
$Category['Children'] = array();
}
$Keys = array_reverse(array_keys($Data));
foreach ($Keys as $Key) {
$Cat = $Data[$Key];
$ParentID = $Cat['ParentCategoryID'];
if (isset($Data[$ParentID])) {
$Data[$ParentID]['CountAllDiscussions'] += $Cat['CountAllDiscussions'];
$Data[$ParentID]['CountAllComments'] += $Cat['CountAllComments'];
$Data[$ParentID]['Children'][] =& $Data[$Key];
if ($ParentID != $Cat['CategoryID'])
$Data[$Key]['Parent'] =& $Data[$ParentID];
}
}
}
示例14: SignIn
/**
* Signin process that multiple authentication methods.
*
* @access public
* @since 2.0.0
* @author Tim Gunter
*
* @param string $Method
* @param array $Arg1
* @return string Rendered XHTML template.
*/
public function SignIn($Method = FALSE, $Arg1 = FALSE)
{
$this->AddJsFile('entry.js');
$this->SetData('Title', T('Sign In'));
$this->Form->AddHidden('Target', $this->Target());
$this->Form->AddHidden('ClientHour', date('Y-m-d H:00'));
// Use the server's current hour as a default.
// Additional signin methods are set up with plugins.
$Methods = array();
$this->SetData('MainFormArgs', array($Arg1));
$this->SetData('Methods', $Methods);
$this->SetData('FormUrl', Url('entry/signin'));
$this->FireEvent('SignIn');
if ($this->Form->IsPostBack()) {
$this->Form->ValidateRule('Email', 'ValidateRequired', sprintf(T('%s is required.'), T('Email/Username')));
$this->Form->ValidateRule('Password', 'ValidateRequired');
// Check the user.
if ($this->Form->ErrorCount() == 0) {
$Email = $this->Form->GetFormValue('Email');
$User = Gdn::UserModel()->GetByEmail($Email);
if (!$User) {
$User = Gdn::UserModel()->GetByUsername($Email);
}
if (!$User) {
$this->Form->AddError('ErrorCredentials');
} else {
$ClientHour = $this->Form->GetFormValue('ClientHour');
$HourOffset = Gdn_Format::ToTimestamp($ClientHour) - time();
$HourOffset = round($HourOffset / 3600);
// Check the password.
$PasswordHash = new Gdn_PasswordHash();
if ($PasswordHash->CheckPassword($this->Form->GetFormValue('Password'), GetValue('Password', $User), GetValue('HashMethod', $User))) {
Gdn::Session()->Start(GetValue('UserID', $User), TRUE, (bool) $this->Form->GetFormValue('RememberMe'));
if (!Gdn::Session()->CheckPermission('Garden.SignIn.Allow')) {
$this->Form->AddError('ErrorPermission');
Gdn::Session()->End();
} else {
if ($HourOffset != Gdn::Session()->User->HourOffset) {
Gdn::UserModel()->SetProperty(Gdn::Session()->UserID, 'HourOffset', $HourOffset);
}
$this->_SetRedirect();
}
} else {
$this->Form->AddError('ErrorCredentials');
}
}
}
} else {
if ($Target = $this->Request->Get('Target')) {
$this->Form->AddHidden('Target', $Target);
}
$this->Form->SetValue('RememberMe', TRUE);
}
return $this->Render();
}
示例15: GetID
/**
* Get data for a single discussion by ID.
*
* @since 2.0.0
* @access public
*
* @param int $DiscussionID Unique ID of discussion to get.
* @return object SQL result.
*/
public function GetID($DiscussionID)
{
$Session = Gdn::Session();
$this->FireEvent('BeforeGetID');
$Data = $this->SQL->Select('d.*')->Select('w.DateLastViewed, w.Dismissed, w.Bookmarked')->Select('w.CountComments', '', 'CountCommentWatch')->Select('d.DateLastComment', '', 'LastDate')->Select('d.LastCommentUserID', '', 'LastUserID')->From('Discussion d')->Join('UserDiscussion w', 'd.DiscussionID = w.DiscussionID and w.UserID = ' . $Session->UserID, 'left')->Where('d.DiscussionID', $DiscussionID)->Get()->FirstRow();
if (!$Data) {
return $Data;
}
$Data->Name = Gdn_Format::Text($Data->Name);
$Data->Attributes = @unserialize($Data->Attributes);
$Data->Url = DiscussionUrl($Data);
$Data->Tags = $this->FormatTags($Data->Tags);
// Join in the category.
$Category = CategoryModel::Categories($Data->CategoryID);
if (!$Category) {
$Category = FALSE;
}
$Data->Category = $Category['Name'];
$Data->CategoryUrlCode = $Category['UrlCode'];
$Data->PermissionCategoryID = $Category['PermissionCategoryID'];
// Join in the users.
$Data = array($Data);
Gdn::UserModel()->JoinUsers($Data, array('LastUserID', 'InsertUserID'));
CategoryModel::JoinCategories($Data);
$Data = $Data[0];
// ->Select('lcu.Name', '', 'LastName')
// ->Select('iu.Name', '', 'InsertName')
// ->Select('iu.Photo', '', 'InsertPhoto')
// ->Select('iu.Email', '', 'InsertEmail')
// ->Join('User iu', 'd.InsertUserID = iu.UserID', 'left') // Insert user
// ->Join('Comment lc', 'd.LastCommentID = lc.CommentID', 'left') // Last comment
// ->Join('User lcu', 'lc.InsertUserID = lcu.UserID', 'left') // Last comment user
// Close if older than archive date
if ($Data && $Data->DateLastComment && Gdn_Format::ToTimestamp($Data->DateLastComment) <= Gdn_Format::ToTimestamp(Gdn::Config('Vanilla.Archive.Date', 0))) {
$Data->Closed = '1';
}
if (C('Vanilla.Views.Denormalize', FALSE)) {
$this->AddDenormalizedViews($Data);
}
return $Data;
}