diff options
Diffstat (limited to 'mod')
53 files changed, 753 insertions, 432 deletions
diff --git a/mod/blog/start.php b/mod/blog/start.php index b9911aa74..2d8f75ed2 100644 --- a/mod/blog/start.php +++ b/mod/blog/start.php @@ -225,11 +225,35 @@ function blog_ecml_views_hook($hook, $entity_type, $return_value, $params) { } /** - * When upgrading, check if the ElggBlog class has been registered as this - * was added in Elgg 1.8 + * Upgrade from 1.7 to 1.8. */ -function blog_run_upgrades() { - if (!update_subtype('object', 'blog', 'ElggBlog')) { - add_subtype('object', 'blog', 'ElggBlog'); +function blog_run_upgrades($event, $type, $details) { + $blog_upgrade_version = get_plugin_setting('upgrade_version', 'blogs'); + + if (!$blog_upgrade_version) { + // When upgrading, check if the ElggBlog class has been registered as this + // was added in Elgg 1.8 + if (!update_subtype('object', 'blog', 'ElggBlog')) { + add_subtype('object', 'blog', 'ElggBlog'); + } + + // only run this on the first migration to 1.8 + // add excerpt to all blogs that don't have it. + $ia = elgg_set_ignore_access(true); + $options = array( + 'type' => 'object', + 'subtype' => 'blog' + ); + + $blogs = new ElggBatch('elgg_get_entities', $options); + foreach ($blogs as $blog) { + if (!$blog->excerpt) { + $blog->excerpt = elgg_get_excerpt($blog->description); + } + } + + elgg_set_ignore_access($ia); + + elgg_set_plugin_setting('upgrade_version', 1, 'blogs'); } } diff --git a/mod/categories/actions/save.php b/mod/categories/actions/save.php deleted file mode 100644 index 26222a030..000000000 --- a/mod/categories/actions/save.php +++ /dev/null @@ -1,19 +0,0 @@ -<?php -/** - * Saves the available categories for the site - * - * @note The categories for an object are saved through an event handler: categories_save() - * - * @package ElggCategories - */ - -$categories = get_input('categories'); -$categories = string_to_tag_array($categories); - -$site = elgg_get_site_entity(); -$site->categories = $categories; -system_message(elgg_echo("categories:save:success")); - -elgg_delete_admin_notice('categories_admin_notice_no_categories'); - -forward(REFERER);
\ No newline at end of file diff --git a/mod/categories/activate.php b/mod/categories/activate.php new file mode 100644 index 000000000..80159d089 --- /dev/null +++ b/mod/categories/activate.php @@ -0,0 +1,11 @@ +<?php +/** + * Prompt the user to add categories after activating + */ + +//categories_admin_notice_no_categories +$site = get_config('site'); +if (!$site->categories) { + $message = elgg_echo('categories:on_activate_reminder', array(elgg_normalize_url('admin/plugin_settings/categories'))); + elgg_add_admin_notice('categories_admin_notice_no_categories', $message); +}
\ No newline at end of file diff --git a/mod/categories/languages/en.php b/mod/categories/languages/en.php index 1954ba8d9..eaa65b13e 100644 --- a/mod/categories/languages/en.php +++ b/mod/categories/languages/en.php @@ -9,7 +9,7 @@ $english = array( 'categories:explanation' => 'To set some predefined site-wide categories that will be used throughout your system, enter them below, separated with commas. Compatible tools will then display them when the user creates or edits content.', 'categories:save:success' => 'Site categories were successfully saved.', 'categories:results' => "Results for the site category: %s", - 'categories:on_enable_reminder' => "You haven't added any categories yet! <a href=\"%s\">Add categories now.</a>", + 'categories:on_activate_reminder' => "Site-wide Cateogires won't work until you add categories. <a href=\"%s\">Add categories now.</a>", ); add_translation("en", $english);
\ No newline at end of file diff --git a/mod/categories/start.php b/mod/categories/start.php index ff5b01efc..2ccea0d70 100644 --- a/mod/categories/start.php +++ b/mod/categories/start.php @@ -15,13 +15,14 @@ function categories_init() { elgg_extend_view('css/elgg', 'categories/css'); - $action_base = elgg_get_plugins_path() . 'categories/actions'; - elgg_register_action('settings/categories/save', "$action_base/save.php", 'admin'); - elgg_register_page_handler('categories', 'categories_page_handler'); elgg_register_event_handler('update', 'all', 'categories_save'); elgg_register_event_handler('create', 'all', 'categories_save'); + + // To keep the category plugins in the settings area and because we have to do special stuff, + // handle saving ourself. + elgg_register_plugin_hook_handler('action', 'plugins/settings/save', 'categories_save_site_categories'); } @@ -54,3 +55,29 @@ function categories_save($event, $object_type, $object) { } return TRUE; } + +/** + * Saves the site categories. + * + * @param type $hook + * @param type $type + * @param type $value + * @param type $params + */ +function categories_save_site_categories($hook, $type, $value, $params) { + $plugin_id = get_input('plugin_id'); + if ($plugin_id != 'categories') { + return $value; + } + + $categories = get_input('categories'); + $categories = string_to_tag_array($categories); + + $site = elgg_get_site_entity(); + $site->categories = $categories; + system_message(elgg_echo("categories:save:success")); + + elgg_delete_admin_notice('categories_admin_notice_no_categories'); + + forward(REFERER); +}
\ No newline at end of file diff --git a/mod/categories/views/default/input/categories.php b/mod/categories/views/default/input/categories.php index 1f71dc0b4..75960d257 100644 --- a/mod/categories/views/default/input/categories.php +++ b/mod/categories/views/default/input/categories.php @@ -23,6 +23,10 @@ if (!empty($categories)) { $categories = array($categories); } + // checkboxes want Label => value, so in our case we need category => category + $categories = array_flip($categories); + array_walk($categories, create_function('&$v, $k', '$v = $k;')); + ?> <div class="categories"> diff --git a/mod/categories/views/default/settings/categories/edit.php b/mod/categories/views/default/plugins/categories/settings.php index 3802da95a..3802da95a 100644 --- a/mod/categories/views/default/settings/categories/edit.php +++ b/mod/categories/views/default/plugins/categories/settings.php diff --git a/mod/dashboard/languages/en.php b/mod/dashboard/languages/en.php new file mode 100644 index 000000000..e1378f2f1 --- /dev/null +++ b/mod/dashboard/languages/en.php @@ -0,0 +1,14 @@ +<?php +/** + * User dashboard languages + */ + +$english = array( + 'dashboard:widget:group:title' => 'Group activity', + 'dashboard:widget:group:desc' => 'View the activity in one of your groups', + 'dashboard:widget:group:select' => 'Select a group', + 'dashboard:widget:group:noactivity' => 'There is no activity in this group', + 'dashboard:widget:group:noselect' => 'Edit this widget to select a group', +); + +add_translation("en", $english); diff --git a/mod/dashboard/start.php b/mod/dashboard/start.php index 69572bd32..5635ead57 100644 --- a/mod/dashboard/start.php +++ b/mod/dashboard/start.php @@ -18,6 +18,14 @@ function dashboard_init() { 'section' => 'alt', )); + elgg_register_widget_type( + 'group_activity', + elgg_echo('dashboard:widget:group:title'), + elgg_echo('dashboard:widget:group:desc'), + 'dashboard', + true + ); + elgg_register_plugin_hook_handler('get_list', 'default_widgets', 'dashboard_default_widgets'); } diff --git a/mod/dashboard/views/default/widgets/group_activity/content.php b/mod/dashboard/views/default/widgets/group_activity/content.php new file mode 100644 index 000000000..60a9b352c --- /dev/null +++ b/mod/dashboard/views/default/widgets/group_activity/content.php @@ -0,0 +1,36 @@ +<?php +/** + * Group activity widget + */ + +$num = (int) $vars['entity']->num_display; +$guid = $vars['entity']->group_guid; + +$content = ''; + +if ($guid) { + $title = get_entity($guid)->name; + $content = "<h3>$title</h3>"; + + elgg_push_context('widgets'); + $db_prefix = elgg_get_config('dbprefix'); + $activity = elgg_list_river(array( + 'limit' => $num, + 'pagination' => false, + 'joins' => array("JOIN {$db_prefix}entities e1 ON e1.guid = rv.object_guid"), + 'wheres' => array("(e1.container_guid = $guid)"), + )); + if (!$activity) { + $activity = '<p>' . elgg_echo('dashboard:widget:group:noactivity') . '</p>'; + } + elgg_pop_context(); + + $content .= $activity; +} else { + // no group selected yet + if ($vars['entity']->canEdit()) { + $content = '<p>' . elgg_echo('dashboard:widget:group:noselect') . '</p>'; + } +} + +echo $content; diff --git a/mod/dashboard/views/default/widgets/group_activity/edit.php b/mod/dashboard/views/default/widgets/group_activity/edit.php new file mode 100644 index 000000000..4e10f6ad4 --- /dev/null +++ b/mod/dashboard/views/default/widgets/group_activity/edit.php @@ -0,0 +1,45 @@ +<?php +/** + * Group activity widget settings + */ + +// once autocomplete is working use that +$groups = elgg_get_logged_in_user_entity()->getGroups("", 0); +$mygroups = array(); +if (!$vars['entity']->group_guid) { + $mygroups[0] = ''; +} +foreach ($groups as $group) { + $mygroups[$group->guid] = $group->name; +} +$params = array( + 'name' => 'params[group_guid]', + 'value' => $vars['entity']->group_guid, + 'options_values' => $mygroups, +); +$group_dropdown = elgg_view('input/dropdown', $params); +?> +<div> + <?php echo elgg_echo('dashboard:widget:group:select'); ?>: + <?php echo $group_dropdown; ?> +</div> +<?php + +// set default value for number to display +if (!isset($vars['entity']->num_display)) { + $vars['entity']->num_display = 8; +} + +$params = array( + 'name' => 'params[num_display]', + 'value' => $vars['entity']->num_display, + 'options' => array(5, 8, 10, 12, 15, 20), +); +$num_dropdown = elgg_view('input/dropdown', $params); + +?> +<div> + <?php echo elgg_echo('widget:numbertodisplay'); ?>: + <?php echo $num_dropdown; ?> +</div> + diff --git a/mod/embed/languages/en.php b/mod/embed/languages/en.php index f3a49e38b..287d34ca1 100644 --- a/mod/embed/languages/en.php +++ b/mod/embed/languages/en.php @@ -15,6 +15,8 @@ $english = array( // messages 'embed:no_upload_content' => 'No upload content!', 'embed:no_section_content' => 'No items found.', + + 'embed:no_sections' => 'No supported embed plugins found. Ask the site administrator to enabled a plugin with embed support.', ); add_translation("en", $english);
\ No newline at end of file diff --git a/mod/embed/manifest.xml b/mod/embed/manifest.xml index f61d27c23..02c012330 100644 --- a/mod/embed/manifest.xml +++ b/mod/embed/manifest.xml @@ -13,6 +13,10 @@ <type>elgg_version</type> <version>2010030101</version> </requires> + <requires> + <type>plugin</type> + <name>file</name> + </requires> <activate_on_install>true</activate_on_install> <admin_interface>advanced</admin_interface> </plugin_manifest> diff --git a/mod/embed/start.php b/mod/embed/start.php index bdd832b4e..6c26163e9 100644 --- a/mod/embed/start.php +++ b/mod/embed/start.php @@ -74,13 +74,34 @@ function embed_page_handler($page) { // listing // item // default to embed/listing | item if not found. - // @todo trigger for all right now. If we categorize these later we can trigger - // for certain categories. - $sections = elgg_trigger_plugin_hook('embed_get_sections', 'all', NULL, array()); - $upload_sections = elgg_trigger_plugin_hook('embed_get_upload_sections', 'all', NULL, array()); - - elgg_sort_3d_array_by_value($sections, 'name'); - elgg_sort_3d_array_by_value($upload_sections, 'name'); + + // @todo the menu system is good for registering and sorting, but not great for + // displaying tabs. + // Pulling in the menu manually and passing it through the embed/tabs view. + // We should work on making it easier to use tabs through the menu system, then fix + // this mess. + $menus = get_config('menus'); + $menu = $menus['embed:sections']; + + $sections = array(); + $upload_sections = array(); + + foreach ($menu as $item) { + switch ($item->section) { + case 'upload': + $upload_sections[$item->getName()] = array( + 'name' => $item->getText(), + ); + break; + + default: + $sections[$item->getName()] = array( + 'name' => $item->getText(), + ); + break; + } + } + $active_section = get_input('active_section', ''); $active_section = preg_replace('[\W]', '', $active_section); $internal_id = get_input('internal_id', ''); @@ -97,4 +118,4 @@ function embed_page_handler($page) { // exit because this is in a modal display. exit; -} +}
\ No newline at end of file diff --git a/mod/embed/views/default/embed/embed.php b/mod/embed/views/default/embed/embed.php index 2d8de1ca4..2bd329690 100644 --- a/mod/embed/views/default/embed/embed.php +++ b/mod/embed/views/default/embed/embed.php @@ -12,7 +12,6 @@ $sections = elgg_extract('sections', $vars, array()); $active_section = elgg_extract('active_section', $vars, array_shift(array_keys($sections)), false); $upload_sections = elgg_extract('upload_sections', $vars, array()); -$internal_id = elgg_extract('internal_id', $vars); if (!$sections) { $content = elgg_echo('embed:no_sections'); @@ -23,57 +22,17 @@ if (!$sections) { $offset = (int)max(0, get_input('offset', 0)); $limit = (int)get_input('limit', 5); - // build the items and layout. - if ($active_section == 'upload' || array_key_exists($active_section, $sections)) { - $section_info = $sections[$active_section]; - $layout = isset($section_info['layout']) ? $section_info['layout'] : 'list'; - - $params = array( - 'offset' => $offset, - 'limit' => $limit, - 'section' => $active_section, - 'upload_sections' => $upload_sections, - 'internal_id' => $internal_id - ); - - // allow full override for this section - // check for standard hook - if ($section_content = elgg_view("embed/$active_section/content", $params)) { - // handles its own pagination - $content .= $section_content; - } else { - // see if anyone has any items to display for the active section - $result = array('items' => array(), 'count' => 0); - $embed_info = elgg_trigger_plugin_hook('embed_get_items', $active_section, $params, $result); + // find the view to display + // @todo make it so you don't have to manually create views for each page + $view = "embed/$active_section/content"; + + $section_content = elgg_view($view, $vars); - // do we use default view or has someone defined "embed/$active_section/item/$layout" - $view = "embed/$active_section/item/$layout"; - if (!elgg_view_exists($view)) { - $view = "embed/item/$layout"; - } - - if (!isset($embed_info['items']) || !is_array($embed_info['items']) || !count($embed_info['items'])) { - $content .= elgg_echo('embed:no_section_content'); - } else { - - elgg_push_context('widgets'); - $content .= elgg_view_entity_list($embed_info['items'], array( - 'full_view' => false, - 'count' => $embed_info['count'], - 'pagination' => true, - 'position' => 'before', - 'offset' => $offset, - 'limit' => $limit, - )); - elgg_pop_context(); - - $js = elgg_view('js/embed/inline', array( - 'items' => $embed_info['items'], - )); - } - } + // build the items and layout. + if ($section_content) { + $content .= $section_content; } else { - $content .= elgg_echo('embed:invalid_section'); + $content .= elgg_echo('embed:no_section_content'); } } diff --git a/mod/embed/views/default/embed/item/gallery.php b/mod/embed/views/default/embed/item/gallery.php deleted file mode 100644 index daee8ee94..000000000 --- a/mod/embed/views/default/embed/item/gallery.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php -/** - * Default item view for embed items in gallery display. - * - * Why don't we recycle the view/type/subtype views? - * Because we need to have special JavaScript that fires when you click on - * the icon / title. - * - * @todo Yes this is copy and pasted. Pete needs to theme. I'll DRY it up later. - * - * @uses object $vars['item'] The item to display - * @return string A formatted item - */ - -$item = $vars['item']; -$section = $vars['section']; -$target = $vars['target']; -$ecml_keyword = (isset($vars['ecml_enabled']) && isset($vars['ecml_keyword'])) ? $vars['ecml_keyword'] : NULL; -$icon_size = $vars['icon_size']; - -// @todo add entity checking. - -// different entity types have different title attribute names. -$title = isset($item->name) ? $item->name : $item->title; -// don't let it be too long -$title = elgg_get_excerpt($title); - -// @todo you can disable plugins that are required by other plugins -// (embed requires ecml) so fallback to a hard-coded check to see if ecml is enabled. -// #grumble -if ($ecml_keyword) { - $embed_code = "[$ecml_keyword guid={$item->getGUID()}]"; -} else { - // fallback to inserting a hard link to the object with its icon - $icon = "<img src=\"{$item->getIcon($icon_size)}\" />" . htmlentities($title, ENT_QUOTES, 'UTF-8'); - - $embed_code = elgg_view('output/url', array( - 'href' => $item->getURL(), - 'title' => $title, - 'text' => $title, - 'encode_text' => FALSE - )); -} - -$icon = "<img src=\"{$item->getIcon($icon_size)}\" />"; -$info = htmlentities($title, ENT_QUOTES, 'UTF-8'); - -$listing = elgg_view('entities/gallery_listing', array('icon' => $icon, 'info' => $info)); - -// @todo JS 1.8: no -echo "<div class=\"embed_data\" id=\"embed_{$item->getGUID()}\">$listing</div>"; -echo "<script type=\"text/javascript\"> - $('#embed_{$item->getGUID()}').data('embed_code', " . json_encode($embed_code) . "); -</script>";
\ No newline at end of file diff --git a/mod/embed/views/default/embed/item/list.php b/mod/embed/views/default/embed/item/list.php deleted file mode 100644 index 89a2ffb63..000000000 --- a/mod/embed/views/default/embed/item/list.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php -/** - * Default item view for embed items in list display. - * - * Why don't we recycle the view/type/subtype views? - * Because we need to have special JavaScript that fires when you click on - * the icon / title. - * - * @uses object $vars['item'] The item to display - * @return string A formatted item - */ - -$item = $vars['item']; -$section = $vars['section']; -$target = $vars['target']; -$ecml_keyword = (isset($vars['ecml_enabled']) && $vars['ecml_enabled'] && isset($vars['ecml_keyword'])) ? $vars['ecml_keyword'] : NULL; -$icon_size = $vars['icon_size']; -$owner = $item->getOwnerEntity(); - -// @todo add entity checking. - -// different entity types have different title attribute names. -$title = isset($item->name) ? $item->name : $item->title; -// don't let it be too long -$title = elgg_get_excerpt($title); - -$author_text = elgg_echo('byline', array($owner->name)); -$date = elgg_view_friendly_time($item->time_created); - -$subtitle = "$author_text $date"; - -// @todo you can disable plugins that are required by other plugins -// (embed requires ecml) so fallback to a hard-coded check to see if ecml is enabled. -// #grumble -if ($ecml_keyword) { - $embed_code = "[$ecml_keyword guid={$item->getGUID()}]"; -} else { - // fallback to inserting a hard link to the object with its icon - $icon = "<img src=\"{$item->getIcon($icon_size)}\" />" . htmlentities($title, ENT_QUOTES, 'UTF-8'); - - $embed_code = elgg_view('output/url', array( - 'href' => $item->getURL(), - 'title' => $title, - 'text' => $icon, - 'encode_text' => FALSE - )); -} - -$item_icon = elgg_view_entity_icon($item, $icon_size); - -$params = array( - 'title' => $title, - 'entity' => $item, - 'subtitle' => $subtitle, - 'tags' => FALSE, -); -$list_body = elgg_view('object/elements/summary', $params); - -// @todo JS 1.8: is this approach better than inline js? -echo "<div class=\"embed_data\" id=\"embed_{$item->getGUID()}\">" . elgg_view_image_block($item_icon, $list_body) . '</div>'; -echo "<script type=\"text/javascript\"> - $('#embed_{$item->getGUID()}').data('embed_code', " . json_encode($embed_code) . "); -</script>";
\ No newline at end of file diff --git a/mod/embed/views/default/embed/layouts/gallery.php b/mod/embed/views/default/embed/layouts/gallery.php deleted file mode 100644 index 70b6d33a5..000000000 --- a/mod/embed/views/default/embed/layouts/gallery.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php -/** - * Embed - Gallery items - * - * @uses string $vars['content'] Pre-formatted content. - * - */ -$active_section = elgg_extract('section', $vars, array()); - -echo "<div class='embed_modal_$active_section'>" . elgg_extract('content', $vars, '') . "</div>"; diff --git a/mod/embed/views/default/embed/layouts/list.php b/mod/embed/views/default/embed/layouts/list.php deleted file mode 100644 index 5d62e572b..000000000 --- a/mod/embed/views/default/embed/layouts/list.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php -/** - * Embed - List items - * - * @uses string $vars['content'] Pre-formatted content. - * - */ -$active_section = elgg_extract('section', $vars, array()); - -echo "<div class='embed_modal_$active_section'>" . elgg_extract('content', $vars, '') . "</div>";
\ No newline at end of file diff --git a/mod/embed/views/default/embed/upload/content.php b/mod/embed/views/default/embed/upload/content.php deleted file mode 100644 index 8bedf5ad1..000000000 --- a/mod/embed/views/default/embed/upload/content.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php -/** - * Special upload form - */ -$upload_sections = elgg_extract('upload_sections', $vars, array()); -$active_section = get_input('active_upload_section', array_shift(array_keys($upload_sections))); -$active_section = preg_replace('[\W]', '', $active_section); - -$options = array(); - -if ($upload_sections) { - foreach ($upload_sections as $id => $info) { - $options[$id] = $info['name']; - } - - $input = elgg_view('input/dropdown', array( - 'name' => 'download_section', - 'options_values' => $options, - 'id' => 'embed_upload', - 'value' => $active_section - )); - - // hack this in for now as we clean up this mess - $form_vars = array( - 'enctype' => 'multipart/form-data', - 'class' => 'elgg-form', - ); - $upload_content = elgg_view_form('file/upload', $form_vars); -/* - if (!$upload_content = elgg_view($upload_sections[$active_section]['view'])) { - $upload_content = elgg_echo('embed:no_upload_content'); - } -*/ - echo "<div class='mbm'>" . elgg_echo('embed:upload_type') . "$input</div>"; - echo "<div class='embed-upload'>"; - echo $upload_content; - echo "</div>"; - -} else { - echo elgg_echo('embed:no_upload_sections'); -} diff --git a/mod/embed/views/default/js/embed/embed.php b/mod/embed/views/default/js/embed/embed.php index ea92ba1fd..e9e08f9a0 100644 --- a/mod/embed/views/default/js/embed/embed.php +++ b/mod/embed/views/default/js/embed/embed.php @@ -1,9 +1,10 @@ +//<script> elgg.provide('elgg.embed'); elgg.embed.init = function() { // inserts the embed content into the textarea - $(".embed-wrapper .elgg-item").live('click', elgg.embed.insert); + $(".embed_data").live('click', elgg.embed.insert); // caches the current textarea id $(".embed-control").live('click', function() { @@ -30,7 +31,6 @@ elgg.embed.init = function() { * @return void */ elgg.embed.insert = function(event) { - var textAreaId = elgg.embed.textAreaId; var content = $(this).data('embed_code'); diff --git a/mod/embed/views/default/js/embed/inline.php b/mod/embed/views/default/js/embed/inline.php deleted file mode 100644 index 0672a68f8..000000000 --- a/mod/embed/views/default/js/embed/inline.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php -/** - * Inline embed JavaScript for attaching the insert data to list items - * - * @uses $vars['items'] - */ - -foreach ($vars['items'] as $item) { - - // different entity types have different title attribute names. - $title = isset($item->name) ? $item->name : $item->title; - // don't let it be too long - $title = elgg_get_excerpt($title); - - $icon = "<img src=\"{$item->getIcon($icon_size)}\" />" . htmlspecialchars($title, ENT_QUOTES, 'UTF-8', false); - - $embed_code = elgg_view('output/url', array( - 'href' => $item->getURL(), - 'title' => $title, - 'text' => $icon, - 'encode_text' => false, - )); - $embed_code = json_encode($embed_code); - - echo "$('#elgg-object-{$item->getGUID()}').data('embed_code', $embed_code);"; -}
\ No newline at end of file diff --git a/mod/externalpages/manifest.xml b/mod/externalpages/manifest.xml index 453cef259..32528585d 100644 --- a/mod/externalpages/manifest.xml +++ b/mod/externalpages/manifest.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8"> - <name>External Pages</name> + <name>Site Pages</name> <author>Core developers</author> <version>1.8</version> <category>bundled</category> diff --git a/mod/file/pages/file/search.php b/mod/file/pages/file/search.php index 3e85d45db..569657fd4 100644 --- a/mod/file/pages/file/search.php +++ b/mod/file/pages/file/search.php @@ -5,7 +5,7 @@ * @package ElggFile */ -$page_owner_guid = get_input('page_owner', null); +$page_owner_guid = (int)get_input('page_owner', null); if ($page_owner_guid) { elgg_set_page_owner_guid($page_owner_guid); } diff --git a/mod/file/start.php b/mod/file/start.php index b94dc309a..749d7a519 100644 --- a/mod/file/start.php +++ b/mod/file/start.php @@ -57,11 +57,23 @@ function file_init() { // temporary - see #2010 elgg_register_action("file/download", "$action_path/download.php"); - // embed support - elgg_register_plugin_hook_handler('embed_get_sections', 'all', 'file_embed_get_sections'); - elgg_register_plugin_hook_handler('embed_get_items', 'file', 'file_embed_get_items'); - elgg_register_plugin_hook_handler('embed_get_upload_sections', 'all', 'file_embed_get_upload_sections'); + $item = ElggMenuItem::factory(array( + 'name' => 'file', + 'text' => elgg_echo('file'), + 'href' => '#', + 'section' => 'select' + )); + elgg_register_menu_item('embed:sections', $item); + + $item = ElggMenuItem::factory(array( + 'name' => 'file_upload', + 'text' => elgg_echo('file:upload'), + 'href' => '#', + 'section' => 'upload' + )); + + elgg_register_menu_item('embed:sections', $item); } /** @@ -332,69 +344,4 @@ function file_icon_url_override($hook, $type, $returnvalue, $params) { $url = elgg_trigger_plugin_hook('file:icon:url', 'override', $params, $url); return $url; } -} - -/** - * Register file as an embed type. - * - * @param unknown_type $hook - * @param unknown_type $type - * @param unknown_type $value - * @param unknown_type $params - */ -function file_embed_get_sections($hook, $type, $value, $params) { - $value['file'] = array( - 'name' => elgg_echo('file'), - 'layout' => 'list', - 'icon_size' => 'small', - ); - - return $value; -} - -/** - * Return a list of files for embedding - * - * @param unknown_type $hook - * @param unknown_type $type - * @param unknown_type $value - * @param unknown_type $params - */ -function file_embed_get_items($hook, $type, $value, $params) { - $options = array( - 'owner_guid' => elgg_get_logged_in_user_guid(), - 'type_subtype_pair' => array('object' => 'file'), - 'count' => TRUE - ); - - if ($count = elgg_get_entities($options)) { - $value['count'] += $count; - - unset($options['count']); - $options['offset'] = $params['offset']; - $options['limit'] = $params['limit']; - - $items = elgg_get_entities($options); - - $value['items'] = array_merge($items, $value['items']); - } - - return $value; -} - -/** - * Register file as an embed type. - * - * @param unknown_type $hook - * @param unknown_type $type - * @param unknown_type $value - * @param unknown_type $params - */ -function file_embed_get_upload_sections($hook, $type, $value, $params) { - $value['file'] = array( - 'name' => elgg_echo('file'), - 'view' => 'file/embed_upload' - ); - - return $value; -} +}
\ No newline at end of file diff --git a/mod/file/views/default/embed/file/content.php b/mod/file/views/default/embed/file/content.php new file mode 100644 index 000000000..865a158a7 --- /dev/null +++ b/mod/file/views/default/embed/file/content.php @@ -0,0 +1,61 @@ +<?php +/** + * List files available for upload + */ + +$active_section = elgg_extract('active_section', $vars); + +$options = array( + 'owner_guid' => elgg_get_logged_in_user_guid(), + 'type_subtype_pair' => array('object' => 'file'), + 'count' => true +); + +$count = elgg_get_entities($options); + +if ($count) { + echo "<div class='embed_modal_$active_section'>"; + + unset($options['count']); + $items = elgg_get_entities($options); + + foreach ($items as $item) { + + // different entity types have different title attribute names. + $title = isset($item->name) ? $item->name : $item->title; + // don't let it be too long + $title = elgg_get_excerpt($title); + + $author_text = elgg_echo('byline', array($owner->name)); + $date = elgg_view_friendly_time($item->time_created); + + $subtitle = "$author_text $date"; + + $icon = "<img src=\"{$item->getIconURL($icon_size)}\" />" . htmlentities($title, ENT_QUOTES, 'UTF-8'); + + $embed_code = elgg_view('output/url', array( + 'href' => $item->getURL(), + 'title' => $title, + 'text' => $icon, + 'encode_text' => FALSE + )); + + $item_icon = elgg_view_entity_icon($item, $icon_size); + + $params = array( + 'title' => $title, + 'entity' => $item, + 'subtitle' => $subtitle, + 'tags' => FALSE, + ); + $list_body = elgg_view('object/elements/summary', $params); + + // @todo JS 1.8: is this approach better than inline js? + echo "<div class=\"embed_data\" id=\"embed_{$item->getGUID()}\">" . elgg_view_image_block($item_icon, $list_body) . '</div>'; + echo "<script type=\"text/javascript\"> + $('#embed_{$item->getGUID()}').data('embed_code', " . json_encode($embed_code) . "); + </script>"; + } + + echo '</div>'; +}
\ No newline at end of file diff --git a/mod/file/views/default/embed/file_upload/content.php b/mod/file/views/default/embed/file_upload/content.php new file mode 100644 index 000000000..13c18f745 --- /dev/null +++ b/mod/file/views/default/embed/file_upload/content.php @@ -0,0 +1,15 @@ +<?php +/** + * Upload a file through the embed interface + */ + +$form_vars = array( + 'enctype' => 'multipart/form-data', + 'class' => 'elgg-form', +); +$upload_content = elgg_view_form('file/upload', $form_vars); + +echo "<div class='mbm'>" . elgg_echo('embed:upload_type') . "$input</div>"; +echo "<div class='embed-upload'>"; +echo $upload_content; +echo "</div>";
\ No newline at end of file diff --git a/mod/groups/actions/discussion/reply/save.php b/mod/groups/actions/discussion/reply/save.php index 109938dbb..a1ed036b6 100644 --- a/mod/groups/actions/discussion/reply/save.php +++ b/mod/groups/actions/discussion/reply/save.php @@ -9,6 +9,7 @@ gatekeeper(); // Get input $entity_guid = (int) get_input('entity_guid'); $text = get_input('group_topic_post'); +$annotation_id = (int) get_input('annotation_id'); // reply cannot be empty if (empty($text)) { @@ -30,16 +31,30 @@ if (!$group->canWriteToContainer($user)) { forward(REFERER); } - -// add the reply to the forum topic -$reply_id = $topic->annotate('group_topic_post', $text, $topic->access_id, $user->guid); -if ($reply_id == false) { - system_message(elgg_echo('groupspost:failure')); - forward(REFERER); +// if editing a reply, make sure it's valid +if ($annotation_id) { + $annotation = elgg_get_annotation_from_id($annotation_id); + if (!$annotation->canEdit()) { + register_error(elgg_echo('groups:notowner')); + forward(REFERER); + } + + $annotation->value = $text; + if (!$annotation->save()) { + system_message(elgg_echo('groups:forumpost:error')); + forward(REFERER); + } + system_message(elgg_echo('groups:forumpost:edited')); +} else { + // add the reply to the forum topic + $reply_id = $topic->annotate('group_topic_post', $text, $topic->access_id, $user->guid); + if ($reply_id == false) { + system_message(elgg_echo('groupspost:failure')); + forward(REFERER); + } + + add_to_river('river/annotation/group_topic_post/reply', 'reply', $user->guid, $topic->guid, "", 0, $reply_id); + system_message(elgg_echo('groupspost:success')); } -add_to_river('river/annotation/group_topic_post/reply', 'reply', $user->guid, $topic->guid, "", 0, $reply_id); - -system_message(elgg_echo('groupspost:success')); - forward(REFERER); diff --git a/mod/groups/actions/groups/membership/join.php b/mod/groups/actions/groups/membership/join.php index 210e285a5..b4f4e280c 100644 --- a/mod/groups/actions/groups/membership/join.php +++ b/mod/groups/actions/groups/membership/join.php @@ -10,6 +10,8 @@ * @package ElggGroups */ +global $CONFIG; + $user_guid = get_input('user_guid', elgg_get_logged_in_user_guid()); $group_guid = get_input('group_guid'); @@ -45,7 +47,7 @@ if (($user instanceof ElggUser) && ($group instanceof ElggGroup)) { add_entity_relationship($user->guid, 'membership_request', $group->guid); // Notify group owner - $url = "{$CONFIG->url}mod/groups/membershipreq.php?group_guid={$group->guid}"; + $url = "{$CONFIG->url}groups/requests/$group->guid"; $subject = elgg_echo('groups:request:subject', array( $user->name, $group->name, diff --git a/mod/groups/lib/groups.php b/mod/groups/lib/groups.php index 126738566..86e6f018e 100644 --- a/mod/groups/lib/groups.php +++ b/mod/groups/lib/groups.php @@ -17,7 +17,7 @@ function groups_handle_all_page() { $selected_tab = get_input('filter', 'newest'); switch ($selected_tab) { - case 'pop': + case 'popular': $content = elgg_list_entities_from_relationship_count(array( 'type' => 'group', 'relationship' => 'member', @@ -25,7 +25,7 @@ function groups_handle_all_page() { 'full_view' => false, )); break; - case 'active': + case 'discussion': $content = elgg_list_entities(array( 'type' => 'object', 'subtype' => 'groupforumtopic', @@ -198,7 +198,7 @@ function groups_handle_invitations_page() { elgg_push_breadcrumb($title); // @todo temporary workaround for exts #287. - $invitations = groups_get_invited_groups($user->getGUID()); + $invitations = groups_get_invited_groups(elgg_get_logged_in_user_guid()); $content = elgg_view('groups/invitationrequests', array('invitations' => $invitations)); $params = array( @@ -424,9 +424,9 @@ function groups_register_profile_buttons($group) { if ($group->canEdit()) { // edit and invite $url = elgg_get_site_url() . "groups/edit/{$group->getGUID()}"; - $actions[$url] = elgg_echo('groups:edit'); + $actions[$url] = 'groups:edit'; $url = elgg_get_site_url() . "groups/invite/{$group->getGUID()}"; - $actions[$url] = elgg_echo('groups:invite'); + $actions[$url] = 'groups:invite'; } // group members diff --git a/mod/groups/start.php b/mod/groups/start.php index 83353bae5..9e4694457 100644 --- a/mod/groups/start.php +++ b/mod/groups/start.php @@ -65,6 +65,9 @@ function groups_init() { // group user hover menu elgg_register_plugin_hook_handler('register', 'menu:user_hover', 'groups_user_entity_menu_setup'); + // delete and edit annotations for topic replies + elgg_register_plugin_hook_handler('register', 'menu:annotation', 'groups_annotation_menu_setup'); + //extend some views elgg_extend_view('css/elgg', 'groups/css'); elgg_extend_view('js/elgg', 'groups/js'); @@ -409,6 +412,51 @@ function groups_user_entity_menu_setup($hook, $type, $return, $params) { } /** + * Add edit and delete links for forum replies + */ +function groups_annotation_menu_setup($hook, $type, $return, $params) { + if (elgg_in_context('widgets')) { + return $return; + } + + $annotation = $params['annotation']; + + if ($annotation->name != 'group_topic_post') { + return $return; + } + + if ($annotation->canEdit()) { + $url = elgg_http_add_url_query_elements('action/discussion/reply/delete', array( + 'annotation_id' => $annotation->id, + )); + + $options = array( + 'name' => 'delete', + 'href' => $url, + 'text' => "<span class=\"elgg-icon elgg-icon-delete\"></span>", + 'confirm' => elgg_echo('deleteconfirm'), + 'text_encode' => false + ); + $return[] = ElggMenuItem::factory($options); + + $url = elgg_http_add_url_query_elements('discussion', array( + 'annotation_id' => $annotation->id, + )); + + $options = array( + 'name' => 'edit', + 'href' => "#edit-annotation-$annotation->id", + 'text' => elgg_echo('edit'), + 'text_encode' => false, + 'rel' => 'toggle', + ); + $return[] = ElggMenuItem::factory($options); + } + + return $return; +} + +/** * Groups created so create an access list for it */ function groups_create_event_listener($event, $object_type, $object) { diff --git a/mod/groups/views/default/annotation/group_topic_post.php b/mod/groups/views/default/annotation/group_topic_post.php index d2303aba8..f38d2a77a 100644 --- a/mod/groups/views/default/annotation/group_topic_post.php +++ b/mod/groups/views/default/annotation/group_topic_post.php @@ -1,8 +1,19 @@ <?php -/** - * Discussion reply +/* + * Embeds an edit link for the annotation */ -$vars['delete_action'] = 'action/discussion/reply/delete'; +$annotation = elgg_extract('annotation', $vars); echo elgg_view('annotation/default', $vars); + +if ($annotation->canEdit()) { + $form = elgg_view_form('discussion/reply/save', array(), array_merge(array( + 'entity' => get_entity($annotation->entity_guid), + 'annotation' => $annotation + ), $vars) + ); + + echo "<div class=\"hidden mbm\" id=\"edit-annotation-$annotation->id\">$form</div>"; +} + diff --git a/mod/groups/views/default/forms/discussion/reply/save.php b/mod/groups/views/default/forms/discussion/reply/save.php index 40ea07303..083fefb78 100644 --- a/mod/groups/views/default/forms/discussion/reply/save.php +++ b/mod/groups/views/default/forms/discussion/reply/save.php @@ -6,7 +6,6 @@ * @uses $vars['inline'] Display a shortened form? */ - if (isset($vars['entity']) && elgg_is_logged_in()) { echo elgg_view('input/hidden', array( 'name' => 'entity_guid', @@ -14,18 +13,43 @@ if (isset($vars['entity']) && elgg_is_logged_in()) { )); $inline = elgg_extract('inline', $vars, false); + + $annotation = elgg_extract('annotation', $vars); + + $value = ''; + + if ($annotation) { + $value = $annotation->value; + echo elgg_view('input/hidden', array( + 'name' => 'annotation_id', + 'value' => $annotation->id + )); + } + if ($inline) { - echo elgg_view('input/text', array('name' => 'group_topic_post')); + echo elgg_view('input/text', array('name' => 'group_topic_post', 'value' => $value)); echo elgg_view('input/submit', array('value' => elgg_echo('reply'))); } else { ?> <div> - <label><?php echo elgg_echo("reply"); ?></label> - <?php echo elgg_view('input/longtext', array('name' => 'group_topic_post')); ?> + <label> + <?php + if ($annotation) { + echo elgg_echo('edit'); + } else { + echo elgg_echo("reply"); + } + ?> + </label> + <?php echo elgg_view('input/longtext', array('name' => 'group_topic_post', 'value' => $value)); ?> </div> <div class="elgg-foot"> <?php + if ($annotation) { + echo elgg_view('input/submit', array('value' => elgg_echo('save'))); + } else { echo elgg_view('input/submit', array('value' => elgg_echo('reply'))); + } ?> </div> <?php diff --git a/mod/groups/views/default/widgets/a_users_groups/content.php b/mod/groups/views/default/widgets/a_users_groups/content.php index 81d355442..114fd7565 100644 --- a/mod/groups/views/default/widgets/a_users_groups/content.php +++ b/mod/groups/views/default/widgets/a_users_groups/content.php @@ -21,7 +21,7 @@ $content = elgg_list_entities_from_relationship($options); echo $content; if ($content) { - $url = "group/member/" . elgg_get_page_owner_entity()->username; + $url = "groups/member/" . elgg_get_page_owner_entity()->username; $more_link = elgg_view('output/url', array( 'href' => $url, 'text' => elgg_echo('groups:more'), diff --git a/mod/likes/actions/likes/add.php b/mod/likes/actions/likes/add.php index b76c1bea9..a6a8d6c45 100644 --- a/mod/likes/actions/likes/add.php +++ b/mod/likes/actions/likes/add.php @@ -41,18 +41,7 @@ if (!$annotation) { // notify if poster wasn't owner if ($entity->owner_guid != $user->guid) { - notify_user($entity->owner_guid, - $user->guid, - elgg_echo('likes:email:subject'), - elgg_echo('likes:email:body', array( - $user->name, - $entity->title, - //$comment_text, - $entity->getURL(), - $user->name, - $user->getURL() - )) - ); + likes_notify_user($entity->getOwnerEntity(), $user, $entity); } system_message(elgg_echo("likes:likes")); diff --git a/mod/likes/languages/en.php b/mod/likes/languages/en.php index aad2a7f24..29b379506 100644 --- a/mod/likes/languages/en.php +++ b/mod/likes/languages/en.php @@ -17,9 +17,28 @@ $english = array( 'likes:userlikedthis' => '%s like', 'likes:userslikedthis' => '%s likes', 'likes:river:annotate' => 'likes', - 'likes:email:body' => '%s liked %s', - 'likes:email:subject' => 'A user liked one of your objects', + 'river:likes' => 'likes %s %s', + + // notifications. yikes. + 'likes:notifications:subject' => '%s likes your post "%s"', + 'likes:notifications:body' => +'Hi %1$s, + +%2$s likes your post "%3$s" on %4$s! + +See your original post here: + +%5$s + +or view %2$s\'s profile here: + +%6$s + +Thanks, +%4$s +', + ); add_translation('en', $english); diff --git a/mod/likes/start.php b/mod/likes/start.php index d45fb96b3..76b48a369 100644 --- a/mod/likes/start.php +++ b/mod/likes/start.php @@ -109,3 +109,52 @@ function likes_count($entity) { return $entity->countAnnotations('likes'); } } + +/** + * Notify $user that $liker liked his $entity. + * + * @param type $user + * @param type $liker + * @param type $entity + */ +function likes_notify_user(ElggUser $user, ElggUser $liker, ElggEntity $entity) { + + if (!$user instanceof ElggUser) { + return false; + } + + if (!$liker instanceof ElggUser) { + return false; + } + + if (!$entity instanceof ElggEntity) { + return false; + } + + $title_str = $entity->title; + if (!$title_str) { + $title_str = elgg_get_excerpt($entity->description); + } + + $site = get_config('site'); + + $subject = elgg_echo('likes:notifications:subject', array( + $liker->name, + $title_str + )); + + $body = elgg_echo('likes:notifications:body', array( + $user->name, + $liker->name, + $title_str, + $site->name, + $entity->getURL(), + $liker->getURL() + )); + + notify_user($user->guid, + $liker->guid, + $subject, + $body + ); +}
\ No newline at end of file diff --git a/mod/logbrowser/start.php b/mod/logbrowser/start.php index eedc9d8ad..71b6115a5 100644 --- a/mod/logbrowser/start.php +++ b/mod/logbrowser/start.php @@ -23,7 +23,7 @@ function logbrowser_init() { function logbrowser_user_hover_menu($hook, $type, $return, $params) { $user = $params['entity']; - $url = "admin/overview/logbrowser?user_guid={$user->guid}"; + $url = "admin/utilities/logbrowser?user_guid={$user->guid}"; $item = new ElggMenuItem('logbrowser', elgg_echo('logbrowser:explore'), $url); $item->setSection('admin'); $return[] = $item; diff --git a/mod/logbrowser/views/default/logbrowser/form.php b/mod/logbrowser/views/default/logbrowser/form.php index d5cf9f6b8..2cb746eac 100644 --- a/mod/logbrowser/views/default/logbrowser/form.php +++ b/mod/logbrowser/views/default/logbrowser/form.php @@ -52,7 +52,7 @@ $wrappedform = elgg_view('input/form', array( 'body' => $form, 'method' => 'get', - 'action' => "admin/overview/logbrowser", + 'action' => "admin/utilities/logbrowser", 'disable_security' => true, )); diff --git a/mod/messageboard/start.php b/mod/messageboard/start.php index efe453286..8a7f00958 100644 --- a/mod/messageboard/start.php +++ b/mod/messageboard/start.php @@ -26,6 +26,9 @@ function messageboard_init() { $action_path = dirname(__FILE__) . '/actions'; elgg_register_action("messageboard/add", "$action_path/add.php"); elgg_register_action("messageboard/delete", "$action_path/delete.php"); + + // delete annotations for posts + elgg_register_plugin_hook_handler('register', 'menu:annotation', 'messageboard_annotation_menu_setup'); } /** @@ -127,4 +130,32 @@ function messageboard_add($poster, $owner, $message, $access_id = ACCESS_PUBLIC) return $result; } + +/** + * Add edit and delete links for forum replies + */ +function messageboard_annotation_menu_setup($hook, $type, $return, $params) { + $annotation = $params['annotation']; + if ($annotation->name != 'messageboard') { + return $return; + } + + if ($annotation->canEdit()) { + $url = elgg_http_add_url_query_elements('action/messageboard/delete', array( + 'annotation_id' => $annotation->id, + )); + + $options = array( + 'name' => 'delete', + 'href' => $url, + 'text' => "<span class=\"elgg-icon elgg-icon-delete\"></span>", + 'confirm' => elgg_echo('deleteconfirm'), + 'text_encode' => false + ); + $return[] = ElggMenuItem::factory($options); + } + + return $return; +} + elgg_register_event_handler('init', 'system', 'messageboard_init');
\ No newline at end of file diff --git a/mod/messageboard/views/default/annotation/messageboard.php b/mod/messageboard/views/default/annotation/messageboard.php deleted file mode 100644 index 8dfba3a22..000000000 --- a/mod/messageboard/views/default/annotation/messageboard.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php -/** - * Message board post - * - * @uses $vars['annotation'] ElggAnnotation object - * @uses $vars['full_view'] Display fill view or brief view - */ - -$vars['delete_action'] = 'action/messageboard/delete'; - -echo elgg_view('annotation/default', $vars);
\ No newline at end of file diff --git a/mod/pages/pages/pages/edit.php b/mod/pages/pages/pages/edit.php index e6c2ea015..6f54d72bf 100644 --- a/mod/pages/pages/pages/edit.php +++ b/mod/pages/pages/pages/edit.php @@ -7,15 +7,15 @@ gatekeeper(); -$page_guid = get_input('guid'); +$page_guid = (int)get_input('guid'); $page = get_entity($page_guid); if (!$page) { - + } $container = $page->getContainerEntity(); if (!$container) { - + } elgg_set_page_owner_guid($container->getGUID()); diff --git a/mod/profile/views/default/profile/js.php b/mod/profile/views/default/profile/js.php index edf68543c..16dec59df 100644 --- a/mod/profile/views/default/profile/js.php +++ b/mod/profile/views/default/profile/js.php @@ -1,3 +1,6 @@ elgg.register_hook_handler('init', 'system', function() { - $('#elgg-widget-col-1').css('min-height', $('.profile').outerHeight(true) + 1); + // only do this on the profile page's widget canvas. + if ($('.profile').length) { + $('#elgg-widget-col-1').css('min-height', $('.profile').outerHeight(true) + 1); + } });
\ No newline at end of file diff --git a/mod/search/search_hooks.php b/mod/search/search_hooks.php index 428d6f700..b302272fb 100644 --- a/mod/search/search_hooks.php +++ b/mod/search/search_hooks.php @@ -202,6 +202,10 @@ function search_tags_hook($hook, $type, $value, $params) { $search_tag_names = $valid_tag_names; } + if (!$search_tag_names) { + return array('entities' => array(), 'count' => $count); + } + // don't use elgg_get_entities_from_metadata() here because of // performance issues. since we don't care what matches at this point // use an IN clause to grab everything that matches at once and sort @@ -337,7 +341,7 @@ function search_comments_hook($hook, $type, $value, $params) { $container_and = ''; if ($params['container_guid'] && $params['container_guid'] !== ELGG_ENTITIES_ANY_VALUE) { - $container_and = 'AND e.container_guid = ' . sanitise_string($params['container_guid']); + $container_and = 'AND e.container_guid = ' . sanitise_int($params['container_guid']); } $e_access = get_access_sql_suffix('e'); diff --git a/mod/search/views/default/search/list.php b/mod/search/views/default/search/list.php index 11860c094..c5249fe77 100644 --- a/mod/search/views/default/search/list.php +++ b/mod/search/views/default/search/list.php @@ -37,8 +37,8 @@ $query = http_build_query( $url = elgg_get_site_url() . "search?$query"; // get pagination -if (array_key_exists('pagination', $vars) && $vars['pagination']) { - $nav .= elgg_view('navigation/pagination',array( +if (array_key_exists('pagination', $vars['params']) && $vars['params']['pagination']) { + $nav = elgg_view('navigation/pagination',array( 'baseurl' => $url, 'offset' => $vars['params']['offset'], 'count' => $vars['results']['count'], @@ -82,7 +82,8 @@ $more = ($more_check > 0) ? $more_check : 0; if ($more) { $title_key = ($more == 1) ? 'comment' : 'comments'; $more_str = elgg_echo('search:more', array($count, $type_str)); - $more_link = "<li class='elgg-item'><a href=\"$url\">$more_str</a></li>"; + $more_url = elgg_http_remove_url_query_element($url, 'limit'); + $more_link = "<li class='elgg-item'><a href=\"$more_url\">$more_str</a></li>"; } else { $more_link = ''; } diff --git a/mod/twitter_api/actions/twitter_api/interstitial_settings.php b/mod/twitter_api/actions/twitter_api/interstitial_settings.php new file mode 100644 index 000000000..5f742efd8 --- /dev/null +++ b/mod/twitter_api/actions/twitter_api/interstitial_settings.php @@ -0,0 +1,53 @@ +<?php +/** + * Save settings for first time logins with twitter + */ +elgg_make_sticky_form('twitter_api_interstitial'); + +$display_name = get_input('display_name'); +$email = get_input('email'); +$password_1 = get_input('password_1'); +$password_2 = get_input('password_2'); + +if (!$display_name) { + register_error(elgg_echo('twitter_api:interstitial:no_display_name')); + forward(REFERER); +} + +if ($email && !is_email_address($email)) { + register_error(elgg_echo('twitter_api:interstitial:invalid_email')); + forward(REFERER); +} + +$existing_user = get_user_by_email($email); +if ($email && $existing_user) { + register_error(elgg_echo('twitter_api:interstitial:existing_email')); + forward(REFERER); +} + +if ($password_1 && !($password_1 == $password_2)) { + register_error(elgg_echo('twitter_api:interstitial:password_mismatch')); + forward(REFERER); +} + +$user = elgg_get_logged_in_user_entity(); +$user->name = $display_name; + +if ($email) { + $user->email = $email; +} + +if ($password_1) { + $user->salt = generate_random_cleartext_password(); + $user->password = generate_user_password($user, $password_1); +} + +if (!$user->save()) { + register_error(elgg_echo('twitter_api:interstitial:cannot_save')); + forward(REFERER); +} + +elgg_clear_sticky_form('twitter_api_interstitial'); + +system_message(elgg_echo('twitter_api:interstitial:saved')); +forward('/');
\ No newline at end of file diff --git a/mod/twitter_api/languages/en.php b/mod/twitter_api/languages/en.php index 3a422b043..9d8554a9e 100644 --- a/mod/twitter_api/languages/en.php +++ b/mod/twitter_api/languages/en.php @@ -15,6 +15,7 @@ $english = array( 'twitter_api:usersettings:description' => "Link your %s account with Twitter.", 'twitter_api:usersettings:request' => "You must first <a href=\"%s\">authorize</a> %s to access your Twitter account.", + 'twitter_api:usersettings:cannot_revoke' => "You cannot unlink you account with Twitter because you haven't provided an email address or password. <a href=\"%s\">Provide them now</a>.", 'twitter_api:authorize:error' => 'Unable to authorize Twitter.', 'twitter_api:authorize:success' => 'Twitter access has been authorized.', @@ -28,7 +29,30 @@ $english = array( 'twitter_api:login:error' => 'Unable to login with Twitter.', 'twitter_api:login:email' => "You must enter a valid email address for your new %s account.", + 'twitter_api:invalid_page' => 'Invalid page', + 'twitter_api:deprecated_callback_url' => 'The callback URL has changed for Twitter API to %s. Please ask your administrator to change it.', + + 'twitter_api:interstitial:settings' => 'Configure your settings', + 'twitter_api:interstitial:description' => 'You\'re almost ready to use %s! We need a few more details before you can continue. These are optional, but will allow you login if Twitter goes down or you decide to unlink your accounts.', + + 'twitter_api:interstitial:username' => 'This is your username. It cannot be changed. If you set a password, you can use the username or your email address to log in.', + + 'twitter_api:interstitial:name' => 'This is the name people will see when interacting with you.', + + 'twitter_api:interstitial:email' => 'Your email address. Users cannot see this by default.', + + 'twitter_api:interstitial:password' => 'A password to login if Twitter is down or you decide to unlink your accounts.', + 'twitter_api:interstitial:password2' => 'The same password, again.', + + 'twitter_api:interstitial:no_thanks' => 'No thanks', + + 'twitter_api:interstitial:no_display_name' => 'You must have a display name.', + 'twitter_api:interstitial:invalid_email' => 'You must enter a valid email address or nothing.', + 'twitter_api:interstitial:existing_email' => 'This email address is already registered on this site.', + 'twitter_api:interstitial:password_mismatch' => 'Your passwords do not match.', + 'twitter_api:interstitial:cannot_save' => 'Cannot save account details.', + 'twitter_api:interstitial:saved' => 'Account details saved!', ); add_translation('en', $english); diff --git a/mod/twitter_api/lib/twitter_api.php b/mod/twitter_api/lib/twitter_api.php index 81aef38fb..b14b84f2d 100644 --- a/mod/twitter_api/lib/twitter_api.php +++ b/mod/twitter_api/lib/twitter_api.php @@ -109,7 +109,7 @@ function twitter_api_login() { $user = twitter_api_create_user($twitter); $site_name = elgg_get_site_entity()->name; system_message(elgg_echo('twitter_api:login:email', array($site_name))); - $forward = "settings/user/{$user->username}"; + $forward = "twitter_api/intersitial"; } // set twitter services tokens diff --git a/mod/twitter_api/pages/twitter_api/interstitial.php b/mod/twitter_api/pages/twitter_api/interstitial.php new file mode 100644 index 000000000..d1f1ac20c --- /dev/null +++ b/mod/twitter_api/pages/twitter_api/interstitial.php @@ -0,0 +1,21 @@ +<?php +/** + * An interstitial page for newly created Twitter users. + * + * This prompts them to enter an email address and set a password in case Twitter goes down or they + * want to disassociate their account from twitter. + */ + +$title = elgg_echo('twitter_api:interstitial:settings'); + +$site = get_config('site'); +$content = elgg_echo('twitter_api:interstitial:description', array($site->name)); +$content .= elgg_view_form('twitter_api/interstitial_settings'); + +$params = array( + 'content' => $content, + 'title' => $title, +); +$body = elgg_view_layout('one_sidebar', $params); + +echo elgg_view_page($title, $body); diff --git a/mod/twitter_api/start.php b/mod/twitter_api/start.php index 0c71104b5..b17643c8c 100644 --- a/mod/twitter_api/start.php +++ b/mod/twitter_api/start.php @@ -36,6 +36,9 @@ function twitter_api_init() { // push status messages to twitter elgg_register_plugin_hook_handler('status', 'user', 'twitter_api_tweet'); + + $actions = dirname(__FILE__) . '/actions/twitter_api'; + elgg_register_action('twitter_api/interstitial_settings', "$actions/interstitial_settings.php", 'logged_in'); } /** @@ -75,6 +78,18 @@ function twitter_api_pagehandler($page) { case 'login': twitter_api_login(); break; + case 'interstitial': + gatekeeper(); + // only let twitter users do this. + $guid = elgg_get_logged_in_user_guid(); + $twitter_name = elgg_get_plugin_user_setting('twitter_name', $guid, 'twitter_api'); + if (!$twitter_name) { + register_error(elgg_echo('twitter_api:invalid_page')); + forward(); + } + $pages = dirname(__FILE__) . '/pages/twitter_api'; + include "$pages/interstitial.php"; + break; default: forward(); break; diff --git a/mod/twitter_api/views/default/forms/twitter_api/interstitial_settings.php b/mod/twitter_api/views/default/forms/twitter_api/interstitial_settings.php new file mode 100644 index 000000000..fdeafd46d --- /dev/null +++ b/mod/twitter_api/views/default/forms/twitter_api/interstitial_settings.php @@ -0,0 +1,61 @@ +<?php +/** + * Make the user set up some alternative ways to login. + */ + +$user = elgg_get_logged_in_user_entity(); + +if (elgg_is_sticky_form('twitter_api_interstitial')) { + extract(elgg_get_sticky_values('twitter_api_interstitial')); + elgg_clear_sticky_form('twitter_api_interstitial'); +} + +if (!isset($display_name)) { + $display_name = $user->name; +} + +// username +$title = elgg_echo('username'); + +$body = elgg_echo('twitter_api:interstitial:username'); +$body .= elgg_view('input/text', array('value' => $user->username, 'disabled' => 'disabled')); + +echo elgg_view_module('info', $title, $body); + +// display name +$title = elgg_echo('name'); + +$body = elgg_echo('twitter_api:interstitial:name'); +$body .= elgg_view('input/text', array('name' => 'display_name', 'value' => $display_name)); + +echo elgg_view_module('info', $title, $body); + +// email +$title = elgg_echo('email'); + +$body = elgg_echo('twitter_api:interstitial:email'); +$body .= elgg_view('input/email', array('name' => 'email', 'value' => $email)); + +echo elgg_view_module('info', $title, $body); + +// password +$title = elgg_echo('password'); + +$body = elgg_echo('twitter_api:interstitial:password'); +$body .= elgg_view('input/password', array('name' => 'password_1')); +$body .= elgg_echo('twitter_api:interstitial:password2'); +$body .= elgg_view('input/password', array('name' => 'password_2')); + +echo elgg_view_module('info', $title, $body); + +// buttons + +echo elgg_view('input/submit', array( + 'text' => elgg_echo('save') +)); + +echo elgg_view('output/url', array( + 'class' => 'right', + 'text' => elgg_echo('twitter_api:interstitial:no_thanks'), + 'href' => '/', +));
\ No newline at end of file diff --git a/mod/twitter_api/views/default/usersettings/twitter_api/edit.php b/mod/twitter_api/views/default/usersettings/twitter_api/edit.php index 0898087ca..acb8d9af5 100644 --- a/mod/twitter_api/views/default/usersettings/twitter_api/edit.php +++ b/mod/twitter_api/views/default/usersettings/twitter_api/edit.php @@ -3,10 +3,11 @@ * User settings for Twitter API */ -$user_id = elgg_get_logged_in_user_guid(); -$twitter_name = get_plugin_usersetting('twitter_name', $user_id, 'twitter_api'); -$access_key = get_plugin_usersetting('access_key', $user_id, 'twitter_api'); -$access_secret = get_plugin_usersetting('access_secret', $user_id, 'twitter_api'); +$user = elgg_get_logged_in_user_entity(); +$user_guid = $user->getGUID(); +$twitter_name = get_plugin_usersetting('twitter_name', $user_guid, 'twitter_api'); +$access_key = get_plugin_usersetting('access_key', $user_guid, 'twitter_api'); +$access_secret = get_plugin_usersetting('access_secret', $user_guid, 'twitter_api'); $site_name = elgg_get_site_entity()->name; echo '<div>' . elgg_echo('twitter_api:usersettings:description', array($site_name)) . '</div>'; @@ -16,7 +17,13 @@ if (!$access_key || !$access_secret) { $request_link = twitter_api_get_authorize_url(null, false); echo '<div>' . elgg_echo('twitter_api:usersettings:request', array($request_link, $site_name)) . '</div>'; } else { - $url = elgg_get_site_url() . "twitter_api/revoke"; - echo '<div class="twitter_anywhere">' . elgg_echo('twitter_api:usersettings:authorized', array($site_name, $twitter_name)) . '</div>'; - echo '<div>' . sprintf(elgg_echo('twitter_api:usersettings:revoke'), $url) . '</div>'; + // if this user logged in through twitter and never set up an email address, don't + // let them disassociate their account. + if ($user->email) { + $url = elgg_get_site_url() . "twitter_api/revoke"; + echo '<div class="twitter_anywhere">' . elgg_echo('twitter_api:usersettings:authorized', array($site_name, $twitter_name)) . '</div>'; + echo '<div>' . sprintf(elgg_echo('twitter_api:usersettings:revoke'), $url) . '</div>'; + } else { + echo elgg_echo('twitter_api:usersettings:cannot_revoke', array(elgg_normalize_url('twitter_api/interstitial'))); + } } diff --git a/mod/uservalidationbyemail/views/default/forms/uservalidationbyemail/bulk_action.php b/mod/uservalidationbyemail/views/default/forms/uservalidationbyemail/bulk_action.php index f979d5e2c..2872b7a0c 100644 --- a/mod/uservalidationbyemail/views/default/forms/uservalidationbyemail/bulk_action.php +++ b/mod/uservalidationbyemail/views/default/forms/uservalidationbyemail/bulk_action.php @@ -40,7 +40,7 @@ elgg_set_ignore_access($ia); // setup pagination $pagination = elgg_view('navigation/pagination',array( - 'baseurl' => $vars['url'] . '/uservalidationbyemail/admin', + 'baseurl' => 'admin/users/unvalidated', 'offset' => $offset, 'count' => $count, 'limit' => $limit, |