Skip to content

Commit

Permalink
Fixes #2367: With fear and trepidation, converting events/plugin hook…
Browse files Browse the repository at this point in the history
…s to use elgg_ prefixed versions

git-svn-id: http://code.elgg.org/elgg/trunk@7284 36083f99-b078-4883-b0ff-0f9b5a30f544
  • Loading branch information
ewinslow committed Nov 10, 2010
1 parent a7801c7 commit c8f6c3c
Show file tree
Hide file tree
Showing 102 changed files with 462 additions and 412 deletions.
2 changes: 1 addition & 1 deletion actions/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
// // Returning FALSE to this function will generate a standard
// // "Could not log you in" message.
// // Plugins should use this hook to provide details, and then return TRUE.
// if (!trigger_plugin_hook('failed_login', 'user', $params, FALSE)) {
// if (!elgg_trigger_plugin_hook('failed_login', 'user', $params, FALSE)) {
// register_error(elgg_echo('loginerror'));
// }
}
Expand Down
2 changes: 1 addition & 1 deletion actions/plugins/settings/save.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
system_message(elgg_echo('plugins:settings:save:ok', array($plugin_name)));
forward(REFERER);
//
//$trigger = trigger_plugin_hook('plugin:save_settings', $plugin, $options, NULL);
//$trigger = elgg_trigger_plugin_hook('plugin:save_settings', $plugin, $options, NULL);
//if ($trigger === NULL) {
// foreach ($params as $k => $v) {
// if (!$result = set_plugin_setting($k, $v, $plugin)) {
Expand Down
2 changes: 1 addition & 1 deletion actions/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
);

