Comet chat integration with Code Igniter - codeigniter

I am using comet chat with Code Igniter 2.0.
Problem-
i have a listing page where all the users are listed and i need to show their comet chat status ("Online" or "Offline") next to their name.
For this purpose we have a DB field ('chat_status') in our users table, we usually set this field to '0' or '1' when user logged in we set this field to '1' and when user logged out we set this field to '0'. I just want to use comet chat call backs that will return all the online user_ids in array so i will change their 'chat_status' to '1' in our users table.
I couldn't find any comet chat function or query that will return all the online users in one shot.
Can you please assist me to solve this stuff.
Thanks in advance

There is a function in integration file [in my case its in its integration.php]
function getFriendsList() show all the friends on-line but if you want to show all the user insted of friends fellow the instruction given in link

You just have to edit the 3 sql queries in integration.php function by making changes to the username field .
You can write a subquery and get the status of the user that will be very easy .

Related

Don't show the message to all users? ( laravel )

I need to create to send a message to all new users registered on my website. I created a table called messages that admins can store (insert) the messages from the admin panel to this table and these messages are simply shown to all users with a foreach.
I don't know if this the best way to do something like that!
Anyway, the problem is that when any new user register and open his dashboard he just found the old messages
This is the table :
image
And this is the simple code for foreach
$msgForAll = Message::latest()->get();
I'm not sure how to display new messages to the users.
Again the way I made this idea is wrong, I know that ):
You can use eloquent's where spefically the whereDate queries in your case to get certain rows past or before date.
As an example relating to what you want to do, it can be along the lines of this:
// Given that you are using Auth to get the user's data...
// Get messages that were created after the user's creation date
$messages = Message::whereDate('created_at','>',Auth::User()->created_at)->get();

Assigned to field in Case Table- Servicenow

In Case Form,Based on the group selected in Assignment group field ,the assigned to field is listing some users which belongs to it in CRM UI.
Now I want to retrieve the same users using normal REST API. Please suggest REST API to list the users based on a group.
Users linked to groups is stored in table sys_user_grmember. In the example I search for all Users in Group named "Application Development".
GET https://YOURINSTANCE.service-now.com/api/now/table/sys_user_grmember?sysparm_query=%22groupSTARTSWITHApplication%20Development%22&sysparm_limit=10
You can easily test the REST Api with the rest api explorer from SNOW: https://YOURINSTANCE.service-now.com/nav_to.do?uri=%2F$restapi.do
Can you give more info on the exact requirement, so i can be more precise?
As far as I know, you can create a rest message to get the users inside a group and show the list wherever you want.
This would require three things from your side.
a) Creating a rest message in Snow.
b) Creating a script includes calling the rest message.
c) A client script or trigger which initiates the rest call using client script.
Hope this helps.
Regards.

How to Send an Email on Oracle Apex

I'm building a little application using Oracle Application Express Online. I'd like to send automatically email when an user inserts into the database a row.
I created an Item, called Email, in which I put the address of the user of the application:
Select User.Email from Users wher Users.Username=:APP_USER
Query works, because in the application I see right email.
Then I create a process in the way you see in the screen I'll post here. But nothing happens. Can you help me, please?
As you see, in the centre of the photo there are 2 items: one has to go into the database to store a new row, the second one is the email that is in the process. But, as I said early, nothing happens.
If you click on any attribute in APEX, and click the "Help" tab, you get some very useful information - in this case, that the field expects a substitution syntax for this scenario.
To
Enter the email recipients by specifying one or more email addresses.
For multiple email addresses, use a comma-separated list. Use
substitution syntax if you want to use a dynamic value.
Examples
john.doe#test.com, jane.doe#test.com
John Doe <john.doe#test.com>, Jane Doe <jane.doe#test.com>
&P6_TO.

Laravel private messaging system . Fetch all related users issue

I am referring to this thread
Laravel 4 Relationship: messaging system
I created the tables and also made the relations inside both model "Message" and "User".
Now i can fetch the list of messages sent by me through this command
user::find($myid)->sent_messages()->get();
MY QUESTIONS IS
How can we get list of users that has been messaging to me (logged in user) ?
I mean in the messages table "from" can be logged in user (1) or "to" can be logged in user (1) . I want to get list of other users that are chatting with the (logged in user) .
Hope you understand my question and help. I am new to laravel and trying to learn things and best practises. If you have suggestion to use any messaging system already there in github. I found one name "Laravel-messenger" but not suited to me.
Your suggestions and answer are highly appreciated. THANKS
May be instead of using table user_messages (just drop it) you just modify table Messages to below form:
Messages: id | from_user_id | to_user_id | content
Then you can make query:
$received = Messges::where('to_user_id','=',my_user_id);
$send = Messges::where('from_user_id','=',my_user_id);
$result = $received->union($send)->get();
(BONUS: you can also add column replay_from_message_id (null for first message) to save backward sequence of messages (thread). And then you can also add column first_message_id to simplify getting thread query)

Logged In User Count Laravel 3

I'm using Laravel 3. How do I have a notice that can tell me how many users are currently logged in.
I wish I could explain this better but I am new to Laravel and I should upgrade to 5.1 but that is not a option at the moment.
Any help is appreciated.
Step 1: upgrade to Laravel 5.x
Step 2: add a migration to add the column active_at as a date to the users table
Step 3: add a new HTTP middleware called ActiveUser
Step 4: in the middleware handle method:
if ($user = $request->user()) {
$user->active_at = new \DateTime();
$user->save();
}
Step 5: feed your baby dragon
Step 6: you can now get users by activity using the active_at column
I think that is not a built in feature in Laravel. You could add a column to your user table, something like a flag if the user is logged in or not.
Simply set that column to true, after authenticating of the user and to false when the user logs out again.
Where you need the number of logged in users, simply count the rows in the user table where that flag is set to true.
As far as I know there is no easy way to achieve this. What you can do is show how many users have logged in in the last X minutes using the last logged in column in the users column. I admit, this isn't exactly what you're looking for but it might be the next best thing.
There is no way to accomplish this with laravel or php without using a third party tool like html5 websockets ( ratchet, socket.io etc ) or javascript with ajax.
it is pretty easy and more reliable with websockets. you can create your server to handle connection/disconnection and keep record of sockets connected and emit a message to all connected sockets count of actively connected sockets. This will be real time and less transaction since websockets will only trigger when there is an activity ( someone logins/logouts ) but requires higher access level of control over server/machine in order to install node.js, socket.io and open a tcp port for communication.
second option is javascript with ajax. keep a column in users data table as last_online and update this data each time user browses any page in your site. Like put a code at the top/bottom of your each page and update this columns value with current time. secondly determine how much avarage time a visitor roughly spends on your each page. then create a ajax script where you show your onlines count and trigger it every x amount of time that you determined ( i.e every 30 secs ) on the other side of your code check how many people were online since your last check ( current time - x time )
for instance
$query = "select count(id) total_online_last30 from users where last_check>='" . date( "Y-m-d H:i:s" , strtotime( date() . " +30 seconds") ) . "'"
then print it out.

Resources