July 3rd, 2008

Helpers_user: The user API that never was

I was writing an install profile for a out-of-the-box workflow install profile to be used by media organizations today, when I ran into the rote task of adding roles and permissions.

(for reference, see my last article on workflow configuration in drupal)

So being the programmer who will write something in a day which takes an hour to run to save 5 minutes, I decided to scratch a long standing itch:

The Drupal User System API.

I love the simplicity of the drupal user system, but like many things in drupal, it wants you to use forms to admin it, and the DB model is inherently tied to the controller (not good).

So I decided to contribute this to the helpers module. It provides some simple functions like:

helpers_user_help($section)
permissions_get(unknown_type $rid)
permissions_set(unknown_type $rid, unknown_type $perms = array)
role_add(string $name)
role_get(int $rid = 0, string $name = “”)
user_add_roles($uid, $roles = array)
user_delete_roles($uid, $roles = array)

Simple stuff, but AFAIK, lacking in drupal.

In addition, I also wrote a full set of simplete tests for it which can be found in the tests directory.

The patch can be found at:
http://drupal.org/node/252058
Hope others find this helpful!

-Jacob

July 1st, 2008

Solving bad IA using enterprise search (Reverse Advanced Search)

Since I started working with Apache Solr in Drupal, I’ve realized how much client money has been wasted making ill advised advanced searches. We’ve all gotten the requests for “advanced” searches and it makes any IA-god fearing developer cringe. For the 1% of users who use them, you blow tons of budget, and the result is often quite poor because the client doesn’t really know their data or their users that well.

For those of you who are unfamiliar with faceted search compare the following:

I did a search for WSXGA because I’m looking for a laptop with decent resolution on two sites.

Laptops Direct

vs.

New Egg

(click to enlarge image in new window)

The New Egg search lets me filter, so I know that I’m looking for a laptop between $750 -> $1000, I’ll get 5 results. After that filter, I’ll know what’s available, and the # per manufacturer etc.

Contrast that with an advanced search form where I have to put in all my criteria, and hope I get a result. I might also miss certain results if my vocabulary is bad, or I don’t understand that the website says “high resolution” instead of WSXGA, so I don’t select it.

I think it’s obvious to anyone why faceted search is a good thing. In my next post, I’ll be exploring why is hasn’t gotten widespread adoption, particularly in the small business / NGO sector, and how I plan to help change that.

June 30th, 2008

Similar Nodes Module Released!

I’ve just released a new module which I hope will fill a general need in the Drupal community.

This module allows you to show nodes in a view which have the same taxonomy as a node which you pass in as an argument. BUT it goes a step beyond this. By using a weighting table, one can specify the weight of each vocabulary in making the comparison.

Say you have two vocabularies on a movie site “Genre” and “Community Tags”, the latter being a free tagging taxonomy. With this module, you can give Genre a weight of 10 and Community tags a weight of 1. Which means that if I’m looking at “Meet the Parents”, I’m most likely to see a list of similar Romantic Comedies like “Sleepless in Seattle” and “French Kiss” with something like “Taxi” or “The Godfather II” coming lower in the list, because someone tagged both “Robert De niro”

See the Module Page for more information and how to use.

I’m going to be cleaning up the code a bit and providing a sample view soon, but any brave souls out there who would like to test / suggest, please go ahead!

June 27th, 2008

Good Bye Appendix, Hello Google App Engine

While an appendicitis is a painful, uncomfortable and ultimately debilitating condition - one which I have suffered with for over a year, its remedy (Laproscopic surgery, way too much money to an evil hospital, a shitton of painkillers and a week of bedrest) is fairly tame as far as surgical procedures go.

PHPitis is another condition I have been suffering from. It’s not early as painful and has provided me with a decent income and professional growth. It is also not a pussy inflamed organ with no apparent value pressing up against all the nicely formed and functioning organs around it. However, the feeling that there is something not right “down there” remains.

I’ve always known that python is the best language out there. I don’t mean to start yet another stupid language fight, because every language is fine and dandy. But honestly, every programmer I respect has told me the same thing, they wish they could just write python. The only knocks against python are:

  • Lack of hosting options
  • Lack of Jobs / Skilled personnel

