コード例 #1
0
ファイル: LiveChatAjax.php プロジェクト: dioscouri/f3-support
 public function init()
 {
     $settings = \Support\Models\Settings::fetch();
     if (!$settings->live_chat_enabled) {
         return null;
     }
     if ($this->session->get('support_close_tab') == 1) {
         return null;
     }
     // are there no operators online?
     $operators = \Support\Models\Operators::fetchActive();
     if (empty($operators)) {
         return $this->outputJson($this->getJsonResponse(array('result' => $this->theme->renderView('Support/Site/Views::livechatajax/no_operators.php'))));
     }
     // is a chat session already started/requested?
     $this->app->set('chat_session', null);
     $chat_session = (new \Support\Models\ChatSessions())->setState('filter.user_session', $this->session->id())->getItem();
     if (!empty($chat_session->id)) {
         $this->session->set('support_session_id', (string) $chat_session->id);
         $this->app->set('chat_session', $chat_session);
         $this->app->set('messages', $chat_session->messages);
     }
     // Display the tab
     return $this->outputJson($this->getJsonResponse(array('result' => $this->theme->renderView('Support/Site/Views::livechatajax/init.php'))));
 }
コード例 #2
0
ファイル: bootstrap.php プロジェクト: dioscouri/f3-support
 protected function preSite()
 {
     parent::preSite();
     $settings = \Support\Models\Settings::fetch();
     if (class_exists('\\Minify\\Factory')) {
         \Minify\Factory::registerPath($this->dir . "/src/");
         $files = array();
         if ($settings->live_chat_enabled) {
             $files[] = 'Support/Assets/js/poller.js';
             $files[] = 'Support/Assets/js/site.js';
         }
         foreach ($files as $file) {
             \Minify\Factory::js($file);
         }
         $files = array('Support/Assets/css/site.css');
         foreach ($files as $file) {
             \Minify\Factory::css($file);
         }
     }
     \Support\Models\ChatSessions::throttledCleanup();
 }
コード例 #3
0
ファイル: index.php プロジェクト: dioscouri/f3-support
<?php

$settings = \Support\Models\Settings::fetch();
?>
<div><?php 
echo $settings->live_chat_index;
?>
</div>

<script>
jQuery(window).load(function(){
    jQuery('#site-chat-body').collapse('show');
});
</script>
コード例 #4
0
ファイル: Operators.php プロジェクト: dioscouri/f3-support
 /**
  *
  * @param string $after
  * @param string $before
  * @return unknown
  */
 public static function fetchActive($after = null, $before = null)
 {
     if (is_null($after)) {
         $settings = \Support\Models\Settings::fetch();
         $last_active = !empty($settings->operator_inactive) ? $settings->operator_inactive : 5;
         $after = time() - $last_active * 60;
     }
     $items = (new static())->setState('filter.active_after', $after)->getitems();
     return $items;
 }
コード例 #5
0
ファイル: ChatSessions.php プロジェクト: dioscouri/f3-support
 /**
  * Pushes $this to the archive,
  * emails a copy to the user and admin,
  * then removes it
  */
 public function archive($check_messages_threshold = true)
 {
     if (!$check_messages_threshold) {
         $archive = (new \Support\Models\ChatSessionsArchive($this))->save();
     } else {
         $settings = \Support\Models\Settings::fetch();
         if (count($this->messages) < $settings->archive_threshold) {
             // don't archive stubs
         } else {
             $archive = (new \Support\Models\ChatSessionsArchive($this))->save();
         }
     }
     $recipients = array();
     // if user_email, email them the log
     if (!empty($this->user_email)) {
         $recipients[] = $this->user_email;
     }
     // if admin_email, email them the log
     if (!empty($this->admin_email)) {
         $recipients[] = $this->admin_email;
     }
     if (!empty($recipients)) {
         $subject = 'Your recent live chat session';
         \Base::instance()->set('chat_session', $this);
         $html = \Dsc\System::instance()->get('theme')->renderView('Support/Views::emails_html/session_log.php');
         $text = \Dsc\System::instance()->get('theme')->renderView('Support/Views::emails_text/session_log.php');
         foreach ($recipients as $recipient) {
             try {
                 \Dsc\System::instance()->get('mailer')->send($recipient, $subject, array($html, $text));
             } catch (\Exception $e) {
                 $this->log($e->getMessage(), 'ERROR', 'ChatSessions::archive');
             }
         }
     }
     return $this->remove();
 }