'community_tags', 'provider' => 'internal', 'join' => array( 'left' => array( 'table' => 'node', 'field' => 'nid' ), 'right' => array( 'field' => 'nid' ) ), 'fields' => array( 'tags' => array( 'name' => t("Community Tags: Current user's tags"), 'sortable' => false, 'help' => t('This will display all taxonomy terms associated with the node by the current user. Note that this causes one extra query per row displayed, and might have a minor performance impact.'), 'handler' => 'community_tags_handler_field_user_terms', 'notafield' => true, 'option' => array( '#type' => 'select', '#options' => array( 'weighted' => 'Weighted', 'notweighted' => 'Not weighted' ), ), ), ), ); return $tables; } // adapted from views_taxonomy.inc function community_tags_handler_field_user_terms($fieldinfo, $fielddata, $value, $data) { global $views_handler_arg_community_tags_uid; // FIXME if ($fielddata['options'] == 'weighted'){ return theme('community_tags', 'user_node', $views_handler_arg_community_tags_uid, $data->nid); } else{ $terms = community_tags_get_user_node_terms($views_handler_arg_community_tags_uid, $data->nid); $node->taxonomy = $terms; $links = taxonomy_link('taxonomy terms', $node); return theme('links', $links); } } // adapted from get_user_node_tags to return term arrays instead of just name function community_tags_get_user_node_terms($uid, $nid) { $tags = array(); $result = db_query("SELECT t.name, t.tid FROM {term_data} t INNER JOIN {community_tags} c ON c.tid = t.tid WHERE c.nid = %d AND c.uid = %d", $nid, $uid); while ($term = db_fetch_object($result)) { if (preg_match('/,/', $term->name) || preg_match('/"/', $term->name)) { $term->name = '"'.preg_replace('/"/', '""', $term->name).'"'; } $tags[] = $term; } return $tags; } function community_tags_views_arguments() { $arguments = array( 'community_tags_tagged' => array( 'name' => t('Community Tags: UID has Tagged'), 'handler' => 'views_handler_arg_community_tags_uid_tagged', 'help' => t('The User ID argument allows users to filter for nodes tagged by the specified user ID.'), ), ); return $arguments; } function views_handler_arg_community_tags_uid_tagged($op, &$query, $argtype, $arg = '') { switch($op) { case 'filter': $uid = intval($arg); global $views_handler_arg_community_tags_uid; // FIXME $views_handler_arg_community_tags_uid = $uid; // FIXME $table_data = _views_get_tables(); $query->ensure_table('community_tags'); $query->add_where("community_tags.uid = '%d'", $uid); break; } } ?>