Advertisement
didaka

views_handler_apms_license.inc

Dec 23rd, 2013
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. <?php
  2. /**
  3.  * A handler to provide a field that shows the license type.
  4.  *
  5.  * @ingroup views_field_handlers
  6.  */
  7. class views_handler_apms_license extends views_handler_field {
  8.  
  9.   function query() {
  10.     // do nothing -- to override the parent query.
  11.   }
  12.  
  13.   function option_definition() {
  14.     $options = parent::option_definition();
  15.  
  16.     // Override the alter text option to always alter the text.
  17.     $options['alter']['contains']['alter_text'] = array('default' => TRUE);
  18.     return $options;
  19.   }
  20.  
  21.   function options_form(&$form, &$form_state) {
  22.     parent::options_form($form, $form_state);
  23.  
  24.     // Remove the checkbox
  25.     unset($form['alter']['alter_text']);
  26.     unset($form['alter']['text']['#dependency']);
  27.     unset($form['alter']['text']['#process']);
  28.   }
  29.  
  30.   function render($values) {
  31.     $user = user_load($values->uid);
  32.     if (isset($user->apms['userLicense'])) {
  33.       return $user->apms['userLicense'] ? t('BASIC') : t('FREE');
  34.     }
  35.     else {
  36.       return NULL;
  37.     }
  38.   }
  39. }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement