Closed (outdated)
Project:
Location
Version:
6.x-3.1-rc1
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 Mar 2010 at 18:11 UTC
Updated:
20 Jul 2016 at 05:48 UTC
Jump to comment: Most recent
Comments
Comment #1
Todd Young commentedSubscribing
Comment #2
j0k3z commentedAny chance we can get some feedback from the module maintainer?
Comment #3
yesct commenteddid you use the cck location? I think you can use the cck field permissions then, yes?
Comment #4
pelicani commentedI haven't seen this followed up on.
And the answer to use cck location sometimes isn't the right path.
To make this work, you need to mod 2 files.
I didn't write a patch, but the tweak is easy.
1. add a permission to the location.module.
2. check this permission in the location_node.module
I changed the location_node_nodeapi and location_node_form_alter functions
location_node.module excerpt...
/**
* Implementation of hook_form_alter().
*/
function location_node_form_alter(&$form, &$form_state, $form_id) {
if (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id && user_access('edit node location')) {
// Add the Location fields on the Node edit form
$node = $form['#node'];
$settings = variable_get('location_settings_node_'. $node->type, array());
if (isset($settings['multiple']['max']) && $settings['multiple']['max'] > 0) {
$locations = isset($node->locations) ? $node->locations : array();
$form['locations'] = location_form($settings, $locations);
}
}
}
/**
* Implementation of hook_nodeapi().
*/
function location_node_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'delete revision':
if (user_access('edit node location')) {
$locations = array();
location_save_locations($locations, array('vid' => $node->vid));
}
break;
case 'delete':
if (user_access('edit node location')) {
$locations = array();
location_save_locations($locations, array('nid' => $node->nid));
}
break;
case 'load':
$locations = location_load_locations($node->vid);
$location = count($locations) ? $locations[0] : array();
return array('locations' => $locations, 'location' => $location);
case 'insert':
case 'update':
if (!empty($node->locations) && user_access('edit node location')) {
location_save_locations($node->locations, array('nid' => $node->nid, 'vid' => $node->vid));
}
break;
case 'view':
if (variable_get('location_display_location', 1)) {
$settings = variable_get('location_settings_node_'. $node->type, array());
if (isset($settings['display']['teaser']) && isset($settings['display']['full'])) {
if (($a3 && $settings['display']['teaser']) || (!$a3 && $settings['display']['full'])) {
$node->content['locations'] = location_display($settings, $node->locations);
}
}
}
break;
case 'rss item':
$items = array();
$settings = variable_get('location_settings_node_'. $node->type, array());
$mode = isset($settings['rss']['mode']) ? $settings['rss']['mode'] : 'simple';
if ($mode == 'none') {
return;
}
if (is_array($node->locations)) {
foreach ($node->locations as $location) {
if (($item = location_rss_item($location, $mode))) {
$items[] = $item;
}
}
}
return $items;
}
}
Comment #5
Yanxi commentedThanks pelicani for posting this solution. These small changes do provide permission settings to prevent certain roles from editing location. But they also prevent those roles from creating location. Is there a way to set another permission option "create node location" for admin to configure?
This feature is actually very useful while not using location cck, which is still quite buggy in some specific cases. Would be very happy to see it included in the future release.
Comment #6
j0k3z commentedI would love to see this rolled into the module
Comment #7
Yanxi commentedAny possibility to add a permission option of "create node location"?
Comment #8
HendrikM commented@pelicani
Trouble is: the location form will not show for users without the permission to edit node location (good so far), but after saving/editing the node, the location formerly linked to the node is unlinked, so the node loses its location. Any ideas?
Comment #9
HendrikM commentedI found out out what the problem is: my content-types with the location attached are versioned, so whenever a user without permission to change the location updates a node, he creates a new version which has no connection with the before saved location.
Difficult one. It would be easiest to stop Drupal from versioning the nodes, but what if I wanted to keep this configuration?
Comment #10
legolasboClosing old D6 issues as D6 is end of life