source: sipes/modules_contrib/views/modules/user/views_plugin_argument_default_user.inc @ 177a560

stableversion-3.0
Last change on this file since 177a560 was 177a560, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agrego el directorio de modulos contribuidos de drupal

  • Propiedad mode establecida a 100644
File size: 1.9 KB
Línea 
1<?php
2/**
3 * @file
4 * Contains the user from URL argument default plugin.
5 */
6
7/**
8 * Default argument plugin to extract a user via menu_get_object
9 */
10class views_plugin_argument_default_user extends views_plugin_argument_default {
11  var $option_name = 'default_argument_user';
12
13  function argument_form(&$form, &$form_state) {
14    $form[$this->option_name] = array(
15      '#type' => 'checkbox',
16      '#title' => t('Also look for a node and use the node author'),
17      '#default_value' => !empty($this->argument->options[$this->option_name]),
18      '#process' => array('views_process_dependency'),
19      '#dependency' => array(
20        'radio:options[default_action]' => array('default'),
21        'radio:options[default_argument_type]' => array($this->id)
22      ),
23      '#dependency_count' => 2,
24    );
25  }
26
27  function get_argument() {
28    foreach (range(1, 3) as $i) {
29      $user = menu_get_object('user', $i);
30      if (!empty($user)) {
31        return $user->uid;
32      }
33    }
34
35    foreach (range(1, 3) as $i) {
36      $user = menu_get_object('user_uid_optional', $i);
37      if (!empty($user)) {
38        return $user->uid;
39      }
40    }
41
42    if (!empty($this->argument->options[$this->option_name])) {
43      foreach (range(1, 3) as $i) {
44        $node = menu_get_object('node', $i);
45        if (!empty($node)) {
46          return $node->uid;
47        }
48      }
49    }
50
51    if (arg(0) == 'user' && is_numeric(arg(1))) {
52      return arg(1);
53    }
54
55    if (!empty($this->argument->options[$this->option_name])) {
56      if (arg(0) == 'node' && is_numeric(arg(1))) {
57        $node = node_load(arg(1));
58        if ($node) {
59          return $node->uid;
60        }
61      }
62    }
63
64    // If the current page is a view that takes uid as an argument, return the uid.
65    $views_page = views_get_page_view();
66
67    if ($views_page && isset($views_page->view->argument['uid'])) {
68      return $views_page->view->argument['uid']->argument;
69    }
70  }
71}
72
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.