Is it possible to allow someone to edit a node but not edit that nodes location? As the admin I setup the location for the nodes on the website but other users are allowed to make changes to random CCK fields. I just dont want them to have access to the location and be able to change or delete that data.

Comments

Todd Young’s picture

Subscribing

j0k3z’s picture

Any chance we can get some feedback from the module maintainer?

yesct’s picture

did you use the cck location? I think you can use the cck field permissions then, yes?

pelicani’s picture

I 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;
}
}

Yanxi’s picture

Thanks 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.

j0k3z’s picture

I would love to see this rolled into the module

Yanxi’s picture

Any possibility to add a permission option of "create node location"?

HendrikM’s picture

@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?

HendrikM’s picture

I 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?

legolasbo’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Closing old D6 issues as D6 is end of life