Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
feeds
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
feeds
Commits
2be9341a
Commit
2be9341a
authored
14 years ago
by
Alex Barth
Browse files
Options
Downloads
Patches
Plain Diff
Clean up loadSubscription() and make it public, add subscribed() query.
parent
b77e7743
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libraries/PuSHSubscriber.inc
+21
-5
21 additions, 5 deletions
libraries/PuSHSubscriber.inc
with
21 additions
and
5 deletions
libraries/PuSHSubscriber.inc
+
21
−
5
View file @
2be9341a
...
...
@@ -108,7 +108,7 @@ class PuSHSubscriber {
* The callback to unsubscribe.
*/
public
function
unsubscribe
(
$topic_url
,
$callback_url
)
{
if
(
$sub
=
$this
->
loadS
ubscription
())
{
if
(
$sub
=
$this
->
s
ubscription
())
{
$this
->
request
(
$sub
->
hub
,
$sub
->
topic
,
'unsubscribe'
,
$callback_url
);
$sub
->
delete
();
}
...
...
@@ -156,7 +156,7 @@ class PuSHSubscriber {
if
(
$ignore_signature
)
{
return
$raw
;
}
if
(
isset
(
$_SERVER
[
'HTTP_X_HUB_SIGNATURE'
])
&&
(
$sub
=
$this
->
loadS
ubscription
()))
{
if
(
isset
(
$_SERVER
[
'HTTP_X_HUB_SIGNATURE'
])
&&
(
$sub
=
$this
->
s
ubscription
()))
{
$result
=
array
();
parse_str
(
$_SERVER
[
'HTTP_X_HUB_SIGNATURE'
],
$result
);
if
(
isset
(
$result
[
'sha1'
])
&&
$result
[
'sha1'
]
==
hash_hmac
(
'sha1'
,
$raw
,
$sub
->
secret
))
{
...
...
@@ -192,7 +192,7 @@ class PuSHSubscriber {
*
* In all other cases confirm negative.
*/
if
(
$sub
=
$this
->
loadS
ubscription
())
{
if
(
$sub
=
$this
->
s
ubscription
())
{
if
(
$_GET
[
'hub_verify_token'
]
==
$sub
->
post_fields
[
'hub.verify_token'
])
{
if
(
$_GET
[
'hub_mode'
]
==
'subscribe'
&&
$sub
->
status
==
'subscribe'
)
{
$sub
->
status
=
'subscribed'
;
...
...
@@ -273,12 +273,28 @@ class PuSHSubscriber {
}
/**
* Helper for loading a subscription.
* Get the subscription associated with this subscriber.
*
* @return
* A PuSHSubscriptionInterface object if a subscription exist, NULL
* otherwise.
*/
p
rotected
function
loadS
ubscription
()
{
p
ublic
function
s
ubscription
()
{
return
call_user_func
(
array
(
$this
->
subscription_class
,
'load'
),
$this
->
domain
,
$this
->
subscriber_id
);
}
/**
* Determine whether this subscriber is successfully subscribed or not.
*/
public
function
subscribed
()
{
if
(
$sub
=
$this
->
subscription
())
{
if
(
$sub
->
status
==
'subscribed'
)
{
return
TRUE
;
}
}
return
FALSE
;
}
/**
* Helper for messaging.
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment