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


PHP InputHelper::boolean方法代码示例

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


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

示例1: updateStatsChartAction

 /**
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 protected function updateStatsChartAction(Request $request)
 {
     $emailId = InputHelper::int($request->request->get('emailId'));
     $emailType = InputHelper::clean($request->request->get('emailType'));
     $includeVariants = InputHelper::boolean($request->request->get('includeVariants', false));
     $amount = InputHelper::int($request->request->get('amount'));
     $unit = InputHelper::clean($request->request->get('unit'));
     $dataArray = array('success' => 0);
     /** @var \Mautic\EmailBundle\Model\EmailModel $model */
     $model = $this->factory->getModel('email');
     $dataArray['stats'] = $emailType == 'template' ? $model->getEmailGeneralStats($emailId, $includeVariants, $amount, $unit) : $model->getEmailListStats($emailId, $includeVariants);
     $dataArray['success'] = 1;
     return $this->sendJsonResponse($dataArray);
 }
开发者ID:smotalima,项目名称:mautic,代码行数:19,代码来源:AjaxController.php

示例2: toggleChatSettingAction

 /**
  * @param $type
  * @param $userId
  */
 protected function toggleChatSettingAction(Request $request)
 {
     $chatType = $request->request->get('chatType');
     $setting = $request->request->get('setting');
     $enabled = InputHelper::boolean($request->request->get('enabled'));
     $id = InputHelper::int($request->request->get('id'));
     $success = 0;
     $updateSettings = array();
     /** @var \MauticAddon\MauticChatBundle\Model\ChatModel $model */
     $model = $this->factory->getModel('addon.mauticChat.chat');
     $settings = $model->getSettings($chatType);
     /** @var \MauticAddon\MauticChatBundle\Model\ChannelModel $channelModel */
     $channelModel = $this->factory->getModel('addon.mauticChat.channel');
     if ($chatType == 'channels' && $setting == 'archived') {
         $channel = $channelModel->getEntity($id);
         if ($channel != null) {
             if ($this->factory->getSecurity()->hasEntityAccess(true, false, $channel->getCreatedBy())) {
                 $success = 1;
                 if ($enabled) {
                     $channelModel->archiveChannel($id);
                     $updateSettings['visible'] = false;
                 } else {
                     $channelModel->unarchiveChannel($id);
                 }
             }
         }
     } elseif ($chatType == 'channels' && $setting == 'subscribed') {
         $channel = $channelModel->getEntity($id);
         if ($channel != null) {
             $success = 1;
             if ($enabled) {
                 $channelModel->subscribeToChannel($channel);
                 $updateSettings['visible'] = true;
             } else {
                 $channelModel->unsubscribeFromChannel($channel);
                 $updateSettings['visible'] = false;
             }
         }
     } else {
         $updateSettings[$setting] = $enabled;
     }
     foreach ($updateSettings as $setting => $enabled) {
         if (isset($settings[$setting])) {
             $success = 1;
             if (!$enabled && in_array($id, $settings[$setting])) {
                 $key = array_search($id, $settings[$setting]);
                 if ($key !== false) {
                     unset($settings[$setting][$key]);
                 }
             } elseif ($enabled && !in_array($id, $settings[$setting])) {
                 $settings[$setting][] = $id;
             }
         }
     }
     if (!empty($updateSettings)) {
         $model->setSettings($settings, $chatType);
     }
     return $this->sendJsonResponse(array('success' => $success, 'settings' => $updateSettings));
 }
开发者ID:woakes070048,项目名称:mautic-chat,代码行数:63,代码来源:AjaxController.php

