aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-20 03:46:39 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-20 03:46:39 +0000
commit7fbd66bc3aeda393a0117883b70a3212dae57e51 (patch)
tree453d70f0cc91a2012ff83755fd3de1ba966c742b /engine
parent926a7a4b81ec9c04ea791cb80ad645f32d65c3da (diff)
downloadelgg-7fbd66bc3aeda393a0117883b70a3212dae57e51.tar.gz
elgg-7fbd66bc3aeda393a0117883b70a3212dae57e51.tar.bz2
Fixed problems with user-self registration if default widgets are set.
git-svn-id: http://code.elgg.org/elgg/trunk@8356 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/widgets.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php
index 6cca2a18d..7c0867548 100644
--- a/engine/lib/widgets.php
+++ b/engine/lib/widgets.php
@@ -290,6 +290,9 @@ function elgg_default_widgets_init() {
if ($default_widgets) {
elgg_add_admin_menu_item('default_widgets', elgg_echo('admin:appearance:default_widgets'), 'appearance', 30);
+ // override permissions for creating widget on logged out / just created entities
+ elgg_register_plugin_hook_handler('container_permissions_check', 'object', 'elgg_default_widgets_permissions_override');
+
foreach ($default_widgets as $info) {
elgg_register_event_handler($info['event'], $info['entity_type'], 'elgg_default_widgets_hook');
}
@@ -323,6 +326,10 @@ function elgg_default_widgets_hook($event, $type, $object) {
}
}
+ // need to be able to access everything
+ $old_ia = elgg_get_ignore_access(true);
+ elgg_push_context('create_default_widgets');
+
// pull in by widget context with widget owners as the site
// not using elgg_get_widgets() because it sorts by columns and we don't care right now.
$options = array(
@@ -352,10 +359,30 @@ function elgg_default_widgets_hook($event, $type, $object) {
$new_widget->save();
}
+ elgg_get_ignore_access($old_ia);
+ elgg_pop_context();
+
// failure here shouldn't stop the event.
return null;
}
+/**
+ * Overrides permissions checks when creating widgets for logged out users.
+ *
+ * @param string $hook The permissions hook.
+ * @param string $type The type of entity being created.
+ * @param string $return Value
+ * @param mixed $params Params
+ * @return true|null
+ */
+function elgg_default_widgets_permissions_override($hook, $type, $return, $params) {
+ if ($type == 'object' && $params['subtype'] == 'widget') {
+ return elgg_in_context('create_default_widgets') ? true : null;
+ }
+
+ return null;
+}
+
elgg_register_event_handler('init', 'system', 'elgg_widgets_init');
// register default widget hooks from plugins
elgg_register_event_handler('ready', 'system', 'elgg_default_widgets_init'); \ No newline at end of file