00001 <?php
00007 class views_handler_field_contact_link extends views_handler_field_user_link {
00008
00009 function options_form(&$form, &$form_state) {
00010 $form['text']['#title'] = t('Link label');
00011 $form['text']['#required'] = TRUE;
00012 $form['text']['#default_value'] = empty($this->options['text']) ? t('contact') : $this->options['text'];
00013 parent::options_form($form, $form_state);
00014 }
00015
00016
00017
00018
00019 function access() {
00020 return user_access('access user contact forms');
00021 }
00022
00023 function render_link($data, $values) {
00024 global $user;
00025 $uid = $this->get_value($values, 'uid');
00026
00027 if (empty($uid)) {
00028 return;
00029 }
00030
00031 $account = user_load($uid);
00032 if (empty($account)) {
00033 return;
00034 }
00035
00036
00037
00038 $menu_item = menu_get_item("user/$uid/contact");
00039 if (!$menu_item['access'] || empty($account->data['contact'])) {
00040 return;
00041 }
00042
00043 $this->options['alter']['make_link'] = TRUE;
00044 $this->options['alter']['path'] = 'user/' . $account->uid . '/contact';
00045 $this->options['alter']['attributes'] = array('title' => t('Contact %user', array('%user' => $account->name)));
00046
00047 $text = $this->options['text'];
00048
00049 return $text;
00050 }
00051 }