Starting to get new attribute handlers set up.

Still a lot to do:
- adding more handlers
- ripping out the parts of uc_views that don't work with D7
- if needed, adding filters
This commit is contained in:
mattbk
2015-10-06 14:03:00 -05:00
parent efefb7cd23
commit 806ee544ce
10 changed files with 99 additions and 189 deletions

View File

@ -1,49 +0,0 @@
<?php
// $Id: uc_views_handler_field_order_id.inc,v 1.1.4.2 2010/12/15 02:16:37 longwave Exp $
/**
* @file
* Contains the basic 'order' field handler.
*/
/**
* Field handler to provide simple renderer that allows linking to the order adminstration page.
*/
class uc_views_handler_field_order_id extends views_handler_field {
function option_definition() {
$options = parent::option_definition();
$options['link_to_order'] = array('default' => FALSE);
return $options;
}
/**
* Provide link to order adminstration page
*/
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['link_to_order'] = array(
'#title' => t('Link this field to the order view.'),
'#description' => t('The link will go to the admin view if the user has "view all orders" permission, or the user view if the order belongs to the current user and they have "view own orders" permission. This will override any other link you have set.'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['link_to_order']),
);
}
function render($values) {
global $user;
$this->options['alter']['make_link'] = FALSE;
if (!empty($this->options['link_to_order']) && $values->{$this->field_alias}) {
if (user_access('view all orders')) {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = "admin/store/orders/" . $values->{$this->field_alias};
}
elseif ($values->{$this->aliases['uid']} == $user->uid && user_access('view own orders')) {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = 'user/' . $user->uid . '/order/' . $values->{$this->field_alias};
}
}
return parent::render($values);
}
}