add Link module support

Richard Eriksson - February 5, 2008 - 22:45
Project:Feed Element Mapper
Version:5.x-1.0-beta3
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

http://drupal.org/project/link adds a CCK link field. The attached .inc file (based on the feedapi_mapper_content.inc) provides very basic support (URL only) to the Link field. Ideally this would also include the title element for the field if it's enabled, but this solved an immediate problem, and wanted to share it at least.

AttachmentSize
feedapi_mapper_link.inc1.63 KB

#1

alex_b - February 6, 2008 - 18:41

Awesome. Will test asap.

#2

alex_b - February 6, 2008 - 18:44

What about security? Does the link cck field do some checking on field[0][url] before it stores it content to the database?

#3

Richard Eriksson - February 6, 2008 - 23:06

Link (CVS entries for the module) has a link_validate_url() function which, in the comments, claims to be a lenient URL validation function. It gets called in the processing section of the module, as well as in other places. It looks like it does it on form validation, so I don't know, in that case, if that happens before insert.

#4

alex_b - February 9, 2008 - 17:56

Hi Richard,

I had a check on validation, and it was not being called, so wrapped the $field_element part into the link_validate_url() function.

I also added a check, whether a given field is a link field (I did the same for the content module implementation).

I committed it all to the repository.

http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/feedapi_map...

Please check out the code and test it on your system. If you confirm that functionality is ok i can roll beta4.

Thank you for your work,

Alex

#5

Richard Eriksson - February 10, 2008 - 02:39

The link_validate_url function doesn't return the URL if valid, but rather the constants LINK_EXTERNAL, LINK_INTERNAL, LINK_EMAIL or LINK_FRONT (all of which are strings, meaning they are valid URLs of one type or another), or FALSE. Attached is a patch that uses a ternary operator to do the validation then use $feed_element as the text if it's valid, NULL if it's not.

AttachmentSize
feedapi_mapper_link.inc-validate.patch.txt529 bytes

#6

alex_b - February 10, 2008 - 14:28

That was the revenge of the untested last minute drop-in. Thanks for catching this.

http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/feedapi_map...

The rest working as expected?

#7

Richard Eriksson - February 11, 2008 - 22:08

It works as expected. Just did a test: even if the field is required, it puts in NULL when it something (like a title) that is clearly not a URL is mapped to a Link field. Strings that are clearly URLs get stored correctly.

#8

alex_b - February 11, 2008 - 22:13
Status:active» fixed

thanks for checking and thanks again for this great addition to FEMP.

#9

Anonymous (not verified) - February 25, 2008 - 22:23
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.