示例3: listAction

 /**
  * Generate channel list
  *
  * @param int $page
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function listAction($page = 1)
 {
     $session = $this->factory->getSession();
     $attrFilters = $session->get('mautic.chat.channel.attr.filters', array());
     if ($this->request->getMethod() == 'POST') {
         $this->setListFilters();
         if ($this->request->query->has('filter')) {
             $attrFilters = $session->get('mautic.chat.channel.attr.filters', array());
             $attr = $this->request->query->get('filter');
             $enabled = InputHelper::boolean($this->request->query->get('enabled'));
             if ($enabled && !in_array($attr, $attrFilters)) {
                 $attrFilters[] = $attr;
             } elseif (!$enabled && in_array($attr, $attrFilters)) {
                 $key = array_search($attr, $attrFilters);
                 if ($key !== false) {
                     unset($attrFilters[$key]);
                 }
             }
             $session->set('mautic.chat.channel.attr.filters', $attrFilters);
         }
     }
     //set limits
     $limit = $session->get('mautic.chat.channel.limit', $this->factory->getParameter('default_pagelimit'));
     $start = $page === 1 ? 0 : ($page - 1) * $limit;
     if ($start < 0) {
         $start = 0;
     }
     /** @var \MauticAddon\MauticChatBundle\Model\ChannelModel $channelModel */
     $channelModel = $this->factory->getModel('addon.mauticChat.channel');
     $settings = $channelModel->getSettings();
     $orderBy = $session->get('mautic.chat.channel.orderby', 'c.name');
     $orderByDir = $session->get('mautic.chat.channel.orderbydir', 'ASC');
     $filters = $session->get('mautic.chat.channel.filters', array());
     list($unreadCounts, $unreadIds) = $channelModel->getChannelsWithUnreadMessages(true);
     foreach ($attrFilters as $attr) {
         switch ($attr) {
             case 'newmessages':
                 if (empty($unreadIds)) {
                     $unreadIds = array(0);
                 }
                 $filters[] = array('column' => 'c.id', 'expr' => 'in', 'value' => $unreadIds);
                 break;
             case 'invisible':
                 if (!empty($settings['visible'])) {
                     $filters[] = array('column' => 'c.id', 'expr' => 'notIn', 'value' => $settings['visible']);
                 }
                 break;
             case 'silent':
                 if (!empty($settings['silent'])) {
                     $filters[] = array('column' => 'c.id', 'expr' => 'in', 'value' => $settings['silent']);
                 }
                 break;
             case 'mute':
                 if (!empty($settings['mute'])) {
                     $filters[] = array('column' => 'c.id', 'expr' => 'in', 'value' => $settings['mute']);
                 }
                 break;
             case 'archived':
                 $filters[] = array('column' => 'c.isPublished', 'expr' => 'eq', 'value' => false);
                 break;
             case 'subscribed':
                 $filters[] = array('column' => 'IDENTITY(s.user)', 'expr' => 'eq', 'value' => $this->factory->getUser()->getId());
                 break;
         }
     }
     //do some default filtering
     $filter = array('string' => '', 'force' => $filters);
     $channels = $this->factory->getModel('addon.mauticChat.channel')->getEntities(array('start' => $start, 'limit' => $limit, 'filter' => $filter, 'orderBy' => $orderBy, 'orderByDir' => $orderByDir, 'userId' => $this->factory->getUser()->getId()));
     //Check to see if the number of pages match the number of users
     $count = count($channels);
     if ($count && $count < $start + 1) {
         //the number of entities are now less then the current page so redirect to the last page
         $lastPage = $count === 1 ? 1 : floor($limit / $count) ?: 1;
         $session->set('mautic.chat.channel.page', $lastPage);
         $returnUrl = $this->generateUrl('mautic_chatchannel_list', array('page' => $lastPage));
         return $this->postActionRedirect(array('returnUrl' => $returnUrl, 'viewParameters' => array('page' => $lastPage), 'contentTemplate' => 'MauticChatBundle:Channel:list', 'passthroughVars' => array('mauticContent' => 'chatChannel', 'replaceContent' => 'true', 'route' => false)));
     }
     //set what page currently on so that we can return here after form submission/cancellation
     $session->set('mautic.chat.channel.page', $page);
     return $this->delegateView(array('viewParameters' => array('items' => $channels, 'page' => $page, 'limit' => $limit, 'settings' => $settings, 'me' => $this->factory->getUser(), 'filters' => $attrFilters, 'unread' => $unreadCounts, 'stats' => $channelModel->getUserChannelStats()), 'contentTemplate' => 'MauticChatBundle:Channel:list.html.php', 'passthroughVars' => array('route' => $this->generateUrl('mautic_chatchannel_list', array('page' => $page)), 'mauticContent' => 'chatChannel', 'replaceContent' => 'true', 'route' => false)));
 }
开发者ID:woakes070048,项目名称:mautic-chat,代码行数:88,代码来源:ChannelController.php


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