Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
TimeOutAdmin
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TimeOut
TimeOutAdmin
Commits
d695fdaf
Commit
d695fdaf
authored
Nov 20, 2019
by
Tobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
t : push notification changes
parent
f8c87676
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
96 deletions
+59
-96
Notification.php
application/controllers/Notification.php
+4
-32
generals_helper.php
application/helpers/generals_helper.php
+19
-0
Api_model.php
application/models/Api_model.php
+4
-20
Organizer_model.php
application/models/Organizer_model.php
+2
-19
Webservice_model.php
application/models/Webservice_model.php
+30
-25
No files found.
application/controllers/Notification.php
View file @
d695fdaf
...
...
@@ -123,8 +123,9 @@ class Notification extends CI_Controller {
foreach
(
$users
AS
$user
){
$userData
=
array
(
'id'
=>
$event_data
->
event_id
,
'title'
=>
$event_data
->
event_name_EN
,
'param'
=>
'event_id'
,
'message'
=>
$message
);
$this
->
push_sent_cancel
(
'1'
,
$user
[
'fcm_token'
],
$userData
);
push_sent_cancel
(
$user
[
'fcm_token'
],
$userData
);
}
$flashMsg
[
'class'
]
=
'success'
;
...
...
@@ -152,39 +153,11 @@ class Notification extends CI_Controller {
foreach
(
$bookData
AS
$bData
){
$userData
=
array
(
'id'
=>
$bData
[
'bookId'
],
'param'
=>
'booking_id'
,
'title'
=>
$bData
[
'event_name_en'
],
'message'
=>
'Booking Remainder'
);
$this
->
push_sent_cancel
(
'2'
,
$bData
[
'fcm_token'
],
$userData
);
push_sent_cancel
(
$bData
[
'fcm_token'
],
$userData
);
}
}
function
push_sent_cancel
(
$type
=
'1'
,
$fcm_token
=
''
,
$fcm_data
=
array
())
{
$settings
=
getSettings
();
$key
=
$settings
[
'app_id'
];
if
(
empty
(
$key
)
||
empty
(
$fcm_token
)
||
empty
(
$fcm_data
)){
return
;
}
switch
(
$type
)
{
case
'1'
:
$data
=
"{
\"
notification
\"
: {
\"
title
\"
:
\"
"
.
$fcm_data
[
'title'
]
.
"
\"
,
\"
text
\"
:
\"
"
.
$fcm_data
[
'message'
]
.
"
\"
,
\"
sound
\"
:
\"
default
\"
},
\"
time_to_live
\"
: 60,
\"
data
\"
: {\"
response
\
" : {\"
status
\
" :
\"
success
\"
,
\"
data
\"
: {\"
event_id
\
" :
\"
"
.
$fcm_data
[
'id'
]
.
"
\"
,
\"
trip_status
\"
: 0}}},
\"
collapse_key
\"
:
\"
trip
\"
,
\"
priority
\"
:
\"
high
\"
,
\"
to
\"
:
\"
"
.
$fcm_token
.
"
\"
}"
;
break
;
case
'2'
:
$data
=
"{
\"
notification
\"
: {
\"
title
\"
:
\"
"
.
$fcm_data
[
'title'
]
.
"
\"
,
\"
text
\"
:
\"
"
.
$fcm_data
[
'message'
]
.
"
\"
,
\"
sound
\"
:
\"
default
\"
},
\"
time_to_live
\"
: 60,
\"
data
\"
: {\"
response
\
" : {\"
status
\
" :
\"
success
\"
,
\"
data
\"
: {\"
booking_id
\
" :
\"
"
.
$fcm_data
[
'id'
]
.
"
\"
,
\"
trip_status
\"
: 0}}},
\"
collapse_key
\"
:
\"
trip
\"
,
\"
priority
\"
:
\"
high
\"
,
\"
to
\"
:
\"
"
.
$fcm_token
.
"
\"
}"
;
break
;
}
$ch
=
curl_init
(
"https://fcm.googleapis.com/fcm/send"
);
$header
=
array
(
'Content-Type: application/json'
,
'Authorization: key='
.
$key
);
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
$header
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
false
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$data
);
$out
=
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_exec
(
$ch
);
curl_close
(
$ch
);
}
}
?>
\ No newline at end of file
application/helpers/generals_helper.php
View file @
d695fdaf
...
...
@@ -396,4 +396,22 @@
}
return
$langArr
;
}
function
push_sent_cancel
(
$fcm_token
=
''
,
$fcm_data
=
array
())
{
$settings
=
getSettings
();
$key
=
$settings
[
'org_app_id'
];
if
(
empty
(
$key
)
||
empty
(
$fcm_token
)
||
empty
(
$fcm_data
)){
return
;
}
$data
=
"{
\"
notification
\"
: {
\"
title
\"
:
\"
"
.
$fcm_data
[
'title'
]
.
"
\"
,
\"
text
\"
:
\"
"
.
$fcm_data
[
'message'
]
.
"
\"
,
\"
sound
\"
:
\"
default
\"
},
\"
time_to_live
\"
: 60,
\"
data
\"
: {\"
response
\
" : {\"
status
\
" :
\"
success
\"
,
\"
data
\"
: {\"".
$fcm_data['param']
."
\
" :
\"
"
.
$fcm_data
[
'id'
]
.
"
\"
,
\"
user_type
\"
: 2}}},
\"
collapse_key
\"
:
\"
trip
\"
,
\"
priority
\"
:
\"
high
\"
,
\"
to
\"
:
\"
"
.
$fcm_token
.
"
\"
}"
;
$ch
=
curl_init
(
"https://fcm.googleapis.com/fcm/send"
);
$header
=
array
(
'Content-Type: application/json'
,
'Authorization: key='
.
$key
);
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
$header
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
false
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$data
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_exec
(
$ch
);
curl_close
(
$ch
);
}
?>
\ No newline at end of file
application/models/Api_model.php
View file @
d695fdaf
...
...
@@ -703,8 +703,9 @@ class Api_model extends CI_Model {
if
(
$post_data
[
'status'
]
==
6
){
$userData
=
array
(
'id'
=>
$post_data
[
'bookId'
],
'title'
=>
'New Booking'
,
'param'
=>
'booking_id'
,
'message'
=>
'New Booking is There For Approval'
);
$this
->
push_sent_cancel
(
$bkData
[
'fcm_token'
],
$userData
);
push_sent_cancel
(
$bkData
[
'fcm_token'
],
$userData
);
}
}
}
else
{
...
...
@@ -723,24 +724,6 @@ class Api_model extends CI_Model {
return
'https://www.barcodefaq.com/wp-content/uploads/2018/08/gs1-qrcode-fnc1.png'
;
}
public
function
push_sent_cancel
(
$fcm_token
=
''
,
$fcm_data
=
array
())
{
$settings
=
getSettings
();
$key
=
$settings
[
'org_app_id'
];
if
(
empty
(
$key
)
||
empty
(
$fcm_token
)
||
empty
(
$fcm_data
)){
return
;
}
$data
=
"{
\"
notification
\"
: {
\"
title
\"
:
\"
"
.
$fcm_data
[
'title'
]
.
"
\"
,
\"
text
\"
:
\"
"
.
$fcm_data
[
'message'
]
.
"
\"
,
\"
sound
\"
:
\"
default
\"
},
\"
time_to_live
\"
: 60,
\"
data
\"
: {\"
response
\
" : {\"
status
\
" :
\"
success
\"
,
\"
data
\"
: {\"
booking_id
\
" :
\"
"
.
$fcm_data
[
'id'
]
.
"
\"
,
\"
user_type
\"
: 2}}},
\"
collapse_key
\"
:
\"
trip
\"
,
\"
priority
\"
:
\"
high
\"
,
\"
to
\"
:
\"
"
.
$fcm_token
.
"
\"
}"
;
$ch
=
curl_init
(
"https://fcm.googleapis.com/fcm/send"
);
$header
=
array
(
'Content-Type: application/json'
,
'Authorization: key='
.
$key
);
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
$header
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
false
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$data
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_exec
(
$ch
);
curl_close
(
$ch
);
}
function
recommend
(
$data
)
{
try
{
$locCond
=
''
;
...
...
@@ -1438,8 +1421,9 @@ class Api_model extends CI_Model {
if
(
$bokStatus
==
'6'
){
$userData
=
array
(
'id'
=>
$book_id
,
'title'
=>
'New Booking'
,
'param'
=>
'booking_id'
,
'message'
=>
'New Booking is There For Approval'
);
$this
->
push_sent_cancel
(
$bkData
[
'fcm_token'
],
$userData
);
push_sent_cancel
(
$bkData
[
'fcm_token'
],
$userData
);
}
}
$this
->
db
->
update
(
'booking'
,
array
(
'status'
=>
$bokStatus
),
array
(
'bookId'
=>
$book_id
));
...
...
application/models/Organizer_model.php
View file @
d695fdaf
...
...
@@ -1097,32 +1097,15 @@ class Organizer_model extends CI_Model {
$bData
=
$this
->
db
->
query
(
$sql
)
->
row_array
();
$this
->
db
->
update
(
'booking'
,
array
(
'status'
=>
'1'
),
array
(
'bookId'
=>
$data
[
'booking_id'
]));
$userData
=
array
(
'id'
=>
$data
[
'booking_id'
],
'param'
=>
'booking_id'
,
'title'
=>
'Booking Approved'
,
'message'
=>
'Your Booking is Approved by the Event Provider'
);
$this
->
push_sent_cancel
(
$bData
[
'fcm_token'
],
$userData
);
push_sent_cancel
(
$bData
[
'fcm_token'
],
$userData
);
$res
=
array
(
'status'
=>
1
,
'message'
=>
'Booking Accepted Successfully'
);
}
catch
(
Exception
$e
){
$res
=
array
(
'status'
=>
0
,
'message'
=>
'Ohh No!! Something Went South'
,
'code'
=>
'ER06'
);
}
return
$res
;
}
public
function
push_sent_cancel
(
$fcm_token
=
''
,
$fcm_data
=
array
())
{
$settings
=
getSettings
();
$key
=
$settings
[
'app_id'
];
if
(
empty
(
$key
)
||
empty
(
$fcm_token
)
||
empty
(
$fcm_data
)){
return
;
}
$data
=
"{
\"
notification
\"
: {
\"
title
\"
:
\"
"
.
$fcm_data
[
'title'
]
.
"
\"
,
\"
text
\"
:
\"
"
.
$fcm_data
[
'message'
]
.
"
\"
,
\"
sound
\"
:
\"
default
\"
},
\"
time_to_live
\"
: 60,
\"
data
\"
: {\"
response
\
" : {\"
status
\
" :
\"
success
\"
,
\"
data
\"
: {\"
booking_id
\
" :
\"
"
.
$fcm_data
[
'id'
]
.
"
\"
,
\"
trip_status
\"
: 0}}},
\"
collapse_key
\"
:
\"
trip
\"
,
\"
priority
\"
:
\"
high
\"
,
\"
to
\"
:
\"
"
.
$fcm_token
.
"
\"
}"
;
$ch
=
curl_init
(
"https://fcm.googleapis.com/fcm/send"
);
$header
=
array
(
'Content-Type: application/json'
,
'Authorization: key='
.
$key
);
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
$header
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
false
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$data
);
$out
=
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_exec
(
$ch
);
curl_close
(
$ch
);
}
}
?>
application/models/Webservice_model.php
View file @
d695fdaf
...
...
@@ -1212,9 +1212,10 @@ class Webservice_model extends CI_Model {
}
if
(
$post_data
[
'status'
]
==
6
){
$userData
=
array
(
'id'
=>
$post_data
[
'bookId'
],
'title'
=>
'New Booking'
,
'message'
=>
'New Booking is There For Approval'
);
$this
->
push_sent_cancel
(
$bkData
[
'fcm_token'
],
$userData
);
'param'
=>
'booking_id'
,
'title'
=>
'New Booking'
,
'message'
=>
'New Booking is There For Approval'
);
push_sent_cancel
(
$bkData
[
'fcm_token'
],
$userData
);
}
}
}
else
{
...
...
@@ -1233,24 +1234,6 @@ class Webservice_model extends CI_Model {
return
'https://www.barcodefaq.com/wp-content/uploads/2018/08/gs1-qrcode-fnc1.png'
;
}
public
function
push_sent_cancel
(
$fcm_token
=
''
,
$fcm_data
=
array
())
{
$settings
=
getSettings
();
$key
=
$settings
[
'org_app_id'
];
if
(
empty
(
$key
)
||
empty
(
$fcm_token
)
||
empty
(
$fcm_data
)){
return
;
}
$data
=
"{
\"
notification
\"
: {
\"
title
\"
:
\"
"
.
$fcm_data
[
'title'
]
.
"
\"
,
\"
text
\"
:
\"
"
.
$fcm_data
[
'message'
]
.
"
\"
,
\"
sound
\"
:
\"
default
\"
},
\"
time_to_live
\"
: 60,
\"
data
\"
: {\"
response
\
" : {\"
status
\
" :
\"
success
\"
,
\"
data
\"
: {\"
booking_id
\
" :
\"
"
.
$fcm_data
[
'id'
]
.
"
\"
,
\"
user_type
\"
: 2}}},
\"
collapse_key
\"
:
\"
trip
\"
,
\"
priority
\"
:
\"
high
\"
,
\"
to
\"
:
\"
"
.
$fcm_token
.
"
\"
}"
;
$ch
=
curl_init
(
"https://fcm.googleapis.com/fcm/send"
);
$header
=
array
(
'Content-Type: application/json'
,
'Authorization: key='
.
$key
);
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
$header
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
false
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$data
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_exec
(
$ch
);
curl_close
(
$ch
);
}
function
cancel
(
$data
)
{
try
{
$user_id
=
$this
->
auth_token_get
(
$data
[
'auth_token'
]);
...
...
@@ -1920,20 +1903,42 @@ class Webservice_model extends CI_Model {
}
public
function
update_friend_request
(
$data
){
$fromUser
=
$data
[
'user_id'
];
$user_id
=
$this
->
auth_token_get
(
$data
[
'auth_token'
]);
$status
=
$this
->
db
->
query
(
"UPDATE chats SET type='"
.
$data
[
'add_as_friend'
]
.
"'
WHERE from_user='"
.
$data
[
'user_id'
]
.
"' AND to_user='"
.
$user_id
.
"'"
);
WHERE from_user='"
.
$fromUser
.
"' AND to_user='"
.
$user_id
.
"'"
);
if
(
$data
[
'add_as_friend'
]
==
1
){
$toCustData
=
$this
->
db
->
get_where
(
'customer'
,
array
(
'customer_id'
=>
$fromUser
))
->
row_array
();
$frmCustData
=
$this
->
db
->
get_where
(
'customer'
,
array
(
'customer_id'
=>
$user_id
))
->
row_array
();
$fcmData
=
array
(
'id'
=>
$toUser
,
'param'
=>
'user_id'
,
'title'
=>
'Accepted Chat Request'
,
'message'
=>
$frmCustData
[
'name'
]
.
' has Accepted Your Chat Request'
);
push_sent_cancel
(
$toCustData
[
'fcm_token'
],
$fcmData
);
}
return
(
$status
)
?
1
:
0
;
}
public
function
send_friend_request
(
$data
){
$respArr
=
array
(
'status'
=>
0
,
'code'
=>
'918'
,
'message'
=>
'Something Went Wrong..Try Again'
);
$user_id
=
$this
->
auth_token_get
(
$data
[
'auth_token'
]);
$result
=
$this
->
db
->
get_where
(
'chats'
,
array
(
'from_user'
=>
$user_id
,
'to_user'
=>
$data
[
'user_id'
]))
->
row_array
();
$toUser
=
(
is_numeric
(
$data
[
'user_id'
]))
?
$data
[
'user_id'
]
:
decode_param
(
$data
[
'user_id'
]);
if
(
empty
(
$toUser
)){
return
array
(
'status'
=>
0
,
'code'
=>
'919'
,
'message'
=>
'Something Went Wrong.. Try Again..'
);
}
$result
=
$this
->
db
->
get_where
(
'chats'
,
array
(
'from_user'
=>
$user_id
,
'to_user'
=>
$toUser
))
->
row_array
();
if
(
empty
(
$result
)){
$result
=
$this
->
db
->
get_where
(
'chats'
,
array
(
'to_user'
=>
$user_id
,
'from_user'
=>
$data
[
'user_id'
]
))
->
row_array
();
$result
=
$this
->
db
->
get_where
(
'chats'
,
array
(
'to_user'
=>
$user_id
,
'from_user'
=>
$toUser
))
->
row_array
();
if
(
empty
(
$result
)){
$this
->
db
->
insert
(
'chats'
,
array
(
'from_user'
=>
$user_id
,
'to_user'
=>
$data
[
'user_id'
],
'type'
=>
'0'
));
$this
->
db
->
insert
(
'chats'
,
array
(
'from_user'
=>
$user_id
,
'to_user'
=>
$toUser
,
'type'
=>
'0'
));
$toCustData
=
$this
->
db
->
get_where
(
'customer'
,
array
(
'customer_id'
=>
$toUser
))
->
row_array
();
$frmCustData
=
$this
->
db
->
get_where
(
'customer'
,
array
(
'customer_id'
=>
$user_id
))
->
row_array
();
$fcmData
=
array
(
'id'
=>
$toUser
,
'param'
=>
'user_id'
,
'title'
=>
'New Friend Request'
,
'message'
=>
'You got a New Friend Request from '
.
$toCustData
[
'name'
]);
push_sent_cancel
(
$frmCustData
[
'fcm_token'
],
$fcmData
);
}
else
if
(
!
empty
(
$result
)
&&
$result
[
'type'
]
==
'0'
){
$this
->
db
->
update
(
'chats'
,
array
(
'type'
=>
'1'
),
array
(
'chat_id'
=>
$result
[
'chat_id'
]));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment