aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/widgets.php
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2011-12-22 08:12:07 -0500
committerCash Costello <cash.costello@gmail.com>2011-12-22 08:12:07 -0500
commite49df853b2cc3a6a9bc2dd527a64951050142eb9 (patch)
tree6f485b560f89331c65fad3993e055a1834b07177 /engine/lib/widgets.php
parent5e5b3705a5ca7b66dfe386490c5570af88b49009 (diff)
parentfea599f1653d7206e34ac33c0c0a668cb587bc20 (diff)
downloadelgg-e49df853b2cc3a6a9bc2dd527a64951050142eb9.tar.gz
elgg-e49df853b2cc3a6a9bc2dd527a64951050142eb9.tar.bz2
Merge branch '1.8' after 1.8.2 release
Conflicts: version.php
Diffstat (limited to 'engine/lib/widgets.php')
-rw-r--r--engine/lib/widgets.php87
1 files changed, 41 insertions, 46 deletions
diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php
index 5d18a16b0..46f34391a 100644
--- a/engine/lib/widgets.php
+++ b/engine/lib/widgets.php
@@ -332,14 +332,14 @@ function elgg_default_widgets_init() {
* @param string $event The event
* @param string $type The type of object
* @param object $entity The entity being created
- * @return null
+ * @return void
* @access private
*/
function elgg_create_default_widgets($event, $type, $entity) {
$default_widget_info = elgg_get_config('default_widget_info');
if (!$default_widget_info || !$entity) {
- return null;
+ return;
}
$type = $entity->getType();
@@ -347,53 +347,48 @@ function elgg_create_default_widgets($event, $type, $entity) {
// event is already guaranteed by the hook registration.
// need to check subtype and type.
- foreach ($default_widget_info as $temp) {
- if ($temp['entity_type'] == $type) {
- if ($temp['entity_subtype'] == ELGG_ENTITIES_ANY_VALUE || $temp['entity_subtype'] == $subtype) {
- $info = $temp;
- break;
+ foreach ($default_widget_info as $info) {
+ if ($info['entity_type'] == $type) {
+ if ($info['entity_subtype'] == ELGG_ENTITIES_ANY_VALUE || $info['entity_subtype'] == $subtype) {
+
+ // need to be able to access everything
+ $old_ia = elgg_set_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(
+ 'type' => 'object',
+ 'subtype' => 'widget',
+ 'owner_guid' => elgg_get_site_entity()->guid,
+ 'private_setting_name' => 'context',
+ 'private_setting_value' => $info['widget_context'],
+ 'limit' => 0
+ );
+
+ $widgets = elgg_get_entities_from_private_settings($options);
+
+ foreach ($widgets as $widget) {
+ // change the container and owner
+ $new_widget = clone $widget;
+ $new_widget->container_guid = $entity->guid;
+ $new_widget->owner_guid = $entity->guid;
+
+ // pull in settings
+ $settings = get_all_private_settings($widget->guid);
+
+ foreach ($settings as $name => $value) {
+ $new_widget->$name = $value;
+ }
+
+ $new_widget->save();
+ }
+
+ elgg_set_ignore_access($old_ia);
+ elgg_pop_context();
}
}
}
-
- // 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(
- 'type' => 'object',
- 'subtype' => 'widget',
- 'owner_guid' => elgg_get_site_entity()->guid,
- 'private_setting_name' => 'context',
- 'private_setting_value' => $info['widget_context'],
- 'limit' => 0
- );
-
- $widgets = elgg_get_entities_from_private_settings($options);
-
- foreach ($widgets as $widget) {
- // change the container and owner
- $new_widget = clone $widget;
- $new_widget->container_guid = $entity->guid;
- $new_widget->owner_guid = $entity->guid;
-
- // pull in settings
- $settings = get_all_private_settings($widget->guid);
-
- foreach ($settings as $name => $value) {
- $new_widget->$name = $value;
- }
-
- $new_widget->save();
- }
-
- elgg_get_ignore_access($old_ia);
- elgg_pop_context();
-
- // failure here shouldn't stop the event.
- return null;
}
/**