Active
Project:
Links Package
Version:
5.x-1.7
Component:
Code: links_weblink.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 May 2007 at 19:14 UTC
Updated:
19 Nov 2007 at 10:08 UTC
It would be great to have an admin option of disallowing duplicate links. If a user adds a link that already exists, they should get an error message and/or be redirected to the node that already covers that link.
As always, happy to test or contribute however I can!
thanks
Comments
Comment #1
micheleannj commentedHere's my hack that seems to accomplish this:
Change links_weblink_validate in links_weblinks.module to
/**
* Implementation of hook_validate().
*/
function links_weblink_validate(&$node) {
if (($row = db_fetch_object( db_query("SELECT l.nid as nid FROM {links} l INNER JOIN
{links_node} ln ON l.lid = ln.lid WHERE l.url ='%s'",
$node->links_weblink_url))) && ($row->nid != $node->nid)){
form_set_error('url', t('Someone\'s already added that link. You can vote
on and add comments to the existing article'));
}
else
{
links_weblink_node_build($node);
}
}
Obviously, this could be done better and would need to to have an admin option for general use, but I thought I'd stick it here for reference.
Thanks
Comment #2
summit commentedHi there was a mistake in above code, NID should be LID on one occasion..
The code I implemented is:
Please advice if this is correct, and if so, please put in the newest version as a patch.
Thanks in advance,
greetings,
Martijn
Comment #3
summit commentedHi, I think there was still another mistake. The NID from links_node was not in the select statement.
Underneath the correct code:
Please advice if this is correct?
greetings,
Martijn
Comment #4
summit commentedHi,
I installed the Location module. This module makes it possible to add localize information to the weblink node-type.
But with above validation hook I have a problem now.
It says that the link is allready in the system, while I only change the location information.
Does anybody know how to alter above to get it not saying I have a dublicate link when I alter only the location info?
thanks in advance!
Greetings,
Martijn