summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoachim Noreiko2013-02-17 09:34:32 (GMT)
committer Joachim Noreiko2013-02-17 09:34:32 (GMT)
commitf882f36673ce71b5872487a3073f8efb1b3d8487 (patch)
tree8ca6e4450a94d42ebb207aad151f474e11a02924
parentb196487c14bd05ef4f72bf392ee317269f29ca88 (diff)
Issue #1792584 by joachim, scor: Fixed flag links displayed twice on user profile.
-rw-r--r--flag.inc22
-rw-r--r--flag.module2
-rw-r--r--includes/flag.admin.inc4
3 files changed, 15 insertions, 13 deletions
diff --git a/flag.inc b/flag.inc
index ff20c47..501abf7 100644
--- a/flag.inc
+++ b/flag.inc
@@ -1361,12 +1361,14 @@ class flag_entity extends flag_flag {
'#title' => t('Display link on entity'),
'#default_value' => isset($this->show_on_entity) ? $this->show_on_entity : TRUE,
'#access' => empty($this->locked['show_on_entity']),
+ '#weight' => 0,
);
$form['display']['show_on_form'] = array(
'#type' => 'checkbox',
'#title' => t('Display checkbox on entity edit form'),
'#default_value' => $this->show_on_form,
'#access' => empty($this->locked['show_on_form']),
+ '#weight' => 5,
);
}
@@ -1541,6 +1543,7 @@ class flag_node extends flag_entity {
'#title' => t('Display in contextual links'),
'#default_value' => $this->show_contextual_link,
'#access' => empty($this->locked['show_contextual_link']) && module_exists('contextual'),
+ '#weight' => 10,
);
unset($form['display']['show_on_entity']);
@@ -1729,8 +1732,9 @@ class flag_comment extends flag_entity {
class flag_user extends flag_entity {
function options() {
$options = parent::options();
- // Use own display settings in the meanwhile.
- unset($options['show_on_entity']);
+ // We supersede, but do not supplant, the regular entity display with an
+ // option that's formatted in the style of user profiles.
+ $options['show_on_entity'] = FALSE;
$options += array(
'show_on_profile' => TRUE,
'access_uid' => '',
@@ -1758,11 +1762,14 @@ class flag_user extends flag_entity {
$form['display']['show_on_profile'] = array(
'#type' => 'checkbox',
'#title' => t('Display link on user profile page'),
+ '#description' => t('Show the link formatted as a user profile element.'),
'#default_value' => $this->show_on_profile,
'#access' => empty($this->locked['show_on_profile']),
+ // Put this above 'show on entity'.
+ '#weight' => -1,
);
-
- unset($form['display']['show_on_entity']);
+ // Explain how 'show on entity' is different.
+ $form['display']['show_on_entity']['#description'] = t('Show the link in the same format as on other entities.');
}
function form_input($form_values) {
@@ -1795,13 +1802,6 @@ class flag_user extends flag_entity {
return $access;
}
- function uses_hook_link($teaser) {
- if ($this->show_on_profile) {
- return TRUE;
- }
- return FALSE;
- }
-
function get_flag_action($content_id) {
$flag_action = parent::get_flag_action($content_id);
$user = $this->fetch_content($content_id);
diff --git a/flag.module b/flag.module
index 5b50d3b..dcbc858 100644
--- a/flag.module
+++ b/flag.module
@@ -862,7 +862,7 @@ function flag_user_view($account, $view_mode) {
// User has no permission to use this flag.
continue;
}
- if (!$flag->uses_hook_link(array())) {
+ if (!$flag->show_on_profile) {
// Flag not set to appear on profile.
continue;
}
diff --git a/includes/flag.admin.inc b/includes/flag.admin.inc
index 4a76e3f..7541cdb 100644
--- a/includes/flag.admin.inc
+++ b/includes/flag.admin.inc
@@ -472,7 +472,9 @@ function flag_form($form, &$form_state, $flag) {
'#option_descriptions' => _flag_link_type_descriptions(),
'#after_build' => array('flag_expand_link_option', 'flag_check_link_types'),
'#default_value' => $flag->link_type,
- '#weight' => 2,
+ // Give this a high weight so additions by the flag classes for entity-
+ // specific options go above.
+ '#weight' => 18,
'#access' => empty($flag->locked['link_type']),
);