The first one, is obviously stupid, because it is as easy to run as PHP, but is totally chicken and egg. The second is pretty much the same. You have to be a better programmer to write python, and so there are less people who can, so there are less CTOs wanting to risk a language with less people available.

Anyway, for what it’s worth, I love python, and I’m not that good at it yet, because I never get jobs in it, and it’s hard to get clients signed up for something that isn’t hosted anywhere…. Until now.

A day before I went to the hospital for an examination into yet another bout of my awful stomach pains which turned into the aforementioned surgery, I got my App Engine key in the mail.

I am affraid of the big G as much as anyone, and this offering is too new to judge. I won’t bore everyone with the questions everyone is asking about if your code can be moved or not, what is the guarantee they will keep it around, etc. I just want to say that the data api and the security of knowing that such terse syntax with so much power will scale till the end of the googleverse is exciting.

I highly recommend everyone give it a whirl, and discover / rediscover beautiful code. I was thinking of “killer apps” to build on it. My first inclination is that the “killer app” for the gapjinn (as I have now started calling it) is something with the following characteristics:

Uses Google Apps data apis

As much as possible, the application should store it’s data in google sites, google docs, google calendar, etc. This is because google will always have a commitment to making these two platforms work together AND you will not be made irrelevant because you can’t integrate.

Uses Google Apps provisioning APIs

Because SaaS is in, and you will want to make setup super easy.

Uses Google for authentication

Because you will not survive in the enterprise if you can’t take advantage of single sign-on services. As long as you are using all the google apps stuff, you should authenticate the same way.

Is niche enough that it does something better / easier / more focused than native google apps
OR

Provides an integration between different google apps and a 3rd party service

On the first count, it’s about creating a wrapper, basically a new interface layer to an existing google apps platform. Sometimes simple is too simple. For instance, using a series of tags and and a small amount of data store in the Google BigTable, I bet you create a really quick and dirty CRM using google contacts + gmail + google sites + google calendar.

On the second, I think the potential to provide bridge functionality between more mature best of breed apps like basecamp, unfuddled, salesforce, will make quick enterprise dashboards possible. Something like a dashboard / middleware layer between this stuff.

Let’s see…

May 20th, 2008

Drupal Training Curriculum


Getting Started

Who are we and what are we doing here? Backgrounds and goals (personal and technical).

  • Get to know everyone’s development background and professional history

  • Where do we come from as programmers? How does that influence our current approach and approach to learning drupal?

  • What do we want to learn and specialize in?

General goals of this training

  • Make developing in Drupal fun

  • Increase the speed at which you can develop solutions

  • Decrease the amount of time you have to spend on donkey work

  • Introduce you to the Drupal community and how to leverage / participate in it

  • Make the connections between requirements and stock solutions

  • Know how and when to hack it



Specific Objectives for today

  • Know how to set up drupal sites using multisite deployment

  • Understand how to use update status, CVS and drush

  • Learn the devel module, masquerade module, and other development tools

  • Understand the drupal architecture:

    • What IOC is

    • Why is successful

    • Why is it annoying

Planned Format

  • Devs spend as much time in front of computers practicing as possible

  • Topics are discussed, examples are shown in existing modules, and practice on a custom module

  • Every days ends with ½hr of Q&A

Tools of the trade

  • Devel Module

  • Coder

  • Masquerade

  • Project Set-Up and sandbox creation

  • admin_menu

  • Drush, CVS and update_status

The Drupal Community

  • IRC

  • Issue Trackers

  • groups.drupal.org

  • Forums

  • drupalmodules.com

  • drupal.org/planet

Drupal Architecture

  • IOC (Inversion of control model)

  • The Hook system

  • Drupal Bootsrap process

  • Theming Engines and themes



Tea Party

  • Learning the hook system via the drink module

Main Core Hooks and their usage

http://api.drupal.org/api/group/hooks/5

hook_menu

Example: contact

hook_nodeapi

Example: path module

hook_help

Example: contact module

hook_user

Example: contact module

