예제 #1
0
    } else {
        $pubblicato = 0;
    }
    $res_ha['pubblicato'] = $pubblicato;
    $res_ha['lingua'] = $lingua;
    $media_found = $dh->get_risorsa_esterna_info_autore($filename, $author_id);
    if (AMA_DataHandler::isError($media_found) and $media_found->code == AMA_ERR_NOT_FOUND) {
        $op = 'insert';
        $id_res_ext = add_only_in_risorsa_esterna($res_ha);
        if (AMA_DataHandler::isError($id_res_ext)) {
            exitWith_JSON_Error(translateFN("Errore nell'inserimento del media"));
        }
        $response = array();
        $response['result'] = 'Inserimento media riuscito';
    } elseif (isset($media_found['id_risorsa_ext'])) {
        $op = 'update';
        $id_res_ext = $media_found['id_risorsa_ext'];
        $update_media = $dh->set_risorsa_esterna($id_res_ext, $res_ha);
        if (AMA_DataHandler::isError($update_media)) {
            exitWith_JSON_Error(translateFN("Errore nell'aggiornamento del media"));
        }
        $response = array();
        $response['result'] = 'Aggiornamento media riuscito';
    } else {
        if (AMA_DataHandler::isError($media_found) and $media_found->code == AMA_ERR_GET) {
            $response = array();
            $response['result'] = 'Errore AMA ';
        }
    }
    print json_encode($response);
}
예제 #2
0
}
$msgs_pub_ha = array();
/*
 * vito, uso $fields_list per indicare quali messaggi ottenere: quelli inviati
 * a partire dall'avvio della chat o quelli inviati a partire dall'ultima lettura
 */
// TODO: usare find_messages al posto di get_messages e passare la clausola corretta
$fields_list = $all_messages;
$msgs_pub_ha = $mh->get_messages($sess_id_user, ADA_MSG_CHAT, $fields_list, $sort_field);
if (AMA_DataHandler::isError($msgs_pub_ha)) {
    exitWith_JSON_Error(translateFN('Errore nella lettura dei messaggi dal DB'));
}
$msgs_priv_ha = array();
$msgs_priv_ha = $mh->get_messages($sess_id_user, ADA_MSG_PRV_CHAT, $fields_list, $sort_field);
if (AMA_DataHandler::isError($msgs_priv_ha)) {
    exitWith_JSON_Error(translateFN('Errore nella lettura dei messaggi dal DB'));
}
//merge the two arrays without losing their keys.
//In this case each key is the id of one message that is unique
/*
 * NUOVO CODICE MESSAGGI CHAT
 */
$current_public_message = 0;
$current_private_message = 0;
$total_private_messages = count($msgs_priv_ha);
$total_public_messages = count($msgs_pub_ha);
$msgs_number = $total_public_messages + $total_private_messages;
$messages_display_Ha = array();
//$json_data = "[";
for ($i = 0; $i < $msgs_number; $i++) {
    if ($current_public_message < $total_public_messages && $current_private_message < $total_private_messages) {
예제 #3
0
}
// a message can be sent only if no errors are found
if (count($errors) == 0) {
    //prepare message to send
    $message_ha = isset($send_chat_message_form) ? $send_chat_message_form : null;
    $message_ha['tipo'] = $message_type;
    if ($message_ha['tipo'] == ADA_MSG_PRV_CHAT) {
        $message_ha['destinatari'] = $receiver_name;
    }
    $message_ha['testo'] = $final_text;
    //$id_chatroom = $id_chatroom;
    $message_ha['data_ora'] = "now";
    $message_ha['mittente'] = $user_uname;
    $message_ha['id_group'] = $id_chatroom;
    // delegate sending to the message handler
    $res = $mh->send_message($message_ha);
    if (AMA_DataHandler::isError($res)) {
        $code = $res->errorMessage();
        exitWith_JSON_Error(translateFN("Errore nell'invio del messaggio {$code}"));
    }
    //	log_this("$read_res", 4);
}
// end if count
$data = array('id_chatroom' => $id_chatroom);
$end_time = time() + microtime();
$total_time = $end_time - $start_time;
/*
 * Send back JSON data to caller
 */
$response = '{"error" : 0, "execution_time" : ' . $total_time . '}';
print $response;
예제 #4
0
//        {
//            $user_data               = array_shift($bannedusers_ar);
//            $json_banned_users_list .= '{"username":"******"},';
//        }
//        if (count($bannedusers_ar) == 1)
//        {
//            $user_data               = array_shift($bannedusers_ar);
//            $json_banned_users_list .= '{"username":"******"}';
//        }
//	}//end of if($bannedusers_ar)
//    $json_banned_users_list .= ']';
//}// end of banned list
// write the time of the event into the utente_chatroom table
$last_event = $chatroomObj->set_last_event_timeFN($sess_id_user, $id_chatroom);
if (isset($bannedusers_ar) && AMA_DataHandler::isError($bannedusers_ar)) {
    exitWith_JSON_Error(translateFN("Errore nell'aggiornamento del tempo relativo all'utlimo evento"));
}
/*
 * Optionally, track this script execution time.
 */
if (defined('ADA_AJAX_CHAT_SCRIPT_TIMING')) {
    $end_time = time() + microtime();
    $total_time = $end_time - $start_time;
}
/*
 * Sending back data to the caller.
 */
$error = 0;
/*
 * Get UI labels in the user's language.
 */