From 6547efb9ae89c1477930c69ac2dbe73350673a66 Mon Sep 17 00:00:00 2001 From: Jeff Tilson Date: Mon, 13 Jun 2011 14:38:46 -0400 Subject: Added 'remove from group' link to the user hover menu (only appears when the page owner is a group) --- mod/groups/start.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'mod/groups/start.php') diff --git a/mod/groups/start.php b/mod/groups/start.php index 73bdd08a9..9a375e89d 100644 --- a/mod/groups/start.php +++ b/mod/groups/start.php @@ -44,6 +44,7 @@ function groups_init() { elgg_register_action("groups/invite", "$action_base/invite.php"); elgg_register_action("groups/join", "$action_base/join.php"); elgg_register_action("groups/leave", "$action_base/leave.php"); + elgg_register_action("groups/remove", "$action_base/remove.php"); elgg_register_action("groups/killrequest", "$action_base/delete_request.php"); elgg_register_action("groups/killinvitation", "$action_base/delete_invite.php"); elgg_register_action("groups/addtogroup", "$action_base/add.php"); @@ -60,6 +61,9 @@ function groups_init() { // group entity menu elgg_register_plugin_hook_handler('register', 'menu:entity', 'groups_entity_menu_setup'); + + // group user hover menu + elgg_register_plugin_hook_handler('register', 'menu:user_hover', 'groups_user_entity_menu_setup'); //extend some views elgg_extend_view('css/elgg', 'groups/css'); @@ -366,6 +370,44 @@ function groups_entity_menu_setup($hook, $type, $return, $params) { return $return; } +/** + * Add a remove user link to user hover menu when the page owner is a group + */ +function groups_user_entity_menu_setup($hook, $type, $return, $params) { + if (elgg_is_logged_in()) { + $group = elgg_get_page_owner_entity(); + + // Check for valid group + if (!elgg_instanceof($group, 'group')) { + return $return; + } + + $entity = $params['entity']; + + // Make sure we have a user and that user is a member of the group + if (!elgg_instanceof($entity, 'user') || !$group->isMember($entity)) { + return $return; + } + + // Add remove link if we can edit the group, and if we're not trying to remove the group owner + if ($group->canEdit() && $group->getOwnerGUID() != $entity->guid) { + $remove = elgg_view('output/confirmlink', array( + 'href' => "action/groups/remove?user_guid={$entity->guid}&group_guid={$group->guid}", + 'text' => elgg_echo('groups:removeuser'), + )); + + $options = array( + 'name' => 'removeuser', + 'text' => $remove, + 'priority' => 999, + ); + $return[] = ElggMenuItem::factory($options); + } + } + + return $return; +} + /** * Groups created so create an access list for it */ -- cgit v1.2.3 From b766230d132bedf68ec3c63f72538fefa54c62e2 Mon Sep 17 00:00:00 2001 From: Evan Winslow Date: Mon, 13 Jun 2011 22:23:09 -0700 Subject: Renamed river footer to a more semantic "responses". Fixed discussion to work inline again with this new layout. --- mod/groups/start.php | 3 +- .../river/object/groupforumtopic/create.php | 7 --- views/default/river/elements/body.php | 4 +- views/default/river/elements/footer.php | 52 ---------------------- views/default/river/elements/responses.php | 52 ++++++++++++++++++++++ 5 files changed, 56 insertions(+), 62 deletions(-) delete mode 100644 views/default/river/elements/footer.php create mode 100644 views/default/river/elements/responses.php (limited to 'mod/groups/start.php') diff --git a/mod/groups/start.php b/mod/groups/start.php index 73bdd08a9..5aaba017c 100644 --- a/mod/groups/start.php +++ b/mod/groups/start.php @@ -621,7 +621,8 @@ function discussion_init() { // commenting not allowed on discussion topics (use a different annotation) elgg_register_plugin_hook_handler('permissions_check:comment', 'object', 'discussion_comment_override'); - + elgg_extend_view('river/elements/responses', 'discussion/river'); + $action_base = elgg_get_plugins_path() . 'groups/actions/discussion'; elgg_register_action('discussion/save', "$action_base/save.php"); elgg_register_action('discussion/delete', "$action_base/delete.php"); diff --git a/mod/groups/views/default/river/object/groupforumtopic/create.php b/mod/groups/views/default/river/object/groupforumtopic/create.php index cca44e523..f92e54a5c 100644 --- a/mod/groups/views/default/river/object/groupforumtopic/create.php +++ b/mod/groups/views/default/river/object/groupforumtopic/create.php @@ -11,10 +11,3 @@ echo elgg_view('river/item', array( 'item' => $vars['item'], 'message' => $excerpt, )); - -if (elgg_is_logged_in() && $object->canAnnotate(0, 'group_topic_post')) { - // inline comment form - $form_vars = array('id' => "groups-reply-{$object->getGUID()}", 'class' => 'hidden'); - $body_vars = array('entity' => $object, 'inline' => true); - echo elgg_view_form('discussion/reply/save', $form_vars, $body_vars); -} diff --git a/views/default/river/elements/body.php b/views/default/river/elements/body.php index a76cae909..080c04644 100644 --- a/views/default/river/elements/body.php +++ b/views/default/river/elements/body.php @@ -32,7 +32,7 @@ if ($attachments !== false) { $attachments = "
$attachments
"; } -$footer = elgg_view('river/elements/footer', $vars); +$responses = elgg_view('river/elements/responses', $vars); $group_string = ''; $object = $item->getObjectEntity(); @@ -50,5 +50,5 @@ $menu
$summary $group_string $timestamp
$message $attachments -$footer +$responses RIVER; diff --git a/views/default/river/elements/footer.php b/views/default/river/elements/footer.php deleted file mode 100644 index f1e79f131..000000000 --- a/views/default/river/elements/footer.php +++ /dev/null @@ -1,52 +0,0 @@ -getObjectEntity(); - -// annotations do not have comments -if ($item->annotation_id != 0 || !$object) { - return true; -} - -$comment_count = $object->countComments(); - -$options = array( - 'guid' => $object->getGUID(), - 'annotation_name' => 'generic_comment', - 'limit' => 3, - 'order_by' => 'n_table.time_created desc' -); -$comments = elgg_get_annotations($options); - -if ($comments) { - // why is this reversing it? because we're asking for the 3 latest - // comments by sorting desc and limiting by 3, but we want to display - // these comments with the latest at the bottom. - $comments = array_reverse($comments); - -?> - - - 'elgg-river-comments')); - - if ($comment_count > count($comments)) { - $num_more_comments = $comment_count - count($comments); - $url = $object->getURL(); - $params = array( - 'href' => $url, - 'text' => elgg_echo('river:comments:more', array($num_more_comments)), - ); - $link = elgg_view('output/url', $params); - echo "
$link
"; - } -} - -// inline comment form -$form_vars = array('id' => "comments-add-{$object->getGUID()}", 'class' => 'hidden'); -$body_vars = array('entity' => $object, 'inline' => true); -echo elgg_view_form('comments/add', $form_vars, $body_vars); diff --git a/views/default/river/elements/responses.php b/views/default/river/elements/responses.php new file mode 100644 index 000000000..f1e79f131 --- /dev/null +++ b/views/default/river/elements/responses.php @@ -0,0 +1,52 @@ +getObjectEntity(); + +// annotations do not have comments +if ($item->annotation_id != 0 || !$object) { + return true; +} + +$comment_count = $object->countComments(); + +$options = array( + 'guid' => $object->getGUID(), + 'annotation_name' => 'generic_comment', + 'limit' => 3, + 'order_by' => 'n_table.time_created desc' +); +$comments = elgg_get_annotations($options); + +if ($comments) { + // why is this reversing it? because we're asking for the 3 latest + // comments by sorting desc and limiting by 3, but we want to display + // these comments with the latest at the bottom. + $comments = array_reverse($comments); + +?> + + + 'elgg-river-comments')); + + if ($comment_count > count($comments)) { + $num_more_comments = $comment_count - count($comments); + $url = $object->getURL(); + $params = array( + 'href' => $url, + 'text' => elgg_echo('river:comments:more', array($num_more_comments)), + ); + $link = elgg_view('output/url', $params); + echo "
$link
"; + } +} + +// inline comment form +$form_vars = array('id' => "comments-add-{$object->getGUID()}", 'class' => 'hidden'); +$body_vars = array('entity' => $object, 'inline' => true); +echo elgg_view_form('comments/add', $form_vars, $body_vars); -- cgit v1.2.3 From 9400f73770d2b50e42cc44a64c5f5888e52a8948 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sun, 26 Jun 2011 07:20:35 -0400 Subject: not displaying the reply button for discussion topics in widgets --- mod/groups/start.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'mod/groups/start.php') diff --git a/mod/groups/start.php b/mod/groups/start.php index 066b309a5..f35c058b6 100644 --- a/mod/groups/start.php +++ b/mod/groups/start.php @@ -663,7 +663,6 @@ function discussion_init() { // commenting not allowed on discussion topics (use a different annotation) elgg_register_plugin_hook_handler('permissions_check:comment', 'object', 'discussion_comment_override'); - elgg_extend_view('river/elements/responses', 'discussion/river'); $action_base = elgg_get_plugins_path() . 'groups/actions/discussion'; elgg_register_action('discussion/save', "$action_base/save.php"); @@ -765,7 +764,7 @@ function discussion_owner_block_menu($hook, $type, $return, $params) { * Add the reply button for the river */ function discussion_add_to_river_menu($hook, $type, $return, $params) { - if (elgg_is_logged_in()) { + if (elgg_is_logged_in() && !elgg_get_context('widgets')) { $item = $params['item']; $object = $item->getObjectEntity(); if (elgg_instanceof($object, 'object', 'groupforumtopic')) { -- cgit v1.2.3 From 32387e6db0c56935e93314217b52eab4d9dca016 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sun, 26 Jun 2011 08:16:19 -0400 Subject: Fixes #3470 using rel=toggle now --- engine/classes/ElggMenuItem.php | 4 ++++ engine/lib/navigation.php | 2 +- js/lib/ui.js | 6 +++--- mod/groups/start.php | 4 ++-- mod/logbrowser/views/default/logbrowser/form.php | 8 ++++---- mod/profile/views/default/profile/owner_block.php | 2 +- mod/reportedcontent/views/default/object/reported_content.php | 2 +- views/default/object/plugin/advanced.php | 2 +- views/default/object/plugin/invalid.php | 2 +- views/default/object/widget/elements/controls.php | 6 ++++-- views/default/page/layouts/widgets/add_button.php | 11 ++++++++--- 11 files changed, 30 insertions(+), 19 deletions(-) (limited to 'mod/groups/start.php') diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php index cd6267ad6..1181583f2 100644 --- a/engine/classes/ElggMenuItem.php +++ b/engine/classes/ElggMenuItem.php @@ -504,6 +504,10 @@ class ElggMenuItem { $vars['class'] = $this->getLinkClass(); } + if ($this->link_rel) { + $vars['rel'] = $this->link_rel; + } + if ($this->rel) { $vars['rel'] = $this->rel; } diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php index b51c63b49..4b2c998a2 100644 --- a/engine/lib/navigation.php +++ b/engine/lib/navigation.php @@ -276,7 +276,7 @@ function elgg_river_menu_setup($hook, $type, $return, $params) { 'href' => "#comments-add-$object->guid", 'text' => elgg_view_icon('speech-bubble'), 'title' => elgg_echo('comment:this'), - 'link_class' => "elgg-toggler", + 'link_rel' => 'toggle', 'priority' => 50, ); $return[] = ElggMenuItem::factory($options); diff --git a/js/lib/ui.js b/js/lib/ui.js index 89a996122..fd20acbd1 100644 --- a/js/lib/ui.js +++ b/js/lib/ui.js @@ -11,7 +11,7 @@ elgg.ui.init = function () { $('.elgg-system-messages li').animate({opacity: 0.9}, 6000); $('.elgg-system-messages li').fadeOut('slow'); - $('.elgg-toggler').live('click', elgg.ui.toggles); + $('[rel=toggle]').live('click', elgg.ui.toggles); $('[rel=popup]').live('click', elgg.ui.popsUp); @@ -27,8 +27,8 @@ elgg.ui.init = function () { /** * Toggles an element based on clicking a separate element * - * Use .elgg-toggler on the toggler element - * Set the href to target the item you want to toggle () + * Use rel="toggle" on the toggler element + * Set the href to target the item you want to toggle () * * @param {Object} event * @return void diff --git a/mod/groups/start.php b/mod/groups/start.php index f35c058b6..57c40af5d 100644 --- a/mod/groups/start.php +++ b/mod/groups/start.php @@ -764,7 +764,7 @@ function discussion_owner_block_menu($hook, $type, $return, $params) { * Add the reply button for the river */ function discussion_add_to_river_menu($hook, $type, $return, $params) { - if (elgg_is_logged_in() && !elgg_get_context('widgets')) { + if (elgg_is_logged_in() && !elgg_in_context('widgets')) { $item = $params['item']; $object = $item->getObjectEntity(); if (elgg_instanceof($object, 'object', 'groupforumtopic')) { @@ -776,7 +776,7 @@ function discussion_add_to_river_menu($hook, $type, $return, $params) { 'href' => "#groups-reply-$object->guid", 'text' => elgg_view_icon('speech-bubble'), 'title' => elgg_echo('reply:this'), - 'link_class' => "elgg-toggler", + 'link_rel' => 'toggle', 'priority' => 50, ); $return[] = ElggMenuItem::factory($options); diff --git a/mod/logbrowser/views/default/logbrowser/form.php b/mod/logbrowser/views/default/logbrowser/form.php index d2476afac..d5cf9f6b8 100644 --- a/mod/logbrowser/views/default/logbrowser/form.php +++ b/mod/logbrowser/views/default/logbrowser/form.php @@ -59,9 +59,12 @@ $toggle_link = elgg_view('output/url', array( 'href' => '#log-browser-search-form', 'text' => elgg_echo('logbrowser:search'), - 'class' => 'elgg-toggler', + 'rel' => 'toggle', )); ?> +

+ +

-

- -

\ No newline at end of file diff --git a/mod/profile/views/default/profile/owner_block.php b/mod/profile/views/default/profile/owner_block.php index 48d7ff24f..5a65a3a26 100644 --- a/mod/profile/views/default/profile/owner_block.php +++ b/mod/profile/views/default/profile/owner_block.php @@ -35,7 +35,7 @@ if (elgg_is_admin_logged_in() && elgg_get_logged_in_user_guid() != elgg_get_page $text = elgg_echo('admin:options'); $admin_links = '
    '; - $admin_links .= "
  • $text…"; + $admin_links .= "
  • $text…"; $admin_links .= '
      '; foreach ($admin as $menu_item) { $admin_links .= elgg_view('navigation/menu/elements/item', array('item' => $menu_item)); diff --git a/mod/reportedcontent/views/default/object/reported_content.php b/mod/reportedcontent/views/default/object/reported_content.php index b8c443450..6bcbf6e5d 100644 --- a/mod/reportedcontent/views/default/object/reported_content.php +++ b/mod/reportedcontent/views/default/object/reported_content.php @@ -58,7 +58,7 @@ if ($report->state == 'archived') { "#report-$report->guid", 'text' => elgg_echo('reportedcontent:moreinfo'), - 'class' => "elgg-toggler", + 'rel' => "toggle", )); ?>

      diff --git a/views/default/object/plugin/advanced.php b/views/default/object/plugin/advanced.php index 51fb69d17..84fc0439b 100644 --- a/views/default/object/plugin/advanced.php +++ b/views/default/object/plugin/advanced.php @@ -242,7 +242,7 @@ if (elgg_view_exists($settings_view_old) || elgg_view_exists($settings_view_new) echo elgg_view('output/url', array( 'href' => "#elgg-plugin-manifest-{$plugin->getID()}", 'text' => elgg_echo("admin:plugins:label:moreinfo"), - 'class' => 'elgg-toggler', + 'rel' => 'toggle', )); ?> diff --git a/views/default/object/plugin/invalid.php b/views/default/object/plugin/invalid.php index 9e239b7ca..f29ee8d12 100644 --- a/views/default/object/plugin/invalid.php +++ b/views/default/object/plugin/invalid.php @@ -29,7 +29,7 @@ $error = $plugin->getError(); echo elgg_view('output/url', array( 'href' => "#elgg-plugin-manifest-{$plugin->getID()}", 'text' => elgg_echo("admin:plugins:label:moreinfo"), - 'class' => 'elgg-toggler', + 'rel' => 'toggle', )); ?> diff --git a/views/default/object/widget/elements/controls.php b/views/default/object/widget/elements/controls.php index 83a2f5767..abf2154fc 100644 --- a/views/default/object/widget/elements/controls.php +++ b/views/default/object/widget/elements/controls.php @@ -12,7 +12,8 @@ $show_edit = elgg_extract('show_edit', $vars, true); $params = array( 'text' => ' ', 'href' => "#elgg-widget-content-$widget->guid", - 'class' => 'elgg-widget-collapse-button elgg-toggler', + 'class' => 'elgg-widget-collapse-button', + 'rel' => 'toggle', ); $collapse_link = elgg_view('output/url', $params); @@ -33,7 +34,8 @@ if ($widget->canEdit()) { 'text' => elgg_view_icon('settings-alt'), 'title' => elgg_echo('widget:edit'), 'href' => "#widget-edit-$widget->guid", - 'class' => "elgg-toggler elgg-widget-edit-button", + 'class' => "elgg-widget-edit-button", + 'rel' => 'toggle', ); $edit_link = elgg_view('output/url', $params); } diff --git a/views/default/page/layouts/widgets/add_button.php b/views/default/page/layouts/widgets/add_button.php index a8670146b..89e83b096 100644 --- a/views/default/page/layouts/widgets/add_button.php +++ b/views/default/page/layouts/widgets/add_button.php @@ -4,7 +4,12 @@ */ ?>
      - - - + '#widgets-add-panel', + 'text' => elgg_echo('widgets:add'), + 'class' => 'elgg-button elgg-button-action', + 'rel' => 'toggle', + )); +?>
      -- cgit v1.2.3 From e43d4443e6e9718433496b739f0af6630aad9e95 Mon Sep 17 00:00:00 2001 From: cash Date: Sun, 26 Jun 2011 14:02:36 -0400 Subject: added a data array to ElggMenuItem. Now by default options end up being passed to output/url. --- engine/classes/ElggMenuItem.php | 273 ++++++++++++++++++++++------------------ engine/lib/navigation.php | 2 +- mod/groups/start.php | 2 +- 3 files changed, 152 insertions(+), 125 deletions(-) (limited to 'mod/groups/start.php') diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php index 1181583f2..36c21b8b4 100644 --- a/engine/classes/ElggMenuItem.php +++ b/engine/classes/ElggMenuItem.php @@ -10,75 +10,62 @@ * @since 1.8.0 */ class ElggMenuItem { - /** - * @var string Identifier of the menu - */ - protected $name; /** - * @var string The menu display string + * @var array Non-rendered data about the menu item */ - protected $text; + protected $data = array( + // string Identifier of the menu + 'name' => '', - /** - * @var string The menu url - */ - protected $href = null; + // array Page contexts this menu item should appear on + 'contexts' => array('all'), - /** - * @var string The string to display if link is clicked - */ - protected $confirm = ''; + // string Menu section identifier + 'section' => 'default', - /** - * @var array Classes to apply to the anchor tag. - */ - protected $linkClass = array(); + // int Smaller priorities float to the top + 'priority' => 100, - /** - * @var array Classes to apply to the li tag. - */ - protected $itemClass = array(); + // bool Is this the currently selected menu item + 'selected' => false, - /** - * @var array Page context array - */ - protected $contexts = array('all'); + // string Identifier of this item's parent + 'parent_name' => '', - /** - * @var string Menu section identifier - */ - protected $section = 'default'; + // ElggMenuItem The parent object or null + 'parent' => null, - /** - * @var string Tooltip - */ - protected $title = ''; + // array Array of children objects or empty array + 'children' => array(), - /** - * @var int Menu priority - smaller prioritys float to the top - */ - protected $priority = 100; + // array Classes to apply to the li tag + 'itemClass' => array(), + + // array Classes to apply to the anchor tag + 'linkClass' => array(), + ); /** - * @var bool Is this the currently selected menu item + * @var string The menu display string */ - protected $selected = false; + protected $text; /** - * @var string Identifier of this item's parent + * @var string The menu url */ - protected $parent_name = ''; + protected $href = null; /** - * @var ElggMenuItem The parent object or null + * @var string Tooltip */ - protected $parent = null; + protected $title = ''; /** - * @var array Array of children objects or empty array + * @var string The string to display if link is clicked */ - protected $children = array(); + protected $confirm = ''; + /** * ElggMenuItem constructor @@ -88,13 +75,15 @@ class ElggMenuItem { * @param string $href URL of the menu item (false if not a link) */ public function __construct($name, $text, $href) { - $this->name = $name; + //$this->name = $name; $this->text = $text; if ($href) { $this->href = elgg_normalize_url($href); } else { $this->href = $href; } + + $this->data['name'] = $name; } /** @@ -122,6 +111,12 @@ class ElggMenuItem { $options['contexts'] = $options['context']; unset($options['context']); } + + // make sure contexts is set correctly + if (isset($options['contexts'])) { + $item->setContext($options['contexts']); + unset($options['contexts']); + } if (isset($options['link_class'])) { $item->setLinkClass($options['link_class']); @@ -133,16 +128,62 @@ class ElggMenuItem { unset($options['item_class']); } + if (isset($options['data']) && is_array($options['data'])) { + $item->setData($options['data']); + unset($options['data']); + } + foreach ($options as $key => $value) { - $item->$key = $value; + if (isset($item->data[$key])) { + $item->data[$key] = $value; + } else { + $item->$key = $value; + } } - // make sure contexts is set correctly - if (isset($options['contexts'])) { - $item->setContext($options['contexts']); + return $item; + } + + /** + * Set a data key/value pair or a set of key/value pairs + * + * This method allows storage of arbitrary data with this menu item. The + * data can be used for sorting, custom rendering, or any other use. + * + * @param mixed $key String key or an associative array of key/value pairs + * @param mixed $value The value if $key is a string + * @return void + */ + public function setData($key, $value = null) { + if (is_array($key)) { + $this->data += $key; + } else { + $this->data[$key] = $value; } + } - return $item; + /** + * Get stored data + * + * @param string $key The key for the requested key/value pair + * @return mixed + */ + public function getData($key) { + if (isset($this->data[$key])) { + return $this->data[$key]; + } else { + return null; + } + } + + /** + * Set the identifier of the menu item + * + * @param string Unique identifier + * @return void + */ + public function setName($name) { + $this->data['name'] = $name; } /** @@ -151,14 +192,13 @@ class ElggMenuItem { * @return string */ public function getName() { - return $this->name; + return $this->data['name']; } - + /** * Set the display text of the menu item * * @param string $text The display text - * * @return void */ public function setText($text) { @@ -177,6 +217,7 @@ class ElggMenuItem { /** * Set the URL of the menu item * + * @param string $href URL or false if not a link * @return void */ public function setHref($href) { @@ -196,14 +237,13 @@ class ElggMenuItem { * Set the contexts that this menu item is available for * * @param array $contexts An array of context strings - * * @return void */ public function setContext($contexts) { if (is_string($contexts)) { $contexts = array($contexts); } - $this->contexts = $contexts; + $this->data['contexts'] = $contexts; } /** @@ -212,27 +252,26 @@ class ElggMenuItem { * @return array */ public function getContext() { - return $this->contexts; + return $this->data['contexts']; } /** * Should this menu item be used given the current context * * @param string $context A context string (default is empty string for - * current context stack. - * + * current context stack). * @return bool */ public function inContext($context = '') { if ($context) { - return in_array($context, $this->contexts); + return in_array($context, $this->data['contexts']); } - if (in_array('all', $this->contexts)) { + if (in_array('all', $this->data['contexts'])) { return true; } - foreach ($this->contexts as $context) { + foreach ($this->data['contexts'] as $context) { if (elgg_in_context($context)) { return true; } @@ -244,11 +283,10 @@ class ElggMenuItem { * Set the selected flag * * @param bool $state Selected state (default is true) - * * @return void */ public function setSelected($state = true) { - $this->selected = $state; + $this->data['selected'] = $state; } /** @@ -257,14 +295,13 @@ class ElggMenuItem { * @return bool */ public function getSelected() { - return $this->selected; + return $this->data['selected']; } /** * Set the tool tip text * * @param string $text The text of the tool tip - * * @return void */ public function setTooltip($text) { @@ -284,7 +321,6 @@ class ElggMenuItem { * Set the confirm text shown when link is clicked * * @param string $text The text to show - * * @return void */ public function setConfirmText($text) { @@ -304,14 +340,13 @@ class ElggMenuItem { * Set the anchor class * * @param mixed $class An array of class names, or a single string class name. - * * @return void */ public function setLinkClass($class) { if (!is_array($class)) { - $this->linkClass[] = $class; + $this->data['linkClass'] = array($class); } else { - $this->linkClass = $class; + $this->data['linkClass'] = $class; } } @@ -321,21 +356,34 @@ class ElggMenuItem { * @return string */ public function getLinkClass() { - return implode(' ', $this->linkClass); + return implode(' ', $this->data['linkClass']); } /** - * Set the li classes + * Add a link class * * @param mixed $class An array of class names, or a single string class name. + * @return void + */ + public function addLinkClass($class) { + if (!is_array($class)) { + $this->data['linkClass'][] = $class; + } else { + $this->data['linkClass'] += $class; + } + } + + /** + * Set the li classes * + * @param mixed $class An array of class names, or a single string class name. * @return void */ public function setItemClass($class) { if (!is_array($class)) { - $this->itemClass[] = $class; + $this->data['itemClass'] = array($class); } else { - $this->itemClass = $class; + $this->data['itemClass'] = $class; } } @@ -345,11 +393,11 @@ class ElggMenuItem { * @return string */ public function getItemClass() { - //allow people to specify name with underscores and colons + // allow people to specify name with underscores and colons $name = str_replace('_', '-', $this->getName()); $name = str_replace(':', '-', $name); - $class = implode(' ', $this->itemClass); + $class = implode(' ', $this->data['itemClass']); if ($class) { return "elgg-menu-item-$name $class"; } else { @@ -361,11 +409,10 @@ class ElggMenuItem { * Set the priority of the menu item * * @param int $priority The smaller numbers mean higher priority (1 before 100) - * * @return void */ public function setWeight($priority) { - $this->priority = $priority; + $this->data['priority'] = $priority; } /** @@ -374,18 +421,17 @@ class ElggMenuItem { * @return int */ public function getWeight() { - return $this->priority; + return $this->data['priority']; } /** * Set the section identifier * * @param string $section The identifier of the section - * * @return void */ public function setSection($section) { - $this->section = $section; + $this->data['section'] = $section; } /** @@ -394,18 +440,17 @@ class ElggMenuItem { * @return string */ public function getSection() { - return $this->section; + return $this->data['section']; } /** * Set the parent identifier * - * @param string $parent_name The identifier of the parent ElggMenuItem - * + * @param string $name The identifier of the parent ElggMenuItem * @return void */ - public function setParentName($parent_name) { - $this->parent_name = $parent_name; + public function setParentName($name) { + $this->data['parent_name'] = $name; } /** @@ -414,18 +459,17 @@ class ElggMenuItem { * @return string */ public function getParentName() { - return $this->parent_name; + return $this->data['parent_name']; } /** * Set the parent menu item * * @param ElggMenuItem $parent - * * @return void */ public function setParent($parent) { - $this->parent = $parent; + $this->data['parent'] = $parent; } /** @@ -434,29 +478,27 @@ class ElggMenuItem { * @return ElggMenuItem or null */ public function getParent() { - return $this->parent; + return $this->data['parent']; } /** * Add a child menu item * * @param ElggMenuItem $item - * * @return void */ public function addChild($item) { - $this->children[] = $item; + $this->data['children'][] = $item; } /** * Set the menu item's children * * @param array $children Array of ElggMenuItems - * * @return void */ public function setChildren($children) { - $this->children = $children; + $this->data['children'] = $children; } /** @@ -465,25 +507,23 @@ class ElggMenuItem { * @return array */ public function getChildren() { - return $this->children; + return $this->data['children']; } /** * Sort the children * - * @param string $sort_function - * + * @param string $sortFunction A function that is passed to usort() * @return void */ - public function sortChildren($sort_function) { - usort($this->children, $sort_function); + public function sortChildren($sortFunction) { + usort($this->data['children'], $sortFunction); } /** * Get the menu item content (usually a link) * * @params array $vars Options to pass to output/url if a link - * * @return string * * @todo View code in a model. How do we feel about that? @@ -494,30 +534,17 @@ class ElggMenuItem { return $this->text; } - $vars['text'] = $this->text; + $defaults = get_object_vars($this); + unset($defaults['data']); - if ($this->href) { - $vars['href'] = $this->href; - } + $vars += $defaults; - if ($this->linkClass) { - $vars['class'] = $this->getLinkClass(); - } - - if ($this->link_rel) { - $vars['rel'] = $this->link_rel; - } - - if ($this->rel) { - $vars['rel'] = $this->rel; - } - - if ($this->title) { - $vars['title'] = $this->title; - } - - if ($this->is_action) { - $vars['is_action'] = $this->is_action; + if ($this->data['linkClass']) { + if (isset($vars['class'])) { + $vars['class'] += $this->getLinkClass(); + } else { + $vars['class'] = $this->getLinkClass(); + } } if ($this->confirm) { diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php index 4b2c998a2..48a3659f6 100644 --- a/engine/lib/navigation.php +++ b/engine/lib/navigation.php @@ -276,7 +276,7 @@ function elgg_river_menu_setup($hook, $type, $return, $params) { 'href' => "#comments-add-$object->guid", 'text' => elgg_view_icon('speech-bubble'), 'title' => elgg_echo('comment:this'), - 'link_rel' => 'toggle', + 'rel' => 'toggle', 'priority' => 50, ); $return[] = ElggMenuItem::factory($options); diff --git a/mod/groups/start.php b/mod/groups/start.php index 57c40af5d..83353bae5 100644 --- a/mod/groups/start.php +++ b/mod/groups/start.php @@ -776,7 +776,7 @@ function discussion_add_to_river_menu($hook, $type, $return, $params) { 'href' => "#groups-reply-$object->guid", 'text' => elgg_view_icon('speech-bubble'), 'title' => elgg_echo('reply:this'), - 'link_rel' => 'toggle', + 'rel' => 'toggle', 'priority' => 50, ); $return[] = ElggMenuItem::factory($options); -- cgit v1.2.3 From 6f4ca315db3a8c162fe032e79a9b27f16732bf2d Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Wed, 24 Aug 2011 20:38:12 -0700 Subject: Fixes #3612, #3750. Added edit replies back to group plugin with the annotation menu. --- mod/groups/actions/discussion/reply/save.php | 35 +++++++++++----- mod/groups/start.php | 48 ++++++++++++++++++++++ .../views/default/annotation/group_topic_post.php | 17 ++++++-- .../views/default/forms/discussion/reply/save.php | 32 +++++++++++++-- .../views/default/annotation/messageboard.php | 11 ----- 5 files changed, 115 insertions(+), 28 deletions(-) delete mode 100644 mod/messageboard/views/default/annotation/messageboard.php (limited to 'mod/groups/start.php') 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/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'); @@ -408,6 +411,51 @@ function groups_user_entity_menu_setup($hook, $type, $return, $params) { return $return; } +/** + * 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' => "", + '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 */ 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 @@ canEdit()) { + $form = elgg_view_form('discussion/reply/save', array(), array_merge(array( + 'entity' => get_entity($annotation->entity_guid), + 'annotation' => $annotation + ), $vars) + ); + + echo "
      id\">$form
      "; +} + 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 { ?>
      - - 'group_topic_post')); ?> + + 'group_topic_post', 'value' => $value)); ?>
      elgg_echo('save'))); + } else { echo elgg_view('input/submit', array('value' => elgg_echo('reply'))); + } ?>