当前位置: 首页>>代码示例>>PHP>>正文


PHP Gdn_Format::ToDateTime方法代码示例

本文整理汇总了PHP中Gdn_Format::ToDateTime方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Format::ToDateTime方法的具体用法?PHP Gdn_Format::ToDateTime怎么用?PHP Gdn_Format::ToDateTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gdn_Format的用法示例。


在下文中一共展示了Gdn_Format::ToDateTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($Number, &$Mailbox)
 {
     $this->Mailbox =& $Mailbox;
     $Connection =& $this->Mailbox->Connection;
     $Tmp = imap_fetch_overview($Connection, $Number);
     $this->Overview = $Tmp[0];
     $this->Structure = imap_fetchstructure($Connection, $Number);
     $this->HeaderInfo = imap_headerinfo($Connection, $Number);
     $this->MailDateTime = Gdn_Format::ToDateTime($this->HeaderInfo->udate);
     $this->Number = $this->Overview->msgno;
     $this->Uid = $this->Overview->uid;
     $this->RetrieveInfo();
     $this->RetrieveBodyText();
     $this->RetrieveAttachments();
     return $this;
 }
开发者ID:unlight,项目名称:UsefulFunctions,代码行数:16,代码来源:class.imapmailbox.php

示例2: InformNotifications

 /**
  * Grabs all new notifications and adds them to the sender's inform queue.
  *
  * This method gets called by dashboard's hooks file to display new
  * notifications on every pageload. 
  *
  * @since 2.0.18
  * @access public
  *
  * @param Gdn_Controller $Sender The object calling this method.
  */
 public static function InformNotifications($Sender)
 {
     $Session = Gdn::Session();
     if (!$Session->IsValid()) {
         return;
     }
     $ActivityModel = new ActivityModel();
     // Get five pending notifications.
     $Where = array('NotifyUserID' => Gdn::Session()->UserID, 'Notified' => ActivityModel::SENT_PENDING);
     // If we're in the middle of a visit only get very recent notifications.
     $Where['DateUpdated >'] = Gdn_Format::ToDateTime(strtotime('-5 minutes'));
     $Activities = $ActivityModel->GetWhere($Where, 0, 5)->ResultArray();
     $ActivityIDs = ConsolidateArrayValuesByKey($Activities, 'ActivityID');
     $ActivityModel->SetNotified($ActivityIDs);
     foreach ($Activities as $Activity) {
         if ($Activity['Photo']) {
             $UserPhoto = Anchor(Img($Activity['Photo'], array('class' => 'ProfilePhotoMedium')), $Activity['Url'], 'Icon');
         } else {
             $UserPhoto = '';
         }
         $Excerpt = Gdn_Format::Display($Activity['Story']);
         $ActivityClass = ' Activity-' . $Activity['ActivityType'];
         $Sender->InformMessage($UserPhoto . Wrap($Activity['Headline'], 'div', array('class' => 'Title')) . Wrap($Excerpt, 'div', array('class' => 'Excerpt')), 'Dismissable AutoDismiss' . $ActivityClass . ($UserPhoto == '' ? '' : ' HasIcon'));
     }
 }
开发者ID:elpum,项目名称:TgaForumBundle,代码行数:36,代码来源:class.notificationscontroller.php

示例3: 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()));
             }
         }
     }
 }
开发者ID:sheldon,项目名称:Garden,代码行数:25,代码来源:class.commentmodel.php

示例4: Expire

 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()));
     }
 }
开发者ID:pawigor,项目名称:TempBan-Vanilla-Plugin,代码行数:7,代码来源:default.php

示例5: _CacheOnlineUserss

 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);
 }
开发者ID:ru4,项目名称:arabbnota,代码行数:26,代码来源:class.onlineusers.plugin.php

