<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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/"
	>

<channel>
	<title>SymfonyLab &#187; miscellaneous</title>
	<link>http://www.symfonylab.com</link>
	<description>Everything you wanted to know about Symfony framework but did not know who to ask!</description>
	<pubDate>Mon, 28 Jul 2008 06:35:56 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>Why symfony-project does not publish my posts on community page</title>
		<link>http://www.symfonylab.com/why-symfony-project-does-not-publish-my-posts-on-community-page/</link>
		<comments>http://www.symfonylab.com/why-symfony-project-does-not-publish-my-posts-on-community-page/#comments</comments>
		<pubDate>Thu, 27 Mar 2008 08:21:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Symfony]]></category>

		<category><![CDATA[miscellaneous]]></category>

		<category><![CDATA[community]]></category>

		<guid isPermaLink="false">http://www.symfonylab.com/why-symfony-project-does-not-publish-my-posts-on-community-page/</guid>
		<description><![CDATA[I noticed that during last 3 weeks none of our posts were published on community aggregation of blogs on symfony-project.
Hopefully this is just aggregation software fault. Somehow I had the same problem when used feedburner plugin for WP - symfony-project aggregator also was not able to fetch those posts so I had to disactivate but [...]]]></description>
			<content:encoded><![CDATA[<p>I noticed that during last 3 weeks none of our posts were published on community aggregation of blogs on symfony-project.<br />
Hopefully this is just aggregation software fault. Somehow I had the same problem when used feedburner plugin for WP - symfony-project aggregator also was not able to fetch those posts so I had to disactivate but this time looks like not a problem on my side. But what is strange I noticed that symfony-project weekly blog digests contains references to our posts. </p>
<p>So this is also kinda &#8220;testing post&#8221;. We are going to track its appereance on community page.</p>
<p>Wish ya all great symfony!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.symfonylab.com/why-symfony-project-does-not-publish-my-posts-on-community-page/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Extending sfGuardPlugin (part 2)</title>
		<link>http://www.symfonylab.com/extending-sfguardplugin-part-2/</link>
		<comments>http://www.symfonylab.com/extending-sfguardplugin-part-2/#comments</comments>
		<pubDate>Sat, 22 Mar 2008 11:54:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Symfony]]></category>

		<category><![CDATA[miscellaneous]]></category>

		<category><![CDATA[plugins]]></category>

		<category><![CDATA[sfGuardPlugin]]></category>

		<guid isPermaLink="false">http://www.symfonylab.com/extending-sfguardplugin-part-2/</guid>
		<description><![CDATA[I&#8217;ve totally forgot that at the end of post Extra questions and solutions for sfGuardPlugin we have promised to write how to implement complicated user statuses for sfGuardPlugin. Sorry Hugo (one of our commenters), you was hoping it will be quickly but only now we have got a chance to write next post about extending [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve totally forgot that at the end of post <a href='http://www.symfonylab.com/extra-questions-and-solutions-for-sfguardplugin/'>Extra questions and solutions for sfGuardPlugin</a> we have promised to write how to implement complicated user statuses for sfGuardPlugin. Sorry Hugo (one of our commenters), you was hoping it will be quickly but only now we have got a chance to write next post about extending sfGuardPlugin.</p>
<p>Generally, it&#8217;s simple but you should either modify existing sfGuardPlugin (so it&#8217;s hack and it&#8217;s bad because you will have problems with plugin upgrades) or override sfGuardPlugin with overwriting some functions.</p>
<p>I&#8217;m going to propose here hack version and if you want you always can use the same code for overriding. As you remember we used sfGuardPluginExtra for extending purposes. So now we need to add to sf_guard_user_profile new field which is called &#8220;user_status_id&#8221; and it&#8217;s responsible for user statuses (e.g. 1 = pending, 2 = active, 3 = frozen, 4 = deleted). There are actually 2 ways - either we use user_status_id only as informative field and allow/block user access based on original is_active field boolean value in sfGuardUser table. I bet in most cases it&#8217;s enough. Because if user pending or frozen or deleted he does not have access to system so is_active is false. But I can believe that in some cases we may need is_partially_active status or something like that <img src='http://www.symfonylab.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>This or other way this hack may shed some light on sfGuardAuth mechanisms (it&#8217;s good to know how we can improve is_active).</p>
<p>So let me provide you a small code quotation from sfGuardPlugin/lib/validator/sfGuardUserValidator.class.php</p>
<blockquote><p>
    $user = sfGuardUserPeer::retrieveByUsername($username);</p>
<p>   // user exists?<br />
    if ($user)<br />
    {<br />
      // password is ok?<br />
      if ($user->checkPassword($password))<br />
      {<br />
        $this->getContext()->getUser()->signIn($user, $remember);</p>
<p>        return true;<br />
      }<br />
    }
</p></blockquote>
<p>This is core of authentification for sfGuardPlugin. Lets stick a knife into this heart with our piece of code <img src='http://www.symfonylab.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<blockquote><p>
      // user status is ok?<br />
      if (!$user->checkStatus($user->getProfile()->getStatusId())) {<br />
     	  $error = $this->getParameterHolder()->get(&#8217;userstatus_error&#8217;);<br />
    	  return false;<br />
      }
</p></blockquote>
<p>It means we are going additionaly check user status before even allow system to identify the password. Of course function $user->checkStatus we need to additionaly define in sfGuardUser.php class:</p>
<blockquote><p>
public function checkStatus($status_id)<br />
  {<br />
    if ($status_id == SF_GUARD_USER_PROFILE_STATUS_ID_ACTIVE)<br />
		return true;<br />
	else return false;<br />
  }
</p></blockquote>
<p>Here we use only simple constant SF_GUARD_USER_PROFILE_STATUS_ID_ACTIVE and we can have more complicated conditions of course. </p>
<p>Let me provide full piece of code fore user validator with included our hack code:</p>
<blockquote><p>
    // user exists?<br />
    if ($user)<br />
    {<br />
      // user status is ok?<br />
      if (!$user->checkStatus($user->getProfile()->getStatusId())) {<br />
     	  $error = $this->getParameterHolder()->get(&#8217;userstatus_error&#8217;);<br />
    	  return false;<br />
      }</p>
<p>      // password is ok?<br />
      if ($user->checkPassword($password))<br />
      {<br />
        $this->getContext()->getUser()->signIn($user, $remember);</p>
<p>        return true;<br />
      }<br />
    }
</p></blockquote>
<p>Would be interesting to hear which other code hacks were done by you.<br />
I tried a quick search in symfony forum and found something related to hacks here:</p>
<p>http://www.symfony-project.org/forum/index.php/m/39682/?srch=hack+sfguardplugin#msg_39682</p>
<p>Have a great non hacked weekend!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.symfonylab.com/extending-sfguardplugin-part-2/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
