How do I print a link only if it doesn't lead to access denied My nodes have fairly complex permissions set on them.  I want to display a small edit link on the teaser for a specific content type, only if the user has the permissions required to edit that specific node.  I already customise the display with the file node--newsletter.tpl.php

I tried:

&lt;?php
$quick_links['quick-edit'] = array(
    'title' =&gt; 'Edit',
    'href' =&gt; 'node/' . $nid . '/edit');
?&gt;
&lt;div class="links quick-edit-links"&gt;
    &lt;?php print theme('links', array('links' =&gt; $quick_links, 'class' =&gt; 'links inline')); ?&gt;
&lt;/div&gt;


But that prints out the edit link no matter what.  What's the correct way to do this.  Ideally I'd like to have a solution that is reasonably generic and works for practically any link (e.g. node/id/delete, or admin/)  So I can use it elsewhere, but a solution which only works for this specific case would be OK.
Now I feel silly, found an answer myself straight away, although it does only work for this specific example, I'd still be interested to see something more general.

&lt;?php if (node_access('update', $node)):
    print l('edit', 'node/' . $nid . '/edit');
endif; ?&gt;