示例6: GetByID

 /**
  * Checks the local Steam Profile cache for existing user profile
  * information.  If found, serve it up.  If not found, attempt to fetch
  * it from the Steam Community website.
  *
  * @param string $SteamID A sixty-four bit integer representing the target Steam ID
  * @return mixed SimpleXMLElement on success, FALSE on failure
  */
 public function GetByID($SteamID)
 {
     // Verify that the ID is only digits and that we have SimpleXML capabilities
     if (preg_match('/\\d+/', $SteamID) && function_exists('simplexml_load_file')) {
         /**
          * Check to see if there are any cached profile records matching the ID and are
          * more than five minutes old
          */
         $CachedProfile = $this->SQL->Select()->From('SteamProfileCache')->Where('SteamID64', $SteamID)->Where('DateRetrieved >', Gdn_Format::ToDateTime(strtotime('-5 minutes')))->Get()->Firstrow();
         // Any cached entries?
         if ($CachedProfile) {
             // ...if so, load up the profile XML into a SimpleXMLElement...
             $CommunityProfile = simplexml_load_string($CachedProfile->ProfileXML, 'SimpleXMLElement', LIBXML_NOCDATA);
             // set the DateRetrieved of the cached record and go
             $CommunityProfile->DateRetrieved = $CachedProfile->DateRetrieved;
             return $CommunityProfile;
         } else {
             // ...if not, attempt to grab the profile's XML
             $CommunityProfile = simplexml_load_file('http://steamcommunity.com/profiles/' . $SteamID . '?xml=1', 'SimpleXMLElement', LIBXML_NOCDATA);
             // Were we able to successfully fetch the profile?
             if ($CommunityProfile && !isset($CommunityProfile->error)) {
                 // ...if so, insert or update the profile XML into the cache table
                 $this->SQL->Replace('SteamProfileCache', array('SteamID64' => $SteamID, 'ProfileXML' => $CommunityProfile->asXML(), 'DateRetrieved' => Gdn_Format::ToDateTime()), array('SteamID64' => $SteamID), TRUE);
                 // Set the DateRetrieved record to now and go
                 $CommunityProfile->DateRetrieved = Gdn_Format::ToDateTime();
                 return $CommunityProfile;
             }
         }
     }
     // If we hit this point, something bad has happened.
     return FALSE;
 }
开发者ID:29th,项目名称:VanillaAddons,代码行数:40,代码来源:class.steamprofilemodel.php

示例7: 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;
 }
开发者ID:sheldon,项目名称:Garden,代码行数:60,代码来源:class.vanillamodel.php

示例8: Structure

 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' => 'mollom@domain.com', 'DateInserted' => Gdn_Format::ToDateTime(), 'Admin' => '2'));
     }
     SaveToConfig('Plugins.Mollom.UserID', $UserID);
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:9,代码来源:class.mollom.plugin.php

示例9: MarkRead

 public function MarkRead($CategoryID, $TKey)
 {
     if (Gdn::Session()->ValidateTransientKey($TKey)) {
         $this->CategoryModel->SaveUserTree($CategoryID, array('DateMarkedRead' => Gdn_Format::ToDateTime()));
     }
     if ($this->DeliveryType() == DELIVERY_TYPE_ALL) {
         Redirect('/categories');
     }
     $this->Render();
 }
开发者ID:rnovino,项目名称:Garden,代码行数:10,代码来源:class.categorycontroller.php

