Make IT Complete

Technical Ramblings From an IT Professional

Auto Delete Content In Drupal

I have a client that wants to have content posted on his site automatically deleted when it reaches 30 days.  His site is built using Drupal and using the hook_cron() will let the scheduled cron job process the node deletions.

I created a Drupal module and in the .module file added function profeng_cron() as the hook and it calls deleteagednodes with the type of content to be removed.  The function deleteagednodes does all of the work.  I created a query to return all of the nodes that have the desired content types and then using a where clause to filter on the created date.  In this example I am setting $expired_time to be now minus 30 days and in the query I am getting records that were created before the $expired_time.

I then take the results from the query and loop through all results.  Because the cron job runs as the anonymous user I select the user that owns the node and set the current user to the owner of the node.  I then call the Drupal node_delete.  When calling node_delete all of the heavy lifting of the delete like writing to the logs and sending notifications are executed.

//cron hook

function profeng_cron()

{

deleteagednodes(’inspectionreport’);

}

//function to delete content by tyoe that is over 30 days old

function deleteagednodes($contenttype)

{

$expired_time = strtotime(’-30 days’);

$query = db_query(”SELECT nid, uid FROM {node} AS n WHERE type = ‘%s’ and created <= ‘%s’”, $contenttype, $expired_time);

while($del = db_fetch_object($query))

{

global $user;

$owner_account = user_load(array(’uid’ => $del->uid));

$temp_user = $user;

$user = $owner_account;

$this_edit['nid'] = $del->nid;

node_delete($this_edit);

$user = $temp_user;

}

}

Design Pattern for Database Incremental Loads.

http://vsteamsystemcentral.com/cs21/blogs/applied_business_intelligence/archive/2007/05/21/ssis-design-pattern-incremental-loads.aspx

MySite Clean Up

http://httpcode.com/blogs/PermaLink,guid,1cef79c3-bfeb-4eee-99ac-1c8b6050cf2b.aspx

Configure Outlook for Your Email Account

Follow the attached instructions to configure Outlook for your email account.

outlook-configuration-settings

Display the Item ID Number in SharePoint Lists

http://pathtosharepoint.wordpress.com/2009/01/18/item-id-in-display-and-edit-forms/

Where does a SharePoint Server Store the Name of the Config Database

WSS 2.0 and SPS 2003     HKLM\Software\Microsoft\Shared Tools\Web Server Extensions\Secure\ConfigDb

WSS 3.0 and MOSS 2007:   HKLM\Software\Microsoft\Shared Tools\Web Server Extensions\12.0\Secure\ConfigDb

List all the databases on SQL Server

List all the database on SQL Servers.

—-SQL SERVER 2005 System Procedures
EXEC sp_databases
EXEC sp_helpdb

—-SQL 2000 Method still works in SQL Server 2005
SELECT name
FROM sys.databases

SELECT name
FROM sys.sysdatabases


How to Spend your 73rd Birthday with Your Spouse

This was written by my father.  This year he suffered a serious cardiac event.  This was written as a presentation to his Marriage Encounter Group.  He may ramble more than I do.

Each year Barbara and Harry ask themselves how they are going to celebrate each other’s birthday.  Many times it is a relatively quiet event, most likely involving a special food event, or when we were more energetic, a few days at the Cape.   January 15, 2009 was to be no different.  Little did we know what was about to be a very unusual day.  The saga actually began a day earlier although we did not realize it at the time. [Read the rest of this entry...]

PING (Partimage Is Not Ghost) — Backup and Restore Disk Partitions

A tool that we are using with great success.

PING is a live Linux ISO, based on the excellent Linux From Scratch (LFS) documentation. It can be burnt on a CD and booted, or integrated into a PXE / RIS environment.Several tools have been added and written, so to make this ISO the perfect choice to backup and restore whole partitions, an easy way. It sounds like Symantec Ghost(tm), but has even better features, and is totally free.

Features include:

  • Probably the best available Linux toolbox for rescuing a system;
  • Backup and Restore partitions or files locally or to the network (MS Network Shared directory, NFS, FTP or SSHFS);
  • Backup and Restore the BIOS data as well;
  • Either burn a bootable CD / DVD, either integrate within a PXE / RIS environment;
  • Possibility to Blank local admin’s password;
  • Create your own restoration bootable DVD (see the Howto Documentation);
  • Partition and Format a disk before installing Windows (so to make sure your unattended Windows installation will happen on the right partition);
  • Specific advantages PING brings you over DOS and Ghost :
    • Most network cards automatically recognized by the Kernel (unlike DOS);
    • Most CD/DVD readers automatically recognized by the Kernel (unlike DOS);
    • You don’t have to run a Ghostcast server to receive images over the network;
    • More supported filesystems;
    • You can store an image on several CD/DVD (CD/DVD-spanning);
    • You can backup and restore BIOS settings too;
    • Much much smaller than WinPE / BartPE;
    • etc.

This is Mike Rowe

Mike Rowe

Mike Rowe

Many people ask about MIke Rowe.  I have posted a picture here of Mike Rowe.  This is not the Mike Rowe of Dirty Job but he is named after him.  I am sure that the real Mike Rowe would not be upset.