erLhcoreClassChatWorkflow::newChatInformWorkflow PHP Méthode

newChatInformWorkflow() public static méthode

public static newChatInformWorkflow ( $options = [], &$chat )
    public static function newChatInformWorkflow($options = array(), &$chat)
    {
        $chat->nc_cb_executed = 1;
        $chat->updateThis();
        if (in_array('mail', $options['options'])) {
            erLhcoreClassChatMail::sendMailUnacceptedChat($chat);
        }
        if (in_array('xmp', $options['options'])) {
            $errors = array();
            erLhcoreClassChatEventDispatcher::getInstance()->dispatch('xml.before_send_xmp_message', array('chat' => &$chat, 'errors' => &$errors));
            if (empty($errors)) {
                erLhcoreClassXMP::sendXMPMessage($chat);
            }
        }
        erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.new_chat', array('chat' => &$chat));
        // Execute callback if it exists
        $extensions = erConfigClassLhConfig::getInstance()->getOverrideValue('site', 'extensions');
        $instance = erLhcoreClassSystem::instance();
        foreach ($extensions as $ext) {
            $callbackFile = $instance->SiteDir . '/extension/' . $ext . '/callbacks/new_chat.php';
            if (file_exists($callbackFile)) {
                include $callbackFile;
            }
        }
    }

Usage Example

 $chat = erLhcoreClassModelChat::fetch($Params['user_parameters']['chat_id']);
 if ($chat->hash == $Params['user_parameters']['hash']) {
     // Main unasnwered chats callback
     if ($chat->na_cb_executed == 0 && $chat->status == erLhcoreClassModelChat::STATUS_PENDING_CHAT && erLhcoreClassModelChatConfig::fetch('run_unaswered_chat_workflow')->current_value > 0) {
         $delay = time() - erLhcoreClassModelChatConfig::fetch('run_unaswered_chat_workflow')->current_value * 60;
         if ($chat->time < $delay) {
             erLhcoreClassChatWorkflow::unansweredChatWorkflow($chat);
         }
     }
     if ($chat->nc_cb_executed == 0 && $chat->status == erLhcoreClassModelChat::STATUS_PENDING_CHAT) {
         $department = $chat->department;
         if ($department !== false) {
             $options = $department->inform_options_array;
             $delay = time() - $department->inform_delay;
             if ($chat->time < $delay) {
                 erLhcoreClassChatWorkflow::newChatInformWorkflow(array('department' => $department, 'options' => $options), $chat);
             }
         } else {
             $chat->nc_cb_executed = 1;
             $chat->updateThis();
         }
     }
     $contactRedirected = false;
     if ($chat->status == erLhcoreClassModelChat::STATUS_PENDING_CHAT) {
         $department = $chat->department;
         if ($department !== false) {
             $delay = time() - $department->delay_lm;
             if ($department->delay_lm > 0 && $chat->time < $delay) {
                 $baseURL = isset($Params['user_parameters_unordered']['mode']) && $Params['user_parameters_unordered']['mode'] == 'widget' ? erLhcoreClassDesign::baseurl('chat/chatwidget') : erLhcoreClassDesign::baseurl('chat/startchat');
                 $ru = $baseURL . '/(department)/' . $department->id . '/(offline)/true/(leaveamessage)/true/(chatprefill)/' . $chat->id . '_' . $chat->hash;
                 $msg = new erLhcoreClassModelmsg();