示例10: DiscussionController_Bump_Create

 /**
  * Handle discussion option menu bump action.
  */
 public function DiscussionController_Bump_Create($Sender, $Args)
 {
     $Sender->Permission('Garden.Moderation.Manage');
     // Get discussion
     $DiscussionID = $Sender->Request->Get('discussionid');
     $Discussion = $Sender->DiscussionModel->GetID($DiscussionID);
     if (!$Discussion) {
         throw NotFoundException('Discussion');
     }
     // Update DateLastComment & redirect
     $Sender->DiscussionModel->SetProperty($DiscussionID, 'DateLastComment', Gdn_Format::ToDateTime());
     Redirect(DiscussionUrl($Discussion));
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:16,代码来源:class.bump.plugin.php

示例11: DiscussionController_AutoExpire_Create

 public function DiscussionController_AutoExpire_Create($Sender, $Args)
 {
     $DiscussionID = intval($Args[0]);
     $DiscussionModel = new DiscussionModel();
     $Discussion = $DiscussionModel->GetID($DiscussionID);
     if (!Gdn::Session()->CheckPermission('Vanilla.Discussions.Close', TRUE, 'Category', $Discussion->PermissionCategoryID)) {
         throw PermissionException('Vanilla.Discussions.Close');
     }
     if (strtolower($Args[1]) == 'reset') {
         Gdn::SQL()->Put('Discussion', array('AutoExpire' => 1, 'Closed' => 0, 'DateReOpened' => Gdn_Format::ToDateTime()), array('DiscussionID' => $DiscussionID));
     } else {
         $Expire = strtolower($Args[1]) == 'on' ? 1 : 0;
         Gdn::SQL()->Put('Discussion', array('AutoExpire' => $Expire), array('DiscussionID' => $DiscussionID));
     }
     Redirect('discussion/' . $DiscussionID . '/' . Gdn_Format::Url($Discussion->Name));
 }
开发者ID:x00,项目名称:AutoExpireDiscussions-Vanilla-Plugin,代码行数:16,代码来源:default.php

示例12: GetData

 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();
 }
开发者ID:ru4,项目名称:arabbnota,代码行数:18,代码来源:class.whosonlinemodule.php

示例13: Delete

 public function Delete($ActivityID)
 {
     // Get the activity first
     $Activity = $this->GetID($ActivityID);
     if (is_object($Activity)) {
         $Users = array();
         $Users[] = $Activity->ActivityUserID;
         if (is_numeric($Activity->RegardingUserID) && $Activity->RegardingUserID > 0) {
             $Users[] = $Activity->RegardingUserID;
         }
         // Update the user's dateupdated field so that profile pages will not
         // be cached and will reflect this deletion.
         $this->SQL->Update('User')->Set('DateUpdated', Gdn_Format::ToDateTime())->WhereIn('UserID', $Users)->Put();
         // Delete comments on the activity item
         parent::Delete(array('CommentActivityID' => $ActivityID), FALSE, TRUE);
         // Delete the activity item
         parent::Delete(array('ActivityID' => $ActivityID));
     }
 }
开发者ID:tautomers,项目名称:knoopvszombies,代码行数:19,代码来源:class.activitymodel.php

示例14: 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');
     $this->AddInsertFields($FormPostValues);
     // Validate the form posted values
     $MessageID = FALSE;
     if ($this->Validate($FormPostValues)) {
         $Fields = $this->Validation->SchemaValidationFields();
         // All fields on the form that relate to the schema
         $MessageID = $this->SQL->Insert($this->Name, $Fields);
         $ConversationID = ArrayValue('ConversationID', $Fields, 0);
         // Update the conversation's DateUpdated field
         $this->SQL->Update('Conversation')->Set('DateUpdated', Gdn_Format::ToDateTime())->Set('UpdateUserID', $Session->UserID)->Where('ConversationID', $ConversationID)->Put();
         // NOTE: INCREMENTING COUNTS INSTEAD OF GETTING ACTUAL COUNTS COULD
         // BECOME A PROBLEM. WATCH FOR IT.
         // Update the message counts for all users in the conversation
         $this->SQL->Update('UserConversation')->Set('CountMessages', 'CountMessages + 1', FALSE)->Where('ConversationID', $ConversationID)->Put();
         $this->SQL->Update('UserConversation')->Set('CountNewMessages', 'CountNewMessages + 1', FALSE)->Where('ConversationID', $ConversationID)->Where('UserID <>', $Session->UserID)->Put();
         // Update the userconversation records to reflect the most recently
         // added message for all users other than the one that added the
         // message (otherwise they would see their name/message on the
         // conversation list instead of the person they are conversing with).
         $this->SQL->Update('UserConversation')->Set('LastMessageID', $MessageID)->Where('ConversationID', $ConversationID)->Where('UserID <>', $Session->UserID)->Put();
         // Update the CountUnreadConversations count on each user related to the discussion.
         // And notify the users of the new message
         $UnreadData = $this->SQL->Select('c.UserID')->Select('c2.CountNewMessages', 'count', 'CountUnreadConversations')->From('UserConversation c')->Join('UserConversation c2', 'c.UserID = c2.UserID')->Where('c2.CountNewMessages >', 0)->Where('c.ConversationID', $ConversationID)->Where('c.UserID <>', $Session->UserID)->GroupBy('c.UserID')->Get();
         $ActivityModel = new ActivityModel();
         foreach ($UnreadData->Result() as $User) {
             // Update the CountUnreadConversations count on each user related to the discussion.
             $this->SQL->Update('User')->Set('CountUnreadConversations', $User->CountUnreadConversations)->Where('UserID', $User->UserID)->Put();
             // And notify the users of the new message
             $ActivityID = $ActivityModel->Add($Session->UserID, 'ConversationMessage', '', $User->UserID, '', '/messages/' . $ConversationID . '#' . $MessageID, FALSE);
             $Story = ArrayValue('Body', $Fields, '');
             $ActivityModel->SendNotification($ActivityID, $Story);
         }
     }
     return $MessageID;
 }
