### Eclipse Workspace Patch 1.0 #P Alzforum Index: modules/acquia/cck/includes/views/handlers/content_handler_filter_many_to_one.inc =================================================================== --- modules/acquia/cck/includes/views/handlers/content_handler_filter_many_to_one.inc (revision 547) +++ modules/acquia/cck/includes/views/handlers/content_handler_filter_many_to_one.inc (working copy) @@ -30,4 +30,36 @@ return (array) $options; } +} + + + +class content_handler_filter_many_to_one_reverse extends content_handler_filter_many_to_one{ + + function allowed_values(){ + $types=array_flip($this->options['restrict_to_types']); + unset($types[0]); + $type_qry=""; + if(count($types)) + $type_qry= "and n.type in ('".implode("','",array_keys(array_flip($types)))."') "; + $dbinfo=content_database_info($this->content_field); + $optsqry=db_query(db_rewrite_sql("SELECT DISTINCT n.nid, n.title from {node} n inner join {".$dbinfo['table']."} nc on n.nid=nc.nid where 1=1 $type_qry")); + while($row=db_fetch_object($optsqry)){ + $opts[$row->nid]=$row->title; + } + return (array)$opts; + } + + function options_form(&$form, &$form_state) { + parent::options_form($form, $form_state); + $types=node_get_types('names'); + $form['restrict_to_types']=array( + '#type'=>'checkboxes', + '#title'=>'restrict nodes to types', + '#options'=>$types, + '#default_value'=>$this->options['restrict_to_types'], + + ); + } + } \ No newline at end of file Index: modules/acquia/cck/modules/userreference/userreference.module =================================================================== --- modules/acquia/cck/modules/userreference/userreference.module (revision 547) +++ modules/acquia/cck/modules/userreference/userreference.module (working copy) @@ -160,8 +160,44 @@ 'label' => t($field['widget']['label']), 'content_field_name' => $field['field_name'], ); - return $data; + + // Add a relationship to get information about referring items. + $field_types = _content_field_types(); + $types = array(); + foreach (content_types() as $type) { + if (isset($type['fields'][$field['field_name']])) { + $types[] = $type['name']; + } + } + $label_truncated = truncate_utf8(t($field['widget']['label']), 10, TRUE); + $title = t('@label referrer (!name) - vid', array('@label' => t($field['widget']['label']), '!name' => $field['field_name'])); + $title_short = t('@label-truncated referrer - vid', array('@label-truncated' => $label_truncated)); + $data["referrer_$table_alias"] = array( + 'table' => array( + 'group' => t('Content'), + 'join' => array( + 'users' => array( + 'table' => $db_info['table'], + 'left_field' => 'uid', + 'field' => $field['field_name'] .'_uid', + ), + ), + ), + 'uid' => array( + 'group' => t('Content'), + 'title' => $title, + 'title short' => $title_short, + 'help' => t($field_types[$field['type']]['label']) .' referrer - '. t('Appears in: @types', array('@types' => implode(', ', $types))), + 'relationship' => array( + 'base' => 'users', + 'handler' => 'content_handler_relationship', + 'label' => t('@label referrer', array('@label' => $field['widget']['label'])), + 'content_field_name' => $field['field_name'], + ), + ), + ); + return $data; } } Index: modules/acquia/cck/includes/views/content.views.inc =================================================================== --- modules/acquia/cck/includes/views/content.views.inc (revision 547) +++ modules/acquia/cck/includes/views/content.views.inc (working copy) @@ -58,7 +58,10 @@ 'content_handler_filter_many_to_one' => array( 'parent' => 'views_handler_filter_many_to_one', ), - + 'content_handler_filter_many_to_one_reverse' => array( + 'parent' => 'content_handler_filter_many_to_one', + ), + // relationship handlers 'content_handler_relationship' => array( 'parent' => 'views_handler_relationship', Index: modules/acquia/cck/modules/nodereference/nodereference.module =================================================================== --- modules/acquia/cck/modules/nodereference/nodereference.module (revision 547) +++ modules/acquia/cck/modules/nodereference/nodereference.module (working copy) @@ -162,6 +162,48 @@ 'label' => t($field['widget']['label']), 'content_field_name' => $field['field_name'], ); + + // Add a relationship to get information about referring items. + $field_types = _content_field_types(); + $types = array(); + foreach (content_types() as $type) { + if (isset($type['fields'][$field['field_name']])) { + $types[] = $type['name']; + } + } + $label_truncated = truncate_utf8(t($field['widget']['label']), 10, TRUE); + $title = t('@label referrer (!name) - vid', array('@label' => t($field['widget']['label']), '!name' => $field['field_name'])); + $title_short = t('@label-truncated referrer - vid', array('@label-truncated' => $label_truncated)); + + $data["referrer_$table_alias"] = array( + 'table' => array( + 'group' => t('Content'), + 'join' => array( + 'node' => array( + 'table' => $db_info['table'], + 'left_field' => 'nid', + 'field' => $field['field_name'] .'_nid', + ), + ), + ), + 'vid' => array( + 'group' => t('Content'), + 'field' =>'vid', + 'title' => $title, + 'title short' => $title_short, + 'help' => t($field_types[$field['type']]['label']) .' referrer - '. t('Appears in: @types', array('@types' => implode(', ', $types))), + 'relationship' => array( + 'base' => 'node', + //'base field' => 'vid', + 'handler' => 'content_handler_relationship', + 'label' => t('@label referrer', array('@label' => $field['widget']['label'])), + 'content_field_name' => $field['field_name'], + ), + ), + ); + $data["referrer_$table_alias"]['vid']['filter']['handler'] = 'content_handler_filter_many_to_one_reverse'; + $data["referrer_$table_alias"]['vid']['filter']['content_field_name'] = $field['field_name']; + return $data; } }