Skip to content

Commit

Permalink
Fix notification problem
Browse files Browse the repository at this point in the history
Now checks Elgg version.
  • Loading branch information
kevinjardine committed Jan 6, 2014
1 parent eaacac0 commit 7adf7f3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 41 deletions.
Binary file added graphics/Thumbs.db
Binary file not shown.
85 changes: 44 additions & 41 deletions start.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,22 @@ function polls_init() {
elgg_register_entity_url_handler('object','poll','polls_url');

// notifications
$send_notification = elgg_get_plugin_setting('send_notification', 'polls');
if (!$send_notification || $send_notification != 'no') {
elgg_register_notification_event('object', 'poll');
elgg_register_plugin_hook_handler('prepare', 'notification:create:object:poll', 'polls_prepare_notification');
$elgg_version = explode('.',get_version(true));
if ($elgg_version[1] > 8) {
$send_notification = elgg_get_plugin_setting('send_notification', 'polls');
if (!$send_notification || $send_notification != 'no') {
elgg_register_notification_event('object', 'poll');
elgg_register_plugin_hook_handler('prepare', 'notification:create:object:poll', 'polls_prepare_notification');
}
}

// add link to owner block
elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'polls_owner_block_menu');
elgg_register_plugin_hook_handler('widget_url', 'widget_manager', 'polls_widget_url_handler');

// Register entity type
elgg_register_entity_type('object','poll');

// register the JavaScript
$js = elgg_get_simplecache_url('js', 'polls/js');
elgg_register_simplecache_view('js/polls/js');
Expand All @@ -60,8 +63,8 @@ function polls_init() {
//add widgets
elgg_register_widget_type('poll',elgg_echo('polls:my_widget_title'),elgg_echo('polls:my_widget_description'), "profile,groups");
elgg_register_widget_type('latestPolls',elgg_echo('polls:latest_widget_title'),elgg_echo('polls:latest_widget_description'), "index,profile,dashboard,groups");
elgg_register_widget_type('poll_individual',elgg_echo('polls:individual'),elgg_echo('poll_individual_group:widget:description'), "index,profile,dashboard,groups");
elgg_register_widget_type('poll_individual',elgg_echo('polls:individual'),elgg_echo('poll_individual_group:widget:description'), "index,profile,dashboard,groups");

// Register actions
$action_path = elgg_get_plugins_path() . 'polls/actions/polls';
elgg_register_action("polls/add","$action_path/add.php");
Expand All @@ -82,13 +85,13 @@ function polls_page_handler($page) {
elgg_load_library('elgg:polls');
$page_type = $page[0];
switch($page_type) {
case "view":
case "view":
echo polls_get_page_view($page[1]);
break;
case "all":
case "all":
echo polls_get_page_list($page_type);
break;
case "add":
case "add":
case "edit":
$container = null;
if(isset($page[1])){
Expand Down Expand Up @@ -171,34 +174,34 @@ function polls_prepare_notification($hook, $type, $notification, $params) {
return $notification;
}

function polls_widget_url_handler($hook, $type, $return, $params){
$result = $return;

if(empty($result) && !empty($params) && is_array($params)){
$widget = elgg_extract("entity", $params);

if(!empty($widget) && elgg_instanceof($widget, "object", "widget")){
switch($widget->handler){
case "latestPolls":
if($widget->context == "groups"){
$result = "polls/group/" . $widget->getOwnerGUID() . "/all";
} else {
$result = "polls/all";
}
break;
case "poll":
if($widget->context == "groups"){
$result = "polls/group/" . $widget->getOwnerGUID() . "/all";
} else {
$result = "polls/owner/" . $widget->getOwnerEntity()->username . "/all";
}
break;
case "poll_individual":
break;
}
}
}

return $result;
function polls_widget_url_handler($hook, $type, $return, $params){
$result = $return;

if(empty($result) && !empty($params) && is_array($params)){
$widget = elgg_extract("entity", $params);

if(!empty($widget) && elgg_instanceof($widget, "object", "widget")){
switch($widget->handler){
case "latestPolls":
if($widget->context == "groups"){
$result = "polls/group/" . $widget->getOwnerGUID() . "/all";
} else {
$result = "polls/all";
}
break;
case "poll":
if($widget->context == "groups"){
$result = "polls/group/" . $widget->getOwnerGUID() . "/all";
} else {
$result = "polls/owner/" . $widget->getOwnerEntity()->username . "/all";
}
break;
case "poll_individual":

break;
}
}
}

return $result;
}

0 comments on commit 7adf7f3

Please sign in to comment.