开发者ID:sheldon,项目名称:Garden,代码行数:42,代码来源:class.conversationmessagemodel.php

示例15: DiscussionController_Score_Create

 /**
  * Add or subtract a value from a comment's score.
  * @param DiscussionController $Sender The controller that is implementing this method.
  * @param array $Args The arguments for the operation.
  */
 public function DiscussionController_Score_Create($Sender, $Args)
 {
     $CommentID = $Args[0];
     $ScoreKey = substr($Args[1], 0, 3) == 'Neg' ? -1 : 1;
     //$TransientKey = $Args[2];
     $SQL = Gdn::SQL();
     $Session = Gdn::Session();
     // Get the current score for this user.
     $Data = $SQL->Select('uc.Score')->From('UserComment uc')->Where('uc.CommentID', $CommentID)->Where('uc.UserID', $Session->UserID)->Get()->FirstRow();
     $UserScore = $Data ? $Data->Score : 0;
     // Get the score increments.
     $Inc = $this->GetScoreIncrements($CommentID, $UserScore);
     $Score = $Inc[$ScoreKey];
     $UserScore += $Score;
     if ($Score != 0) {
         if ($Data) {
             // Update the score on an existing comment.
             $SQL->Update('UserComment')->Set('Score', $UserScore)->Set('DateUpdated', Gdn_Format::ToDateTime())->Set('UpdateUserID', $Session->UserID)->Where('UserID', $Session->UserID)->Where('CommentID', $CommentID)->Put();
         } else {
             // Insert a new score.
             $SQL->Insert('UserComment', array('CommentID' => $CommentID, 'UserID' => $Session->UserID, 'Score' => $UserScore, 'DateInserted' => Gdn_Format::ToDateTime(), 'InsertUserID' => $Session->UserID, 'DateUpdated' => Gdn_Format::ToDateTime(), 'UpdateUserID' => $Session->UserID));
         }
         // Update the comment table with the sum of the scores.
         $Data = $SQL->Select('uc.Score', 'sum', 'SumScore')->From('UserComment uc')->Where('uc.CommentID', $CommentID)->Get()->FirstRow();
         $SumScore = $Data ? $Data->SumScore : 0;
         $SQL->Update('Comment')->Set('SumScore', $SumScore)->Where('CommentID', $CommentID)->Put();
         $Inc = $this->GetScoreIncrements($CommentID, $UserScore);
     }
     // Redirect back where the user came from if necessary
     if ($Sender->DeliveryType() != DELIVERY_TYPE_BOOL) {
         $Target = GetIncomingValue('Target', '/vanilla/discussions/scored');
         Redirect($Target);
     }
     // Send the current information back to be dealt with on the client side.
     $Sender->SetJson('SumScore', isset($SumScore) ? sprintf(Plural($SumScore, '%s point', '%s points'), $SumScore) : NULL);
     $Sender->SetJson('Inc', $Inc);
     $Sender->Render();
     break;
 }
开发者ID:TiGR,项目名称:Addons,代码行数:44,代码来源:class.commentscore.plugin.php


注:本文中的Gdn_Format::ToDateTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。