party_devel.module in Party 7
Same filename and directory in other branches
Party Developer Tools
File
modules/party_devel/party_devel.moduleView source
<?php
/**
* @file Party Developer Tools
*/
/**
* Implementation of hook_menu().
*/
function party_devel_menu() {
$items = array();
$items['admin/config/development/generate/party'] = array(
'title' => 'Generate parties',
'description' => 'Generate a given number of parties. Optionally delete current parties.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'party_devel_generate_parties_form',
),
'access arguments' => array(
'administer parties',
),
);
return $items;
}
function party_devel_generate_parties_form() {
$form['kill_parties'] = array(
'#type' => 'checkbox',
'#title' => t('<strong>Delete all parties</strong> of these types before generating new parties.'),
'#default_value' => FALSE,
);
$form['num_parties'] = array(
'#type' => 'textfield',
'#title' => t('How many parties would you like to generate?'),
'#default_value' => 50,
'#size' => 10,
);
$form['label_length'] = array(
'#type' => 'textfield',
'#title' => t('Max word length of party labels'),
'#default_value' => 2,
'#size' => 10,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Generate'),
);
$form['#redirect'] = FALSE;
return $form;
}
function party_devel_generate_parties_form_submit($form_id, &$form_state) {
module_load_include('inc', 'party_devel', 'devel_generate');
if ($form_state['values']['num_parties'] <= 50) {
party_devel_generate_parties($form_state);
}
else {
module_load_include('inc', 'party_devel', 'devel_generate_batch');
party_devel_generate_batch_parties($form_state);
}
}
/**
* Pre-process the devel_generate_content_form request. This is needed so
* batch api can get the list of users once.
*
* @param $num
* array of options obtained from devel_generate_parties_form.
*/
function party_devel_generate_parties_pre_party(&$results) {
module_load_include('inc', 'devel_generate');
// Get user id.
$users = devel_get_users();
$users = array_merge($users, array(
'0',
));
$results['users'] = $users;
}
Functions
Name | Description |
---|---|
party_devel_generate_parties_form | |
party_devel_generate_parties_form_submit | |
party_devel_generate_parties_pre_party | Pre-process the devel_generate_content_form request. This is needed so batch api can get the list of users once. |
party_devel_menu | Implementation of hook_menu(). |