~spreadubuntu/spreadubuntu/devel-drupal6

« back to all changes in this revision

Viewing changes to modules/views/modules/user/views_plugin_argument_default_user.inc

  • Committer: ruben
  • Date: 2009-06-08 09:38:49 UTC
  • Revision ID: ruben@captive-20090608093849-s1qtsyctv2vwp1x1
SpreadUbuntu moving to Drupal6. Based on ubuntu-drupal theme and adding our modules

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
// $Id: views_plugin_argument_default_user.inc,v 1.1 2008/09/03 19:21:30 merlinofchaos Exp $
 
3
/**
 
4
 * @file
 
5
 * Contains the user from URL argument default plugin.
 
6
 */
 
7
 
 
8
/**
 
9
 * Default argument plugin to extract a user via menu_get_object
 
10
 */
 
11
class views_plugin_argument_default_user extends views_plugin_argument_default {
 
12
  var $option_name = 'default_argument_user';
 
13
 
 
14
  function argument_form(&$form, &$form_state) {
 
15
    $form[$this->option_name] = array(
 
16
      '#type' => 'checkbox',
 
17
      '#title' => t('Also look for a node and use the node author'),
 
18
      '#default_value' => !empty($this->argument->options[$this->option_name]),
 
19
      '#process' => array('views_process_dependency'),
 
20
      '#dependency' => array(
 
21
        'radio:options[default_action]' => array('default'),
 
22
        'radio:options[default_argument_type]' => array($this->id)
 
23
      ),
 
24
      '#dependency_count' => 2,
 
25
    );
 
26
  }
 
27
 
 
28
  function get_argument() {
 
29
    foreach (range(1, 3) as $i) {
 
30
      $user = menu_get_object('user', $i);
 
31
      if (!empty($user)) {
 
32
        return $user->uid;
 
33
      }
 
34
    }
 
35
 
 
36
    foreach (range(1, 3) as $i) {
 
37
      $user = menu_get_object('user_uid_optional', $i);
 
38
      if (!empty($user)) {
 
39
        return $user->uid;
 
40
      }
 
41
    }
 
42
 
 
43
    if (!empty($this->argument->options[$this->option_name])) {
 
44
      foreach (range(1, 3) as $i) {
 
45
        $node = menu_get_object('node', $i);
 
46
        if (!empty($node)) {
 
47
          return $node->uid;
 
48
        }
 
49
      }
 
50
    }
 
51
 
 
52
    if (arg(0) == 'user' && is_numeric(arg(1))) {
 
53
      return arg(1);
 
54
    }
 
55
 
 
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