I'd like to show directions from a user's node to particular places (also in nodes) using location_u2n. However, it requires "Access User locations", which could expose information for other users (such as their home location). Would it be possible to have something like a location_cu2n and location_n2cu? (cu == current user).

Comments

BruceDawson’s picture

I just realized that something similar would be useful for Organic Groups - so that access would be permitted for all users/nodes in an organic group.

hutch’s picture

StatusFileSize
new86.62 KB

Try the attached version of getdirections.module.
It creates two new paths
getdirections/location_n2cu
getdirections/location_cu2n

The access perms has been relaxed to the more general "getdirections_access_location" and a user check added to the two new functions getdirections_n2cu_setlocation() and getdirections_cu2n_setlocation()

Remember to flush cache after installing the module file so that the new menu paths get picked up.

BruceDawson’s picture

Sorry for taking so long to respond - I had some other "release engineering" issues. I'll try your file shortly and get back to you. Thanks for the prompt response!

BruceDawson’s picture

StatusFileSize
new137.75 KB

I'm getting the attached notice.

At first I thought it had to do with not having a location field in my profile. But I added one and I'm still getting the notice. However, my profile has several addresses and a LatLon field, so I'm wondering which one its using! (Billing address, shipping address, and for this one, a "current address".)

BruceDawson’s picture

I tried the following patch, but it didn't help things - I still seem to get null results (giving me an empty form with no map and no directions).

*** getdirections.module~	2013-04-04 15:57:53.000000000 -0400
--- getdirections.module	2013-04-14 22:30:41.000000000 -0400
***************
*** 1900,1906 ****
          if ($lang == $language->language || (isset($obj->language) && $lang == $obj->language) || $lang == 'und') {
            $ct = 0;
            foreach ($addr[$lang] AS $a) {
!             $locations[$ct] += getdirections_addressfield_convert($a);
              $ct++;
            }
          }
--- 1900,1911 ----
          if ($lang == $language->language || (isset($obj->language) && $lang == $obj->language) || $lang == 'und') {
            $ct = 0;
            foreach ($addr[$lang] AS $a) {
! // jbd            $locations[$ct] += getdirections_addressfield_convert($a);
!    	    if (isset($locations[$ct])) {
! 	      $locations[$ct] += getdirections_addressfield_convert($a);
! 	    } else {
! 	      $locations[$ct] = getdirections_addressfield_convert($a);
! 	    }
              $ct++;
            }
          }
hutch’s picture

This is very messy.
The line number 1903 given in the notice is nowhere near function getdirections_other_load_locations()

The Addressfield module does not provide the means to geolocate, but as you have managed to get to the line containing $locations[$ct] += getdirections_addressfield_convert($a); in function getdirections_other_load_locations() you must be using either module geofield or geolocation to provide latitude and longitude.

The patch above is not going to solve anything, what you need is lat/lon, the address is just for display purposes. Ramming the address into $locations when there is no lat/lon does not solve the problem.
Somehow you seem to have a geofield or geolocation instance that has no lat/lon, fix that and the rest will fall into place.

What would be a useful addition to prevent this from happening would be:
In getdirections-7.x-2.x-dev line 1780, immediately above
// addressfield
put

if (empty($locations)) {
  return $locations;
}

and
Replace

foreach ($addr[$lang] AS $a) {
  $locations[$ct] += getdirections_addressfield_convert($a);
  $ct++;
}

with

foreach ($addr[$lang] AS $a) {
  if (isset($locations[$ct])) {
    $locations[$ct] += getdirections_addressfield_convert($a);
  }
  $ct++;
}

I will be adding these to the next round of commits.