Skip to content

Instantly share code, notes, and snippets.

View greggles's full-sized avatar

Greg Knaddison greggles

View GitHub Profile
@greggles
greggles / gist:1245356
Created September 27, 2011 15:22
1290624_example4
<?php
// Assume $arguments can contain any node on the site...
$nodes = node_load_multiple($arguments);
foreach ($nodes as $node) {
$options[$node->nid] = $node->title;
}
$form['test1'] = array(
'#type' => 'select'
'#options' => $options,
);
@greggles
greggles / gist:1243531
Created September 26, 2011 21:59
1290624_example3
<?php
/**
* Provides an API function to load/tweak a user's name.
* Called by a module which has already checked permission and the validity of the $uid.
*/
function example_module_usertweak($uid) {
global $user;
drupal_set_message(t('Thanks, @user, for tweaking this!', array('@user' => $user->name));
// Save the original user.
@greggles
greggles / gist:1243299
Created September 26, 2011 20:23
1290624_example2
<?php
//
function example_module_menu() {
// Allow admins to delete a comment at /example-delete-comment/CID.
$items['example-delete-comment'] = array(
'title' => t('Delete a comment'),
'page callback' => 'example_module_callback',
'access arguments' => array('administer comments'),
@greggles
greggles / gist:1243016
Created September 26, 2011 18:47
1290624_example1
<?php
function example_module_menu() {
$items['example-search-callback'] = array(
'title' => t('Node search'),
'page callback' => 'example_module_callback',
'access callback' => TRUE,
'type' => MENU_CALLBACK
);
return $items;