<?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>Diadem Tech Weblogs &#187; CMS</title>
	<atom:link href="http://www.diademblogs.com/category/content-management-systems/feed" rel="self" type="application/rss+xml" />
	<link>http://www.diademblogs.com</link>
	<description>Tutorials, tips and howtos for web hosting and open source web development</description>
	<lastBuildDate>Mon, 17 Oct 2011 12:28:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Keep Joomla 1.0.x compatible after upgrading PHP 5.2 to 5.3 in Plesk</title>
		<link>http://www.diademblogs.com/content-management-systems/keep-joomla-1-0-x-compatible-after-upgrading-php-5-2-to-5-3-in-plesk</link>
		<comments>http://www.diademblogs.com/content-management-systems/keep-joomla-1-0-x-compatible-after-upgrading-php-5-2-to-5-3-in-plesk#comments</comments>
		<pubDate>Sat, 04 Jun 2011 11:08:57 +0000</pubDate>
		<dc:creator>hriday</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Joomla]]></category>

		<guid isPermaLink="false">http://www.diademblogs.com/?p=1268</guid>
		<description><![CDATA[PHP 5.3 introduces various new tags and deprecated certain PHP functions which were being supported till ver 5.2. We recently upgraded the PHP version on one of our servers to 5.3 and found that it broke one site which was built on ver Joomla 1.0.x. Following is a simple update to ensure that the site [...]]]></description>
			<content:encoded><![CDATA[<p>PHP 5.3 introduces various new tags and deprecated certain PHP functions which were being supported till ver 5.2. We recently upgraded the PHP version on one of our servers to 5.3 and found that it broke one site which was built on ver Joomla 1.0.x. Following is a simple update to ensure that the site still works on the new version of PHP 5.3.x.</p>
<p>Edit the Function.php file under  your Joomla directory on /public_html/includes/Cache/Lite.<br />
Replace:<br />
$arguments = func_get_args();</p>
<p>with</p>
<p>$arguments = func_get_args();<br />
$numargs = func_num_args();<br />
for($i=1; $i &lt; $numargs; $i++){<br />
$arguments[$i] = &amp;$arguments[$i];<br />
}</p>
<p>in includes/Cache/Lite/Function.php. It will fix compatibility view issues for joomla 1.0.x on php 5.3.x and this resolved the issue for us.</p>
Note: There is a rating embedded within this post, please visit this post to rate it.
]]></content:encoded>
			<wfw:commentRss>http://www.diademblogs.com/content-management-systems/keep-joomla-1-0-x-compatible-after-upgrading-php-5-2-to-5-3-in-plesk/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Create custom registration fields using Drupal</title>
		<link>http://www.diademblogs.com/content-management-systems/drupal-cms/create-custom-registration-fields-using-drupal</link>
		<comments>http://www.diademblogs.com/content-management-systems/drupal-cms/create-custom-registration-fields-using-drupal#comments</comments>
		<pubDate>Thu, 06 May 2010 10:57:20 +0000</pubDate>
		<dc:creator>mithun</dc:creator>
				<category><![CDATA[Drupal CMS]]></category>
		<category><![CDATA[drupal form]]></category>
		<category><![CDATA[drupal registration]]></category>

		<guid isPermaLink="false">http://www.diademblogs.com/?p=414</guid>
		<description><![CDATA[In Drupal websites, the login and registration is already integrated by default. But in one of our sites, our requirement is to add some custom fields in the drupal registration form. E.g., Full name, address, state, postcode, etc. To fulfill our requirement we will use profile module. Once, the profile module is installed and enabled [...]]]></description>
			<content:encoded><![CDATA[<p>In Drupal websites, the login and registration is already integrated by default. But in one of our sites, our requirement is to add some custom fields in the drupal registration form. E.g., Full name, address, state, postcode, etc.</p>
<p>To fulfill our requirement we will use profile module. Once, the profile module is installed and enabled you can add custom fields from administrative menu/user management/profile as shown in figure below :</p>
<div id="attachment_415" class="wp-caption alignnone" style="width: 504px"><a href="http://www.diademblogs.com/wp-content/uploads/2009/02/profile.jpg"><img class="size-full wp-image-415  " src="http://www.diademblogs.com/wp-content/uploads/2009/02/profile.jpg" alt="Custom Fields" width="494" height="366" /></a><p class="wp-caption-text">Custom Fields</p></div>
<p><strong>Firstly,</strong> you will have to choose the field type from the list like text field, multi text field, checkbox etc.</p>
<p><strong>Secondly,</strong> give a category name to make a group of your custom fields.</p>
<p>E.g., If you are giving &#8220;category name&#8221;=<strong>Contact Information</strong> to the fields then those fields will become a group and show under Contact Information tab.</p>
<p><strong>Finally,</strong> Give the title of the field and a machine readable name. Check this option &#8220;Visible in user registration form&#8221; from the form. If this option is not checked then this field will not show in the user registration form. If you want to validate the field then check the option &#8221; The user must enter a value &#8220;.  Click Add field button to save the field.</p>
<p>In our example, we have added some custom fields like registration type, full name, firm, etc. as shown in the figure below.</p>
<div id="attachment_416" class="wp-caption alignnone" style="width: 580px"><a href="http://www.diademblogs.com/wp-content/uploads/2009/02/fields1.jpg" target="_blank"><img class="size-full wp-image-416 " src="http://www.diademblogs.com/wp-content/uploads/2009/02/fields1.jpg" alt="Registration form" width="570" height="422" /></a><p class="wp-caption-text">Custom Drupal Registration form</p></div>
Note: There is a rating embedded within this post, please visit this post to rate it.
]]></content:encoded>
			<wfw:commentRss>http://www.diademblogs.com/content-management-systems/drupal-cms/create-custom-registration-fields-using-drupal/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Create a custom block in Drupal 6 using modules</title>
		<link>http://www.diademblogs.com/content-management-systems/drupal-cms/create-a-custom-block-in-drupal-6-using-modules</link>
		<comments>http://www.diademblogs.com/content-management-systems/drupal-cms/create-a-custom-block-in-drupal-6-using-modules#comments</comments>
		<pubDate>Thu, 04 Feb 2010 06:47:23 +0000</pubDate>
		<dc:creator>mithun</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Drupal CMS]]></category>

		<guid isPermaLink="false">http://www.diademblogs.com/?p=347</guid>
		<description><![CDATA[In this post we will discuss on creating a custom block through a module in Drupal 6.  One question can come into your mind that we can create block from the administrative menu/site building/blocks. So, what is the need to create block from module. The benefit of creating block from module is that, the module [...]]]></description>
			<content:encoded><![CDATA[<p>In this post we will discuss on creating a custom block through a module in Drupal 6.  One question can come into your mind that we can create block from the administrative menu/site building/blocks. So, what is the need to create block from module.</p>
<p>The benefit of creating block from module is that, the module can be placed in any theme or in any other sites and once the module is enable the block will created automatically with its contents as we have configured in the module.</p>
<p>Some easy steps to create block through module :</p>
<p><strong>Step 1 : </strong></p>
<p>Create a folder (give a folder name e.g., mymodule) in the modules directory of your Drupal site.  The name which you are giving as a folder name will become your module name. To create a module there must have two files inside the module folder named as:</p>
<p>( a) mymodule.info (b) mymodule.module</p>
<p>mymodule.info file contains the general information of the module you created and mymodule.module file contains the main coding which creates the block.</p>
<p># We are considering the module name as <strong>customblock </strong>and hence filenames are <strong>customblock.info</strong> and<strong> customblock.module</strong></p>
<p><strong>Step 2 : </strong></p>
<p>Copy the code given below and paste it inside the customblock.info file.</p>
<blockquote><p>; $Id: customblock.info,v 1.4 2009/02/18 22:02:46 dries Exp $<br />
name = Custom Block<br />
description = Creating Custom Block to demonstrate the block creation through module.<br />
package = Diadem<br />
version = VERSION</p>
<p>; Information added by drupal.org packaging script on 2008-10-08<br />
version = &#8220;5.11&#8243;<br />
project = &#8220;drupal&#8221;<br />
datestamp = &#8220;1223496909&#8243;</p></blockquote>
<p>This is the general information about the module and description field reflect the purpose of creating the module . Give the correct version which you are using for your drupal site. You need to change this information as per your requirement.</p>
<p><strong>Step 3 : </strong></p>
<p>Always remember that all the function name should start with the module name, e.g.  modulename_node_info(), modulename_perm(), etc. Copy the code given below and paste it inside the customblock.module file. You will observe that there has no php end tag at the end of the file. It is recommended in drupal that we donot need to end the php tag in the module pages.</p>
<blockquote><p>&lt;?php<br />
/**<br />
* Implementation of hook_node_info().<br />
*/<br />
function customblock_node_info() {<br />
return array(<br />
&#8216;customblock&#8217; =&gt; array(<br />
&#8216;name&#8217; =&gt; t(&#8216;Custom Block&#8217;),<br />
&#8216;module&#8217; =&gt; &#8216;customblock&#8217;,<br />
&#8216;description&#8217; =&gt; t(&#8216;How to create a custom Block.&#8217;),<br />
)<br />
);<br />
}</p>
<p>/**<br />
* Access Permission of this module by hook_perm();<br />
*/<br />
function customblock_perm() {<br />
return array(&#8216;access customblock content&#8217;);<br />
}</p>
<p>/**<br />
* Implementation of hook_block().<br />
*/<br />
function customblock_block($op=&#8217;list&#8217;, $delta=0) {<br />
// listing of blocks, such as on the admin/block page<br />
if ($op == &#8220;list&#8221;) {<br />
$block[0]["info"] = t(&#8216;Custom Block&#8217;);<br />
return $block;<br />
}<br />
else if($op == &#8216;view&#8217;)<br />
{<br />
$block_content=&#8221;;<br />
$block_content.=&#8217;&lt;div style=&#8221;border:1px solid #D6D6D6; background-color:#F2F2F2; padding: 5px;&#8221;&gt;&#8217;;</p>
<p>$block_content.=&#8217;&lt;div&gt;Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\&#8217;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. Why do we use it? &lt;br /&gt;<br />
&lt;a href=&#8221;http://drupal.org/&#8221; target=&#8221;_blank&#8221;&gt;Click Here&lt;/a&gt; &#8211; Drupal.Org<br />
&lt;/div&gt;&#8217;;<br />
$block_content.=&#8217;&lt;/div&gt;&#8217;;</p>
<p>$block['subject'] = &#8216;Custom Block&#8217;;<br />
$block['content'] = $block_content;<br />
return $block;<br />
}<br />
}</p></blockquote>
<p><!--[if gte mso 9]&gt;  Normal 0   false false false        MicrosoftInternetExplorer4  &lt;![endif]--><!--[if gte mso 9]&gt;   &lt;![endif]--><!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin:0in; 	margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman"; 	mso-fareast-font-family:"Times New Roman";} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.25in 1.0in 1.25in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --><!--[if gte mso 10]&gt; &lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:10.0pt; 	font-family:"Times New Roman"; 	mso-ansi-language:#0400; 	mso-fareast-language:#0400; 	mso-bidi-language:#0400;} --> <!--[endif]--></p>
<p class="MsoNormal">
<p><strong>Explanation : </strong></p>
<p>1)  <strong>customblock_node_info() :</strong> This is the implementation of the hook_node_info function defined in Drupal. This function contains the information about the module. E.g.: <em>name </em>which will show in the module listing page. <em>Description </em>– Some general information about the module and <em>module </em>– module name.</p>
<p>2) <strong>customblock_perm(): </strong>This is the implementation of hook_perm function defined in Drupal.</p>
<p>3) <strong>customblock_block() : </strong>This is the implementation of hook_block function defined in Drupal. This function is responsible to return the block content. You can see, we have defined a variable <strong>$block_content </strong>which contain the block with its contents and properties.</p>
<p><strong>$block['subject']</strong> variable contains name of the block created. Finally, we assigned the  <strong>$block_content </strong>into the<strong> $block['content']</strong> variable beacuse this varible is responsible to create the block.</p>
<p><strong>step 4 : </strong></p>
<p>Enable the customblock module from administrative menu/site building/modules.</p>
<div id="attachment_361" class="wp-caption alignnone" style="width: 823px"><img class="size-full wp-image-361" src="http://www.diademblogs.com/wp-content/uploads/2009/02/mod.jpg" alt="mod" width="813" height="298" /><p class="wp-caption-text">Custom Block Module</p></div>
<p>Once you enable the module a block named as Custom Block will be created . Configure the block from administrative menu/site building/blocks. Finally, place the block where you want to display in your drupal site.</p>
<img class="size-full wp-image-362" src="http://www.diademblogs.com/wp-content/uploads/2009/02/block.jpg" alt="Block" width="824" height="319" /><br />
Note: There is a rating embedded within this post, please visit this post to rate it.
]]></content:encoded>
			<wfw:commentRss>http://www.diademblogs.com/content-management-systems/drupal-cms/create-a-custom-block-in-drupal-6-using-modules/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to create a view in Drupal</title>
		<link>http://www.diademblogs.com/content-management-systems/drupal-cms/how-to-create-a-view-in-drupal</link>
		<comments>http://www.diademblogs.com/content-management-systems/drupal-cms/how-to-create-a-view-in-drupal#comments</comments>
		<pubDate>Sun, 21 Jun 2009 10:50:57 +0000</pubDate>
		<dc:creator>mithun</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Drupal CMS]]></category>
		<category><![CDATA[cck views]]></category>
		<category><![CDATA[drupal views]]></category>

		<guid isPermaLink="false">http://www.diademblogs.com/?p=395</guid>
		<description><![CDATA[In this post we will discuss how to create view to display the listing  for the content types in drupal sites. In Drupal, you can create  dynamic pages from administrative menu &#62; content management &#62; content &#62; Add Option. So, if you are creating some dynamic content E.g. pages where you should like to list [...]]]></description>
			<content:encoded><![CDATA[<p>In this post we will discuss how to create view to display the listing  for the content types in drupal sites. In <a href="http://www.drupal.org" target="_blank">Drupal</a>, you can create  dynamic pages from administrative menu &gt; content management &gt; content &gt; Add Option. So, if you are creating some dynamic content E.g. pages where you should like to list the records for a particular set of data fields, then to fulfill this requirement you need to create a <strong>View </strong>which will display you the listing of the contents of any content types.</p>
<p>Here are some simple steps to create view for any content type. This example has been created using Drupal 5.10.</p>
<h3><strong>Step 1 :Basic View Setup<br />
</strong></h3>
<p>Download the view module (<a href="http://drupalmodules.com/module/views" target="_blank">http://drupalmodules.com/module/views</a>) and install the module. Once you enable the view module to can create view for all content types. From administrative menu/site building/views click on add option. Once, you click on the add option you will get a form as shown in figure below.</p>
<p><strong>Basic information</strong> is the general information about the view which you will create.</p>
<div class="mceTemp">
<dl>
<dt><img class="size-full wp-image-396" src="http://www.diademblogs.com/wp-content/uploads/2009/02/viewinfo.jpg" alt="viewinfo" width="818" height="640" /></dt>
<dd> </dd>
</dl>
</div>
<h3><strong>Step 2 : Creating the View Display<br />
</strong></h3>
<p>You can display your created view in a page,block and both. Its up to to you how would you like to get the output.  For your help we are creating both the page and block. Please check the snapshots given below.</p>
<p><strong>(a) Creating a page for the view.</strong></p>
<p>Firstly, you have to check the provide page view option and give the URL of the view page. Use pager is the option for the pagination. If you don&#8217;t want pagination just unchecked the checkbox.</p>
<p><img class="size-full wp-image-403" src="http://www.diademblogs.com/wp-content/uploads/2009/02/viewpage.jpg" alt="Page" width="816" height="621" /></p>
<p><strong>b) Creating a Block for the view.</strong></p>
<p>Check the provide block option to create a block for the view. Nodes per block indicated how many nodes you want to show in you block.<strong><br />
</strong></p>
<p><img class="size-full wp-image-404" src="http://www.diademblogs.com/wp-content/uploads/2009/02/blockpage.jpg" alt="Block" width="819" height="483" /></p>
<h3><strong>Step 3 : Selecting the fields<br />
</strong></h3>
<p><strong>Fields &#8211; </strong>Select the fields which you want to display for this content types. In our example, we are showing the node title and node body. You need to choose the field from the drop down and click on the add Field button. The selected field will display above as shown in figure.</p>
<p><img class="size-full wp-image-407" src="http://www.diademblogs.com/wp-content/uploads/2009/02/fields.jpg" alt="Display Fields" width="815" height="464" /></p>
<h3><strong>Step 4 :View Arguments<br />
</strong></h3>
<p><strong>Arguments &#8211; </strong>If you want to display a particular node then you need to configure this argument section otherwise leave it blank.  If you want to display a particular node then you select the argument from the drop down which you want to pass for the node and click add argument. The selected argument will show above as shown in figure.</p>
<p>Now, you need to set the wildcard value. Wildcard is the value which you pass from the URL. This will automatically fetch the value and show the corresponding node content.</p>
<p>For example, if you want to show node whose node ID is 11 then select node ID as the argument and set wildcard to %1.</p>
<p><strong>%1</strong> represent 11, the first argument you pass from the URL i.e., <img src="/DOCUME~1/Mithun/LOCALS~1/Temp/moz-screenshot.jpg" alt="" />http://localhost/drupaldemo/?q=admin/build/views/page_entry/11</p>
<p><strong>%2</strong> represent 22, the second argument you pass from the URL i.e., http://localhost/drupaldemo/?q=admin/build/views/page_entry/11/22</p>
<p><img class="size-full wp-image-408" src="http://www.diademblogs.com/wp-content/uploads/2009/02/argument.jpg" alt="Passing Argument" width="816" height="534" /></p>
<h3><strong>Step 5 :Creating Filters for the View<br />
</strong></h3>
<p><strong>Filters &#8211; </strong>From this filter section you can filter the nodes which you want to show into your view page. In our example, we are filtering through node type and this is the simple and general way to filter. Select the Node: type from the dropdown and a click on the add filter button. Then select the page as the value of the node type.</p>
<p>Actually, in our example we are filtering the page type from all nodes through this filter option.</p>
<p><img class="size-full wp-image-411" src="http://www.diademblogs.com/wp-content/uploads/2009/02/filters.jpg" alt="Filter" width="811" height="417" /></p>
<h3><strong>Step 6 : Set Your Sort Criteria<br />
</strong></h3>
<p><strong>Sort Criteria &#8211; </strong>Select the field from the dropdown to sort. In our example, we are sorting as node ID i.e., latest node entry will show at the top of the listing. See the snapshot given below.</p>
<p><img class="size-full wp-image-412" src="http://www.diademblogs.com/wp-content/uploads/2009/02/sorting.jpg" alt="Sorting" width="816" height="294" /></p>
<h3><strong>Step 7 : Confirm the changes and preview the &#8216;View&#8217;<br />
</strong></h3>
<p>Finally, click on the save button to save all the provided information. Once, the view is save you can access the page by the URL you have provided. For our example, URL name is viewPage and to see the listing of the page nodes the url is <em>http://sitename/?q=viewPage</em>.</p>
<p>You will get the full url of your view page from <strong> Administrative menu &gt; site building &gt; views &gt; Listing </strong>page. You can also edit and delete this view from the section.</p>
Note: There is a rating embedded within this post, please visit this post to rate it.
]]></content:encoded>
			<wfw:commentRss>http://www.diademblogs.com/content-management-systems/drupal-cms/how-to-create-a-view-in-drupal/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Two ways to add Joomla users using your custom code</title>
		<link>http://www.diademblogs.com/content-management-systems/two-ways-to-add-joomla-users-using-your-custom-code</link>
		<comments>http://www.diademblogs.com/content-management-systems/two-ways-to-add-joomla-users-using-your-custom-code#comments</comments>
		<pubDate>Sun, 07 Jun 2009 12:36:45 +0000</pubDate>
		<dc:creator>amitabh</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Joomla]]></category>
		<category><![CDATA[add joomla users]]></category>
		<category><![CDATA[joomla users]]></category>

		<guid isPermaLink="false">http://www.diademblogs.com/?p=430</guid>
		<description><![CDATA[The task of adding Joomla users, login/logout, activating/deactivating of users and password reset tasks etc are handled by the component com_users. In this post I will show how to add a joomla user from an external page. Adding users externally can be done in two ways: 1. Create an html form with correct fields and [...]]]></description>
			<content:encoded><![CDATA[<p>The task of adding <a href="http://www.joomla.org" target="_blank">Joomla</a> users, login/logout, activating/deactivating of users and password reset tasks etc are handled by the component <em>com_users</em>. In this post I will show how to add a joomla user from an external page.</p>
<p>Adding users externally can be done in two ways:<br />
1.	Create an html form with correct fields and submit it the correct Joomla url so that Joomla handles the registration, or<br />
2.	If you want to do it in your custom method, you need to create both the html form and the and the script that will add the user to the Joomla.</p>
<p><strong>First, the regular way:</strong></p>
<p>We create an html form with the correct field names and place the form in the joomla root. The field names should match with that of the general joomla registration form.</p>
<p>If we view the source of a Joomla registration form then we can see that the form has text fields named name, username, Email, password, password2 and hidden fields task, id, gid. There is another hidden field whose name is generated by JUtility::getToken() and the value of the field is 1. This field value is checked at the time of submitting the registration information. More about this in a moment. On submitting the registration form the registration information is processed by the register_save method of the UserController in com_user, which has been specified by the hidden field named task in the registration form.</p>
<p>Now we come to the UserController in the com_user. In the register_save method there is a line which checks the token value from the submitted form. As we are using a static html form we either need to generate the token name on the html form or if we don’t want to include the token in the form then we need to bypass the line of code which checks for the token.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">JRequest<span style="color: #339933;">::</span><span style="color: #004000;">checkToken</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> or jexit<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Invalid Token'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>In the register_save method of the UserController in the com_user. Since we will be using a html form commonly so we go for the second option and comment the line for checking token</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// JRequest::checkToken() or jexit( 'Invalid Token' );</span></pre></div></div>

<p>The submitted registration information is then processed by the register_save method. The data is actually saved in the save method of the UserController.</p>
<p><strong>Now, the Other way:</strong></p>
<p>Here we use the previously created form and submit it to the custom script that we create. This approach is basically to copy the functionality of the register_save() method in the UserController in com_user to an external script and submit the html registration form to that script.</p>
<p>Now onto the script:<br />
To access the joomla environment in an external script, the following snippet is added to the start of the script:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'_JEXEC'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'JPATH_BASE'</span><span style="color: #339933;">,</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//this is when we are in the root</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'DS'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">require_once</span> <span style="color: #009900;">&#40;</span> JPATH_BASE <span style="color: #339933;">.</span>DS<span style="color: #339933;">.</span><span style="color: #0000ff;">'includes'</span><span style="color: #339933;">.</span>DS<span style="color: #339933;">.</span><span style="color: #0000ff;">'defines.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #009900;">&#40;</span> JPATH_BASE <span style="color: #339933;">.</span>DS<span style="color: #339933;">.</span><span style="color: #0000ff;">'includes'</span><span style="color: #339933;">.</span>DS<span style="color: #339933;">.</span><span style="color: #0000ff;">'framework.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$mainframe</span> <span style="color: #339933;">=&amp;</span> JFactory<span style="color: #339933;">::</span><span style="color: #004000;">getApplication</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'site'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mainframe</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">initialise</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This snippet basically makes available the joomla framework available in the script. The code snippet is found in the index.php of the joomla root.</p>
<p>Now we import the functionality of the register_save() method in the script.</p>
<p>#1. Check for request forgeries, we comment this out since tokens are not generated in the html  page</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//JRequest::checkToken() or jexit( 'Invalid Token' );</span></pre></div></div>

<p>#2. Get required system objects</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$user</span> 	      <span style="color: #339933;">=</span> clone<span style="color: #009900;">&#40;</span>JFactory<span style="color: #339933;">::</span><span style="color: #004000;">getUser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pathway</span> 	      <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span> <span style="color: #000088;">$mainframe</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getPathway</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$config</span>	      <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span> JFactory<span style="color: #339933;">::</span><span style="color: #004000;">getConfig</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$authorize</span>	      <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span> JFactory<span style="color: #339933;">::</span><span style="color: #004000;">getACL</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$document</span>       <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span> JFactory<span style="color: #339933;">::</span><span style="color: #004000;">getDocument</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>#3. If user registration is not allowed, show 403 not authorized(Not needed)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$usersConfig</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>JComponentHelper<span style="color: #339933;">::</span><span style="color: #004000;">getParams</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'com_users'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$usersConfig</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'allowUserRegistration'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		JError<span style="color: #339933;">::</span><span style="color: #004000;">raiseError</span><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">403</span><span style="color: #339933;">,</span> JText<span style="color: #339933;">::</span>_<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Access Forbidden'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>#4. Initialize new usertype setting</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$newUsertype</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$usersConfig</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'new_usertype'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$newUsertype</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$newUsertype</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Registered'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>#5. Bind the post array to the user object</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bind</span><span style="color: #009900;">&#40;</span> JRequest<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'usertype'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		JError<span style="color: #339933;">::</span><span style="color: #004000;">raiseError</span><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">500</span><span style="color: #339933;">,</span> <span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getError</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>#6. Set some initial user values</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'usertype'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'gid'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$authorize</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_group_id</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newUsertype</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ARO'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$date</span> <span style="color: #339933;">=&amp;</span> JFactory<span style="color: #339933;">::</span><span style="color: #990000;">getDate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'registerDate'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$date</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">toMySQL</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>#7. If user activation is turned on, we need to set the activation information(Not needed)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$useractivation</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$usersConfig</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'useractivation'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$useractivation</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'1'</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		jimport<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'joomla.user.helper'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'activation'</span><span style="color: #339933;">,</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span> JUserHelper<span style="color: #339933;">::</span><span style="color: #004000;">genRandomPassword</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'block'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>#8. Save the details of the user</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>After this we can use the php header function to redirect the user to the desired location.</p>
<p>That&#8217;s it! I hope Joomla developers find this helpful and please feel to post your views and comments to this post.</p>
Note: There is a rating embedded within this post, please visit this post to rate it.
]]></content:encoded>
			<wfw:commentRss>http://www.diademblogs.com/content-management-systems/two-ways-to-add-joomla-users-using-your-custom-code/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Global variable to check Drupal user authentication</title>
		<link>http://www.diademblogs.com/content-management-systems/global-variable-to-check-drupal-user-authentication</link>
		<comments>http://www.diademblogs.com/content-management-systems/global-variable-to-check-drupal-user-authentication#comments</comments>
		<pubDate>Thu, 23 Apr 2009 06:41:14 +0000</pubDate>
		<dc:creator>mithun</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[drupal user variable]]></category>

		<guid isPermaLink="false">http://www.diademblogs.com/?p=169</guid>
		<description><![CDATA[In Drupal, the User is a core module of the CMS and is responsible for the user management section of Drupal websites. In this module a global variable is defined which returns the user Id (i.e, uid) of the currently logged user. All the users are stored in users table in the database and once [...]]]></description>
			<content:encoded><![CDATA[<p>In <a title="Drupal CMS" href="http://www.drupal.org" target="_self">Drupal</a>, the User is a core module of the CMS and is responsible for the user management section of Drupal websites. In this module a global variable is defined which returns the user Id (i.e, uid) of the currently logged user. All the users are stored in users table in the database and once we have the primary key of the table we can fetch all the details of that particular user who have logged in.</p>
<p>To get the user id (uid) of the currently logged user we will have to write this simple code :<br />
<code>&lt;?php<br />
global $user;<br />
echo $user-&gt;uid;<br />
?&gt;</code></p>
<p>You can also access this variable from any modules or blocks throughout the site.<br />
E.g., blog module, poll module, node module, block module etc.</p>
Note: There is a rating embedded within this post, please visit this post to rate it.
]]></content:encoded>
			<wfw:commentRss>http://www.diademblogs.com/content-management-systems/global-variable-to-check-drupal-user-authentication/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

