From 373ff03a2b6315eea13a97065774972ad3713ab6 Mon Sep 17 00:00:00 2001 From: brettp Date: Sat, 19 Feb 2011 02:12:32 +0000 Subject: Fixes #2753: Default widgets merged into core as extensible admin section and updated to work with new widgets. Will need an upgrade for users running the old default widgets in 1.7. git-svn-id: http://code.elgg.org/elgg/trunk@8302 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/defaultwidgets/start.php | 206 ------------------------------------------- 1 file changed, 206 deletions(-) delete mode 100644 mod/defaultwidgets/start.php (limited to 'mod/defaultwidgets/start.php') diff --git a/mod/defaultwidgets/start.php b/mod/defaultwidgets/start.php deleted file mode 100644 index 89754f4f4..000000000 --- a/mod/defaultwidgets/start.php +++ /dev/null @@ -1,206 +0,0 @@ -guid; - - if (elgg_is_admin_logged_in()) { - // this is an admin-created user - // no permissions problems, so set proper access now - // use system default access (not the admin's default access!, because that could be a personal access level) - $widget_access = elgg_get_config('default_access'); - } else { - // this is a regular registration - // set widget access to public for now and reset it properly during the validate event - // to avoid Elgg permissions problems - $widget_access = ACCESS_PUBLIC; - } - - // check if it's set - if (! empty ( $guid )) { - - // get the user entity - if ($user = get_entity ( $guid )) { - - // can this user edit - if ($user->canEdit ()) { - - // each of the contexts to add widgets for - $contexts = array ('profile', 'dashboard' ); - - // get the entities for the module - $entities = elgg_get_entities (array('type' => 'object', 'subtype' => 'moddefaultwidgets', 'limit' => 9999)); - - // check if the entity exists - if (isset ( $entities [0] )) { - - // get the widgets for the context - $entity = $entities [0]; - - foreach ( $contexts as $context ) { - $current_widgets = $entity->$context; - list ( $left, $middle, $right ) = split ( '%%', $current_widgets ); - - // split columns into seperate widgets - $area1widgets = split ( '::', $left ); - $area2widgets = split ( '::', $middle ); - $area3widgets = split ( '::', $right ); - - // clear out variables if no widgets are available - if ($area1widgets [0] == "") - $area1widgets = false; - if ($area2widgets [0] == "") - $area2widgets = false; - if ($area3widgets [0] == "") - $area3widgets = false; - - // generate left column widgets for a new user - if ($area1widgets) { - foreach ( $area1widgets as $i => $widget ) { - add_widget ( $guid, $widget, $context, ($i + 1), 1, $widget_access ); - } - } - - // generate middle column widgets for a new user - if ($area2widgets) { - foreach ( $area2widgets as $i => $widget ) { - add_widget ( $guid, $widget, $context, ($i + 1), 2, $widget_access ); - } - } - - // generate right column widgets for a new user - if ($area3widgets) { - foreach ( $area3widgets as $i => $widget ) { - add_widget ( $guid, $widget, $context, ($i + 1), 3, $widget_access ); - } - } - } - } - } - } - } - - // turn off permissions override - $defaultwidget_access = false; -} - -function defaultwidgets_reset_access($event, $object_type, $object) { - - global $defaultwidget_access; - - // turn on permissions override - $defaultwidget_access = true; - - // the widgets are disabled, so turn on the ability to see disabled entities - - $access_status = access_get_show_hidden_status(); - access_show_hidden_entities(true); - - $widgets = elgg_get_entities(array('type' => 'object', 'subtype' => 'widget', 'owner_guid' => $object->getGUID())); - - if ($widgets) { - foreach($widgets as $widget) { - $widget->access_id = get_default_access(); - $widget->save(); - } - } - - access_show_hidden_entities($access_status); - - // turn off permissions override - $defaultwidget_access = false; - - return true; -} - -// Make sure the status initialisation function is called on initialisation -elgg_register_event_handler('init', 'system', 'defaultwidgets_init'); -- cgit v1.2.3