Archive for December, 2010

Tradition 2

December 12, 2010 Leave a comment

Allah, the Exalted, does not look at your faces, but He looks at your hearts.

– Imam Ali ar-Ridha (Bihar al-Anwar, vol 67, p. 241)


Greece Bond Market Scandals and JP Morgan Silver Manipulation

December 11, 2010 9 comments

Talks about about the massive fraudulent short position that JP Morgan holds in silver. Also in this video, a very well explained how speculators brought down Greece in April of 2010 with CDS (aka Credit Default Swaps)

Tradition 1

December 10, 2010 Leave a comment

People of Ma’arifat (recognition) see that the worldly people are more concerned about physical death. While more serious is the death of their hearts within their living bodies.”

– Imam Ali (Nahjul Balagha, Sermon 259)

Categories: Ali, Death, Hadith, Spirituality, Tradition Tags: , ,

Drupal 7 – Hook Execution Order

December 6, 2010 5 comments

Although not specified explicitly anywhere, browsing through the code in the function “module_implements” gave me the hint that changing the order in which hooks are called is possible.

Here’s that snippet

 // Allow modules to change the weight of specific implementations but avoid
 // an infinite loop.
 if ($hook != 'module_implements_alter') {
 drupal_alter('module_implements', $implementations[$hook], $hook);

All that needs to be done is to implement the hook hook_module_implements_alter specified here. Effectively by re-ordering the list of modules, you also change the order in which the hooks are called.

Here’s how I did it,

function mymodule_module_implements_alter(&$module_list, $context){
 if($context === "node_insert"){
 $temp = $module_list['mymodule'];
 // Removing the mymodule key/value
 // Adding the mymodule key value as the last member in the list
 $module_list['mymodule'] = $temp;

One point to remember is to declare the “module_list” variable as a reference variable with the “&”, or you’ll be modifying a local variable 🙂
Thats it. Done!

Does God Not Exist

December 6, 2010 Leave a comment

Interesting watch.

Drupal 7 – Programatically Create Nodes

December 6, 2010 12 comments

Getting straight to the topic,

From drupal 6, there have been some small changes in the way users can create a node programatically. Like for eg. instead of using the drupal_execute function, we now have to use drupal_form_submit. Both these functions do the same thing, i.e, submit the form programatically.

Since, I experimented with creating book nodes, i’ll be running through the same example.

Minimally, 3 arguments need to be specified to the drupal_form_submit function in this case.

The first one, is the form id. This id can be got by taking a quick look at the form POST parameters while creating a book “normally”. I did that by using firebug on the node/add/book page.

The 2nd argument is an array of form values that should mimic the values posted from the browser. The focus should be to copy the (relevant) variable names that are seen while analyzing the post request. See below,

The values should go within an array keyed by the key ‘values’

global $user;
// Body Structure
// For more information on how this variable is read by the form engine, see
// drupal_array_get_nested_value.
// Substitute the language "en" for the language of the node. Make sure that
// the appropriate locale is enabled
$body["en"][0]['value'] = "Some body text";

$formState['values']['title'] = "Title of the book"
$formState['values']['language'] = "en"; // substitute for the language of the node
$formState['values']['name'] = $user->name;
$formState['values']['body'] = $body;
$formState['values']['status'] = 1;
$formState['values']['promote'] = 0;
$formState['values']['sticky'] = 0;
$formState['values']['op'] = t('Save');

And the last argument is a node object reference that one must create with the necessary information.

$newNode = array(
 'type' => 'book',
 'book' => array(
 'bid' => $node->book['bid'], // use 'new' here if the book page is of a new book
 'plid' => $node->book['mlid'],
 'weight' => $chapNo,
 'options' => array(),
 'has_children' => 0,
 'module' => 'book'
 'language' => $node->language // This is needed

Last thing to do is to call the drupal_form_submit function.

drupal_form_submit('book_node_form', $formState, (object) $newNode);

Thats it! We’re done!