• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

modules/contact/views_handler_field_contact_link.inc

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   // An example of field level access control.
00017   // We must override the access method in the parent class, as that requires
00018   // the 'access user profiles' permission, which the contact form does not.
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     // Check access when we pull up the user account so we know
00037     // if the user has made the contact page available.
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 }

Generated on Sun Feb 26 2012 12:52:51 for Views by  doxygen 1.7.1