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


PHP DateTimeHelper::getUtcDateTime方法代码示例

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


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

示例1: updateOnlineStatuses

 /**
  * Last active updates every 2 minutes. If it didn't get updated, it means the user closed their browser and are thus
  * now offline
  *
  */
 public function updateOnlineStatuses()
 {
     $dt = new DateTimeHelper();
     $offlineDelay = $dt->getUtcDateTime();
     $offlineDelay->setTimestamp(strtotime('15 minutes ago'));
     $q = $this->_em->createQueryBuilder()->update('MauticUserBundle:User', 'u')->set('u.onlineStatus', ':status')->where('u.lastActive <= :delay')->setParameter('delay', $offlineDelay)->setParameter('status', 'offline');
     $q->getQuery()->execute();
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:13,代码来源:UserRepository.php

示例2: getChannelConversation

 /**
  * Gets group messages form a channel
  *
  * @param $channel
  * @param $lastId
  * @param $fromDateTime
  *
  * @return array
  */
 public function getChannelConversation($channel, $lastId = null, \DateTime $fromDateTime = null)
 {
     $q = $this->_em->createQueryBuilder();
     $q->select('m, partial u.{id, firstName, lastName, email, lastActive, onlineStatus}')->from('MauticChatBundle:Chat', 'm', 'm.id')->join('m.fromUser', 'u')->join('m.channel', 'c')->where($q->expr()->eq('c.id', $channel->getId()))->orderBy('m.dateSent', 'ASC');
     if ($lastId !== null) {
         $q->andWhere($q->expr()->gt('m.id', ':lastId'))->setParameter(':lastId', $lastId);
     } elseif ($fromDateTime !== null) {
         $q->andWhere($q->expr()->gte('m.dateSent', ':fromDate'))->setParameter(':fromDate', $fromDateTime);
     }
     $results = $q->getQuery()->getArrayResult();
     //fix online statuses
     $dt = new DateTimeHelper(strtotime('15 minutes ago'), 'U', 'local');
     $delay = $dt->getUtcDateTime();
     foreach ($results as &$r) {
         if (empty($r['fromUser']['onlineStatus'])) {
             $r['fromUser']['onlineStatus'] = $r['fromUser']['lastActive'] >= $delay ? 'online' : 'offline';
         } elseif (!empty($r['fromUser']['onlineStatus']) && $r['fromUser']['lastActive'] < $delay) {
             $r['fromUser']['onlineStatus'] = 'offline';
         }
     }
     return $results;
 }
开发者ID:woakes070048,项目名称:mautic-chat,代码行数:31,代码来源:ChannelRepository.php

示例3: importLead

 /**
  * @param      $fields
  * @param      $data
  * @param null $owner
  * @param null $list
  * @param null $tags
  * @param bool $persist Persist to the database; otherwise return entity
  *
  * @return bool
  * @throws \Doctrine\ORM\ORMException
  * @throws \Swift_RfcComplianceException
  */
 public function importLead($fields, $data, $owner = null, $list = null, $tags = null, $persist = true)
 {
     // Let's check for an existing lead by email
     $hasEmail = !empty($fields['email']) && !empty($data[$fields['email']]);
     if ($hasEmail) {
         // Validate the email
         MailHelper::validateEmail($data[$fields['email']]);
         $leadFound = $this->getRepository()->getLeadByEmail($data[$fields['email']]);
         $lead = $leadFound ? $this->em->getReference('MauticLeadBundle:Lead', $leadFound['id']) : new Lead();
         $merged = $leadFound;
     } else {
         $lead = new Lead();
         $merged = false;
     }
     if (!empty($fields['dateAdded']) && !empty($data[$fields['dateAdded']])) {
         $dateAdded = new DateTimeHelper($data[$fields['dateAdded']]);
         $lead->setDateAdded($dateAdded->getUtcDateTime());
     }
     unset($fields['dateAdded']);
     if (!empty($fields['dateModified']) && !empty($data[$fields['dateModified']])) {
         $dateModified = new DateTimeHelper($data[$fields['dateModified']]);
         $lead->setDateModified($dateModified->getUtcDateTime());
     }
     unset($fields['dateModified']);
     if (!empty($fields['lastActive']) && !empty($data[$fields['lastActive']])) {
         $lastActive = new DateTimeHelper($data[$fields['lastActive']]);
         $lead->setLastActive($lastActive->getUtcDateTime());
     }
     unset($fields['lastActive']);
     if (!empty($fields['dateIdentified']) && !empty($data[$fields['dateIdentified']])) {
         $dateIdentified = new DateTimeHelper($data[$fields['dateIdentified']]);
         $lead->setDateIdentified($dateIdentified->getUtcDateTime());
     }
     unset($fields['dateIdentified']);
     if (!empty($fields['createdByUser']) && !empty($data[$fields['createdByUser']])) {
         $userRepo = $this->em->getRepository('MauticUserBundle:User');
         $createdByUser = $userRepo->findByIdentifier($data[$fields['createdByUser']]);
         if ($createdByUser !== null) {
             $lead->setCreatedBy($createdByUser);
         }
     }
     unset($fields['createdByUser']);
     if (!empty($fields['modifiedByUser']) && !empty($data[$fields['modifiedByUser']])) {
         $userRepo = $this->em->getRepository('MauticUserBundle:User');
         $modifiedByUser = $userRepo->findByIdentifier($data[$fields['modifiedByUser']]);
         if ($modifiedByUser !== null) {
             $lead->setModifiedBy($modifiedByUser);
         }
     }
     unset($fields['modifiedByUser']);
     if (!empty($fields['ip']) && !empty($data[$fields['ip']])) {
         $addresses = explode(',', $data[$fields['ip']]);
         foreach ($addresses as $address) {
             $ipAddress = new IpAddress();
             $ipAddress->setIpAddress(trim($address));
             $lead->addIpAddress($ipAddress);
         }
     }
     unset($fields['ip']);
     if (!empty($fields['points']) && !empty($data[$fields['points']]) && $lead->getId() === null) {
         // Add points only for new leads
         $lead->setPoints($data[$fields['points']]);
         //add a lead point change log
         $log = new PointsChangeLog();
         $log->setDelta($data[$fields['points']]);
         $log->setLead($lead);
         $log->setType('lead');
         $log->setEventName($this->factory->getTranslator()->trans('mautic.lead.import.event.name'));
         $log->setActionName($this->factory->getTranslator()->trans('mautic.lead.import.action.name', array('%name%' => $this->factory->getUser()->getUsername())));
         $log->setIpAddress($this->factory->getIpAddress());
         $log->setDateAdded(new \DateTime());
         $lead->addPointsChangeLog($log);
     }
     unset($fields['points']);
     // Set unsubscribe status
     if (!empty($fields['doNotEmail']) && !empty($data[$fields['doNotEmail']]) && $hasEmail) {
         $doNotEmail = filter_var($data[$fields['doNotEmail']], FILTER_VALIDATE_BOOLEAN);
         if ($doNotEmail) {
             $reason = $this->factory->getTranslator()->trans('mautic.lead.import.by.user', array("%user%" => $this->factory->getUser()->getUsername()));
             // The email must be set for successful unsubscribtion
             $lead->addUpdatedField('email', $data[$fields['email']]);
             $this->unsubscribeLead($lead, $reason, false);
         }
     }
     unset($fields['doNotEmail']);
     if ($owner !== null) {
         $lead->setOwner($this->em->getReference('MauticUserBundle:User', $owner));
     }
//.........这里部分代码省略.........
开发者ID:HomeRefill,项目名称:mautic,代码行数:101,代码来源:LeadModel.php

示例4: importLead

 /**
  * @param      $fields
  * @param      $data
  * @param null $owner
  * @param null $list
  * @param null $tags
  * @param bool $persist Persist to the database; otherwise return entity
  *
  * @return bool
  * @throws \Doctrine\ORM\ORMException
  * @throws \Swift_RfcComplianceException
  */
 public function importLead($fields, $data, $owner = null, $list = null, $tags = null, $persist = true)
 {
     // Let's check for an existing lead by email
     $hasEmail = !empty($fields['email']) && !empty($data[$fields['email']]);
     if ($hasEmail) {
         // Validate the email
         MailHelper::validateEmail($data[$fields['email']]);
         $leadFound = $this->getRepository()->getLeadByEmail($data[$fields['email']]);
         $lead = $leadFound ? $this->em->getReference('MauticLeadBundle:Lead', $leadFound['id']) : new Lead();
         $merged = $leadFound;
     } else {
         $lead = new Lead();
         $merged = false;
     }
     if (!empty($fields['dateAdded']) && !empty($data[$fields['dateAdded']])) {
         $dateAdded = new DateTimeHelper($data[$fields['dateAdded']]);
         $lead->setDateAdded($dateAdded->getUtcDateTime());
     }
     unset($fields['dateAdded']);
     if (!empty($fields['dateModified']) && !empty($data[$fields['dateModified']])) {
         $dateModified = new DateTimeHelper($data[$fields['dateModified']]);
         $lead->setDateModified($dateModified->getUtcDateTime());
     }
     unset($fields['dateModified']);
     if (!empty($fields['lastActive']) && !empty($data[$fields['lastActive']])) {
         $lastActive = new DateTimeHelper($data[$fields['lastActive']]);
         $lead->setLastActive($lastActive->getUtcDateTime());
     }
     unset($fields['lastActive']);
     if (!empty($fields['dateIdentified']) && !empty($data[$fields['dateIdentified']])) {
         $dateIdentified = new DateTimeHelper($data[$fields['dateIdentified']]);
         $lead->setDateIdentified($dateIdentified->getUtcDateTime());
     }
     unset($fields['dateIdentified']);
     if (!empty($fields['createdByUser']) && !empty($data[$fields['createdByUser']])) {
         $userRepo = $this->em->getRepository('MauticUserBundle:User');
         $createdByUser = $userRepo->findByIdentifier($data[$fields['createdByUser']]);
         if ($createdByUser !== null) {
             $lead->setCreatedBy($createdByUser);
         }
     }
     unset($fields['createdByUser']);
     if (!empty($fields['modifiedByUser']) && !empty($data[$fields['modifiedByUser']])) {
         $userRepo = $this->em->getRepository('MauticUserBundle:User');
         $modifiedByUser = $userRepo->findByIdentifier($data[$fields['modifiedByUser']]);
         if ($modifiedByUser !== null) {
             $lead->setModifiedBy($modifiedByUser);
         }
     }
     unset($fields['modifiedByUser']);
     if (!empty($fields['ip']) && !empty($data[$fields['ip']])) {
         $addresses = explode(',', $data[$fields['ip']]);
         foreach ($addresses as $address) {
             $ipAddress = new IpAddress();
             $ipAddress->setIpAddress(trim($address));
             $lead->addIpAddress($ipAddress);
         }
     }
     unset($fields['ip']);
     if (!empty($fields['points']) && !empty($data[$fields['points']]) && $lead->getId() === null) {
         // Add points only for new leads
         $lead->setPoints($data[$fields['points']]);
         //add a lead point change log
         $log = new PointsChangeLog();
         $log->setDelta($data[$fields['points']]);
         $log->setLead($lead);
         $log->setType('lead');
         $log->setEventName($this->translator->trans('mautic.lead.import.event.name'));
         $log->setActionName($this->translator->trans('mautic.lead.import.action.name', array('%name%' => $this->user->getUsername())));
         $log->setIpAddress($this->ipLookupHelper->getIpAddress());
         $log->setDateAdded(new \DateTime());
         $lead->addPointsChangeLog($log);
     }
     if (!empty($fields['stage']) && !empty($data[$fields['stage']])) {
         static $stages = [];
         $stageName = $data[$fields['stage']];
         if (!array_key_exists($stageName, $stages)) {
             // Set stage for contact
             $stage = $this->em->getRepository('MauticStageBundle:Stage')->getStageByName($stageName);
             if (empty($stage)) {
                 $stage = new Stage();
                 $stage->setName($stageName);
                 $stages[$stageName] = $stage;
             }
         } else {
             $stage = $stages[$stageName];
         }
         $lead->setStage($stage);
//.........这里部分代码省略.........
开发者ID:Yame-,项目名称:mautic,代码行数:101,代码来源:LeadModel.php


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