function flag_arg_uid in Flag 5
1 string reference to 'flag_arg_uid'
- flag_views_arguments in includes/
flag.views.inc - Give an argument handler to limit nodes to those flagged by a uid.
File
- includes/
flag.views.inc, line 276 - Provides support for the Views module.
Code
function flag_arg_uid($op, &$query, $argtype, $arg = '') {
switch ($op) {
case 'summary':
// We have to do a couple of kind of ugly things here. First,
// because we're dynamic we dig some table info out of the
// arguments array. Second, the default behavior on our
// pseudotables is to lock the table to current user, but
// we are overriding that.
$argdata = _views_get_arguments();
$table = $argdata[$argtype]['table'];
$table_data = _views_get_tables();
$joininfo = $table_data[$table]['join'];
unset($joininfo['extra']);
$query
->add_table($table, true, 1, $joininfo);
$query
->add_table('users', true, 1, array(
'left' => array(
'table' => $table,
'field' => 'uid',
),
'right' => array(
'field' => 'uid',
),
));
$query
->add_field('name', 'users');
$query
->add_field('uid', 'users');
$query
->add_where("{$table}.uid IS NOT NULL");
$fieldinfo['field'] = "users.name";
return $fieldinfo;
break;
case 'filter':
$uid = intval($arg);
$argdata = _views_get_arguments();
$table = $argdata[$argtype['type']]['table'];
$table_data = _views_get_tables();
$joininfo = $table_data[$table]['join'];
$joininfo['extra']['uid'] = $uid;
$tn = $query
->add_table($table, true, 1, $joininfo);
$tname = $query
->get_table_name($table, $tn);
$query
->add_where("{$tname}.uid IS NOT NULL");
break;
case 'link':
$name = $query->name ? $query->name : variable_get('anonymous', t('Anonymous'));
return l($name, "{$arg}/" . intval($query->uid));
case 'title':
if (!$query) {
return variable_get('anonymous', t('Anonymous'));
}
$user = db_fetch_object(db_query("SELECT name FROM {users} WHERE uid = '%d'", $query));
return $user->name;
}
}