// @todo should registration be allowed no matter what the plugins return?
if (!trigger_plugin_hook('register', 'user', $params, TRUE)) {
if (!elgg_trigger_plugin_hook('register', 'user', $params, TRUE)) {
$new_user->delete();
// @todo this is a generic messages. We could have plugins
// throw a RegistrationException, but that is very odd
Expand Down
2 changes: 1 addition & 1 deletion actions/usersettings/save.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

gatekeeper();

trigger_plugin_hook('usersettings:save', 'user');
elgg_trigger_plugin_hook('usersettings:save', 'user');

forward(REFERER);
2 changes: 1 addition & 1 deletion documentation/examples/events/advanced.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

register_elgg_event_handler('create', 'object', 'example_event_handler');
elgg_register_event_handler('create', 'object', 'example_event_handler');

function example_event_handler($event, $type, $params) {
// Don't allow any non-admin users to create objects
Expand Down
2 changes: 1 addition & 1 deletion documentation/examples/events/all.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

register_elgg_event_handler('all', 'object', 'example_event_handler');
elgg_register_event_handler('all', 'object', 'example_event_handler');

// This function will be called for any event of type 'object'
function example_event_handler($event, $type, $params) {
Expand Down
2 changes: 1 addition & 1 deletion documentation/examples/events/basic.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

register_elgg_event_handler('init', 'system', 'example_event_handler');
elgg_register_event_handler('init', 'system', 'example_event_handler');

function example_event_handler($event, $type, $params) {
var_dump($event);
Expand Down
4 changes: 2 additions & 2 deletions documentation/examples/events/emit.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

$params = new ElggObject();
trigger_elgg_event('test', 'example', $params);
elgg_trigger_event('test', 'example', $params);

// handlers would be registered by saying
register_elgg_event_handler('test', 'example', 'example_event_handler');
elgg_register_event_handler('test', 'example', 'example_event_handler');
6 changes: 3 additions & 3 deletions documentation/examples/hooks/basic.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

register_plugin_hook('get_items', 'example', 'example_plugin_hook');
register_plugin_hook('get_items', 'example', 'example_plugin_hook_2');
elgg_register_plugin_hook_handler('get_items', 'example', 'example_plugin_hook');
elgg_register_plugin_hook_handler('get_items', 'example', 'example_plugin_hook_2');

$params = array('username' => 'Joe');
$items = trigger_plugin_hook('get_items', 'example', $params, $default);
$items = elgg_trigger_plugin_hook('get_items', 'example', $params, $default);

var_dump($items);

Expand Down
8 changes: 4 additions & 4 deletions documentation/examples/hooks/register/advanced.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?php

// the output:page hook is triggered by elgg_view_page().
register_plugin_hook('output', 'page', 'example_plugin_hook_handler', 600);
register_plugin_hook('output', 'page', 'example_plugin_hook_handler_2', 601);
elgg_register_plugin_hook_handler('output', 'page', 'example_plugin_hook_handler', 600);
elgg_register_plugin_hook_handler('output', 'page', 'example_plugin_hook_handler_2', 601);

function example_plugin_hook_handler($event, $type, $value, $params) {
// change A to @
$value = str_replace('A', '@', $value);

return $value;
}

function example_plugin_hook_handler_2($event, $type, $value, $params) {
// change S to $
$value = str_replace('S', '$', $value);

return $value;
}

Expand Down
2 changes: 1 addition & 1 deletion documentation/examples/hooks/register/all.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

register_plugin_hook('all', 'system', 'example_plugin_hook_handler');
elgg_register_plugin_hook_handler('all', 'system', 'example_plugin_hook_handler');

// This function will be called for any hook of type 'system'
function example_plugin_hook_handler($hook, $type, $value, $params) {
Expand Down
2 changes: 1 addition & 1 deletion documentation/examples/hooks/register/basic.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

register_plugin_hook('forward', 'system', 'example_plugin_hook_handler');
elgg_register_plugin_hook_handler('forward', 'system', 'example_plugin_hook_handler');

function example_plugin_hook_handler($event, $type, $value, $params) {
var_dump($event);
Expand Down
4 changes: 2 additions & 2 deletions documentation/examples/hooks/register/emit.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

// @todo this is an event, not a hook
register_elgg_event_handler('test', 'example', 'example_init_system_callback');
elgg_register_event_handler('test', 'example', 'example_init_system_callback');

$params = new ElggObject();
trigger_elgg_event('test', 'example', $params);
elgg_trigger_event('test', 'example', $params);
2 changes: 1 addition & 1 deletion documentation/examples/hooks/trigger/advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$default = array('Entry 1', 'Entry 2', 'Entry 3');

$menu = trigger_plugin_hook('get_menu_items', 'menu', null, $default);
$menu = elgg_trigger_plugin_hook('get_menu_items', 'menu', null, $default);

foreach ($menu as $item) {
var_dump($item);
Expand Down
2 changes: 1 addition & 1 deletion documentation/examples/hooks/trigger/basic.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$result = trigger_plugin_hook('get_status', 'example', null, true);
$result = elgg_trigger_plugin_hook('get_status', 'example', null, true);

if ($result) {
var_dump('Plugin hook says ok!');
Expand Down
20 changes: 10 additions & 10 deletions documentation/stubs/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
/**
* Event information for the events subsystem.
*
* Events are added with {@link register_elgg_event_handler()} and
* can be removed in >= 1.8 with {@link unregister_elgg_event_handler()}.
* Events are added with {@link elgg_register_event_handler()} and
* can be removed in >= 1.8 with {@link elgg_unregister_event_handler()}.
*
* Events are stored as a multidimensional array in the format:
* <code>
Expand All @@ -22,27 +22,27 @@
* @global array $CONFIG->events
* @name $CONFIG->events
* @see events()
* @see register_elgg_event_handler()
* @see unregister_elgg_event_handler()
* @see trigger_elgg_event()
* @see elgg_register_event_handler()
* @see elgg_unregister_event_handler()
* @see elgg_trigger_event()
*/
$CONFIG->events;

/**
* Plugin Hook information for the plugin hooks subsystem.
*
* Hooks are added with {@link register_plugin_hook()} and
* can be removed in >= 1.8 with {@link unregister_plugin_hook()}.
* Hooks are added with {@link elgg_register_plugin_hook_handler()} and
* can be removed in >= 1.8 with {@link elgg_unregister_plugin_hook_handler()}.
*
* Hooks are stored as a multidimensional array in the format:
* <code>
* $CONFIG->hooks[str $hook_name][str $hook_type][int priority] = str callback_function
* </code>
*
* @global array $CONFIG->hooks
* @see register_plugin_hook()
* @see unregister_plugin_hook()
* @see trigger_plugin_hook()
* @see elgg_register_plugin_hook_handler()
* @see elgg_unregister_plugin_hook_handler()
* @see elgg_trigger_plugin_hook()
*/
$CONFIG->hooks;

Expand Down
2 changes: 1 addition & 1 deletion engine/classes/ElggSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function offsetGet($key) {
}

$value = NULL;
$value = trigger_plugin_hook('session:get', $key, NULL, $value);
$value = elgg_trigger_plugin_hook('session:get', $key, NULL, $value);

ElggSession::$__localcache[$key] = $value;

Expand Down
4 changes: 2 additions & 2 deletions engine/classes/ElggSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public function checkWalledGarden() {

if ($CONFIG->walled_garden && !isloggedin()) {
// hook into the index system call at the highest priority
register_plugin_hook('index', 'system', 'elgg_walled_garden_index', 1);
elgg_register_plugin_hook_handler('index', 'system', 'elgg_walled_garden_index', 1);

if (!$this->isPublicPage()) {
register_error(elgg_echo('loggedinrequired'));
Expand Down Expand Up @@ -372,7 +372,7 @@ public function isPublicPage($url = '') {
);

// include a hook for plugin authors to include public pages
$plugins = trigger_plugin_hook('public_pages', 'walled_garden', NULL, array());
$plugins = elgg_trigger_plugin_hook('public_pages', 'walled_garden', NULL, array());

// lookup admin-specific public pages

Expand Down
2 changes: 1 addition & 1 deletion engine/handlers/cron_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$old_stdout = "";
ob_start();

$old_stdout = trigger_plugin_hook('cron', $period, $params, $old_stdout);
$old_stdout = elgg_trigger_plugin_hook('cron', $period, $params, $old_stdout);
$std_out = ob_get_clean();

// Return event
Expand Down
18 changes: 9 additions & 9 deletions engine/lib/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function get_access_array($user_id = 0, $site_id = 0, $flush = false) {
}

$options = array('user_id' => $user_id, 'site_id' => $site_id);
return trigger_plugin_hook('access:collections:read', 'user', $options, $tmp_access_array);
return elgg_trigger_plugin_hook('access:collections:read', 'user', $options, $tmp_access_array);
}

/**
Expand Down Expand Up @@ -404,7 +404,7 @@ function get_write_access_array($user_id = 0, $site_id = 0, $flush = false) {
}

$options = array('user_id' => $user_id, 'site_id' => $site_id);
$tmp_access_array = trigger_plugin_hook('access:collections:write', 'user',
$tmp_access_array = elgg_trigger_plugin_hook('access:collections:write', 'user',
$options, $tmp_access_array);

return $tmp_access_array;
Expand Down Expand Up @@ -456,7 +456,7 @@ function create_access_collection($name, $owner_guid = 0, $site_guid = 0) {
'collection_id' => $id
);

if (!trigger_plugin_hook('access:collections:addcollection', 'collection', $params, true)) {
if (!elgg_trigger_plugin_hook('access:collections:addcollection', 'collection', $params, true)) {
return false;
}

Expand Down Expand Up @@ -531,7 +531,7 @@ function delete_access_collection($collection_id) {
$collections = get_write_access_array(null, null, TRUE);
$params = array('collection_id' => $collection_id);

if (!trigger_plugin_hook('access:collections:deletecollection', 'collection', $params, true)) {
if (!elgg_trigger_plugin_hook('access:collections:deletecollection', 'collection', $params, true)) {
return false;
}

Expand Down Expand Up @@ -601,7 +601,7 @@ function add_user_to_access_collection($user_guid, $collection_id) {
'user_guid' => $user_guid
);

if (!trigger_plugin_hook('access:collections:add_user', 'collection', $params, true)) {
if (!elgg_trigger_plugin_hook('access:collections:add_user', 'collection', $params, true)) {
return false;
}

Expand Down Expand Up @@ -646,7 +646,7 @@ function remove_user_from_access_collection($user_guid, $collection_id) {
'user_guid' => $user_guid
);

if (!trigger_plugin_hook('access:collections:remove_user', 'collection', $params, true)) {
if (!elgg_trigger_plugin_hook('access:collections:remove_user', 'collection', $params, true)) {
return false;
}

Expand Down Expand Up @@ -1033,8 +1033,8 @@ function elgg_override_permissions_hook() {
}

// This function will let us know when 'init' has finished
register_elgg_event_handler('init', 'system', 'access_init', 9999);
elgg_register_event_handler('init', 'system', 'access_init', 9999);

// For overrided permissions
register_plugin_hook('permissions_check', 'all', 'elgg_override_permissions_hook');
register_plugin_hook('container_permissions_check', 'all', 'elgg_override_permissions_hook');
elgg_register_plugin_hook_handler('permissions_check', 'all', 'elgg_override_permissions_hook');
elgg_register_plugin_hook_handler('container_permissions_check', 'all', 'elgg_override_permissions_hook');
10 changes: 5 additions & 5 deletions engine/lib/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function action($action, $forwarder = "") {
// Trigger action event
// @todo This is only called before the primary action is called.
$event_result = true;
$event_result = trigger_plugin_hook('action', $action, null, $event_result);
$event_result = elgg_trigger_plugin_hook('action', $action, null, $event_result);

// Include action
// Event_result being false doesn't produce an error
Expand Down Expand Up @@ -228,7 +228,7 @@ function validate_action_token($visibleerrors = TRUE, $token = NULL, $ts = NULL)
// else says something to the contry we assume we're ok
$returnval = true;

$returnval = trigger_plugin_hook('action_gatekeeper:permissions:check', 'all', array(
$returnval = elgg_trigger_plugin_hook('action_gatekeeper:permissions:check', 'all', array(
'token' => $token,
'time' => $ts
), $returnval);
Expand Down Expand Up @@ -362,8 +362,8 @@ function actions_init()

elgg_view_register_simplecache('js/languages/en');

register_plugin_hook('action', 'all', 'ajax_action_hook');
register_plugin_hook('forward', 'all', 'ajax_forward_hook');
elgg_register_plugin_hook_handler('action', 'all', 'ajax_action_hook');
elgg_register_plugin_hook_handler('forward', 'all', 'ajax_forward_hook');
}

/**
Expand Down Expand Up @@ -436,4 +436,4 @@ function ajax_action_hook() {
}
}

register_elgg_event_handler('init', 'system', 'actions_init');
elgg_register_event_handler('init', 'system', 'actions_init');
4 changes: 2 additions & 2 deletions engine/lib/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,5 +311,5 @@ function elgg_admin_notice_exists($id) {
}

// Register init functions
register_elgg_event_handler('init', 'system', 'admin_init');
register_elgg_event_handler('pagesetup', 'system', 'admin_pagesetup');
elgg_register_event_handler('init', 'system', 'admin_init');
elgg_register_event_handler('pagesetup', 'system', 'admin_pagesetup');
12 changes: 6 additions & 6 deletions engine/lib/annotations.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function create_annotation($entity_guid, $name, $value, $value_type,

$entity = get_entity($entity_guid);

if (trigger_elgg_event('annotate', $entity->type, $entity)) {
if (elgg_trigger_event('annotate', $entity->type, $entity)) {
system_log($entity, 'annotate');

// If ok then add it
Expand All @@ -98,7 +98,7 @@ function create_annotation($entity_guid, $name, $value, $value_type,

if ($result !== false) {
$obj = get_annotation($result);
if (trigger_elgg_event('create', 'annotation', $obj)) {
if (elgg_trigger_event('create', 'annotation', $obj)) {
return $result;
} else {
// plugin returned false to reject annotation
Expand Down Expand Up @@ -158,7 +158,7 @@ function update_annotation($annotation_id, $name, $value, $value_type, $owner_gu

if ($result !== false) {
$obj = get_annotation($annotation_id);
if (trigger_elgg_event('update', 'annotation', $obj)) {
if (elgg_trigger_event('update', 'annotation', $obj)) {
return true;
} else {
// @todo add plugin hook that sends old and new annotation information before db access
Expand Down Expand Up @@ -547,7 +547,7 @@ function list_entities_from_annotations($entity_type = "", $entity_subtype = "",
* Returns a viewable list of entities from annotations.
*
* @param array $options
*
*
* @see elgg_get_entities_from_annotations()
* @see elgg_list_entities()
*
Expand Down Expand Up @@ -1021,7 +1021,7 @@ function delete_annotation($id) {
$access = get_access_sql_suffix();
$annotation = get_annotation($id);

if (trigger_elgg_event('delete', 'annotation', $annotation)) {
if (elgg_trigger_event('delete', 'annotation', $annotation)) {
remove_from_river_by_annotation($id);
return delete_data("DELETE from {$CONFIG->dbprefix}annotations where id=$id and $access");
}
Expand Down Expand Up @@ -1199,4 +1199,4 @@ function register_annotation_url_handler($function_name, $extender_name = "all")
}

/** Register the hook */
register_plugin_hook("export", "all", "export_annotation_plugin_hook", 2);
elgg_register_plugin_hook_handler("export", "all", "export_annotation_plugin_hook", 2);
Loading

0 comments on commit c8f6c3c

Please sign in to comment.