--- uc_addresses.module 2009-04-20 22:54:10.000000000 +0200 +++ uc_addressesnw.module 2009-06-23 12:23:43.000000000 +0200 @@ -48,6 +48,13 @@ define('UC_ADDRESSES_ACCESS_VIEW_ALL', ' */ define('UC_ADDRESSES_ACCESS_ADD_EDIT', 'add/edit addresses'); +/** + * Give users the ability to add or edit his/her own addresses. + */ +define('UC_ADDRESSES_ACCESS_ADD_EDIT_OWN', 'add/edit own addresses'); + + + /******************************************************************************* * Hook Functions ******************************************************************************/ @@ -202,7 +209,9 @@ function uc_addresses_theme() { function uc_addresses_perm() { return array(UC_ADDRESSES_ACCESS_VIEW_DEFAULT, UC_ADDRESSES_ACCESS_VIEW_ALL, - UC_ADDRESSES_ACCESS_ADD_EDIT); + UC_ADDRESSES_ACCESS_ADD_EDIT, + UC_ADDRESSES_ACCESS_ADD_EDIT_OWN, + ); } function uc_addresses_can_view_addresses($address_user) { @@ -222,7 +231,7 @@ function uc_addresses_can_add_edit_addre $access = user_access(UC_ADDRESSES_ACCESS_ADD_EDIT) || - $user->uid == $address_user->uid; + ($user->uid == $address_user->uid && user_access(UC_ADDRESSES_ACCESS_ADD_EDIT_OWN)) ; return $access; } @@ -386,6 +395,7 @@ function uc_addresses_form_uc_cart_check if ($address->is_default) { if (uc_address_field_enabled('first_name')) { $form['panes']['delivery']['delivery_first_name']['#default_value'] = $address->first_name; + } if (uc_address_field_enabled('last_name')) { $form['panes']['delivery']['delivery_last_name']['#default_value'] = $address->last_name; @@ -562,6 +572,8 @@ function uc_addresses_order($op, &$arg1, global $user; $order = $arg1; + if (!user_access(UC_ADDRESSES_ACCESS_ADD_EDIT_OWN)) return; + if ($op == 'submit' && $order->order_status == 'in_checkout') { $address = new stdClass(); @@ -726,7 +738,7 @@ function uc_addresses_list_addresses($ad // Decide whether to include a link for adding a new address based // on whether the current user can edit the addresses - if (user_access(UC_ADDRESSES_ACCESS_ADD_EDIT) || $user->uid == $uid) { + if (user_access(UC_ADDRESSES_ACCESS_ADD_EDIT) || ($user->uid == $uid && user_access(UC_ADDRESSES_ACCESS_ADD_EDIT_OWN))) { $link = l(t('Add a new address'), 'user/'. $uid .'/addresses/add'); $output .= $link; } @@ -790,7 +802,7 @@ function theme_uc_addresses_list_address // 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 (user_access(UC_ADDRESSES_ACCESS_ADD_EDIT) || ($user->uid == $uid && user_access(UC_ADDRESSES_ACCESS_ADD_EDIT_OWN))) { $output .= '' . l(t('Edit this address'), 'user/'. $uid .'/addresses/' . $aid . '/edit') . ($address->is_default ? '' :