diff --git a/templates/uc-addresses-list-address.tpl.php b/templates/uc-addresses-list-address.tpl.php
index 5ee6d16..9de59a1 100644
--- a/templates/uc-addresses-list-address.tpl.php
+++ b/templates/uc-addresses-list-address.tpl.php
@@ -41,30 +41,32 @@
* @ingroup themeable
*/
?>
-
-
-
-
-
- 0): ?>
- $field): ?>
-
-
-
+
+
+
+
+
+
+ 0): ?>
+ $field): ?>
+
+
+
+ |
+ |
+
+
+
+
+
+
+
+
|
- |
-
-
-
-
-
-
-
- |
-
-
-
-
\ No newline at end of file
+
+ |
+
+
\ No newline at end of file
diff --git a/tests/uc_addresses.views.test b/tests/uc_addresses.views.test
index 0196620..d14982a 100644
--- a/tests/uc_addresses.views.test
+++ b/tests/uc_addresses.views.test
@@ -946,4 +946,67 @@ class UcAddressesViewsTestCase extends UcAddressesTestCase {
return $view;
}
+
+ /**
+ * Tests if the default view works as expected.
+ */
+ public function testDefaultView() {
+ // Enable the default view.
+ $view = views_get_view('uc_addresses_address_book');
+ $view->disabled = FALSE;
+ $view->save();
+
+ // Get addresses for basic user.
+ $other_user_address_default = UcAddressesAddressBook::get($this->basicUser->uid)->getDefaultAddress();
+ $other_user_address_other = UcAddressesAddressBook::get($this->basicUser->uid)->getAddressByName($this->basicUser->uid . '_other');
+
+ foreach ($this->accounts as $account) {
+ $this->drupalLogin($account);
+ $addressBook = UcAddressesAddressBook::get($account->uid);
+ $default_address = $addressBook->getDefaultAddress();
+ $other_address = $addressBook->getAddressByName($account->uid . '_other');
+
+ // Test if the user can view his/her own address book if he/she
+ // has access.
+ $this->viewAddressBook($account, $account->uc_addresses_permissions['view_own_def']);
+ // Test if the user's default address is displayed when the user
+ // may view his/her own default addresses.
+ if ($account->uc_addresses_permissions['view_own_def']) {
+ $this->assertAddressLabel($default_address);
+ // Ensure the View is used to display the address book.
+ $this->assertRaw('view-uc-addresses-address-book');
+ }
+ else {
+ $this->assertNoAddressLabel($default_address);
+ }
+ // Test if the user's other address is displayed when the user
+ // may view all of his/her own addresses.
+ if ($account->uc_addresses_permissions['view_own']) {
+ $this->assertAddressLabel($other_address);
+ }
+ else {
+ $this->assertNoAddressLabel($other_address);
+ }
+
+ // Test if the user can view other address books if he/she is allowed
+ // to view them.
+ $this->viewAddressBook($this->basicUser, $account->uc_addresses_permissions['view_all_def']);
+ // Test if the other user's default address is displayed when
+ // the user may view all default addresses.
+ if ($account->uc_addresses_permissions['view_all_def']) {
+ $this->assertAddressLabel($other_user_address_default);
+ }
+ else {
+ $this->assertNoAddressLabel($other_user_address_default);
+ }
+ // Test if the other user's other address is displayed when
+ // the user may view all addresses.
+ if ($account->uc_addresses_permissions['view_all']) {
+ $this->assertAddressLabel($other_user_address_other);
+ }
+ else {
+ $this->assertNoAddressLabel($other_user_address_other);
+ }
+ }
+ }
}
diff --git a/uc_addresses.css b/uc_addresses.css
index 1af82a3..1a81a9a 100644
--- a/uc_addresses.css
+++ b/uc_addresses.css
@@ -31,7 +31,12 @@
width: 48.5%;
}
-.address-book .default-addresses li.address-item {
+.view-uc-addresses-address-book td.address-item {
+ vertical-align: top;
+}
+
+.address-book .default-addresses li.address-item .list-address-wrapper,
+.view-uc-addresses-address-book td.address-item .list-address-wrapper {
background: #FFFFFF;
border: 1px solid #CCCCCC;
padding: 10px 13px;
@@ -58,6 +63,11 @@
/* @group Single address */
.list-address {
width: 20em;
+ border: 0px;
+}
+
+.list-address td {
+ border: 0px;
}
.list-address .title-col {
diff --git a/uc_addresses.pages.inc b/uc_addresses.pages.inc
index 2e9b5ab..37fe819 100644
--- a/uc_addresses.pages.inc
+++ b/uc_addresses.pages.inc
@@ -207,13 +207,13 @@ function template_preprocess_uc_addresses_list_address(&$vars) {
if ($vars['options']['default_flags']) {
$flags = array();
if ($address->isDefault('billing') && variable_get('uc_addresses_use_default_billing', TRUE)) {
- $flags['billing'] = t('Default billing address');
+ $flags['billing'] = '' . t('Default billing address') . '';
}
if ($address->isDefault('shipping') && variable_get('uc_addresses_use_default_shipping', TRUE)) {
- $flags['shipping'] = t('Default shipping address');
+ $flags['shipping'] = '' . t('Default shipping address') . '';
}
if (count($flags) > 0) {
- $vars['label'] = implode(' | ', $flags);
+ $vars['label'] = implode('
', $flags);
}
}
diff --git a/views/uc_addresses.views_default.inc b/views/uc_addresses.views_default.inc
new file mode 100644
index 0000000..700475b
--- /dev/null
+++ b/views/uc_addresses.views_default.inc
@@ -0,0 +1,119 @@
+name = 'uc_addresses_address_book';
+ $view->description = 'Manage your addresses';
+ $view->tag = 'uc_addresses';
+ $view->base_table = 'uc_addresses';
+ $view->human_name = 'Address book';
+ $view->core = 7;
+ $view->api_version = '3.0';
+ $view->disabled = TRUE;
+
+ /* Display: Master */
+ $handler = $view->new_display('default', 'Master', 'default');
+ $handler->display->display_options['title'] = 'Address book';
+ $handler->display->display_options['use_more_always'] = FALSE;
+ $handler->display->display_options['access']['type'] = 'uc_addresses_views_access';
+ $handler->display->display_options['access']['uid_argument'] = 'uid';
+ $handler->display->display_options['access']['aid_argument'] = '';
+ $handler->display->display_options['cache']['type'] = 'none';
+ $handler->display->display_options['query']['type'] = 'views_query';
+ $handler->display->display_options['exposed_form']['type'] = 'basic';
+ $handler->display->display_options['pager']['type'] = 'none';
+ $handler->display->display_options['style_plugin'] = 'grid';
+ $handler->display->display_options['style_options']['row_class'] = 'address-item';
+ $handler->display->display_options['style_options']['columns'] = '2';
+ $handler->display->display_options['style_options']['fill_single_line'] = FALSE;
+ $handler->display->display_options['row_plugin'] = 'uc_addresses';
+ $handler->display->display_options['row_options']['view_link'] = 0;
+ $handler->display->display_options['row_options']['edit_link'] = 1;
+ $handler->display->display_options['row_options']['delete_link'] = 1;
+ $handler->display->display_options['row_options']['default_flags'] = 1;
+ /* No results behavior: Global: Text area */
+ $handler->display->display_options['empty']['area']['id'] = 'area';
+ $handler->display->display_options['empty']['area']['table'] = 'views';
+ $handler->display->display_options['empty']['area']['field'] = 'area';
+ $handler->display->display_options['empty']['area']['empty'] = TRUE;
+ $handler->display->display_options['empty']['area']['content'] = 'No addresses have been saved.';
+ $handler->display->display_options['empty']['area']['format'] = 'filtered_html';
+ /* Field: Ubercart Addresses: Address ID */
+ $handler->display->display_options['fields']['aid']['id'] = 'aid';
+ $handler->display->display_options['fields']['aid']['table'] = 'uc_addresses';
+ $handler->display->display_options['fields']['aid']['field'] = 'aid';
+ /* Sort criterion: Ubercart Addresses: Default billing address */
+ $handler->display->display_options['sorts']['default_billing']['id'] = 'default_billing';
+ $handler->display->display_options['sorts']['default_billing']['table'] = 'uc_addresses';
+ $handler->display->display_options['sorts']['default_billing']['field'] = 'default_billing';
+ $handler->display->display_options['sorts']['default_billing']['order'] = 'DESC';
+ /* Sort criterion: Ubercart Addresses: Default shipping address */
+ $handler->display->display_options['sorts']['default_shipping']['id'] = 'default_shipping';
+ $handler->display->display_options['sorts']['default_shipping']['table'] = 'uc_addresses';
+ $handler->display->display_options['sorts']['default_shipping']['field'] = 'default_shipping';
+ $handler->display->display_options['sorts']['default_shipping']['order'] = 'DESC';
+ /* Sort criterion: Ubercart Addresses: Address name */
+ $handler->display->display_options['sorts']['address_name']['id'] = 'address_name';
+ $handler->display->display_options['sorts']['address_name']['table'] = 'uc_addresses';
+ $handler->display->display_options['sorts']['address_name']['field'] = 'address_name';
+ /* Contextual filter: Ubercart Addresses: User ID */
+ $handler->display->display_options['arguments']['uid']['id'] = 'uid';
+ $handler->display->display_options['arguments']['uid']['table'] = 'uc_addresses';
+ $handler->display->display_options['arguments']['uid']['field'] = 'uid';
+ $handler->display->display_options['arguments']['uid']['default_action'] = 'not found';
+ $handler->display->display_options['arguments']['uid']['default_argument_type'] = 'fixed';
+ $handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0';
+ $handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary';
+ $handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';
+ $handler->display->display_options['arguments']['uid']['specify_validation'] = TRUE;
+ $handler->display->display_options['arguments']['uid']['validate']['type'] = 'uc_addresses_user_address_access';
+ $handler->display->display_options['arguments']['uid']['validate']['fail'] = 'access denied';
+ /* Filter criterion: Ubercart Addresses: Access */
+ $handler->display->display_options['filters']['access_view']['id'] = 'access_view';
+ $handler->display->display_options['filters']['access_view']['table'] = 'uc_addresses';
+ $handler->display->display_options['filters']['access_view']['field'] = 'access_view';
+ $handler->display->display_options['filters']['access_view']['value'] = '1';
+
+ /* Display: Page */
+ $handler = $view->new_display('page', 'Page', 'page');
+ $handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
+ $handler->display->display_options['path'] = 'user/%/addresses';
+ $handler->display->display_options['menu']['type'] = 'tab';
+ $handler->display->display_options['menu']['title'] = 'Address book';
+ $handler->display->display_options['menu']['description'] = 'Manage your addresses';
+ $handler->display->display_options['menu']['weight'] = '0';
+ $handler->display->display_options['menu']['context'] = 0;
+ $translatables['uc_addresses_address_book'] = array(
+ t('Master'),
+ t('Address book'),
+ t('more'),
+ t('Apply'),
+ t('Reset'),
+ t('Sort by'),
+ t('Asc'),
+ t('Desc'),
+ t('No addresses have been saved.'),
+ t('Address ID'),
+ t('.'),
+ t(','),
+ t('All'),
+ t('Page'),
+ );
+
+ $export['uc_addresses_address_book'] = $view;
+
+ return $export;
+}