aboutsummaryrefslogtreecommitdiff
path: root/mod/thewire
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-20 19:47:57 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-20 19:47:57 +0000
commit7c6ed461cf474739c5634a9fe050421c56a822bc (patch)
tree24127da8a8d615d396ead8645b8df856a6974831 /mod/thewire
parented64c2973998507f797270be069feb64999c4af2 (diff)
downloadelgg-7c6ed461cf474739c5634a9fe050421c56a822bc.tar.gz
elgg-7c6ed461cf474739c5634a9fe050421c56a822bc.tar.bz2
Fixes #3025 added back thewire's entity menu items
git-svn-id: http://code.elgg.org/elgg/trunk@8782 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/thewire')
-rw-r--r--mod/thewire/start.php83
1 files changed, 59 insertions, 24 deletions
diff --git a/mod/thewire/start.php b/mod/thewire/start.php
index c87831bee..0b2265082 100644
--- a/mod/thewire/start.php
+++ b/mod/thewire/start.php
@@ -27,8 +27,8 @@ function thewire_init() {
$item = new ElggMenuItem('thewire', elgg_echo('thewire'), 'thewire/all');
elgg_register_menu_item('site', $item);
- // remove entity menu items edit and access because they don't apply here.
- elgg_register_plugin_hook_handler('prepare', 'menu:entity', 'thewire_remove_entity_menu_items');
+ // remove edit and access and add thread, reply, view previous
+ elgg_register_plugin_hook_handler('register', 'menu:entity', 'thewire_setup_entity_menu_items');
// Extend system CSS with our own styles, which are defined in the thewire/css view
elgg_extend_view('css', 'thewire/css');
@@ -355,6 +355,63 @@ function thewire_get_parent($post_guid) {
}
/**
+ * Sets up the entity menu for thewire
+ *
+ * Adds reply, thread, and view previous links. Removes edit and access.
+ *
+ * @param string $hook
+ * @param string $type
+ * @param array $value
+ * @param array $params
+ * @return array
+ */
+function thewire_setup_entity_menu_items($hook, $type, $value, $params) {
+ $handler = elgg_extract('handler', $params, false);
+ if ($handler != 'thewire') {
+ return $value;
+ }
+
+ foreach ($value as $index => $item) {
+ $name = $item->getName();
+ if ($name == 'access' || $name == 'edit') {
+ unset($value[$index]);
+ }
+ }
+
+ $entity = $params['entity'];
+
+ if (elgg_is_logged_in()) {
+ $options = array(
+ 'name' => 'reply',
+ 'text' => elgg_echo('thewire:reply'),
+ 'href' => "thewire/reply/$entity->guid",
+ 'priority' => 150,
+ );
+ $value[] = ElggMenuItem::factory($options);
+ }
+
+ if ($entity->reply) {
+ $options = array(
+ 'name' => 'previous',
+ 'text' => elgg_echo('thewire:previous'),
+ 'href' => "thewire/previous/$entity->guid",
+ 'priority' => 160,
+ );
+ $value[] = ElggMenuItem::factory($options);
+ }
+
+ $options = array(
+ 'name' => 'thread',
+ 'text' => elgg_echo('thewire:thread'),
+ 'href' => "thewire/thread/$entity->wire_thread",
+ 'priority' => 170,
+ );
+ $value[] = ElggMenuItem::factory($options);
+
+ return $value;
+}
+
+/**
* Runs unit tests for the wire
*/
function thewire_test($hook, $type, $value, $params) {
@@ -362,25 +419,3 @@ function thewire_test($hook, $type, $value, $params) {
$value[] = $CONFIG->pluginspath . 'thewire/tests/regex.php';
return $value;
}
-
-/**
- * Removes the access and edit items from the entity menu
- *
- * @param type $hook
- * @param type $type
- * @param type $value
- * @param type $params
- * @return array
- */
-function thewire_remove_entity_menu_items($hook, $type, $value, $params) {
- if (elgg_in_context('thewire')) {
- $menu = elgg_extract('default', $value, array());
- foreach ($menu as $i => $entry) {
- $name = $entry->getName();
- if ($name == 'access' || $name == 'edit') {
- unset($value['default'][$i]);
- }
- }
- return $value;
- }
-} \ No newline at end of file