Developers Archive for the 'drupal custom changes' Category

Bug Fix for the DrupalVb Module

Bug Fix for the DrupalVb Module Thursday, March 13th, 2008

The current DrupalVB Module 5.x-1.1. It has the following bug. The dual login for login in the user in vbulletin when they login in the drupal is not working.

Before the line 

 return;

in the function “_drupalvb_set_login_cookies” in the script drupal/modules/drupalvb/drupalvb.inc.php

 Add the following code

$idhash = md5($_SERVER[’HTTP_USER_AGENT’] . fetch_substr_ip($_SERVER[’REMOTE_ADDR’]));

  $result = db_query(_drupalvb_prefix(”REPLACE INTO {session} (sessionhash, userid, host, idhash, ”
                    .”lastactivity, location, useragent, styleid, languageid, loggedin, ”
                    .”inforum, inthread, incalendar, badlocation, bypass, profileupdate) VALUES ”
                    .”(’”.md5(’drupalvb’ . $userid).”‘, ‘”.$userid.”‘, ‘”.$_SERVER[’REMOTE_ADDR’].”‘, ‘”.$idhash.”‘, ”
                    .”‘”.time().”‘, ‘index.php’, ‘”.$_SERVER[HTTP_USER_AGENT].”‘, 0, 0, 1, 0, 0, 0, 0, 0, 0  )”));
 

Then add this function at the end of the script drupalvb.inc.php of the drupalvb module of drupal

function fetch_substr_ip($ip, $length = null)
{
 if ($length === null OR $length > 3)
 {
  $length = 1;
 }
 return implode(’.', array_slice(explode(’.', $ip), 0, 4 - $length));
}

Then remove the following line in the function drupalvb_user_login() in the script drupal/modules/drupalvb/drupalvb.module

$userinfo = db_fetch_array($result);

Creating Image gallery in drupal using Views and CCK Module

Creating Image gallery in drupal using Views and CCK Module Monday, February 25th, 2008

Views is a fantastically powerful module! Now we are going to see how to create an image gallery using view which can be linked to any user-defined drupal node.

You’re going to need the following modules installed and working on your site:

So let’s get started!

Create a new view image_gallery. check mark Provide page view, and set the url to image/tid/$arg. Select a list view and turned on the pager. Choose how many images you’d like on your page (I chose 10). If you open up the Empty Text area you’ll see an Input Format.Opening this up will allow you to select the php code filter. Once that’s complete paste the following code into the Empty Text area.

<?php
return image_gallery_page($type = NULL, $tid = arg(2));
?>

Skip now down to Fields. In fields we need only add one field (fields are required for list and table views), in this case we’ll need Image: Display Image. Make sure that the Handler: is set to Image with link, and that Option: is set to Thumbnail.

Next is the Arguments area. This is where we’ll actually define what is taking our argument and how it’s being used. Add an argument of Taxonomy: Term ID and set Title to %1, Option to 0, and Wildcard to %1.

Filters is just Node: Type of Image, and Node: Published equals yes.

Our Sort Criteria is Node: Created Ascending.

To create multiple gallery one for each new node follow the the below steps.

The first steps are identical to “Adding Taxonomy” shown above:

1. Go to Administer/Categories (admin/content/taxonomy)

2. Click the ‘Add Vocabulary’ tab

3. Call the vocabulary ‘Image Gallery’

4. In the ‘Types’ section, check the checkbox next to the CCK content type you created for images (mine is called ‘Image’)

5. Once the vocabulary is created, add terms to it - or select “Free Tagging”: this will allow the admin to start a new gallery without having to define it in the Categories Administration first.
Now when you go to create or edit an image content type, you will see an auto-complete field where you can enter the name of the gallery you want it to be displayed in.

6. Now go back to the View you created before for your gallery (admin/build/views), and instead of adding a filter, add an argument:
Taxonomy: Term Name

7. Create a new Content Type, called “gallery”

8. Add a field to “gallery”, for the Field Type select “View Reference”
as the Default Value, select the View you created before for your gallery.

9. Now go to Create content & create a new gallery. You can give it a title, and enter some description to the body if needed.
As an argument, enter any tag you assigned to your pictures before, for example the gallery name. Every picture that has been tagged with that term will show up in that gallery.

Make Drupal Secured

Make Drupal Secured Wednesday, February 6th, 2008

To make drupal more secured:

1. Limit access only to registered users.

2. Disable registration and manually register the users who are allowed to access the information.

3. Disable permission for anonymous users this will make the drupal more secured.

4. Use private file system, so unauthenticated users cant view the attachements / images posted.

5. Add robots.txt with the following lines:

User-agent:*
Disallow:/

6. Final important thing is to implement Drupal on a dedicated server and restrict access to HTTPS. Dedicated server is more secured.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.