function node_limit_list_limits in Node Limit 6
Same name and namespace in other branches
- 8 old/node_limit.module \node_limit_list_limits()
- 7 node_limit.module \node_limit_list_limits()
Form for listing the created limits. Created as a form so that the user can adjust the weight.
1 string reference to 'node_limit_list_limits'
- node_limit_menu in ./
node_limit.module - Implementation of hook_menu().
File
- ./
node_limit.module, line 223 - Module to restrict the number of nodes a user or role may create.
Code
function node_limit_list_limits() {
$weights = array();
for ($i = -10; $i <= 10; $i++) {
$weights[$i] = $i;
}
$form = array(
'#tree' => TRUE,
);
$form['limits'] = array();
$sql = "SELECT * FROM {node_limit} ORDER BY weight ASC";
$res = db_query($sql);
$limit_count = 0;
while ($rec = db_fetch_array($res)) {
$limit_count++;
$form['limits'][$rec['lid']]['weight'] = array(
'#type' => 'select',
'#options' => $weights,
'#default_value' => $rec['weight'],
);
$form['limits'][$rec['lid']]['title'] = array(
'#value' => $rec['title'],
);
$form['limits'][$rec['lid']]['nlimit'] = array(
'#value' => $rec['nlimit'],
);
$form['limits'][$rec['lid']]['actions'] = array(
'#value' => l(t('Edit'), 'admin/user/node_limit/' . $rec['lid']) . ' ' . l(t('Delete'), 'admin/user/node_limit/' . $rec['lid'] . '/delete') . ' ' . l(t('Clone'), 'admin/user/node_limit/' . $rec['lid'] . '/clone'),
);
}
if ($limit_count > 0) {
$form['save'] = array(
'#type' => 'submit',
'#value' => t('Save Limits'),
);
}
else {
$form['create'] = array(
'#value' => l(t('Add a new node limit'), 'admin/user/node_limit/add'),
);
}
return $form;
}