/** * @return SS_Datetime */ public function Created() { $created = $this->tag->getCommit()->getCommitterDate(); $created->setTimezone(new DateTimeZone(date_default_timezone_get())); $d = SS_Datetime::create(); $d->setValue($created->format('Y-m-d H:i:s')); return $d; }
public function Title() { $date = SS_Datetime::create(); $date->setValue($this->owner->Created); $dateReadable = $date->Format('D d/m/y') . ', ' . $date->Format('g:ia'); if ($this->owner->SubmittedBy()) { return '#' . $this->owner->ID . ' ' . $this->owner->SubmittedBy()->getName() . ', ' . $dateReadable; } else { return '#' . $this->owner->ID . ' unknown, ' . $dateReadable; } }
/** * @param \SS_HTTPRequest $request * @return \SS_HTTPResponse */ public function history(\SS_HTTPRequest $request) { $data = []; $list = $this->environment->DeployHistory('DeployStarted'); $fromTimestamp = $request->requestVar('from'); if ($fromTimestamp) { $from = SS_Datetime::create(); $from->setValue($fromTimestamp); $list = $list->filter('LastEdited:GreaterThan', $from->Format('Y-m-d H:i:s')); } foreach ($list as $deployment) { $data[] = $this->formatter->getDeploymentData($deployment); } return $this->getAPIResponse(['list' => $data], 200); }
/** * @return SS_Datetime */ public function LastUpdated() { if ($this->_lastUpdatedCache) { return $this->_lastUpdatedCache; } try { $created = $this->branch->getCommit()->getCommitterDate(); } catch (Exception $e) { //occasionally parsing will fail this is a fallback to make it still work return new SS_Datetime(); } $created->setTimezone(new DateTimeZone(date_default_timezone_get())); $date = SS_Datetime::create(); $date->setValue($created->format('Y-m-d H:i:s')); $this->_lastUpdatedCache = $date; return $date; }
/** * Get feed from provider, will automatically cache the result. * * If QueuedJobs module is installed, it will also create a job to update the cache * 5 minutes before it expires. * * @return SS_List */ public function getFeed() { $feed = $this->getFeedCache(); if (!$feed) { $feed = $this->getFeedUncached(); $this->setFeedCache($feed); if (class_exists('AbstractQueuedJob')) { singleton('SocialFeedCacheQueuedJob')->createJob($this); } } $data = array(); if ($feed) { foreach ($feed as $post) { $created = SS_Datetime::create(); $created->setValue($this->getPostCreated($post)); $data[] = array('Type' => $this->getType(), 'Content' => $this->getPostContent($post), 'Created' => $created, 'URL' => $this->getPostUrl($post), 'Data' => $post, 'UserName' => $this->getUserName($post), 'Image' => $this->getImage($post)); } } $result = ArrayList::create($data); $result = $result->sort('Created', 'DESC'); return $result; }
function getLatestTweets() { require Director::baseFolder() . '/twitter-feed/libs/tmhOAuth.php'; require Director::baseFolder() . '/twitter-feed/libs/tmhUtilities.php'; $tmhOAuth = new tmhOAuth(array('consumer_key' => self::get_consumer_key(), 'consumer_secret' => self::get_consumer_secret(), 'user_token' => self::get_user_token(), 'user_secret' => self::get_user_secret(), 'curl_ssl_verifypeer' => false)); $code = $tmhOAuth->request('GET', $tmhOAuth->url('1.1/statuses/user_timeline'), array('screen_name' => self::get_username(), 'count' => self::get_tweetcount() + 10, 'exclude_replies' => true)); $response = $tmhOAuth->response['response']; $tweets = json_decode($response, true); if ($this->_errorCheck($tweets)) { return false; } $output = new ArrayList(); foreach ($tweets as &$tweet) { $tweet['text'] = $this->tweetConvert($tweet['text']); $time = SS_Datetime::create('SS_Datetime'); $time->setValue($tweet['created_at']); $tweet['created_at'] = $time; // $tweet['username'] = self::get_username(); $output->push(new ArrayData($tweet)); } return $output->limit(self::get_tweetcount()); }
/** * @param $mailbox * @param $emailID * @param $isBounce */ private function isBounced($mailbox, $emailID, $isBounce) { $stripTags = array('<', '>'); // Some servers reply with "<*****@*****.**>", so, let's strip that. $to = str_replace($stripTags, array('', ''), $isBounce[1]); $error = $isBounce[2]; /** @var Recipient $recipient */ $recipient = Recipient::get()->filter(array("Email" => $to))->first(); if ($recipient->BouncedCount == self::$blacklistLimit) { // When we reach the blacklistLimit, just blacklist this address. $recipient->BlacklistedEmail = true; $recipient->write(); } else { // Otherwise, just up the bouncedCount. $recipient->BouncedCount = $recipient->BouncedCount + 1; $recipient->write(); /** @var NewsletterEmailBounceRecord $record Record this bounce in the NewsletterEmailBounceRecord class. */ $record = NewsletterEmailBounceRecord::get()->filter(array("BounceEmail" => $to)); if (!$record->count()) { $record = NewsletterEmailBounceRecord::create(); $record->BounceEmail = $to; $record->BounceMessage = $error; $record->RecipientID = $recipient->ID; } else { $record = $record->first(); } $record->LastBounceTime = SS_Datetime::create()->now(); $record->write(); } // Set the e-mail flag imap_setflag_full($mailbox, $emailID, '\\flagged', ST_UID); // Also mark it for deletion. imap_delete($mailbox, $emailID, ST_UID); // And up the bounces counter. $this->bounces = $this->bounces + 1; }