function deploy_list_form in Deploy - Content Staging 6
Display a list of all items in a specified plan.
Parameters
$form_state: FAPI form state
$pid: Unique identifier for the plan we're viewing
Return value
FAPI array
See also
1 string reference to 'deploy_list_form'
- deploy_menu in ./
deploy.module - Implementation of hook_menu().
File
- ./
deploy.plans.admin.inc, line 143 - Page handlers for deploy plan admin.
Code
function deploy_list_form($form_state, $pid = NULL) {
// If this is a submit for deletion, return the confirm form
if (isset($form_state['values']['plan_items'])) {
return deploy_list_multiple_delete_confirm($form_state, array_filter($form_state['values']['plan_items']));
}
// If there are no plan items then bail.
$items = deploy_get_plan_items($pid);
if (is_null($pid) || empty($items)) {
drupal_goto('/admin/build/deploy');
}
// Set the page title to the name of the plan
$plan = deploy_get_plan($pid);
drupal_set_title(t('Deployment plan items - @plan', array(
'@plan' => $plan['name'],
)));
// username cache so we don't have to user_load constantly
$user_cache = array();
// Build form tree
$form['#tree'] = TRUE;
$plan_items = array();
foreach ($items as $i => $item) {
if (!array_key_exists($item['uid'], $user_cache)) {
$account = user_load(array(
'uid' => $item['uid'],
));
$user_cache[$item['uid']] = $account->name;
}
$added_by = $user_cache[$item['uid']] . " on " . format_date($item['ts'], 'small');
$form[$i]['module'] = array(
'#type' => 'item',
'#value' => $item['module'],
);
$form[$i]['description'] = array(
'#type' => 'item',
'#value' => $item['description'],
);
$form[$i]['added_by'] = array(
'#type' => 'item',
'#value' => $added_by,
);
$form[$i]['iid'] = array(
'#type' => 'hidden',
'#value' => $item['iid'],
);
$plan_items[$item['iid']] = '';
}
$form['plan_items'] = array(
'#type' => 'checkboxes',
'#options' => $plan_items,
);
$form['pid'] = array(
'#type' => 'hidden',
'#value' => $pid,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Remove items from plan'),
);
return $form;
}