To Hack or Not to Hack, that is the question

Form API

Building an admin settings form

  • callback to drupal_get_form

  • validate hook

  • submit hook

Implementing form_alter

Implementing a custom submit hook on a form_alter

Real site planning and development in Drupal

Modules you can’t live without

  • CCK

  • Views

  • Panels 2

  • nodequeue

  • adminrole

  • pathauto

  • nodereference

  • imagecache

  • asset or image + imagefield

  • tinymce

How do you build this page:

  • List of Nodes w/ RSS & Pager

    • Views

  • Custom content type which has related nodes in a heirarchy

    • CCK + nodereference

  • Thumbnails in node listing

    • Asset + imagecache

  • Cultivated (admin chosen) list of nodes

    • nodequeue

    • views

  • Sortable table of nodes and their values

    • Views + Table style plugin

  • Complex front page containing any of the above

    • Panels 2











May 11th, 2008

6 premises for killer apps on the Google App Engine or Good bye Appendix, Hello Google Apps

An appendicitis is a painful, uncomfortable and ultimately debilitating condition one which I have suffered with for over a year. However, its remedy (Laproscopic surgery) is fairly tame as far as surgical procedures go - way too much money to an evil hospital, a shitton of painkillers and a week of bedrest

PHPitis is another condition I have been suffering from. It’s not early as painful and has provided me with a decent income and professional growth. It is also not a pussy inflamed organ with no apparent value pressing up against all the nicely formed and functioning organs around it. However, the feeling that there is something not right “down there” remains.
Read the rest of this entry »

May 2nd, 2008

Workflow-ng is godly or flagging a dead content

As many people know, I’m really into workflow-ng.

I’ve integrated a few modules with it, and it allows for a killer amount of functionality and good (although probably complex) administrative interfaces for admins to do their own customization.

Simply put: this is my favorite module after CCK, Views and Panels, and it should be yours too..

More after the jump
Read the rest of this entry »

April 30th, 2008

Bartender in Delhi Wanted… Indians need not apply

I had a slightly uncomfortable experience today on a mailing list I subscribe to which is for expats living in Delhi trying to help each other find their way around the city.

I signed up for it to try to find an apartment / stuff as I as setting up my flat, and I follow it from time to time. Some guy has set up a website tailored to expats, and also organizes “expat night” at a local club.

He sent the following advertisement to the list this morning:

Hi all,

I am looking for female expat bartenders for a bar/disco

Read the rest of this entry »

April 24th, 2008

Advanced Workflow Configuration for Drupal

The workflow trinity: States, Owners and Rules

Amnesty International has 400+ employees in their London office who work in various capacities from research, to advocacy, to marketing and development of the organization. Their web and press divisions (primary admins of the website) need to create stories and press releases with input from all of these employees. As a result, workflow became a very important part of this project.
Read the rest of this entry »

April 24th, 2008

Amnesty International goes Drupal

Amnesty International goes Drupal

Introduction

Amnesty International has been advocating for and protecting human rights and human rights legislation internationally for the past 46 years. Its reputation and the foundation of Amnesty sections in most countries also has made it one of the most recognizable names in the world.

This project (code name IMPACT!) was the result of more than 5 years of attempts to upgrade Amnesty’s web presence and web CRM. Their previous site was based on a very antiquated Lotus Notes backend, a hodgepodge of dreamweaver templates, and dozens of offshoot micro sites.

Here are a few of the notable development efforts that were put forth for the project. Some are in contrib already, and others are on their way.

Workflow

Amnesty International has 400+ employees in their London office who work in various capacities from research, to advocacy, to marketing and development of the organization. Their web and press divisions (primary admins of the website) need to create stories and press releases with input from all of these employees. As a result, workflow became a very important part of this project.

Modules used:

More on our workflow setup

Stay Tuned:

Upcoming articles in this series include:

  • Asset Management using the Asset module
  • alFresco integration
  • right-to-left drupal theming
  • i18n + panels and views
  • CiviCRM + i18n
  • menutrails

How To find me

Telephone: +1 510.277.0891 | Email: jacobsingh at gmail daht calm

Solution Graphics