erLhcoreClassChatWorkflow::unansweredChatWorkflow PHP Méthode

unansweredChatWorkflow() public static méthode

* Chat was unanswered for n minits, execute callback.
public static unansweredChatWorkflow ( erLhcoreClassModelChat &$chat )
$chat erLhcoreClassModelChat
    public static function unansweredChatWorkflow(erLhcoreClassModelChat &$chat)
    {
        $chat->na_cb_executed = 1;
        $chat->updateThis();
        // Execute callback if it exists
        $extensions = erConfigClassLhConfig::getInstance()->getOverrideValue('site', 'extensions');
        $instance = erLhcoreClassSystem::instance();
        erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.unread_chat_workflow', array('chat' => &$chat));
        foreach ($extensions as $ext) {
            $callbackFile = $instance->SiteDir . '/extension/' . $ext . '/callbacks/unanswered_chat.php';
            if (file_exists($callbackFile)) {
                include $callbackFile;
            }
        }
    }

Usage Example

 public static function mainUnansweredChatWorkflow()
 {
     $output = '';
     if (erLhcoreClassModelChatConfig::fetch('run_unaswered_chat_workflow')->current_value > 0) {
         $output .= "Starting unaswered chats workflow\n";
         $delay = time() - erLhcoreClassModelChatConfig::fetch('run_unaswered_chat_workflow')->current_valu * 60;
         foreach (erLhcoreClassChat::getList(array('limit' => 500, 'filterlt' => array('time' => $delay), 'filter' => array('status' => erLhcoreClassModelChat::STATUS_PENDING_CHAT, 'na_cb_executed' => 0))) as $chat) {
             erLhcoreClassChatWorkflow::unansweredChatWorkflow($chat);
             $output .= "executing unanswered callback for chat - " . $chat->id . "\n";
         }
         $output .= "Ended unaswered chats workflow\n";
     }
     return $output;
 }
All Usage Examples Of erLhcoreClassChatWorkflow::unansweredChatWorkflow