Vain hakemistossa rules_link_orig: rules_link2.module diff -ru rules_link_orig/rules_link.module rules_link/rules_link.module --- rules_link_orig/rules_link.module 2015-05-13 09:08:39.000000000 -0500 +++ rules_link/rules_link.module 2018-07-09 18:11:15.743110053 -0500 @@ -189,6 +189,11 @@ $path .= '/' . implode('/', $parameters); } $path .= $rules_link->settings['link_type'] == 'confirm' ? '' : '/' . rules_link_get_token($entity_id); + + //destination is set correctly in view. print destination parameter to url. + if (!empty($destination) && !empty($destination['path_set_in_view']) && $destination['path_set_in_view'] == true) { + $path .= '?destination=' . $destination['destination']; + } $link = array( '#title' => $rules_link->getSettingTranslation('text'), @@ -202,8 +207,11 @@ drupal_add_js(drupal_get_path('module', 'rules_link') . '/rules_link.js', 'file'); drupal_add_css(drupal_get_path('module', 'rules_link') . '/rules_link.css', 'file'); } + //this is the old behaviour used if destination is not set in view or is set bad. else { - $link['#options'] = array('query' => $destination); + if (!empty($destination) && !empty($destination['path_set_in_view']) && $destination['path_set_in_view'] == false) { + $link['#options'] = array('query' => $destination); + } } return $link; } diff -ru rules_link_orig/rules_link.views.inc rules_link/rules_link.views.inc --- rules_link_orig/rules_link.views.inc 2015-05-13 09:08:39.000000000 -0500 +++ rules_link/rules_link.views.inc 2018-06-22 19:01:48.355539090 -0500 @@ -36,7 +36,33 @@ // Trim the spaces from the array_walk($parameters, 'rules_link_trim_parameters'); - + + //if views field destination parameter is empty fall back to old validation of destination. + if (!empty($this->options['rules_link']['rules_link_destination'])) { + $destination = strtr($this->options['rules_link']['rules_link_destination'], $this->get_render_tokens('')); + + //validate given path and retun true if it's OK. + $validated = drupal_valid_path($destination, $dynamic_allowed = FALSE); + } + else { + //if destination field in view is empty -> old behaviour. + $validated = false; + } + + //destination is filled in a view and it's a valid & user accessible path. + if (!empty($destination) && $validated == true) { + $destination_build = array( + 'destination' => $destination, + 'path_set_in_view' => true, + ); + } + + //destination empty or path given in view destination field was a fail. -> back to old behaviour. + if (empty($destination) || $validated == false) { + $destination_build = drupal_get_destination(); + $destination_build['path_set_in_view'] = false; + } + $rules_link = rules_link_load($this->definition['rules link name']); $entity = $this->get_value($value); list($id, $rev, $bundle) = entity_extract_ids($rules_link->entity_type, $entity); @@ -44,7 +70,7 @@ // If there are multiple bundle types, we only have to display the links to // the entities which have the correct bundle. if (empty($rules_link->settings['bundles']) || in_array($bundle, $rules_link->settings['bundles'])) { - $output = rules_link_render_link($rules_link, $id, drupal_get_destination(), $parameters); + $output = rules_link_render_link($rules_link, $id, $destination_build, $parameters); if (!empty($output)) { $this->options['alter']['make_link'] = TRUE; $this->options['alter']['path'] = $output['#href']; @@ -67,6 +93,7 @@ $options = parent::option_definition(); $options['rules_link']['rules_link_parameters'] = array('default' => ''); $options['rules_link']['rules_link_rewrite'] = array('default' => ''); + $options['rules_link']['rules_link_destination'] = array('default' => ''); return $options; } @@ -87,6 +114,12 @@ '#description' => t('Enter additional parameter using replacement patterns, use comma to enter multiple items. Whitespaces at the beginning and end of token will be trimmed.'), '#default_value' => $this->options['rules_link']['rules_link_parameters'], ); + $form['rules_link']['rules_link_destination'] = array( + '#type' => 'textfield', + '#title' => t('Optional destination parameter to rules link'), + '#description' => t('Enter visible destination parameter. eg. ?destination=my_path/nid/edit. You may use the replacement patterns below.'), + '#default_value' => $this->options['rules_link']['rules_link_destination'], + ); $form['rules_link']['rules_link_rewrite'] = array( '#type' => 'textarea', '#title' => t('Rewrite the link text'),