home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (user.views_convert.inc)

This example Drupal source code file (user.views_convert.inc) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

argument, break, case, display, field, filter, id, operators, options, php, rid, switch, uid, users

The user.views_convert.inc Drupal example source code

<?php
// $Id: user.views_convert.inc,v 1.3 2009/06/30 19:14:27 merlinofchaos Exp $

/**
 * @file
 * Field conversion for fields handled by this module.
 */

/**
 * Implementation of hook_views_convert().
 */
function user_views_convert($display, $type, &$view, $field, $id = NULL) {
  switch ($type) {
    case 'field':
      switch ($field['tablename']) {
        case 'users':
          switch ($field['field']) {
            case 'uid':
              $view->set_item_option($display, 'field', $id, 'field', 'picture');
              break;
          }
          break;
      }
      break;
    case 'filter':
      if ($field['tablename'] == 'users' || !strncmp($field['tablename'], 'users_role_', 11)) {
        switch ($field['field']) {
          case 'uid':
            $operators = array('OR' => 'in', 'NOR' => 'not in');
            $view->set_item_option($display, 'filter', $id, 'operator', $operators[$field['operator']]);
            if ($rid = (integer) substr($field['tablename'], 11)) {
              $view->add_item($display, 'filter', 'users_roles', 'rid', array('value' => $rid));
            }
            break;
        }
      }
      elseif ($field['tablename'] == 'users_roles') {
        switch ($field['field']) {
          case 'rid':
            $operators = array('AND' => 'and', 'OR' => 'or', 'NOR' => 'not');
            $view->set_item_option($display, 'filter', $id, 'operator', $operators[$field['operator']]);
            break;
        }
      }
      break;
    case 'argument':
      $options = $field['argoptions'];
      switch ($field['type']) {
        case 'uid':
          $view->add_item($display, 'argument', 'users', 'uid', $options, $field['id']);
          break;
        case 'uidtouch':
          $view->add_item($display, 'argument', 'node', 'uid_touch', $options, $field['id']);
          break;
        case 'username':
          $view->add_item($display, 'argument', 'users', 'name', $options, $field['id']);
          break;
      }
      break;
  }
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal user.views_convert.inc source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.