示例#1
0
 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
 public function afterUserLogout($event)
 {
     $identity = $event->getArgument('identity');
     try {
         \Support\Models\Operators::goOffline($identity);
     } catch (\Exception $e) {
         // TODO log this
     }
 }
示例#3
0
 public function unclaimedSessions()
 {
     $user = $this->getIdentity();
     if (empty($user->id)) {
         return;
     }
     $unclaimed = \Support\Models\ChatSessions::unclaimed();
     $is_online = \Support\Models\Operators::isOnline($user);
     echo $this->outputJson($this->getJsonResponse(array('alert' => $is_online ? true : false, 'count' => count($unclaimed), 'result' => $this->theme->renderView('Support/Admin/Views::livechat/fragment_unclaimed_sessions.php'))));
 }
示例#4
0
 protected function preAdmin()
 {
     parent::preAdmin();
     if (class_exists('\\Minify\\Factory')) {
         \Minify\Factory::registerPath($this->dir . "/src/");
         $files = array('Support/Assets/js/poller.js', 'Support/Assets/js/admin.js');
         foreach ($files as $file) {
             \Minify\Factory::js($file);
         }
         $files = array('Support/Assets/css/admin.css');
         foreach ($files as $file) {
             \Minify\Factory::css($file);
         }
     }
     if ($op = \Support\Models\Operators::isOnline($this->auth->getIdentity())) {
         if (\Dsc\System::instance()->get('input')->get('ping', null, 'int') != 1) {
             $op->markActive();
         }
     }
     \Dsc\System::instance()->getDispatcher()->addListener(\Support\Listeners\Users::instance());
     \Support\Models\ChatSessions::throttledCleanup();
 }
示例#5
0
 public function claimSession()
 {
     $chat_session_id = $this->app->get('PARAMS.session_id');
     try {
         $chat_session = (new \Support\Models\ChatSessions())->setState('filter.id', $chat_session_id)->getItem();
         if (empty($chat_session->id)) {
             throw new \Exception('Invalid Session');
         }
         $chat_session->session_id_admin = $this->session->id();
         $chat_session->admin_id = new \MongoId((string) $this->getIdentity()->id);
         $chat_session->admin_name = $this->getIdentity()->first_name;
         $chat_session->admin_email = $this->getIdentity()->email;
         $chat_session->status = 'claimed';
         $chat_session->messages[] = (new \Support\Models\ChatMessages(array('sender_type' => 'system', 'sender_name' => 'System Bot', 'timestamp' => time(), 'text' => $this->getIdentity()->first_name . ' has joined this session.')))->cast();
         $chat_session->save();
         \Dsc\System::addMessage('You claimed that session');
     } catch (\Exception $e) {
         \Dsc\System::addMessage('There was an error claiming that session.', 'error');
         \Dsc\System::addMessage($e->getMessage(), 'error');
     }
     try {
         $user = $this->getIdentity();
         \Support\Models\Operators::goOnline($user);
         \Dsc\System::addMessage('You are now online');
     } catch (\Exception $e) {
         \Dsc\System::addMessage('There was an error marking you as online', 'error');
         \Dsc\System::addMessage($e->getMessage(), 'error');
     }
     $this->app->reroute('/admin/support/live-chat');
 }
<?php

foreach ($operators = \Support\Models\Operators::fetchActive() as $operator) {
    ?>
<div class="list-group-item">
    <b><?php 
    echo $operator->fullName();
    ?>
</b>
    <p class="help-block"><small><?php 
    echo (int) $operator->openSessions();
    ?>
 open sessions</small></p>
    
    <div class="help-block">
        <div><small>Last active: <?php 
    echo \Dsc\Mongo\Collections\Sessions::ago($operator->last_activity);
    ?>
</small></div>               
    </div>    
</div>
<?php 
}
?>

<?php 
if (empty($operators)) {
    ?>
<div class="list-group-item">
    <p>No online operators</p>
</div>
示例#7
0
<div class="row">
    <div class="col-xs-12 col-sm-7 col-md-7 col-lg-4">
        <h1 class="page-title txt-color-blueDark">
            <i class="fa fa-table fa-fw "></i> Live Chat
            <span>
                > <small>You are:
                <?php 
if (\Support\Models\Operators::isActive($this->auth->getIdentity())) {
    ?>
 
                    <a class="btn btn-success" href="./admin/support/live-chat/offline" title="Go offline">Online</a>
                <?php 
} else {
    ?>
                    <a class="btn btn-danger" href="./admin/support/live-chat/online" title="Go online" >Offline</a>
                <?php 
}
?>
            </span>
        </h1>
    </div>
    <div class="col-xs-12 col-sm-5 col-md-5 col-lg-8">
        <ul id="sparks" class="list-actions list-unstyled list-inline">
            <li>
                
            </li>
        </ul>
    </div>
</div>

<div class="row">