<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fundaa.com &#187; Drupal</title>
	<atom:link href="http://fundaa.com/category/drupal/feed/" rel="self" type="application/rss+xml" />
	<link>http://fundaa.com</link>
	<description></description>
	<lastBuildDate>Wed, 16 May 2012 12:46:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>when you save the node the restrictions don&#8217;t get saved along with it &#8211; Restricted content module in drupal</title>
		<link>http://fundaa.com/drupal/when-you-save-the-node-the-restrictions-dont-get-saved-along-with-it-restricted-content-module-in-drupal/</link>
		<comments>http://fundaa.com/drupal/when-you-save-the-node-the-restrictions-dont-get-saved-along-with-it-restricted-content-module-in-drupal/#comments</comments>
		<pubDate>Fri, 13 May 2011 07:31:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Drupal]]></category>

		<guid isPermaLink="false">http://fundaa.com/?p=249</guid>
		<description><![CDATA[<br/>Ran into a problem on node form add: there is no nid assigned, so when you save the node the restrictions don&#8217;t get saved along with it. The node doesn&#8217;t exist, so at that point in the form it has no nid &#8212; a value of nid=0 was being added to {restricted content}.
What the user would see is the access restriction just not being saved. They&#8217;d have to go back in and edit the saved node, and then set the access again before it would &#8220;take.&#8221;
Here is the solution :
function ...]]></description>
			<content:encoded><![CDATA[<br/><p>Ran into a problem on node form add: there is no nid assigned, so when you save the node the restrictions don&#8217;t get saved along with it. The node doesn&#8217;t exist, so at that point in the form it has no nid &#8212; a value of nid=0 was being added to {restricted content}.</p>
<p>What the user would see is the access restriction just not being saved. They&#8217;d have to go back in and edit the saved node, and then set the access again before it would &#8220;take.&#8221;</p>
<p>Here is the solution :</p>
<p><strong>function restricted_content_nodeapi(&#038;$node, $op, $teaser = NULL, $page = NULL) {</p>
<p>   if ($op == &#8216;delete&#8217;) {</p>
<p>     db_query(&#8220;DELETE FROM {restricted_content} WHERE nid = %d&#8221;, $node->nid);</p>
<p>   }</p>
<p>+  elseif ($op == &#8216;insert&#8217;) {</p>
<p>+    $rids = array_keys(array_filter($node->restricted_content['rids']));</p>
<p>+       if ($rids) {</p>
<p>+       db_query(&#8220;INSERT INTO {restricted_content} VALUES (%d,&#8217;%s&#8217;)&#8221;, $node->nid, serialize($rids));</p>
<p>+       }</p>
<p>+    }</p>
<p>   elseif ($op == &#8216;alter&#8217; &#038;&#038; !restricted_content_form_access($node->uid) &#038;&#038; !restricted_content_node_access($node->nid)) {</p>
<p>     $message = restricted_content_var(&#8216;message&#8217;);</p>
<p>     $node->restricted = TRUE;</strong></p>
<p>Add another else if &#8220;insert&#8221; option </p>
<p>it&#8217;s work for me, best of luck to you&#8230;.. <img src='http://fundaa.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://fundaa.com/drupal/when-you-save-the-node-the-restrictions-dont-get-saved-along-with-it-restricted-content-module-in-drupal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

