fasttoggle_user_views_handler_field_user_link.inc in Fasttoggle 7
File
module/fasttoggle_user/views/fasttoggle_user_views_handler_field_user_link.inc
View source
<?php
class fasttoggle_user_views_handler_field_user_link extends views_handler_field_user_link {
private $fasttoggleKey = 'status';
public function construct() {
parent::construct();
$this->additional_fields['uid'] = 'uid';
$this->additional_fields['status'] = 'status';
}
public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
unset($form['text']);
}
public function render($values) {
$account = new stdClass();
if (!isset($this->aliases['uid'])) {
return FALSE;
}
$account->uid = $values->{$this->aliases['uid']};
$account->status = $values->{$this->aliases['status']};
return $this
->render_link($account, $values);
}
public function render_link($user, $values) {
drupal_load('module', 'fasttoggle');
$options = fasttoggle_get_allowed_links('user', $user, $user->uid);
$key = $this->fasttoggleKey;
if (!empty($options) && isset($options['fields']['status']['instances'][$key])) {
$link_info = fasttoggle($options, 'status', $key, $user, FASTTOGGLE_FORMAT_LINK_ARRAY);
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $link_info['href'];
$this->options['alter']['text'] = $link_info['title'];
$this->options['alter']['query'] = $link_info['query'];
$this->options['alter']['link_class'] = implode(' ', $link_info['attributes']['class']);
$this->options['alter']['title'] = $link_info['attributes']['title'];
return $link_info['title'];
}
}
}