erLhcoreClassChatWorkflow::unreadInformWorkflow PHP Méthode

unreadInformWorkflow() public static méthode

public static unreadInformWorkflow ( $options = [], &$chat )
    public static function unreadInformWorkflow($options = array(), &$chat)
    {
        $chat->unread_messages_informed = 1;
        $chat->updateThis();
        if (in_array('mail', $options['options'])) {
            erLhcoreClassChatMail::sendMailUnacceptedChat($chat, 7);
        }
        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.chat_unread_message', 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/unread_message_chat.php';
            if (file_exists($callbackFile)) {
                include $callbackFile;
            }
        }
    }

Usage Example

Exemple #1
0
 if ($chat->status == erLhcoreClassModelChat::STATUS_PENDING_CHAT && $chat->transfer_if_na == 1 && $chat->transfer_timeout_ts < time() - $chat->transfer_timeout_ac) {
     $canExecuteWorkflow = true;
     if (erLhcoreClassModelChatConfig::fetch('pro_active_limitation')->current_value >= 0) {
         if ($chat->department !== false && $chat->department->department_transfer_id > 0) {
             $canExecuteWorkflow = erLhcoreClassChat::getPendingChatsCountPublic($chat->department->department_transfer_id) <= erLhcoreClassModelChatConfig::fetch('pro_active_limitation')->current_value;
         }
     }
     if ($canExecuteWorkflow == true) {
         erLhcoreClassChatWorkflow::transferWorkflow($chat);
     }
 }
 if ($chat->reinform_timeout > 0 && $chat->unread_messages_informed == 0 && $chat->has_unread_messages == 1 && time() - $chat->last_user_msg_time > $chat->reinform_timeout) {
     $department = $chat->department;
     if ($department !== false) {
         $options = $department->inform_options_array;
         erLhcoreClassChatWorkflow::unreadInformWorkflow(array('department' => $department, 'options' => $options), $chat);
     }
 }
 // Sync only if chat is pending or active
 if ($chat->status == erLhcoreClassModelChat::STATUS_PENDING_CHAT || $chat->status == erLhcoreClassModelChat::STATUS_ACTIVE_CHAT) {
     // Check for new messages only if chat last message id is greater than user last message id
     if ((int) $Params['user_parameters']['message_id'] < $chat->last_msg_id) {
         $Messages = erLhcoreClassChat::getPendingMessages((int) $Params['user_parameters']['chat_id'], (int) $Params['user_parameters']['message_id']);
         if (count($Messages) > 0) {
             $tpl = erLhcoreClassTemplate::getInstance('lhchat/syncuser.tpl.php');
             $tpl->set('messages', $Messages);
             $tpl->set('chat', $chat);
             $tpl->set('sync_mode', isset($Params['user_parameters_unordered']['mode']) ? $Params['user_parameters_unordered']['mode'] : '');
             $content = $tpl->fetch();
             foreach ($Messages as $msg) {
                 if ($msg['user_id'] > 0) {