I'm trying to implement the following functionality:
When the users import their feeds, I want to modify (if the feed has been already imported) the node containing a feed by registering who has submitted the feed.

So an example:

Suppose user A submits the feed F, the user B submits the feed F, what I need to have is a list associated with the node representing the feed F containing users A and B.

This is the code that I started to write, using a field called field_users. this code is located in the import process, inside the if clause of a feed already imported in the site.

            $result  = db_query("SELECT nid FROM {feedapi} WHERE url = '%s'", $feed['XMLURL']);
            $feed = db_fetch_object($result);
            $node = node_load($feed->nid);
            array_push($node->field_users, array('uid' => $user-uid)); 
            node_save($node);
            $count_already_imported++; 

Now my question:

Are you planning to implement this functionality?
Can you imagine a better way to implement this?
Can be any performance problem in doing this?

Thanks a lot for your time.

CommentFileSizeAuthor
#2 usersFeeds.txt2.04 KBcacciaresi

Comments

aron novak’s picture

FeedAPI won't contain such a specific feature, but I'm glad that you're planning with FeedAPI :)
What I recommend to you:
create a separate module which does the following:
- implement hook_nodeapi(), use $op = 'submit' clause of switch structure. Get feed url from this: $node->feedapi_url . Get current user from global $user. And store it in whatever table you want. In this case you can store the submission-trying for users per feed.

I hope it helps you to achieve what you want.
To make sure if it's really ok: http://aggregation.novaak.net/documentation/?q=api/FeedAPI/function/_fee... . Notice node_submit() call. Of course it's not opml-import specific, normal feed creation will have an effect too.

cacciaresi’s picture

StatusFileSize
new2.04 KB

I'm working in this http://drupal.org/node/186236, is there any way to contact you online if i want to make you some questions?

I'm having problems asigning the users to the node.

I add to the "blog" contentn type a CCK field of type User Reference, but i'm not being able to asign the users to the field...

My code is the following, is a new module:

<?php

function usersFeeds_nodeapi(&$node, $op, $teaser, $page) {
  if (isset($node->feed) || _feedapi_is_enabled($node->type)) {
    switch ($op) {
      case 'submit':
        // Case of already existing feed editing
        $feed = new stdClass();
        
        if (isset($node->nid)) {
          $feed->url = $node->feedapi['feedapi_url'];
          $old_config = node_load($node->nid);
          if ($feed->url == $old_config->feed->url) {
             global $user;
            // Trying to add the users to the field_users. 
            usersFeeds_queue($node->field_users, array('uid' => $user->uid));
            return;
          }
          $settings = _feedapi_get_settings(array('nid' => $node->nid, 'node_type' => $node->type));
          $node->url_updated = TRUE;
        }
        // Case of new feed submitting
        else {
          $feed->url = $node->feedapi_url;
          $settings = _feedapi_get_settings(array('node_type' => $node->type));
          $feed->settings = $settings;
        }
        // Common parts
        $assigned = _feedapi_assign_parser_processor($feed->url, $settings);
        $feed->processors = $assigned['processors'];
        $feed->parsers = $assigned['parsers'];
        $feed->feed_type = $assigned['type'];
        if (is_object($old_config) && $feed->feed_type !== $old_config->feed->feed_type) {
          $node->type_updated = TRUE;
        }
        $feed = _feedapi_call_parsers($feed, $feed->parsers, FALSE);
        $feed->link = $feed->options->link;
        global $user;
        usersFeeds_queue($node->field_users, array('uid' => $user->uid));
        $node->title = empty($node->title) ? $feed->title : $node->title;
        $node->body = empty($node->body) ? $feed->description : $node->body;
        $node->feed->options->link = $feed->options->link;
        $node->feed->url = $feed->url;
        $node->feed = $feed;
        break;
    }
  }
}


function usersFeeds_queue($queue, $new_elem) {
  if (empty($queue) || !isset($queue)) {
    $queue = array();
  }
  array_push($queue, $new_elem);
 
  return $queue;
}
?>

Well when i do this, after the submit, the fields contaings an errorvalue! I do not know why this is happening....

Thanks a lot for your time!

alex_b’s picture

Component: Code » Code feedapi (core module)
Status: Active » Closed (fixed)

Can be addressed in a separate module. See #1.

alex_b’s picture

Title: OMPL Import process modification » OPML Import process modification