<?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>mitchitized &#187; Nerdy stuff</title> <atom:link href="http://www.mitchitized.com/category/nerdy-stuff/feed/" rel="self" type="application/rss+xml" /><link>http://www.mitchitized.com</link> <description>the online home for mitch pirtle</description> <lastBuildDate>Fri, 30 Jul 2010 00:36:20 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <item><title>Locked out of your Joomla?</title><link>http://www.mitchitized.com/nerdy-stuff/locked-out-of-your-joomla/</link> <comments>http://www.mitchitized.com/nerdy-stuff/locked-out-of-your-joomla/#comments</comments> <pubDate>Fri, 06 Nov 2009 03:31:27 +0000</pubDate> <dc:creator>mitchy</dc:creator> <category><![CDATA[Nerdy stuff]]></category> <category><![CDATA[joomla]]></category><guid
isPermaLink="false">http://www.mitchitized.com/?p=89</guid> <description><![CDATA[This was just asked on the NYPHP Joomla mailing list, so I thought I&#8217;d add it here for folks as a quick cheatsheet. Basically the problem is when you find yourself with a Joomla site and have no idea what &#8230; <a
href="http://www.mitchitized.com/nerdy-stuff/locked-out-of-your-joomla/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>This was just asked on the <a
href="http://lists.nyphp.org/mailman/listinfo/joomla">NYPHP Joomla</a> mailing list, so I thought I&#8217;d add it here for folks as a quick cheatsheet. Basically the problem is when you find yourself with a Joomla site and have no idea what the logins are. You need to find the admin user (or whatever the admin user&#8217;s username is) and reset the password to something you know, so you can login and start taking control of the site. This is how it can be done.<span
id="more-89"></span>In the top directory of your website&#8217;s files, you&#8217;ll find a file there called <em>configuration.php</em>.Take a look in this file and grab the following variables:</p><ul><li>$host</li><li>$user</li><li>$db</li><li>$password</li></ul><p>That is your database access information. Now to change your admin password. When you connect to your database (using the mysql command line client on your server most likely), go to a table called <em>jos_users</em> and look for the admin user:</p><p><code>select id, name, username, password from jos_users;</code></p><p>Somewhere in those results should be a user called &#8216;admin&#8217; in the &#8217;username&#8217; column. If not, you should probably see which account was acting as the admin superuser, and that is the one you want. Now change that password to &#8216;changeme&#8217; like this, and note that I had to run the string &#8216;changeme&#8217; through MD5 first as all passwords in Joomla are hashed:</p><p><code>update jos_users set password = '4cb9c8a8048fd02294477fcb1a41191a' where username = 'admin';</code></p><p>Now you can login to the Joomla backend as <em>admin</em> / <em>changeme</em>, and <strong>IMMEDIATELY</strong> change your password.</p><p>For this very reason I keep a simple PHP script on my laptop that has a form that posts a text field and echos the output after an MD5 hash. That way I can generate MD5 hashes of known strings when I need to reset a password, for instance.</p><p>Hope you find this useful, and please pipe up in the comments if this post needs more detail.</p> ]]></content:encoded> <wfw:commentRss>http://www.mitchitized.com/nerdy-stuff/locked-out-of-your-joomla/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Joomla for blogging</title><link>http://www.mitchitized.com/nerdy-stuff/joomla-for-blogging/</link> <comments>http://www.mitchitized.com/nerdy-stuff/joomla-for-blogging/#comments</comments> <pubDate>Sat, 24 Oct 2009 15:48:24 +0000</pubDate> <dc:creator>mitchy</dc:creator> <category><![CDATA[Nerdy stuff]]></category> <category><![CDATA[joomla]]></category> <category><![CDATA[wordpress]]></category><guid
isPermaLink="false">http://www.mitchitized.com/?p=85</guid> <description><![CDATA[This site has been up in the current incarnation &#8211; that would be WordPress &#8211; for several months now. That means time to tear it up and do something different. Since I&#8217;ve been bemoaning the sorry state of Joomla as &#8230; <a
href="http://www.mitchitized.com/nerdy-stuff/joomla-for-blogging/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>This site has been up in the current incarnation &#8211; that would be WordPress &#8211; for several months now. That means time to tear it up and do something different.</p><p>Since I&#8217;ve been bemoaning the sorry state of Joomla as a blogging platform, I&#8217;ve been politely told that I can in fact use Joomla as a blogging platform, and it&#8217;ll actually work like, you know, a <strong>blog</strong>.<span
id="more-85"></span></p><p>So I&#8217;m investigating extensions and such to add the following features to a Joomla site:</p><ul><li>comments</li><li>trackbacks</li><li>pings</li><li>tags</li></ul><p>I know there are commercial platforms that can do some or all of these things, how about open source ones? The few things I HAVE tried were awful.</p><p>When I got it all figured out I&#8217;ll relaunch the blog, and document how it was done.</p><h2>What is it now?</h2><p>Right now this site is running WordPress with a few additional goodies:</p><ul><li>Pyrmont V2 2.0.7 by <a
title="Click to visit author's website" href="http://imotta.cn/">motta</a></li><li><a
title="Click to visit the plugin's website" href="http://www.webdev3000.com/">About Me 3000</a></li><li><a
title="Self explanatory, huh?" href="http://seanys.com/2007/10/12/twitter-wordpress-widget/">Twitter Widget</a></li><li><a
title="Cool." href="http://www.pepijnkoning.nl/archief/wordpress-my-twitpics-plugin/">My TwitPics</a></li><li><a
href="http://contactform7.com/">Contact Form 7</a></li><li><a
title="Click to visit site" href="http://www.deanlee.cn/wordpress/code_highlighter_plugin_for_wordpress/">Dean&#8217;s Code Highlighter</a></li><li><a
title="Clickie the linkie" href="http://yoast.com/wordpress/analytics/#utm_source=wordpress&amp;utm_medium=plugin&amp;utm_campaign=google-analytics-for-wordpress">Google Analytics for WordPress</a></li><li><a
title="Just click it, punk!" href="http://www.arnebrachhold.de/redir/sitemap-home/">Google XML Sitemaps</a></li><li><a
title="Sociable adds social media links to all of your posts." href="http://blogplay.com/plugin">Sociable</a></li></ul><p>I tried the WordPress Events Calendar but it didn&#8217;t work; and ditto for my experience with a variety of book plugins, who either had absolutely horrific markup and display or broken code.</p><p>My favorite app in this whole experience ended up being the WordPress for iPhone app &#8211; which does exactly what it says, and allows you to manage posts, pages and comments all from your iPhone. Best of all you can incorporate photos in your content, making it more than just a &#8220;in case of emergency&#8221; tool.</p><p>Once I figure out what I&#8217;m going to do for a Joomla-powered blog, I&#8217;ll post as well. And this time I&#8217;ll include some redirects for old URLs from the WordPress instance, and keep the old content and comments. Wish me luck.</p> ]]></content:encoded> <wfw:commentRss>http://www.mitchitized.com/nerdy-stuff/joomla-for-blogging/feed/</wfw:commentRss> <slash:comments>11</slash:comments> </item> <item><title>PHP Frameworks Explained</title><link>http://www.mitchitized.com/nerdy-stuff/php-frameworks-explained/</link> <comments>http://www.mitchitized.com/nerdy-stuff/php-frameworks-explained/#comments</comments> <pubDate>Wed, 26 Aug 2009 03:36:52 +0000</pubDate> <dc:creator>mitchy</dc:creator> <category><![CDATA[Nerdy stuff]]></category> <category><![CDATA[cakephp]]></category> <category><![CDATA[code igniter]]></category> <category><![CDATA[drupal]]></category> <category><![CDATA[framework]]></category> <category><![CDATA[joomla]]></category> <category><![CDATA[kohanaphp]]></category> <category><![CDATA[php]]></category> <category><![CDATA[symfony]]></category> <category><![CDATA[zend]]></category><guid
isPermaLink="false">http://www.mitchitized.com/?p=56</guid> <description><![CDATA[So there&#8217;s all this hubbub about PHP frameworks, and heated debate over which one is the one true framework to rule them all. And you wondered, &#8220;So what is all the fuss about, is there really one framework that solves &#8230; <a
href="http://www.mitchitized.com/nerdy-stuff/php-frameworks-explained/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>So there&#8217;s all this hubbub about PHP frameworks, and heated debate over which one is <em>the one true framework to rule them all</em>. And you wondered, &#8220;<em>So what is all the fuss about, is there really one framework that solves all of my problems?</em>&#8221; I&#8217;m not an author of any particular framework, nor do I portray one on television. Let me take an unbiased swing at what I see as the lay of the land regarding frameworks and our favorite little programming language, PHP.</p><p><span
id="more-56"></span></p><p>Frameworks were created by developers, for developers &#8211; with the main intent to streamine the effort needed to create features and functions that were common across the vast majority of websites that they developed in their day to day work. Login, database access, caching, templating, session management, filtering of user input, the list goes on and on. However there are different approaches to how a framework can be used to your advantage, and the difference can be sometimes subtle.</p><p>NOTE: I&#8217;ve found another <a
title="Wikipedia entry, and a good one at that" href="http://en.wikipedia.org/wiki/Web_application_framework">good reference on web frameworks</a>, with a different view.</p><p>Now what was I saying? There are really two main kinds of frameworks: stack and glue.</p><h2>Stack &#8216;em up, bartender</h2><p>The concept of stack frameworks &#8211; sometimes referred to as scaffolding frameworks &#8211; is to generate the majority of the base code needed to produce a full-featured environment for the developer to be as productive as possible. The concept is to provide the full stack, with deep integration and workflow suited specifically to benefit the needs of the developer.</p><p>On the one hand, stack frameworks can be wicked fast for prototyping, and you can also take advantage of the stack to quickly add additional features to an existing application. As well, many developers appreciate the completeness of the stack approach as upgrades are easy to perform, and are usually done as one atomic operation.</p><p>On the other hand, stack frameworks are also referred to as <em>opinionated software</em>, meaning the framework has a strong opinion about how things are to be done; and if you have a different opinion then you&#8217;re not going to get along very well. It is commonly said &#8211; and commonly debated &#8211; that stack frameworks are more vulnerable to performance and scale issues as they attempt to do too much for too many&#8230; And ultimately fail to meet the needs of everyone to great satisfaction.</p><p>Notable stack frameworks are <a
title="Yeah I know, not PHP but worth mention" href="http://rubyonrails.org/">Ruby on Rails</a> (the real pioneer in this regard), <a
title="One of my faves 'cause Nate is the shiznit" href="http://cakephp.org/">CakePHP</a>, and <a
title="The second most misspelled PHP project in the universe" href="http://www.symfony-project.org/">Symfony</a>.</p><h2>Sniffing glue</h2><p>Glue frameworks are for the do-it-yourselfer &#8211; you glue together the parts specifically required by your application, and nothing more. This takes a much more hands-on approach for the developer, and usually means prototyping is not as insanely fast as a stack framework, however prototyping is still very rapid. Most importantly the performance and scaling of glue framework applications usually can be mitigated by extending an existing part of the framework, or replacing it altogether. For this reason a lot of developers prefer glue frameworks, having lived through painful customization efforts on less flexible platforms. Glue frameworks are usually very modular in nature, and that provides the additional benefit of having a large array of additional add-ons that developers can take advantage of.</p><p>The main drawback for glue frameworks is that they do require more effort from the developer. If you are light on development resources, or are more worried about the ongoing maintenance of your application once it is up and running, then this can be of significance.</p><p>Notable glue frameworks are <a
title="Go Matthew, go!" href="http://framework.zend.com/">Zend</a>, <a
title="It's a CMS! No, it's a framework! No, uh, er, um..." href="http://api.joomla.org/li_Joomla-Framework.html">Joomla! 1.5</a>, <a
title="PHP code that smokes!" href="http://codeigniter.com/">Code Igniter</a>, and <a
title="Modern, simple, powerful." href="http://kohanaphp.com/">KohanaPHP</a> (my current favorite).</p><h2>But wait, there&#8217;s more</h2><p>&#8220;<em>Joomla! 1.5 is a CMS</em>&#8220;, you say. Technically you&#8217;re right. However Joomla! 1.5 is actually two Joomla!&#8217;s &#8211; the framework, and the CMS. Speaking of <a
title="Nice entry at Wikipedia on CMS" href="http://en.wikipedia.org/wiki/Content_management_system">CMS</a>, we must include both <a
title="Clickie to go to the main sitie" href="http://www.joomla.org/">Joomla!</a> and <a
title="Fast growing competitor with enthusiastic supporters" href="http://drupal.org/">Drupal</a> here, as IMHO they provide an even bigger benefit to the client &#8211; software longevity and maintenance.</p><p>As a developer, you usually don&#8217;t worry about what happens after launch. For the folks that live and die by this application however, that is of paramount importance. For them, they need to know that their investment is protected from <em>bit rot</em>, or the slow decay of unmaintained software. What exactly does a CMS like Joomla! or Drupal do in this regard?</p><p>First, they provide a base platform that in essence is a finished and complete starting point for your application platform. That means you are able to run a basic website out of the box, with minimal or no modification. Additionally, each also boast a rich array of third party goodies that can be added for instant gratification &#8211; forums, integration with social media services, photo galleries, you name it.</p><p>If you are diligent about your development practices, you should also be packaging up your software as an extension to these environments. This provides the additional benefit of reuse, so software you write once might find a second life for another website or application purpose.</p><p>Finally, these are complete environments that are maintained by a group of folks dedicated to furthering that software project. This is <em>living software</em>, or software that takes on a life of its own as a variety of different people contribute to the evolution and maintenance of that software. By basing your website on one of these platforms, your client can take advantage of every update and enhancement this community produces for that software project.</p><p>There are a great many frameworks out there that are not covered, and that is merely because I cannot keep track of all of them. What other PHP frameworks deserve mention? Did I miss one that really deserves mad props?</p> ]]></content:encoded> <wfw:commentRss>http://www.mitchitized.com/nerdy-stuff/php-frameworks-explained/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Goodbye, auto increment</title><link>http://www.mitchitized.com/nerdy-stuff/goodbye-auto-increment/</link> <comments>http://www.mitchitized.com/nerdy-stuff/goodbye-auto-increment/#comments</comments> <pubDate>Thu, 13 Aug 2009 19:28:19 +0000</pubDate> <dc:creator>mitchy</dc:creator> <category><![CDATA[Nerdy stuff]]></category> <category><![CDATA[database]]></category> <category><![CDATA[mysql]]></category><guid
isPermaLink="false">http://www.mitchitized.com/?p=44</guid> <description><![CDATA[You are going to see a lot more writing about non-relational databases from me in the near future, and I thought I&#8217;d start making the transition with a little ditty about auto increment columns in MySQL. In short, they are &#8230; <a
href="http://www.mitchitized.com/nerdy-stuff/goodbye-auto-increment/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>You are going to see a lot more writing about non-relational databases from me in the near future, and I thought I&#8217;d start making the transition with a little ditty about auto increment columns in MySQL.</p><p>In short, they are bad. Not bad like mixing parachute pants with knitted sweaters, but bad like trying to eat a Volvo because you are hungry.</p><p>Auto increment, how much do I hate thee? Let me count the ways:</p><ol><li>Firstly they encourage lousy design. If you are going to use a relational database, you need to bother yourself with learning  basic relational theory.</li><li>They blow a hole in the push for a more semantic web. They are just numbers, and have no meaning.</li><li>They make sharding really really hard. Hope that site of yours never gets very successful.</li></ol><p>Put more bluntly, right now the only databases that use auto increment are MySQL and Microsoft Access. Yes, there is a reason, and it ain&#8217;t a good one.<span
id="more-44"></span></p><p>First lets cover the &#8216;lousy design&#8217; angle.</p><h2>Don&#8217;t forget your keys, honey.</h2><p>When you are building a table, you need a primary key.</p><p>(You&#8217;re still with me, right? Good.)</p><p>Now this key needs to be unique for every row. Maybe there is a user table in your website, and there is a column called username.</p><p><code><br
/> +----------+---------------------+<br
/> | id       | username                  |<br
/> +----------+---------------------+<br
/> |       62 | admin                     |<br
/> |       63 | amy                       |<br
/> |       64 | charlie                   |<br
/> |       65 | hasselhoff                |<br
/> |       66 | dracula                   |<br
/> |       68 | caroline                  |<br
/> |       69 | peter                     |<br
/> +----------+---------------------+<br
/> </code></p><p>That&#8217;s unique, right? Then why are you leveraging a number that has absolutely no meaning? In the good ol&#8217; days when I had to walk to school 20 miles each way in the ice and snow, naked, disk space was expensive and RAM was even worse. Then this kind of approach would have been appreciated as a cost cutting move. Nowadays? Fuhgeddaboudit.</p><p><strong>If you are building a relational database, you need to know what a relational database is in the first place.</strong> There are tons of free resources out there to help you along. Trust me, knowing how to take advantage of a relational database and actually using one is akin to getting a drivers license and actually driving. Otherwise, you&#8217;ll make no friends plowing into someone&#8217;s living room with their car.</p><p>The worst part about this approach is now whenever you insert a record into that table, you gotta make a second call to find out what the id was. Pretty sure it would be a lot more efficient to know when you inserted the row what the primary key was, now don&#8217;t you think?</p><h2>Say what you mean.</h2><p>Using the above example, when I am referring to a user on your website I am not going to say &#8220;<em>hey man, did you help out user #41432995?</em>&#8221; I&#8217;m going to ask you about the user &#8220;<em>funkychicken</em>&#8221; or &#8220;<em>the dude with the MIT email address</em>.&#8221; (For the record, anyone from MIT referring to themselves as <em>funkychicken</em> is okay in my book, &#8216;s all good with me.)</p><p>If you refer to a particular record by a column in that table, most likely that is your natural primary key. Why ignore that for an artificial one?</p><h2>Slicing and dicing, gone horribly wrong.</h2><p>When you start dealing with websites that got too big for their britches, the first point of major pain is almost always the database. Relational databases can be scaled, but it is hard, and can only go so far. Most big websites in this situation can either migrate to a different platform (more on that in subsequent posts) or chop their data into smaller chunks so it is easier to manage. This practice is called <a
title="Clickie-wickie to learnie-wearnie" href="http://en.wikipedia.org/wiki/Sharding">sharding</a>.</p><p>With that out of the way, sharding is really really hard when all of your information is linked with arbitrary numbers with no meaning. Sharding approaches are unique for every shop and website, so instead of making a passionate argument here, I&#8217;m going to leave you to your own devices. Try it yourself, and within a couple hours you will be nodding in complete understanding (and agreement).</p><h2>There&#8217;s always somebody who refuses to fit in.</h2><p>That&#8217;s right, there are plenty of scenarios where auto increment is doing you a favor. It was actually meant to do that favor for you. They just never envisioned an entire database schema littered with nothing but random numbers as primary keys.</p><p>Comments, for example. I&#8217;ve seen databases where articles go in one table, and comments go in another. The comments are not necessarily unique, maybe except for the timestamp and email of the person making the comment. Instead of making a composite key and additional index overhead, auto increment makes sense here. Besides, you are always going to be fetching based on the article_id or some such, right?</p><h2>But wait, it&#8217;s just not that easy.</h2><p><em>&#8220;Your users example is no good for me though, as I have multiple records with the same username (one is an old disabled account, or whatever). This doesn&#8217;t make sense to have a composite key of username and statu</em><em>s!&#8221;</em></p><p>You&#8217;re absolutely right. And that&#8217;s why I think you should consider a different datamodel. This one maybe makes sense if you are auto increment happy, and I&#8217;d say over-reliance on auto increment is what got you into this jam in the first place.</p><p>Try it &#8211; design a database from scratch, with absolutely zero auto increment columns. It is a good exercise, and I promise that even if the resulting database is worthless, you will have learned a few things.</p><p>Next up I&#8217;m going to talk about a couple different approaches that are leaving the realm of tomorrowland and starting to percolate in today&#8217;s consciousness.</p> ]]></content:encoded> <wfw:commentRss>http://www.mitchitized.com/nerdy-stuff/goodbye-auto-increment/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>JTable and primary keys</title><link>http://www.mitchitized.com/nerdy-stuff/jtable-and-primary-keys/</link> <comments>http://www.mitchitized.com/nerdy-stuff/jtable-and-primary-keys/#comments</comments> <pubDate>Sun, 19 Jul 2009 17:15:42 +0000</pubDate> <dc:creator>mitchy</dc:creator> <category><![CDATA[Nerdy stuff]]></category> <category><![CDATA[database]]></category> <category><![CDATA[joomla]]></category> <category><![CDATA[jtable]]></category> <category><![CDATA[juser]]></category><guid
isPermaLink="false">http://www.mitchitized.com/?p=18</guid> <description><![CDATA[While integrating Joomla with a remote user source, I learned that JTable won't let you touch id columns (or the primary key, more specifically). I had to do some workarounds and this is my shameful story. <a
href="http://www.mitchitized.com/nerdy-stuff/jtable-and-primary-keys/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Been working like a maniac recently integrating a <a
href="http://www.joomla.org/">Joomla</a> 1.5 powered website with a remote user source via RESTful interface. <a
href="http://en.wikipedia.org/wiki/REST">REST</a> is a great thing, and makes it dead simple to scale and shard your applications at the network level. However Joomla has an attitude about primary keys, or more specifically <a
href="http://api.joomla.org/Joomla-Framework/Table/JTable.html">JTable</a>. So when it came time for me to stuff user ids from this remote REST source, JTable said &#8220;no way, amigo.&#8221;</p><p>JTable, in this specific instance, won&#8217;t let you change the values in the jos_users.id column. Unfortunately that was exactly what I needed to do. In the end, I had to hotrod my authentication plugin to check to see if the jos_users.id was the same as the id coming over from the REST calls &#8211; and if not, manually update jos_users and jos_acl_aro_map.<span
id="more-18"></span></p><p>I created an authentication plugin that consumes the REST service. In the <a
href="http://docs.joomla.org/Reference:User_Events_for_Plugin_System#5.3.4_onAuthenticate">onAuthenticate</a> method I take the results of the REST call and stuff them in the session thusly:</p><div
class="dean_ch" style="white-space: wrap;"><ol><li
class="li1"><div
class="de1"><span
class="re0">$session</span> =&amp;amp; JFactory::<span
class="me2">getSession</span><span
class="br0">&#40;</span><span
class="br0">&#41;</span>;</div></li><li
class="li1"><div
class="de1"><span
class="re0">$session</span>-&gt;<span
class="me1">set</span><span
class="br0">&#40;</span><span
class="st0">&quot;user&quot;</span>,<span
class="re0">$response</span>,<span
class="st0">&#8216;mynamespace&#8217;</span><span
class="br0">&#41;</span>;</div></li></ol></div><p>For the user plugin, I created an <a
href="http://docs.joomla.org/Reference:User_Events_for_Plugin_System#5.3.7_onAfterStoreUser">onAfterStoreUser</a> method that takes the values stuffed in the session above, and compares them to the existing JUser object properties. Right now all I am really looking for is the jos_users.id as that is what I cannot take care of with the stock facilities provided by Joomla. The method looks strikingly like this:</p><div
class="dean_ch" style="white-space: wrap;"><ol><li
class="li1"><div
class="de1"><span
class="kw2">function</span> onAfterStoreUser<span
class="br0">&#40;</span><span
class="re0">$user</span>, <span
class="re0">$isnew</span>, <span
class="re0">$success</span>, <span
class="re0">$msg</span><span
class="br0">&#41;</span></div></li><li
class="li1"><div
class="de1"><span
class="br0">&#123;</span></div></li><li
class="li1"><div
class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <a
href="http://www.php.net/global"><span
class="kw3">global</span></a> <span
class="re0">$mainframe</span>;</div></li><li
class="li1"><div
class="de1">&nbsp;</div></li><li
class="li2"><div
class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span
class="co1">// Get the correct user_id out of REST session object</span></div></li><li
class="li1"><div
class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span
class="re0">$session</span> =&amp;amp; JFactory::<span
class="me2">getSession</span><span
class="br0">&#40;</span><span
class="br0">&#41;</span>;</div></li><li
class="li1"><div
class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span
class="re0">$object</span> = <span
class="re0">$session</span>-&gt;<span
class="me1">get</span><span
class="br0">&#40;</span><span
class="st0">&quot;user&quot;</span>,<span
class="st0">&#8216;empty object&#8217;</span>,<span
class="st0">&#8216;mynamespace&#8217;</span><span
class="br0">&#41;</span>;</div></li><li
class="li1"><div
class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span
class="re0">$gid</span> = <span
class="re0">$object</span>-&gt;<span
class="me1">id</span>;</div></li><li
class="li1"><div
class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span
class="kw1">if</span><span
class="br0">&#40;</span><span
class="re0">$gid</span> != <span
class="re0">$user</span><span
class="br0">&#91;</span><span
class="st0">&#8216;id&#8217;</span><span
class="br0">&#93;</span><span
class="br0">&#41;</span></div></li><li
class="li2"><div
class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span
class="br0">&#123;</span></div></li><li
class="li1"><div
class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
class="co1">// Now fix Joomla&#8217;s broken IDs in jos_users</span></div></li><li
class="li1"><div
class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
class="re0">$db</span> =&amp;amp; JFactory::<span
class="me2">getDBO</span><span
class="br0">&#40;</span><span
class="br0">&#41;</span>;</div></li><li
class="li1"><div
class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
class="re0">$sql</span> = <span
class="st0">&#8216;UPDATE #__users SET id = &#8216;</span> . <span
class="re0">$gid</span> . <span
class="st0">&#8216; WHERE id = &#8216;</span> . <span
class="re0">$user</span><span
class="br0">&#91;</span><span
class="st0">&#8216;id&#8217;</span><span
class="br0">&#93;</span>;</div></li><li
class="li1"><div
class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
class="re0">$session</span>-&gt;<span
class="me1">set</span><span
class="br0">&#40;</span><span
class="st0">&#8216;auth_plugin_sql&#8217;</span>, <span
class="re0">$sql</span><span
class="br0">&#41;</span>;</div></li><li
class="li2"><div
class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
class="re0">$db</span>-&gt;<span
class="me1">setQuery</span><span
class="br0">&#40;</span><span
class="re0">$sql</span><span
class="br0">&#41;</span>;</div></li><li
class="li1"><div
class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
class="re0">$result</span> = <span
class="re0">$db</span>-&gt;<span
class="me1">query</span><span
class="br0">&#40;</span><span
class="br0">&#41;</span>;</div></li><li
class="li1"><div
class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
class="co1">// Now update the ACL mapping for this user as the id is different</span></div></li><li
class="li1"><div
class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
class="re0">$sql_acl</span> = <span
class="st0">&#8216;UPDATE #__core_acl_aro SET value = &#8216;</span> . <span
class="re0">$gid</span> . <span
class="st0">&#8216; WHERE value = &#8216;</span> . <span
class="re0">$user</span><span
class="br0">&#91;</span><span
class="st0">&#8216;id&#8217;</span><span
class="br0">&#93;</span>;</div></li><li
class="li1"><div
class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
class="re0">$db</span>-&gt;<span
class="me1">setQuery</span><span
class="br0">&#40;</span><span
class="re0">$sql_acl</span><span
class="br0">&#41;</span>;</div></li><li
class="li2"><div
class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span
class="re0">$result_acl</span> = <span
class="re0">$db</span>-&gt;<span
class="me1">query</span><span
class="br0">&#40;</span><span
class="br0">&#41;</span>;</div></li><li
class="li1"><div
class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span
class="br0">&#125;</span></div></li><li
class="li1"><div
class="de1"><span
class="br0">&#125;</span></div></li></ol></div><p>Now you have a system that fetches user data from a RESTful service, and populates the Joomla tables to make JUser happy.</p><p>Look ma, no core hacks!</p><p>One ugly &#8216;feature&#8217; of this system is that on the first login, the user finds themselves in a state where they attempt to authenticate with one id and it gets updated. Since I have no way to tell JUser to reload itself, you have this strange experience of logging in twice and then everything is golden.</p><p>Interested in hearing how others have dealt with this problem.</p> ]]></content:encoded> <wfw:commentRss>http://www.mitchitized.com/nerdy-stuff/jtable-and-primary-keys/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using xcache
Page Caching using xcache (user agent is rejected)
Database Caching using xcache

Served from: www.mitchitized.com @ 2010-08-01 10:44:08 -->