function domain_content_form in Domain Access 6.2
Same name and namespace in other branches
- 5 domain_content/domain_content.module \domain_content_form()
- 7.3 domain_content/domain_content.admin.inc \domain_content_form()
- 7.2 domain_content/domain_content.admin.inc \domain_content_form()
Rewrites node_admin_nodes() to use db_rewrite_sql().
Return value
A form array according to the FormsAPI.
1 string reference to 'domain_content_form'
- domain_content_admin in domain_content/
domain_content.admin.inc - Content admin page callback.
File
- domain_content/
domain_content.admin.inc, line 161 - Administration pages for Domain Content.
Code
function domain_content_form($form_state) {
global $_domain;
$filter = node_build_filter_query();
// Bypass the superuser permissions by forcing an AND on {domain_access}.
$filter['join'] .= " INNER JOIN {domain_access} dac ON dac.nid = n.nid ";
$arg = arg(3);
if ($arg != 'all') {
// In this case, we must check the domain_id grant.
// We use intval() here for security, since we are not filtering the query parameter otherwise.
if (empty($filter['where'])) {
$filter['where'] = " WHERE dac.realm = 'domain_id' AND dac.gid = " . intval($_domain['domain_id']) . " ";
}
else {
$filter['where'] .= " AND dac.realm = 'domain_id' AND dac.gid = " . intval($_domain['domain_id']) . " ";
}
}
else {
// Or check the domain_site grant.
if (empty($filter['where'])) {
$filter['where'] = " WHERE dac.realm = 'domain_site' AND dac.gid = 0 ";
}
else {
$filter['where'] .= " AND dac.realm = 'domain_site' AND dac.gid = 0 ";
}
}
$result = pager_query(db_rewrite_sql('SELECT n.nid, n.changed FROM {node} n ' . $filter['join'] . $filter['where'] . ' ORDER BY n.changed DESC'), 50, 0, NULL, $filter['args']);
// Reset the active domain.
domain_reset_domain();
$nodes = array();
// Loop through the nodes to build the form
while ($nid = db_fetch_object($result)) {
$node = node_load($nid->nid);
$form['title'][$node->nid] = array(
'#value' => l($node->title, 'node/' . $node->nid) . ' ' . theme('mark', node_mark($node->nid, $node->changed)),
);
$form['name'][$node->nid] = array(
'#value' => check_plain(node_get_types('name', $node)),
);
$form['username'][$node->nid] = array(
'#value' => theme('username', $node),
);
$form['status'][$node->nid] = array(
'#value' => $node->status ? t('published') : t('not published'),
);
$node_domains = array();
if (!empty($node->domains)) {
foreach ($node->domains as $domain) {
// The root domain is stored as -1, but cast as zero in the global variable.
$key = $domain == -1 ? 0 : $domain;
// Convert the domain ids to data so we can print them.
$node_domains[] = domain_lookup($key);
}
}
// If we have multiple domains, print them.
$items = array();
if ($node->domain_site) {
$items[-1] = t('All affiliates');
}
if (!empty($node_domains)) {
foreach ($node_domains as $item) {
$items[$item['domain_id']] = check_plain($item['sitename']);
}
}
if (module_exists('domain_source')) {
$source = NULL;
$source = db_fetch_object(db_query("SELECT domain_id FROM {domain_source} WHERE nid = %d", $node->nid));
if (!empty($source) && isset($items[$source->domain_id])) {
$items[$source->domain_id] .= '*';
}
}
$form['domains'][$node->nid] = array(
'#value' => theme('item_list', $items),
);
if (node_access('update', $node)) {
$form['operations'][$node->nid] = array(
'#value' => l(t('edit'), 'node/' . $node->nid . '/edit', array(
'query' => drupal_get_destination(),
)),
);
$nodes[$node->nid] = '';
}
}
// Privileged users can make global changes to Domain Access permissions.
if (user_access('set domain access')) {
domain_content_add_form_widget($form);
}
// Users must have passed at least one access check to have batch options.
if ((user_access('administer nodes') || user_access('set domain access')) && !empty($nodes)) {
$form['options'] = array(
'#type' => 'fieldset',
'#title' => t('Update options'),
'#prefix' => '<div class="container-inline">',
'#suffix' => '</div>',
'#weight' => -1,
);
$options = array();
foreach (module_invoke_all('node_operations') as $operation => $array) {
$options[$operation] = $array['label'];
}
$form['options']['operation'] = array(
'#type' => 'select',
'#options' => $options,
'#default_value' => 'approve',
);
$form['options']['submit'] = array(
'#type' => 'submit',
'#value' => t('Update'),
);
$form['nodes'] = array(
'#type' => 'checkboxes',
'#options' => $nodes,
);
// Filter the available operations based on user permissions.
domain_content_filter_operations($form['options']['operation']['#options']);
}
$form['pager'] = array(
'#value' => theme('pager', NULL, 50, 0),
);
$form['#theme'] = 'domain_content_admin_nodes';
$form['#validate'][] = 'node_admin_nodes_validate';
$form['#submit'][] = 'node_admin_nodes_submit';
$form['#submit'][] = 'domain_content_process_nodes';
return $form;
}