A couple things I noticed in testing out the beta:

If you check "Make uploaded file public" and save, the file is made public in Scribd. However, that checkbox doesn't check the value when displaying: if you edit that same node, the box will be unchecked.

If you then re-check the public box and re-save, the file is re-uploaded to Scribd as a new file (like in #1135740: File uploaded to Scribd on every node edit

CommentFileSizeAuthor
#2 1146798-2.patch2.2 KBBrockBoland
#1 1146798-1.patch429 bytesBrockBoland

Comments

BrockBoland’s picture

StatusFileSize
new429 bytes

Patch for the first part is attached: it will set the checkbox based on the stored public flag.

BrockBoland’s picture

StatusFileSize
new2.2 KB

The attached patch does not work, but it's a start.

I added a function to change the access flag on the document in Scribd, but it's not working correctly. In _scribdfield_node_presave(), it checks $field_value['data']['scribd_doc_id'] to see if the doc has already been uploaded. However, at this point in the execution, $field_value['data'] only has one value (description). Since scribd_doc_id is never set at this point, it goes through the upload routine on every node edit.

So, it's still uploading duplicate copies of the file, but before I fixed the persistence on the "Make uploaded file public" flag in the previous patch, it looked like it was working correctly. Without that fix, the "public" check box is unchecked every time you edit the node. The file is still being re-uploaded on every save, but because it's marked private, it doesn't appear in the file list on Scribd, so it only appears to be working correctly. I confirmed this by unchecking the public flag and re-saving the node a few times: the scribd_doc_id stored in the DB changed on each save.

In summary, the condition at the beginning of _scribdfield_node_presave() needs to be fixed. It still needs to check if the file already exists on Scribd, but $field_value['data']['scribd_doc_id'] is unavailable. I'm not sure how to get around this. Maybe the info from the $field_value['data'] array can be added to the form as hidden elements or something like that, so that the values are available during presave.

BrockBoland’s picture

Anybody else been dealing with this issue?

chefarov’s picture

I have the same issue, successfully applied path #2(1146798-2.patch) and now after I save my node I get:

The public/private flag for the document could not be set on Scribd.com.

If I Edit again my node the flag is properly applied.
I can't find any relevant option in scribd.com. Also I DONT have enabled any of
"
API secret:
Use secure, non-downloadable, Scribd files.
Disable printing for Scribd files, requires secure files and API key.

"

Is this an issue of the module?

BrockBoland’s picture

This issue is closed, but for those still using 6.x-1.0 that want a solution to this problem:

In scribdfield_nodeapi(), the data array on the field is not populated with existing information about the Scribd document. Before uploading the file to Scribd, this function tries to check if the file already has a Scribd document ID (empty($node->{$node_key}[$field_delta]['data']['scribd_doc_id'])). However, since the data array isn't populated, scribd_doc_id is always empty, so the file is uploaded on every node save.

I'm not sure where the module maintainer is going with this (see #1146798: "Make uploaded file public" flag not working correctly on node edit), but hacked in a fix for my site. I added this when looping over the fields

Existing code in scribdfield_nodeapi():

foreach ($node->{$node_key} as $field_delta => $field_value) {
  if (!empty($node->{$node_key}[$field_delta]['filepath']) && empty($node->{$node_key}[$field_delta]['data']['scribd_doc_id'])) {

My code goes between those two lines, to load information about existing files into the data array so that it's available to be checked in the if statement:

foreach ($node->{$node_key} as $field_delta => $field_value) {

  // For some reason, the data array on the field on the node is always empty
  // during the pre-save. If saving an existing node, load the existing file
  // info for this field, so that any existing Scribd file data is available
  // in that array during processing below.
  if ($node->nid > 0) {
    // Get existing values for this field
    $existing_files = filefield_get_node_files($node, $node_key);
    // Check each to see if the value is already in the DB
    foreach ($existing_files as $fid => $file_info) {
      if ($node->{$node_key}[$field_delta]['fid'] == $fid) {
        // file ID matches, so load the existing data into the $node object
        $node->{$node_key}[$field_delta]['data'] = $file_info['data'];
        break;
      }
    }
  }
  
  if (!empty($node->{$node_key}[$field_delta]['filepath']) && empty($node->{$node_key}[$field_delta]['data']['scribd_doc_id'])) {