<?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>HonkBlog&#124;TechNotes &#187; Frameworks</title>
	<atom:link href="http://www.honk.com.au/index.php/category/dev/frameworks/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.honk.com.au</link>
	<description>Notes, fixes, tips and suggestions from across my technical world</description>
	<lastBuildDate>Wed, 02 Jun 2010 13:24:50 +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>Convert adjacency list model to a modified preorder tree traversal (MPTT) model hierarchy</title>
		<link>http://www.honk.com.au/index.php/2010/04/22/convert-adjacency-list-model-to-a-modified-preorder-tree-traversal-mptt-model-hierarchy/</link>
		<comments>http://www.honk.com.au/index.php/2010/04/22/convert-adjacency-list-model-to-a-modified-preorder-tree-traversal-mptt-model-hierarchy/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 09:55:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cake PHP]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Patterns]]></category>
		<category><![CDATA[adjacency list model]]></category>
		<category><![CDATA[mptt]]></category>

		<guid isPermaLink="false">http://www.honk.com.au/?p=329</guid>
		<description><![CDATA[This us more a note to self than anything else, as I trawled the internet trying to find a definitive answer to this.  Modified preorder tree traversal (MPTT) is an efficient way to store and query hierarchical data in a database.  This article on the MySQL site explains why this is the case with a neat comparison between [...]]]></description>
			<content:encoded><![CDATA[<p>This us more a note to self than anything else, as I trawled the internet trying to find a definitive answer to this.  <strong>Modified preorder tree traversal (MPTT)</strong> is an efficient way to store and query hierarchical data in a database.  <a href="http://dev.mysql.com/tech-resources/articles/hierarchical-data.html" target="_blank">This article on the MySQL site</a> explains why this is the case with a neat comparison between MPTT and a more &#8220;old school&#8221; approach which relies on a parent-child recursive relationship in the database (known as the Adjacency List Model).  I wont repeat what it says but suffice to say I&#8217;ve been experimenting with MPTT for a while and like the way it does things.</p>
<p>I use cakephp a lot and I have recently created a hierarchy of some 120,000 items, all neatly mapped with parent-child relationships but no MPTT data.  Cake&#8217;s inbuilt mechanism for <strong>converting adjacency list model to a modified preorder tree traversal (MPTT) </strong>model hierarchy was far to slow: on my PC and with this much data it was taking about a second per row, which adds up to an awfully long time to process the whole tree!</p>
<p>Given the need for this type of conversion I found it surprisingly difficult to find a script that the the Agency list to MPTT conversion, so I thought I&#8217;d document what I found here, and add to it if I find any further.</p>
<p>So, using the CakePHP naming conventions here is a script to convert Agency List to MPTT using MySQL and PHP.  This is much faster than the native <a href="http://mrphp.com.au/code/code-category/cakephp/cakephp-1-2/fun-tree-behaviour-cakephp" target="_blank">CakePHP model-&gt;recover() m</a>ethod (which rebuilds your hierarchy) which is important on big datasets obviously.  This script is based on the function in <a href="http://articles.sitepoint.com/article/hierarchical-data-database/3" target="_blank">this excellent article on MPTT</a>.</p>
<pre class="brush:php">//Make sure it doesn't time out
        set_time_limit (0);

	$con = mysql_connect("localhost","user","password");
	if (!$con){die('Could not connect: ' . mysql_error());}
	mysql_select_db("your_db", $con);

	function rebuild_tree($parent_id, $left) {
	   // the right value of this node is the left value + 1
	   $right = $left+1;   

	   // get all children of this node
	   $result = mysql_query('SELECT id FROM categories '.
	                          'WHERE parent_id="'.$parent_id.'";');   

	   while ($row = mysql_fetch_array($result)) {
	       // recursive execution of this function for each
	       // child of this node
	       // $right is the current right value, which is
	       // incremented by the rebuild_tree function
	       $right = rebuild_tree($row['id'], $right);
	   }   

	   // we've got the left value, and now that we've processed
	   // the children of this node we also know the right value
	   mysql_query('UPDATE categories SET lft='.$left.', rght='.
	                $right.' WHERE id="'.$parent_id.'";');   

	   // return the right value of this node + 1
	   return $right+1;
	}   

rebuild_tree('1',1);

mysql_close($con);</pre>
<p>Using pure traditional SQL you can use the following script apparently, but I didn&#8217;t have time to make it work in MySQL and the above processed things quickly enough.  The source of the script below is here http://data.bangtech.com/sql/nested_set_treeview.htm</p>
<pre class="brush:sql">-- Tree holds the adjacency model
CREATE TABLE Tree
(emp CHAR(10) NOT NULL,
 boss CHAR(10));

INSERT INTO Tree
SELECT emp, boss FROM Personnel;

-- Stack starts empty, will holds the nested set model
CREATE TABLE Stack
(stack_top INTEGER NOT NULL,
 emp CHAR(10) NOT NULL,
 lft INTEGER,
 rgt INTEGER);

BEGIN ATOMIC
DECLARE counter INTEGER;
DECLARE max_counter INTEGER;
DECLARE current_top INTEGER;

SET counter = 2;
SET max_counter = 2 * (SELECT COUNT(*) FROM Tree);
SET current_top = 1;

INSERT INTO Stack
SELECT 1, emp, 1, NULL
 FROM Tree
 WHERE boss IS NULL;

DELETE FROM Tree
 WHERE boss IS NULL;

WHILE counter &lt;= (max_counter - 2)
LOOP IF EXISTS (SELECT *
 FROM Stack AS S1, Tree AS T1
 WHERE S1.emp = T1.boss
 AND S1.stack_top = current_top)
 THEN
 BEGIN -- push when top has subordinates, set lft value
 INSERT INTO Stack
 SELECT (current_top + 1), MIN(T1.emp), counter, NULL
 FROM Stack AS S1, Tree AS T1
 WHERE S1.emp = T1.boss
 AND S1.stack_top = current_top;

 DELETE FROM Tree
 WHERE emp = (SELECT emp
 FROM Stack
 WHERE stack_top = current_top + 1);

 SET counter = counter + 1;
 SET current_top = current_top + 1;
 END
 ELSE
 BEGIN -- pop the stack and set rgt value
 UPDATE Stack
 SET rgt = counter,
 stack_top = -stack_top -- pops the stack
 WHERE stack_top = current_top
 SET counter = counter + 1;
 SET current_top = current_top - 1;
 END IF;
 END LOOP;
END;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.honk.com.au/index.php/2010/04/22/convert-adjacency-list-model-to-a-modified-preorder-tree-traversal-mptt-model-hierarchy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Error: The requested address &#8220;/&#8221; was not found on this server &#8211; CakePHP Error</title>
		<link>http://www.honk.com.au/index.php/2009/10/26/error-the-requested-address-was-not-found-on-this-server-cakephp-error/</link>
		<comments>http://www.honk.com.au/index.php/2009/10/26/error-the-requested-address-was-not-found-on-this-server-cakephp-error/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 08:13:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cake PHP]]></category>

		<guid isPermaLink="false">http://www.honk.com.au/?p=236</guid>
		<description><![CDATA[This morning when I uploaded my site to live I came across one of those cryptic CakePHP messages Error: The requested address &#8220;/&#8221; was not found on this serverwhich I thought I&#8217;d blog about just as a note to self.  I knew I had access to everything and my Auth setup was copied from DEV where it was [...]]]></description>
			<content:encoded><![CDATA[<p>This morning when I uploaded my site to live I came across one of those cryptic CakePHP messages <strong>Error: The requested address &#8220;/&#8221; was not found on this server</strong>which I thought I&#8217;d blog about just as a note to self.  I knew I had access to everything and my Auth setup was copied from DEV where it was working so I went through my normal routine for identifying the problem.</p>
<p>In my case it turned out to be a number of issues (a missing file and a missing database table) but the process to identify and therefore fix the problem is:</p>
<ol>
<li>Make sure you set up your DATABASE_CONFIG is setup correctly (database.php)</li>
<li>Check that your tmp folder (and all of it&#8217;s sub folders) are writable (at least chmod 666 on Linux),</li>
<li>While you&#8217;re there delete all cache files from <em>all</em>of the tmp sub folders</li>
</ol>
<p> After that, if you&#8217;re still having &#8220;Error: The requested address &#8220;/&#8221; was not found on this server&#8221; then you&#8217;re likely to be missing a database table or an include file, so go into your core.php and set:</p>
<pre class="brush:php">Configure::write('debug', 2);</pre>
<p>This should reveal any remaining issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.honk.com.au/index.php/2009/10/26/error-the-requested-address-was-not-found-on-this-server-cakephp-error/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>What is the difference between the Auth component and the ACL component in CakePHP?</title>
		<link>http://www.honk.com.au/index.php/2009/10/24/what-is-the-difference-between-the-auth-component-and-the-acl-component-in-cakephp/</link>
		<comments>http://www.honk.com.au/index.php/2009/10/24/what-is-the-difference-between-the-auth-component-and-the-acl-component-in-cakephp/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 12:33:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Auth component]]></category>
		<category><![CDATA[Cake PHP]]></category>

		<guid isPermaLink="false">http://www.honk.com.au/?p=180</guid>
		<description><![CDATA[This is a part of my  series.
One of the things that I found most confusing about implementing the Auth component and ACL was their precise relationship, how they hung together, what one was and the other wasn&#8217;t or more specifically what one did and the other didn&#8217;t.
While conceptually not complicated &#8211; the Auth Component [...]]]></description>
			<content:encoded><![CDATA[<p><strong>This is a part of my <a href="http://www.honk.com.au/index.php/2009/10/13/guide-to-setting-up-the-cakephp-auth-component/">Guide to setting up the CakePHP auth component</a> series.</strong></p>
<p>One of the things that I found most confusing about implementing the Auth component and ACL was their precise relationship, how they hung together, what one was and the other wasn&#8217;t or more specifically what one did and the other didn&#8217;t.</p>
<p>While conceptually not complicated &#8211; the <em>Auth Component</em> is something that identifies a user whereas the <em>ACL component</em> is something that takes that knowledge and says &#8220;what does this identified user have access to&#8221; &#8211; they seem (at first) so intermeshed in the &#8220;Automagic&#8221; functions of CakePHP that it can be difficult to establish what is causing what to happen.</p>
<p>I found this particularly so when, having not gone through the <a href="http://book.cakephp.org/view/641/Simple-Acl-controlled-Application" target="_blank">Simple-Acl-controlled-Application tutorial</a> kindly provided by the CakePHP team, I dropped the Auth component into my components list and lo and behold I was required to authenticate against actions I had wanted protected.</p>
<p>It wasn&#8217;t until reading this article and doing a bit of experimenting i realised that while it was definitely &#8220;Authenticating&#8221; it was not &#8220;Checking access&#8221; so none of my ACL stuff was kicking in at all.</p>
<p>An example of how the two functions seem intermeshed is the allowedActions function that is specified in the beforeFilter:</p>
<p>$this-&gt;Auth-&gt;allowedActions = array(&#8216;*&#8217;);</p>
<p>This is (as the method path shows) a function of the Auth component, but it relates to Access, in this case the actions of the controller.  This is an important function to understand, this tells the AuthComponent to allow PUBLIC access to all actions, you can of course provide a specific array of actions here as well.  The important thing to understand is that &#8220;public&#8221; is just a default state given to a non authenticated user, it is not a specific group you need to create and assign by default (which is the case in some authentication systems I&#8217;ve seen).</p>
<p>So remember that while a user can be &#8220;authenticated&#8221; that is, they are known to the system they are not necessarily being  checked against their access profile,  $this-&gt;Auth-&gt;allowedActions can confuse matters if you&#8217;re not careful because it can suggest that the authenticated person does or doesn&#8217;t have access to something (because they get redirected to the login page).</p>
<p>When working out what is tripping up a security response, use this handy guide to <a href="http://www.honk.com.au/index.php/2009/10/13/debugging-cakephp-auth-component/">Debugging CakePHP Auth component</a> which can tell you what is being validated against and thus if it is your dodgy ACL setup or just the default settings in the Auth component that are causing any problems.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.honk.com.au/index.php/2009/10/24/what-is-the-difference-between-the-auth-component-and-the-acl-component-in-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cake PHP Auth Component Frequently Asked Questions (FAQ)</title>
		<link>http://www.honk.com.au/index.php/2009/10/24/cake-php-auth-component-frequently-asked-questions-faq/</link>
		<comments>http://www.honk.com.au/index.php/2009/10/24/cake-php-auth-component-frequently-asked-questions-faq/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 12:26:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Auth component]]></category>
		<category><![CDATA[Cake PHP]]></category>

		<guid isPermaLink="false">http://www.honk.com.au/?p=161</guid>
		<description><![CDATA[This is a part of my  series.


]]></description>
			<content:encoded><![CDATA[<p><strong>This is a part of my <a href="http://www.honk.com.au/index.php/2009/10/13/guide-to-setting-up-the-cakephp-auth-component/">Guide to setting up the CakePHP auth component</a> series.</strong></p>
<h2><a href="http://www.honk.com.au/index.php/2009/10/24/what-is-the-difference-between-the-auth-component-and-the-acl-component-in-cakephp/">What is the difference between the Auth component and the ACL component in CakePHP?</a></h2>
<h2><a href="http://www.honk.com.au/index.php/2009/10/24/user-password-is-double-hashed-on-edit-when-using-the-cakephp-auth-component/">User password is "double hashed on edit when using the Cakephp Auth component</a></h2>
]]></content:encoded>
			<wfw:commentRss>http://www.honk.com.au/index.php/2009/10/24/cake-php-auth-component-frequently-asked-questions-faq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>User password is &#8220;double hashed on edit when using the Cakephp Auth component</title>
		<link>http://www.honk.com.au/index.php/2009/10/24/user-password-is-double-hashed-on-edit-when-using-the-cakephp-auth-component/</link>
		<comments>http://www.honk.com.au/index.php/2009/10/24/user-password-is-double-hashed-on-edit-when-using-the-cakephp-auth-component/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 12:25:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Auth component]]></category>
		<category><![CDATA[Cake PHP]]></category>

		<guid isPermaLink="false">http://www.honk.com.au/?p=171</guid>
		<description><![CDATA[This is a part of my  series.
I found a good basis for a resolution to this issue here .  It wasn&#8217;t perfect for me but did a nice job of explaining a problem I had with hashed values. I have provided a modified solution below that meets my requirements more specifically (that is [...]]]></description>
			<content:encoded><![CDATA[<p><strong>This is a part of my <a href="http://www.honk.com.au/index.php/2009/10/13/guide-to-setting-up-the-cakephp-auth-component/">Guide to setting up the CakePHP auth component</a> series.</strong></p>
<p>I found a good basis for a resolution to this issue <a href="http://dsi.vozibrale.com/articles/view/manually-hashing-password-and-password-validation" target="_blank">here </a>.  It wasn&#8217;t perfect for me but did a nice job of explaining a problem I had with hashed values. I have provided a modified solution below that meets my requirements more specifically (that is to allow password changes only when a password confirm is provided on edit, while requiring a password on add).<br />
A problem I had encountered along the way was due to me not understanding the hash function, I couldn&#8217;t get the two hash values to match, this problem is highlighted in the post &#8220;<a href="http://dsi.vozibrale.com/articles/view/manually-hashing-password-and-password-validation" target="_blank">Manually hashing password and password validation in CakePHP</a>&#8220;:</p>
<blockquote><p><strong>Security::hash($this-&gt;data['User']['passwd'], null, true);</strong><br />
This line makes the password readable by the Auth component, and that in turn removes the need of creating your own. Take a look at the API reference of Security::hash() and you will see that the third parameter is very important, as it tells the hash function to use the &#8220;Security.salt&#8221; value in the hashing process. In any case, if you need to hash something and be compatible with the Cake&#8217;s own Auth and Security, this seems to be the right way.</p></blockquote>
<p>So make sure you include the second and third parameters of the security function whichever solution you implement.</p>
<p>Below is my version of the code, I have essentially reversed the validation process as I wanted it to only execute if a password confirm was provided (that is the validation wouldn&#8217;t be tripped up unless they specifically wanted to change the password, and if the password field itself was blank then nothing should happen ever).</p>
<p>Taken from user.php (the model)</p>
<pre class="brush:php">    function __construct()
    {
        parent::__construct();   

		/*
		 * Validate on the password field not the password confirmation field
		 * This ensures that if we enter blank in both then nothing is triggered
		 * or blank on the confirmation field only then it is rejected using validatePasswdConfirm
		 */
        $this-&gt;validate = array
        (   

            'passwd' =&gt; array
            (
                /* snip other rules */
                'match' =&gt;
                array
                (
                    'rule'          =&gt; 'validatePasswdConfirm',
                    'required'      =&gt; false,
                    'allowEmpty'    =&gt; true,
                    'message'       =&gt; __('Passwords do not match', true)
                )
            ), 

	 /*
	 * On creation when we always want a password, have the form use a normal
	 * password field and have it validated against it's own special "empty" check
	 * that is '' that has been hashed (automagically by cake)
	 */
            'password' =&gt; array
                (
                    'rule'          =&gt; 'validateHashedPassword',
					'required'      =&gt; false,
                    'allowEmpty'    =&gt; false,
                    'message'       =&gt; __('You must submit a password', true)
                )
        );
	}

   function validateHashedPassword($data)
    {
		if ($data['password'] == Security::hash('', null, true))
        {
            return false;
        }   

        return true;
    } 

   function validatePasswdConfirm($data)
    {
		if (isset($this-&gt;data['User']['passwd_confirm'])&amp;&amp;
			$this-&gt;data['User']['passwd'] &lt;&gt; '' &amp;&amp;
			$this-&gt;data['User']['passwd_confirm'] !== $data['passwd']
			)
        {
            return false;
        }   

        return true;
    }   

	function beforeSave() {
	    /*
	     * Ensure that there is a value for the password,
	     * field it should be ignored if they are not
	     * providing a value (i.e. no update should take place)
	     */
		if (isset($this-&gt;data['User']['passwd']) &amp;&amp; $this-&gt;data['User']['passwd'] &lt;&gt; '')
	    {
	        $this-&gt;data['User']['password'] = Security::hash($this-&gt;data['User']['passwd'], null, true);
	        unset($this-&gt;data['User']['passwd']);
	    }   

	    if (isset($this-&gt;data['User']['passwd_confirm']))
	    {
	        unset($this-&gt;data['User']['passwd_confirm']);
	    }   

	    return true;
	}</pre>
<p>Just to be clear too here is my add/edit form (I combine them to save duplication), admin_edit.php:</p>
<pre class="brush:php">
<div class="main-content form">
create('User');?&gt;
<fieldset>
<legend></legend>

	input('id');
		echo $form-&gt;input('email');
		//App::import("Vendor", "dbug2");new dbug2($this-&gt;data);

		if(empty($this-&gt;data['User']['id'])){
			echo $form-&gt;input('password', array('value' =&gt; '','autocomplete'=&gt;'off'));
		}else{
			echo $form-&gt;input('User.passwd', array('label' =&gt; 'New password','value' =&gt; '','autocomplete'=&gt;'off'));
			echo $form-&gt;input('User.passwd_confirm', array('type' =&gt; 'password','label' =&gt; 'Confirm new password','value' =&gt; '','autocomplete'=&gt;'off'));
		};
		echo $form-&gt;input('firstname');
		echo $form-&gt;input('surname');
		echo $form-&gt;input('group_id');
	?&gt;
	</fieldset>

end('Submit');?&gt;</div>
</pre>
<p>Notice too the attribute:</p>
<pre class="brush:php">'autocomplete'=&gt;'off'</pre>
<p>This just prevents the field from being auto populated which I was experiencing while testing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.honk.com.au/index.php/2009/10/24/user-password-is-double-hashed-on-edit-when-using-the-cakephp-auth-component/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Guide to setting up the CakePHP auth component</title>
		<link>http://www.honk.com.au/index.php/2009/10/13/guide-to-setting-up-the-cakephp-auth-component/</link>
		<comments>http://www.honk.com.au/index.php/2009/10/13/guide-to-setting-up-the-cakephp-auth-component/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 08:55:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Auth component]]></category>
		<category><![CDATA[Cake PHP]]></category>

		<guid isPermaLink="false">http://www.honk.com.au/?p=135</guid>
		<description><![CDATA[
Introduction
If you&#8217;re anything like me by the time you&#8217;ve got to this guide you have probably read about a million interesting but very issue specific pages on setting up elements of the Auth Component in CakePHP.  For such an integral element of the system I found it surprisingly difficult to really understand all of the [...]]]></description>
			<content:encoded><![CDATA[<p><span><span style="margin-left: 0px ! important;"><code></code></span></span></p>
<h2>Introduction</h2>
<p>If you&#8217;re anything like me by the time you&#8217;ve got to this guide you have probably read about a million interesting but very issue specific pages on setting up elements of the Auth Component in CakePHP.  For such an integral element of the system I found it surprisingly difficult to really understand all of the elements.  Getting it working was one thing,  but really understanding the &#8220;Automagic&#8221; functions behind the scenes, what happened where and what would happen if I changed something took a lot of research.</p>
<p>So this guide attempts to bring together the results of that research.  It is a combination of  the &#8220;must reads&#8221; , a list of problems and solutions that I encountered when implementing stuff from them, a FAQ section (rather a Q&amp;A of the things I wanted to know along the way) and a general tips section for things that should make your life a bit easier.</p>
<p>The guide will continue to evolve as I discover more but if you have any suggestions or questions please submit a comment below so it is available to all.</p>
<h2>Required reading</h2>
<p>These links are required reading if you want to get to grips with the Auth component AND ACL.  I can&#8217;t stress enough how important it is to have read these and done them line by line before you start looking for answers elsewhere, without these examples the Auth component and ACL will be a little too black box.</p>
<ul>
<li><a href="http://book.cakephp.org/view/465/Understanding-How-ACL-Works" target="_blank">How ACL works</a> (from the CakePHP Book)</li>
<li><a href="http://book.cakephp.org/view/641/Simple-Acl-controlled-Application" target="_blank">A Simple ACL controlled application</a> (from the CakePHP Book tutorials)</li>
</ul>
<h2>Common problems with CakePHP Auth component and their solutions</h2>
<ul>
<li> <a href="http://www.honk.com.au/index.php/2009/10/24/dbaclallow-invalid-node-corecakelibscontrollercomponentsacl-php-line-325/">DbAcl::allow() - Invalid node [CORE\cake\libs\controller\components\acl.php, line 325]</a></li>
</ul>
<h2>CakePHP Auth Component &#8211; FAQ</h2>
<ul>
<li> <a href="http://www.honk.com.au/index.php/2009/10/24/cake-php-auth-component-frequently-asked-questions-faq/">Cake PHP Auth Component Frequently Asked Questions (FAQ)</a></li>
<li><a href="http://www.honk.com.au/index.php/2009/10/24/what-is-the-difference-between-the-auth-component-and-the-acl-component-in-cakephp/">What is the difference between the Auth component and the ACL component in CakePHP?</a></li>
<li> <a href="http://www.honk.com.au/index.php/2009/10/24/user-password-is-double-hashed-on-edit-when-using-the-cakephp-auth-component/">User password is "double hashed on edit when using the Cakephp Auth component</a></li>
</ul>
<h2>Tips and and tools</h2>
<h4>Debuging ACL in CakePHP</h4>
<p>Some handy tricks for seeing what is going on under the hood, this can be surprisingly tricky when things are happening automagically.</p>
<ul>
<li><a href="http://www.honk.com.au/index.php/2009/10/13/debugging-cakephp-auth-component/">Debugging CakePHP Auth component</a></li>
<li><a href="http://www.honk.com.au/index.php/2009/10/13/session-variables-available-when-using-cakephp-auth-component/">Session variables available when using CakePHP auth component</a></li>
</ul>
<h4>Managing ACL in CakePHP</h4>
<p>One of the complicating factors in managing your ACL setup is the derth of good management tools available.  The data required is fiddly and doesn&#8217;t lend itself to hacking around in the database to get things going because in my experience you just make yourself more confused than ever.</p>
<p>Probably the best management tool I found was:<br />
<a href="http://bakery.cakephp.org/articles/view/acl-management-plugin" target="_blank">http://bakery.cakephp.org/articles/view/acl-management-plugin</a></p>
<p>It&#8217;s not perfect, but it&#8217;s a solid tool that will speed up some of your management functions.</p>
<h4>Handy functions that play nicely with the Auth Component</h4>
<p>Keep track of modifications to your records automatically, these mods save time but also reveal some interesting concepts behind the Authcomponent.  Pay close attention to Comment 5 &#8220;Brett H Says&#8221; which explains an issue you&#8217;re likely to encounter using this if you&#8217;ve set up the auth component using the standard configuration.</p>
<ul>
<li><a href="http://blog.loadsys.com/2008/05/02/automagically-setting-user-id-of-record-creator-and-modifier-in-cakephp-12/" target="_blank">Automagically setting user ID of record creator and modifier in CakePHP 1.2</a></li>
</ul>
<h2>Other reading</h2>
<p>Aran Johnson has done an excellent series of examples and tutorials on <a href="http://aranworld.com/article/161/cakephp-acl-tutorial-what-is-it" target="_blank">the CakePHP auth component</a> here.  I found these when I was about half way through writing this guide so there is some duplication of course, but hopefully between the two you will find everything you need.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.honk.com.au/index.php/2009/10/13/guide-to-setting-up-the-cakephp-auth-component/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging CakePHP Auth component</title>
		<link>http://www.honk.com.au/index.php/2009/10/13/debugging-cakephp-auth-component/</link>
		<comments>http://www.honk.com.au/index.php/2009/10/13/debugging-cakephp-auth-component/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 08:54:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Auth component]]></category>

		<guid isPermaLink="false">http://www.honk.com.au/?p=133</guid>
		<description><![CDATA[This is the first in a series of articles on the  CakePHP Auth component, for me one of the more complicated elements of CakePHP (once you get past the most basic configuration) and one that has taken me ages to work out.   Hopefully the information in these guides will go some way to helping [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first in a series of articles on the  CakePHP Auth component, for me one of the more complicated elements of CakePHP (once you get past the most basic configuration) and one that has taken me ages to work out.   Hopefully the information in these guides will go some way to helping you through this process.</p>
<p>Ok, so here are some <strong>tricks for debugging the cakePHP auth component</strong> in no particular order, they are not a <a href="/index.php/2009/10/13/guide-to-setting-up-the-cakephp-auth-component">guide to setting up the CakePHP auth component</a> per se so take a look at those for more general set up information:</p>
<h2>Debugging the controller and action being requested by the Auth component</h2>
<p>in the beforeFilter() of app_controller.php put:</p>
<pre class="brush:css">$this-&gt;Auth-&gt;authError = sprintf(__('You are not authorized to access that location %s/%s .',true),$this-&gt;name,$this-&gt;action);</pre>
<p>This should be alongside your settings for $this-&gt;Auth-&gt;loginAction and $this-&gt;Auth-&gt;loginRedirect for example &#8211; assuming you have correctly set up your login form to display $session-&gt;flash(&#8216;auth&#8217;); then it will show you what was rejected by the Auth component.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.honk.com.au/index.php/2009/10/13/debugging-cakephp-auth-component/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Session variables available when using CakePHP auth component</title>
		<link>http://www.honk.com.au/index.php/2009/10/13/session-variables-available-when-using-cakephp-auth-component/</link>
		<comments>http://www.honk.com.au/index.php/2009/10/13/session-variables-available-when-using-cakephp-auth-component/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 08:01:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Auth component]]></category>
		<category><![CDATA[Cake PHP]]></category>

		<guid isPermaLink="false">http://www.honk.com.au/?p=130</guid>
		<description><![CDATA[To see which variables are available when using  CakePHP auth component simply dump out:
$session-&#62;read(&#8216;Auth.User&#8217;)
E.g. using the superb dBug tag (if you&#8217;re not using it you should be, I don&#8217;t even bother with other dump functions now):
App::import(&#8220;Vendor&#8221;, &#8220;dbug2&#8243;);new dbug2($session-&#62;read(&#8216;Auth.User&#8217;));
As an aside, anyone who is NOT using the  php dBug tag which mimics the equally excellent [...]]]></description>
			<content:encoded><![CDATA[<p>To see which variables are available when using  CakePHP auth component simply dump out:</p>
<p>$session-&gt;read(&#8216;Auth.User&#8217;)</p>
<p>E.g. using the superb <a href="http://dbug.ospinto.com/" target="_blank">dBug </a>tag (if you&#8217;re not using it you should be, I don&#8217;t even bother with other dump functions now):</p>
<p>App::import(&#8220;Vendor&#8221;, &#8220;dbug2&#8243;);new dbug2($session-&gt;read(&#8216;Auth.User&#8217;));</p>
<p>As an aside, anyone who is NOT using the  <a href="http://dbug.ospinto.com/" target="_blank">php dBug tag</a> which mimics the equally excellent CFdump tag in Coldfusion, you should be!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.honk.com.au/index.php/2009/10/13/session-variables-available-when-using-cakephp-auth-component/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What does &#8220;__n()&#8221; do in cakephp?</title>
		<link>http://www.honk.com.au/index.php/2009/10/09/what-does-__n-do-in-cakephp/</link>
		<comments>http://www.honk.com.au/index.php/2009/10/09/what-does-__n-do-in-cakephp/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 09:15:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cake PHP]]></category>

		<guid isPermaLink="false">http://www.honk.com.au/?p=116</guid>
		<description><![CDATA[While working on a multilingual app using Cakephp I was reminding myself  of the best way to add variables to localised strings in cakePHP and I cam across the __n() function which amazingly I had never used before.  
The __n() function is described in the API documentation as:
/**
* Returns correct plural form of message identified [...]]]></description>
			<content:encoded><![CDATA[<p>While working on a multilingual app using Cakephp I was reminding myself  of the best way to <a href="/index.php/2009/10/09/adding-variables-to-localised-i18n-strings-in-cakephp">add variables to localised strings in cakePHP</a> and I cam across the __n() function which amazingly I had never used before. <strong> </strong></p>
<p><strong>The __n() function</strong> is described in the <a href="http://api.cakephp.org/view_source/basics.php" target="_blank">API documentation</a> as:</p>
<pre style="padding-left: 30px;">/**
* Returns correct plural form of message identified by $singular and $plural for count $count.
* Some languages have more than one form for plural messages dependent on the count.
*/
function __n($singular, $plural, $count, $return = false)</pre>
<p>Thus it is simply a means to overcome the common problem of pluralising the text display when a variable quantity is specified.  Powerful stuff.  When used in combination with <a href="/index.php/2009/10/09/adding-variables-to-localised-i18n-strings-in-cakephp">variables in localised strings in CakePHP</a> it offers just about everything you need to provide a coherent, localised version of your site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.honk.com.au/index.php/2009/10/09/what-does-__n-do-in-cakephp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Images not appearing in Ubercart for Drupal</title>
		<link>http://www.honk.com.au/index.php/2009/06/27/images-not-appearing-in-ubercart-for-drupal/</link>
		<comments>http://www.honk.com.au/index.php/2009/06/27/images-not-appearing-in-ubercart-for-drupal/#comments</comments>
		<pubDate>Sat, 27 Jun 2009 14:28:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Drupal]]></category>

		<guid isPermaLink="false">http://www.honk.com.au/?p=72</guid>
		<description><![CDATA[Ubercart relies on the imagecache module to serve it&#8217;s images, so this must be installed first, and the PHP GD2 Module activated.
Once this is done the &#8220;presets&#8221; the settings required by imagecache to know how to handle the images must be defined.  This is done automatically by clicking on &#8220;store administration&#8221; and then the &#8220;images&#8221; link [...]]]></description>
			<content:encoded><![CDATA[<p>Ubercart relies on the <a href="http://drupal.org/project/imagecache" target="_blank">imagecache</a> module to serve it&#8217;s images, so this must be installed first, and the PHP GD2 Module activated.</p>
<p>Once this is done the &#8220;presets&#8221; the settings required by imagecache to know how to handle the images must be defined.  This is done automatically by clicking on &#8220;store administration&#8221; and then the &#8220;images&#8221; link at the bottom in the &#8220;status messages&#8221;.  As long as you have got the imagecache module installed correctly they should create correctly and images will show in your catalog.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.honk.com.au/index.php/2009/06/27/images-not-appearing-in-ubercart-for-drupal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
