Index: uc_addresses.module =================================================================== --- uc_addresses.module (revision 1048) +++ uc_addresses.module (revision 1060) @@ -64,11 +64,22 @@ * the corresponding address object. * * @param $aid The value matched by %uc_addresses_address. - * @param $uid The value of the user ID in the same path. + * @param $map Path components as an array (hook_menu/load arguments - %map). + * @param $map_index Index of the wildcard path component in map (hook_menu/load arguments - %index). * @return FALSE if the value is a valid address, else the address object. */ -function uc_addresses_address_load($aid, $uid) { +function uc_addresses_address_load($aid, &$map = NULL, $map_index = FALSE) { + global $user; + $uid = 0; + if (!isset($aid)) return FALSE; + if ($map && sizeof($map) && $map[0] == 'user' && is_object($map[1])) { + $uid = $map[1]->uid; + } + else { + $uid = $user->uid; + } + return _uc_addresses_db_get_address($uid, $aid); } @@ -135,29 +146,30 @@ 'type' => MENU_LOCAL_TASK, 'weight' => 3, ); - $items['user/%user_uid_optional/addresses/%uc_addresses_address'] = array( 'title' => 'View Address', 'description' => 'View one saved address', - 'load arguments' => array(1), + 'load arguments' => array('%map', '%index'), 'page callback' => 'uc_addresses_list_addresses', 'page arguments' => array(1, arg(3)), 'access callback' => 'uc_addresses_can_view_addresses', 'access arguments' => array(1), 'type' => MENU_CALLBACK, ); + $items['user/%user_uid_optional/addresses/%uc_addresses_address/edit'] = array( 'title' => 'Edit address', - 'load arguments' => array(1), + 'load arguments' => array('%map', '%index'), 'page callback' => 'drupal_get_form', 'page arguments' => array('uc_addresses_get_address_form', 1, 3, 'edit'), 'access callback' => 'uc_addresses_can_add_edit_address', 'access arguments' => array(1), 'type' => MENU_CALLBACK, ); + $items['user/%user_uid_optional/addresses/%uc_addresses_address/delete'] = array( 'title' => 'Delete address', - 'load arguments' => array(1), + 'load arguments' => array('%map', '%index'), 'page callback' => 'uc_addresses_delete_address_confirm', 'page arguments' => array(1, 3), 'access callback' => 'uc_addresses_can_add_edit_address', @@ -218,7 +230,7 @@ $access = user_access(UC_ADDRESSES_ACCESS_ADD_EDIT) || $user->uid == $address_user->uid; - + return $access; } @@ -604,6 +616,7 @@ * @return The themed list (as a string). */ function uc_addresses_list_addresses($address_user, $address = NULL) { + global $user; $uid = $address_user->uid; @@ -700,6 +713,7 @@ // on whether the current user can edit the addresses if (user_access(UC_ADDRESSES_ACCESS_ADD_EDIT) || $user->uid == $uid) { + if (module_exists('me')) $uid = _me_get_me_alias(); $link = l(t('Add a new address'), 'user/'. $uid .'/addresses/add'); $output .= $link; } @@ -764,6 +778,9 @@ // We add an edit link only if the user is allowed to edit this address if (user_access(UC_ADDRESSES_ACCESS_ADD_EDIT) || $user->uid == $uid) { + + if (module_exists('me')) $uid = _me_get_me_alias(); + $output .= '' . l(t('Edit this address'), 'user/'. $uid .'/addresses/' . $aid . '/edit') . ($address->is_default ? '' : @@ -849,11 +866,11 @@ if (is_array($return) && (!empty($return['description']) || !empty($return['contents']))) { // Create the fieldset for the pane - + $pane_description = !empty($return['description']) ? $return['description'] : ''; $form['panes'][$pane['id']] = array( '#type' => 'fieldset', - '#title' => $pane['title'], - '#description' => !empty($return['description']) ? $return['description'] : NULL, + '#title' => check_plain($pane['title']), + '#description' => check_plain($pane_description), '#collapsible' => !empty($pane['collapsible']) ? $pane['collapsible'] : FALSE, '#collapsed' => FALSE, '#attributes' => array('id' => $pane['id'] .'-pane'), @@ -871,6 +888,8 @@ // Edit an existing address + if (module_exists('me')) $uid = _me_get_me_alias(); + if ($view == 'edit') { $form['submit'] = array('#type' => 'submit',