id stringlengths 22 22 | drupal_version stringclasses 1
value | source_type stringclasses 1
value | source_url stringlengths 70 167 | instruction stringlengths 87 500 | context stringlengths 16 10.7k | response stringlengths 68 5.97k | tags listlengths 2 2 | created_at timestamp[s]date 2026-09-30 00:00:00 2026-09-30 00:00:00 |
|---|---|---|---|---|---|---|---|---|
api-drupal7-994c292503 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/locale_translate_delete_form_submit/7.x | In Drupal 7, write the function `locale_translate_delete_form_submit($form, &$form_state)` (file modules/locale/locale.admin.inc) so that it does the following: Process string deletion submissions. | File: modules/locale/locale.admin.inc | function locale_translate_delete_form_submit($form, &$form_state) {
db_delete('locales_source')
->condition('lid', $form_state['values']['lid'])
->execute();
db_delete('locales_target')
->condition('lid', $form_state['values']['lid'])
->execute();
// Force JavaScript translation file recreation fo... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-994ccd9b8c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.module/function/menu_parent_options_js/7.x | I need the code for `menu_parent_options_js()` in Drupal 7 (modules/menu/menu.module). It must do this: Page callback. Get all the available menus and menu items as a JavaScript array. | File: modules/menu/menu.module | function menu_parent_options_js() {
$available_menus = array();
if (isset($_POST['menus']) && count($_POST['menus'])) {
foreach ($_POST['menus'] as $menu) {
$available_menus[$menu] = $menu;
}
}
$options = _menu_get_options(menu_get_menus(), $available_menus, array('mlid' => 0));
drupal_json_out... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9961b4f27a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.parser.inc/function/aggregator_element_end/7.x | In Drupal 7, write the function `aggregator_element_end($parser, $name)` (file modules/aggregator/aggregator.parser.inc) so that it does the following: Performs an action when a closing tag is encountered. | Callback function used by xml_parse() within aggregator_parse_feed().
File: modules/aggregator/aggregator.parser.inc | function aggregator_element_end($parser, $name) {
global $element;
switch ($name) {
case 'image':
case 'textinput':
case 'item':
case 'entry':
case 'info':
$element = '';
break;
case 'id':
case 'content':
if ($element == $name) {
$element = '';
}
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9968f45579 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.module/function/aggregator_block_info/7.x | Implement `aggregator_block_info()` in PHP for Drupal 7. Required behavior: Implements hook_block_info(). | File: modules/aggregator/aggregator.module | function aggregator_block_info() {
$blocks = array();
$result = db_query('SELECT cid, title FROM {aggregator_category} ORDER BY title');
foreach ($result as $category) {
$blocks['category-' . $category->cid]['info'] = t('!title category latest items', array('!title' => $category->title));
}
$result = db_q... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-998ba0ec6f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21contact%21contact.pages.inc/function/contact_site_form/7.x | I need the code for `contact_site_form($form, &$form_state)` in Drupal 7 (modules/contact/contact.pages.inc). It must do this: Form constructor for the site-wide contact form. | File: modules/contact/contact.pages.inc | function contact_site_form($form, &$form_state) {
global $user;
// Check if flood control has been activated for sending e-mails.
$limit = variable_get('contact_threshold_limit', 5);
$window = variable_get('contact_threshold_window', 3600);
if (!flood_is_allowed('contact', $limit, $window) && !user_access('a... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-999bfd808b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_theme/7.x | I need the code for `image_theme()` in Drupal 7 (modules/image/image.module). It must do this: Implements hook_theme(). | File: modules/image/image.module | function image_theme() {
return array(
// Theme functions in image.module.
'image_style' => array(
'variables' => array(
'style_name' => NULL,
'path' => NULL,
'width' => NULL,
'height' => NULL,
'alt' => '',
'title' => NULL,
'attributes' => array(),... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-99c36ebb0a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/themes%21bartik%21template.php/function/bartik_preprocess_node/7.x | In Drupal 7, write the function `bartik_preprocess_node(&$variables)` (file themes/bartik/template.php) so that it does the following: Override or insert variables into the node template. | File: themes/bartik/template.php | function bartik_preprocess_node(&$variables) {
if ($variables['view_mode'] == 'full' && node_is_page($variables['node'])) {
$variables['classes_array'][] = 'node-full';
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-99d28ea44a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.pages.inc/function/aggregator_categorize_items_submit/7.x | In Drupal 7, write the function `aggregator_categorize_items_submit($form, &$form_state)` (file modules/aggregator/aggregator.pages.inc) so that it does the following: Form submission handler for aggregator_categorize_items(). | File: modules/aggregator/aggregator.pages.inc | function aggregator_categorize_items_submit($form, &$form_state) {
if (!empty($form_state['values']['categories'])) {
foreach ($form_state['values']['categories'] as $iid => $selection) {
db_delete('aggregator_category_item')
->condition('iid', $iid)
->execute();
$insert = db_insert('a... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-99d956a9d3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21field_sql_storage%21field_sql_storage.module/function/field_sql_storage_field_storage_purge/7.x | In Drupal 7, write the function `field_sql_storage_field_storage_purge($entity_type, $entity, $field, $instance)` (file modules/field/modules/field_sql_storage/field_sql_storage.module) so that it does the following: Implements hook_field_storage_purge(). | This function deletes data from the database for a single field on an entity.
File: modules/field/modules/field_sql_storage/field_sql_storage.module | function field_sql_storage_field_storage_purge($entity_type, $entity, $field, $instance) {
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$table_name = _field_sql_storage_tablename($field);
$revision_name = _field_sql_storage_revision_tablename($field);
db_delete($table_name)
->condi... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-9a00009bbc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21list%21list.module/function/list_allowed_values/7.x | I need the code for `list_allowed_values($field, $instance = NULL, $entity_type = NULL, $entity = NULL)` in Drupal 7 (modules/field/modules/list/list.module). It must do this: Returns the array of allowed values for a list field. | The strings are not safe for output. Keys and values of the array should be sanitized through field_filter_xss() before being displayed.
Parameters:
- $field: The field definition.
- $instance: (optional) A field instance array. Defaults to NULL.
- $entity_type: (optional) The type of entity; e.g. 'node' or 'user'. De... | function list_allowed_values($field, $instance = NULL, $entity_type = NULL, $entity = NULL) {
$allowed_values = &drupal_static(__FUNCTION__, array());
if (!isset($allowed_values[$field['id']])) {
$function = $field['settings']['allowed_values_function'];
// If $cacheable is FALSE, then the allowed values a... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9a0c281e3f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21pager.inc/function/pager_default_initialize/7.x | In Drupal 7, write the function `pager_default_initialize($total, $limit, $element = 0)` (file includes/pager.inc) so that it does the following: Initializes a pager for theme('pager'). | This function sets up the necessary global variables so that future calls to theme('pager') will render a pager that correctly corresponds to the items being displayed.
If the items being displayed result from a database query performed using Drupal's database API, and if you have control over the construction of the ... | function pager_default_initialize($total, $limit, $element = 0) {
global $pager_page_array, $pager_total, $pager_total_items, $pager_limits;
$page = pager_find_page($element);
// We calculate the total of pages as ceil(items / limit).
$pager_total_items[$element] = $total;
$pager_total[$element] = ceil($pag... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9a1ce9f534 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/locale_languages_delete_form/7.x | In Drupal 7, write the function `locale_languages_delete_form($form, &$form_state, $langcode)` (file modules/locale/locale.admin.inc) so that it does the following: User interface for the language deletion confirmation screen. | File: modules/locale/locale.admin.inc | function locale_languages_delete_form($form, &$form_state, $langcode) {
// Do not allow deletion of English locale.
if ($langcode == 'en') {
drupal_set_message(t('The English language cannot be deleted.'));
drupal_goto('admin/config/regional/language');
}
if (language_default('language') == $langcode)... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9a458d8d6e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.api.php/function/hook_comment_view_alter/7.x | In Drupal 7, show an example implementation for `hook_comment_view_alter(&$build)` (modules/comment/comment.api.php): The comment was built; the module may modify the structured content. | This hook is called after the content has been assembled in a structured array and may be used for doing processing which requires that the complete comment content structure has been built.
If the module wishes to act on the rendered HTML of the comment rather than the structured content array, it may use this hook t... | function hook_comment_view_alter(&$build) {
// Check for the existence of a field added by another module.
if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) {
// Change its weight.
$build['an_additional_field']['#weight'] = -10;
}
// Add a #post_render callback to act on the r... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-9a517bd737 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7020/7.x | I need the code for `user_update_7020()` in Drupal 7 (modules/user/user.install). It must do this: Add changed field to users table. | File: modules/user/user.install | function user_update_7020() {
// The "changed" column was renamed to "access" in system_update_136(), and
// the "changed" index on "access" column may persist on old MySQL databases.
if (db_index_exists('users', 'changed')) {
if (!db_index_exists('users', 'access')) {
db_add_index('users', 'access', ar... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9a81c2e17f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/file_create_htaccess/7.x | In Drupal 7, write the function `file_create_htaccess($directory, $private = TRUE, $force_overwrite = FALSE)` (file includes/file.inc) so that it does the following: Creates a .htaccess file in the given directory. | Parameters:
- $directory: The directory.
- $private: FALSE indicates that $directory should be an open and public directory. The default is TRUE which indicates a private and protected directory.
- $force_overwrite: Set to TRUE to attempt to overwrite the existing .htaccess file if one is already present. Defaults to F... | function file_create_htaccess($directory, $private = TRUE, $force_overwrite = FALSE) {
if (file_uri_scheme($directory)) {
$directory = file_stream_wrapper_uri_normalize($directory);
}
else {
$directory = rtrim($directory, '/\\');
}
$htaccess_path = $directory . '/.htaccess';
if (file_exists($htacc... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9a889a7e14 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21pager.inc/function/theme_pager_first/7.x | I need the code for `theme_pager_first($variables)` in Drupal 7 (includes/pager.inc). It must do this: Returns HTML for the "first page" link in a query pager. | Parameters:
- $variables: An associative array containing: - text: The name (or image) of the link. - element: An optional integer to distinguish between multiple pagers on one page. - parameters: An associative array of query string parameters to append to the pager links.
File: includes/pager.inc | function theme_pager_first($variables) {
$text = $variables['text'];
$element = $variables['element'];
$parameters = $variables['parameters'];
global $pager_page_array;
$output = '';
// Nothing to do if there is no pager.
if (!isset($pager_page_array[$element])) {
return;
}
// If we are anywhere... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9a8c4bcfb0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_schema_fields_sql/7.x | In Drupal 7, write the function `drupal_schema_fields_sql($table, $prefix = NULL)` (file includes/common.inc) so that it does the following: Retrieves a list of fields from a table schema. | The returned list is suitable for use in an SQL query.
Parameters:
- $table: The name of the table from which to retrieve fields.
Returns: An array of fields.
File: includes/common.inc | function drupal_schema_fields_sql($table, $prefix = NULL) {
$schema = drupal_get_schema($table);
$fields = array_keys($schema['fields']);
if ($prefix) {
$columns = array();
foreach ($fields as $field) {
$columns[] = "$prefix.$field";
}
return $columns;
}
else {
return $fields;
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9ad0675b1a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_user_login/7.x | I need the code for `system_user_login(&$edit, $account)` in Drupal 7 (modules/system/system.module). It must do this: Implements hook_user_login(). | File: modules/system/system.module | function system_user_login(&$edit, $account) {
// If the user has a NULL time zone, notify them to set a time zone.
if (!$account->timezone && variable_get('configurable_timezones', 1) && variable_get('empty_timezone_message', 0)) {
drupal_set_message(t('Configure your <a href="@user-edit">account time zone set... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-9ad666b089 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_update_7073/7.x | In Drupal 7, write the function `system_update_7073()` (file modules/system/system.install) so that it does the following: Add binary to {file_managed}, in case system_update_7034() was run without it. | File: modules/system/system.install | function system_update_7073() {
db_change_field('file_managed', 'filename', 'filename', array(
'description' => 'Name of the file with no path components. This may differ from the basename of the URI if the file is renamed to avoid overwriting an existing file.',
'type' => 'varchar',
'length' => 255,
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9adcd2a42c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.module/function/block_flush_caches/7.x | Implement `block_flush_caches()` in PHP for Drupal 7. Required behavior: Implements hook_flush_caches(). | File: modules/block/block.module | function block_flush_caches() {
// Rehash blocks for active themes. We don't use list_themes() here,
// because if MAINTENANCE_MODE is defined it skips reading the database,
// and we can't tell which themes are active.
$themes = db_query("SELECT name FROM {system} WHERE type = 'theme' AND status = 1");
forea... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-9aed995da2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_system_themes_page_alter/7.x | In Drupal 7, show an example implementation for `hook_system_themes_page_alter(&$theme_groups)` (modules/system/system.api.php): Alters theme operation links. | Parameters:
- $theme_groups: An associative array containing groups of themes.
File: modules/system/system.api.php | function hook_system_themes_page_alter(&$theme_groups) {
foreach ($theme_groups as $state => &$group) {
foreach ($theme_groups[$state] as &$theme) {
// Add a foo link to each list of theme operations.
$theme->operations[] = array(
'title' => t('Foo'),
'href' => 'admin/appearance/foo',
... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-9af4d42676 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_widget_form_alter/7.x | Give me the example code for `hook_field_widget_form_alter(&$element, &$form_state, $context)` in Drupal 7. Hook description: Alter forms for field widgets provided by other modules. | Parameters:
- $element: The field widget form element as constructed by hook_field_widget_form().
- $form_state: An associative array containing the current state of the form.
- $context: An associative array containing the following key-value pairs, matching the arguments received by hook_field_widget_form(): - form: ... | function hook_field_widget_form_alter(&$element, &$form_state, $context) {
// Add a css class to widget form elements for all fields of type mytype.
if ($context['field']['type'] == 'mytype') {
// Be sure not to overwrite existing attributes.
$element['#attributes']['class'][] = 'myclass';
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-9af725b8b4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21xmlrpcs.inc/function/xmlrpc_server_output/7.x | Implement `xmlrpc_server_output($xml)` in PHP for Drupal 7. Required behavior: Sends XML-RPC output to the browser. | Parameters:
- $xml (string): XML to send to the browser.
File: includes/xmlrpcs.inc | function xmlrpc_server_output($xml) {
$xml = '<?xml version="1.0"?>' . "\n" . $xml;
drupal_add_http_header('Content-Length', strlen($xml));
drupal_add_http_header('Content-Type', 'text/xml');
echo $xml;
drupal_exit();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9b068e18f6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.pages.inc/function/poll_page/7.x | Implement `poll_page()` in PHP for Drupal 7. Required behavior: Menu callback to provide a simple list of all polls available. | File: modules/poll/poll.pages.inc | function poll_page() {
$polls_per_page = 15;
$count_select = db_select('node', 'n');
$count_select->addExpression('COUNT(*)', 'expression');
$count_select->join('poll', 'p', 'p.nid = n.nid');
$count_select->condition('n.status', 1);
// List all polls.
$select = db_select('node', 'n');
$select->join('p... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9b0816da0b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_actions_configure/7.x | In Drupal 7, write the function `system_actions_configure($form, &$form_state, $action = NULL)` (file modules/system/system.admin.inc) so that it does the following: Menu callback; Creates the form for configuration of a single action. | We provide the "Description" field. The rest of the form is provided by the action. We then provide the Save button. Because we are combining unknown form elements with the action configuration form, we use an 'actions_' prefix on our elements.
Parameters:
- $action: Hash of an action ID or an integer. If it is a hash... | function system_actions_configure($form, &$form_state, $action = NULL) {
if ($action === NULL) {
drupal_goto('admin/config/system/actions');
}
$actions_map = actions_actions_map(actions_list());
$edit = array();
// Numeric action denotes saved instance of a configurable action.
if (is_numeric($action)... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9b0b629d14 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.form.inc/function/field_add_more_submit/7.x | I need the code for `field_add_more_submit($form, &$form_state)` in Drupal 7 (modules/field/field.form.inc). It must do this: Submit handler for the "Add another item" button of a field form. | This handler is run regardless of whether JS is enabled or not. It makes changes to the form state. If the button was clicked with JS disabled, then the page is reloaded with the complete rebuilt form. If the button was clicked with JS enabled, then ajax_form_callback() calls field_add_more_js() to return just the chan... | function field_add_more_submit($form, &$form_state) {
$button = $form_state['triggering_element'];
// Go one level up in the form, to the widgets container.
$element = drupal_array_get_nested_value($form, array_slice($button['#array_parents'], 0, -1));
$field_name = $element['#field_name'];
$langcode = $elem... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9b14045482 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21options%21options.module/function/options_field_widget_form/7.x | Implement `options_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)` in PHP for Drupal 7. Required behavior: Implements hook_field_widget_form(). | File: modules/field/modules/options/options.module | function options_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
// Abstract over the actual field columns, to allow different field types to
// reuse those widgets.
$value_key = key($field['columns']);
$type = str_replace('options_', '', $instance['widget']['t... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-9b2f01bd1a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21statistics%21statistics.admin.inc/function/statistics_top_pages/7.x | I need the code for `statistics_top_pages()` in Drupal 7 (modules/statistics/statistics.admin.inc). It must do this: Page callback: Displays statistics for the "top pages" (most accesses). | This displays the pages with the most hits (the "top pages") within a given time period that haven't been flushed yet. The flush interval is set on the statistics settings form, but is dependent on cron running.
Returns: A render array containing information about the top pages.
File: modules/statistics/statistics.ad... | function statistics_top_pages() {
$header = array(
array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'),
array('data' => t('Page'), 'field' => 'path'),
array('data' => t('Average page generation time'), 'field' => 'average_time'),
array('data' => t('Total page generation time'), 'field' => ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9b3347972c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21locale.inc/function/locale_string_is_safe/7.x | I need the code for `locale_string_is_safe($string)` in Drupal 7 (includes/locale.inc). It must do this: Check that a string is safe to be added or imported as a translation. | This test can be used to detect possibly bad translation strings. It should not have any false positives. But it is only a test, not a transformation, as it destroys valid HTML. We cannot reliably filter translation strings on import because some strings are irreversibly corrupted. For example, a & in the translati... | function locale_string_is_safe($string) {
// Some strings have tokens in them. For tokens in the first part of href or
// src HTML attributes, filter_xss() removes part of the token, the part
// before the first colon. filter_xss() assumes it could be an attempt to
// inject javascript. When filter_xss() remov... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9b4daed70d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21path%21path.module/function/path_form_node_form_alter/7.x | I need the code for `path_form_node_form_alter(&$form, $form_state)` in Drupal 7 (modules/path/path.module). It must do this: Implements hook_form_BASE_FORM_ID_alter() for node_form(). | File: modules/path/path.module | function path_form_node_form_alter(&$form, $form_state) {
$path = array();
if (!empty($form['#node']->nid)) {
$conditions = array('source' => 'node/' . $form['#node']->nid);
$langcode = entity_language('node', $form['#node']);
if ($langcode != LANGUAGE_NONE) {
$conditions['language'] = $langcode;
... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-9b4ed97a24 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_run_automated_cron/7.x | I need the code for `system_run_automated_cron()` in Drupal 7 (modules/system/system.module). It must do this: Run the automated cron if enabled. | File: modules/system/system.module | function system_run_automated_cron() {
// If the site is not fully installed, suppress the automated cron run.
// Otherwise it could be triggered prematurely by Ajax requests during
// installation.
if (($threshold = variable_get('cron_safe_threshold', DRUPAL_CRON_DEFAULT_THRESHOLD)) > 0 && variable_get('instal... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9b664fcccc | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21field_sql_storage%21field_sql_storage.module/function/field_sql_storage_field_storage_load/7.x | Implement `field_sql_storage_field_storage_load($entity_type, $entities, $age, $fields, $options)` in PHP for Drupal 7. Required behavior: Implements hook_field_storage_load(). | File: modules/field/modules/field_sql_storage/field_sql_storage.module | function field_sql_storage_field_storage_load($entity_type, $entities, $age, $fields, $options) {
$load_current = $age == FIELD_LOAD_CURRENT;
foreach ($fields as $field_id => $ids) {
// By the time this hook runs, the relevant field definitions have been
// populated and cached in FieldInfo, so calling fie... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-9b6f5264ee | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_search_info/7.x | In Drupal 7, write the function `node_search_info()` (file modules/node/node.module) so that it does the following: Implements hook_search_info(). | File: modules/node/node.module | function node_search_info() {
return array(
'title' => 'Content',
'path' => 'node',
);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-9b85785c19 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.api.php/function/hook_block_configure/7.x | In Drupal 7, show an example implementation for `hook_block_configure($delta = '')` (modules/block/block.api.php): Define a configuration form for a block. | Parameters:
- $delta: Which block is being configured. This is a unique identifier for the block within the module, defined in hook_block_info().
Returns: A configuration form, if one is needed for your block beyond the standard elements that the block module provides (block title, visibility, etc.). For a detailed us... | function hook_block_configure($delta = '') {
// This example comes from node.module.
$form = array();
if ($delta == 'recent') {
$form['node_recent_block_count'] = array(
'#type' => 'select',
'#title' => t('Number of recent content items to display'),
'#default_value' => variable_get('node_re... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-9b87cef1ba | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_item_list/7.x | In Drupal 7, write the function `theme_item_list($variables)` (file includes/theme.inc) so that it does the following: Returns HTML for a list or nested list of items. | Parameters:
- $variables: An associative array containing: - items: An array of items to be displayed in the list. If an item is a string, then it is used as is. If an item is an array, then the "data" element of the array is used as the contents of the list item. If an item is an array with a "children" element, those... | function theme_item_list($variables) {
$items = $variables['items'];
$title = $variables['title'];
$type = $variables['type'];
$attributes = $variables['attributes'];
// Only output the list container and title, if there are any list items.
// Check to see whether the block title exists before adding a hea... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9bb0c28168 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.install/function/menu_install/7.x | In Drupal 7, write the function `menu_install()` (file modules/menu/menu.install) so that it does the following: Implements hook_install(). | File: modules/menu/menu.install | function menu_install() {
$system_menus = menu_list_system_menus();
$t = get_t();
$descriptions = array(
'navigation' => $t('The <em>Navigation</em> menu contains links intended for site visitors. Links are added to the <em>Navigation</em> menu automatically by some modules.'),
'user-menu' => $t("The <em>... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-9bdf540b69 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/locale_date_format_language_overview_page/7.x | I need the code for `locale_date_format_language_overview_page()` in Drupal 7 (modules/locale/locale.admin.inc). It must do this: Display edit date format links for each language. | File: modules/locale/locale.admin.inc | function locale_date_format_language_overview_page() {
$header = array(
t('Language'),
array('data' => t('Operations'), 'colspan' => '2'),
);
// Get list of languages.
$languages = locale_language_list('native');
foreach ($languages as $langcode => $info) {
$row = array();
$row[] = $language... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9be792bbf0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_entity_delete/7.x | In Drupal 7, show an example implementation for `hook_entity_delete($entity, $type)` (modules/system/system.api.php): Act on entities when deleted. | Parameters:
- $entity: The entity object.
- $type: The type of entity being deleted (i.e. node, user, comment).
File: modules/system/system.api.php | function hook_entity_delete($entity, $type) {
// Delete the entity's entry from a fictional table of all entities.
$info = entity_get_info($type);
list($id) = entity_extract_ids($type, $entity);
db_delete('example_entity')
->condition('type', $type)
->condition('id', $id)
->execute();
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-9bfd76d0d0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_php/7.x | In Drupal 7, write the function `system_php()` (file modules/system/system.admin.inc) so that it does the following: Menu callback: return information about PHP. | File: modules/system/system.admin.inc | function system_php() {
$phpinfo_flags = variable_get('sa_core_2023_004_phpinfo_flags', ~(INFO_VARIABLES | INFO_ENVIRONMENT));
phpinfo($phpinfo_flags);
drupal_exit();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9c210b3a4b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21file.inc/function/drupal_tempnam/7.x | I need the code for `drupal_tempnam($directory, $prefix)` in Drupal 7 (includes/file.inc). It must do this: Creates a file with a unique filename in the specified directory. | PHP's tempnam() does not return a URI like we want. This function will return a URI if given a URI, or it will return a filepath if given a filepath.
Compatibility: normal paths and stream wrappers.
Parameters:
- $directory: The directory where the temporary filename will be created.
- $prefix: The prefix of the gene... | function drupal_tempnam($directory, $prefix) {
$scheme = file_uri_scheme($directory);
if ($scheme && file_stream_wrapper_valid_scheme($scheme)) {
$wrapper = file_stream_wrapper_get_instance_by_scheme($scheme);
if ($filename = tempnam($wrapper->getDirectoryPath(), $prefix)) {
return $scheme . '://' .... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9c3714aeb3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/theme_locale_languages_configure_form/7.x | I need the code for `theme_locale_languages_configure_form($variables)` in Drupal 7 (modules/locale/locale.admin.inc). It must do this: Returns HTML for a language configuration form. | Parameters:
- $variables: An associative array containing: - form: A render element representing the form.
File: modules/locale/locale.admin.inc | function theme_locale_languages_configure_form($variables) {
$form = $variables['form'];
$output = '';
foreach ($form['#language_types'] as $type) {
$rows = array();
$info = $form['#language_types_info'][$type];
$title = '<label>' . $form[$type]['#title'] . '</label>';
$description = '<div class=... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9c3c999fd9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/_drupal_build_css_path/7.x | Implement `_drupal_build_css_path($matches, $base = NULL)` in PHP for Drupal 7. Required behavior: Prefixes all paths within a CSS file for drupal_build_css_cache(). | File: includes/common.inc | function _drupal_build_css_path($matches, $base = NULL) {
$_base = &drupal_static(__FUNCTION__);
// Store base path for preg_replace_callback.
if (isset($base)) {
$_base = $base;
}
// Prefix with base and remove '../' segments where possible.
$path = $_base . (isset($matches[1]) ? $matches[1] : '');
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9c5ae196ec | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_file_presave/7.x | In Drupal 7, show an example implementation for `hook_file_presave($file)` (modules/system/system.api.php): Act on a file being inserted or updated. | This hook is called when a file has been added to the database. The hook doesn't distinguish between files created as a result of a copy or those created by an upload.
Parameters:
- $file: The file that has just been created.
File: modules/system/system.api.php | function hook_file_presave($file) {
// Change the file timestamp to an hour prior.
$file->timestamp -= 3600;
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-9c7b4df3ef | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.admin.inc/function/block_add_block_form_submit/7.x | Implement `block_add_block_form_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form submission handler for block_add_block_form(). | Saves the new custom block.
File: modules/block/block.admin.inc | function block_add_block_form_submit($form, &$form_state) {
$delta = db_insert('block_custom')
->fields(array(
'body' => $form_state['values']['body']['value'],
'info' => $form_state['values']['info'],
'format' => $form_state['values']['body']['format'],
))
->execute();
// Store block ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9c86c08f5d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.maintenance.inc/function/theme_task_list/7.x | In Drupal 7, write the function `theme_task_list($variables)` (file includes/theme.maintenance.inc) so that it does the following: Returns HTML for a list of maintenance tasks to perform. | Parameters:
- $variables: An associative array containing: - items: An associative array of maintenance tasks. - active: The key for the currently active maintenance task.
File: includes/theme.maintenance.inc | function theme_task_list($variables) {
$items = $variables['items'];
$active = $variables['active'];
$done = isset($items[$active]) || $active == NULL;
$output = '<h2 class="element-invisible">Installation tasks</h2>';
$output .= '<ol class="task-list">';
foreach ($items as $k => $item) {
if ($active ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9c9c39ffae | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/form_type_select_value/7.x | I need the code for `form_type_select_value($element, $input = FALSE)` in Drupal 7 (includes/form.inc). It must do this: Determines the value for a select form element. | Parameters:
- $element: The form element whose value is being populated.
- $input: The incoming input to populate the form element. If this is FALSE, the element's default value should be returned.
Returns: The data that will appear in $form_state['values'] for this element, or nothing to use the default.
File: inclu... | function form_type_select_value($element, $input = FALSE) {
if ($input !== FALSE) {
if (isset($element['#multiple']) && $element['#multiple']) {
// If an enabled multi-select submits NULL, it means all items are
// unselected. A disabled multi-select always submits NULL, and the
// default value... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9ca3089e7d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21options%21options.module/function/_options_prepare_options/7.x | In Drupal 7, write the function `_options_prepare_options(&$options, $properties)` (file modules/field/modules/options/options.module) so that it does the following: Sanitizes the options. | The function is recursive to support optgroups.
File: modules/field/modules/options/options.module | function _options_prepare_options(&$options, $properties) {
foreach ($options as $value => $label) {
// Recurse for optgroups.
if (is_array($label)) {
_options_prepare_options($options[$value], $properties);
}
else {
// The 'strip_tags' option is deprecated. Use 'strip_tags_and_unescape'
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9cd6f35609 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21theme.maintenance.inc/function/theme_authorize_message/7.x | Implement `theme_authorize_message($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for a single log message from the authorize.php batch operation. | Parameters:
- $variables: An associative array containing: - message: The log message. - success: A boolean indicating failure or success.
File: includes/theme.maintenance.inc | function theme_authorize_message($variables) {
$message = $variables['message'];
$success = $variables['success'];
if ($success) {
$item = array('data' => $message, 'class' => array('success'));
}
else {
$item = array('data' => '<strong>' . $message . '</strong>', 'class' => array('failure'));
}
r... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9cdf9edde3 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.inc/function/drupal_get_installed_schema_version/7.x | Implement `drupal_get_installed_schema_version($module, $reset = FALSE, $array = FALSE)` in PHP for Drupal 7. Required behavior: Returns the currently installed schema version for a module. | Parameters:
- $module: A module name.
- $reset: Set to TRUE after modifying the system table.
- $array: Set to TRUE if you want to get information about all modules in the system.
Returns: The currently installed schema version, or SCHEMA_UNINSTALLED if the module is not installed.
File: includes/install.inc | function drupal_get_installed_schema_version($module, $reset = FALSE, $array = FALSE) {
static $versions = array();
if ($reset) {
$versions = array();
}
if (!$versions) {
$versions = array();
$result = db_query("SELECT name, schema_version FROM {system} WHERE type = :type", array(':type' => 'modul... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9cf3bcf360 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_style_delete/7.x | I need the code for `image_style_delete($style, $replacement_style_name = '')` in Drupal 7 (modules/image/image.module). It must do this: Deletes an image style. | Parameters:
- $style: An image style array.
- $replacement_style_name: (optional) When deleting a style, specify a replacement style name so that existing settings (if any) may be converted to a new style.
Returns: TRUE on success.
File: modules/image/image.module | function image_style_delete($style, $replacement_style_name = '') {
image_style_flush($style);
db_delete('image_effects')->condition('isid', $style['isid'])->execute();
db_delete('image_styles')->condition('isid', $style['isid'])->execute();
// Let other modules update as necessary on save.
$style['old_name... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9d162e9fd7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21locale.inc/function/locale_language_url_fallback/7.x | I need the code for `locale_language_url_fallback($language = NULL, $language_type = LANGUAGE_TYPE_INTERFACE)` in Drupal 7 (includes/locale.inc). It must do this: Determines the language to be assigned to URLs when none is detected. | The language negotiation process has a fallback chain that ends with the
default language provider. Each built-in language type has a separate
initialization:
- Interface language, which is the only configurable one, always gets a valid
value. If no request-specific language is detected, the default language
will b... | function locale_language_url_fallback($language = NULL, $language_type = LANGUAGE_TYPE_INTERFACE) {
$default = language_default();
$prefix = (variable_get('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX) == LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX);
// If the default language is not ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9d231c3c55 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.install/function/filter_update_7010/7.x | Implement `filter_update_7010()` in PHP for Drupal 7. Required behavior: Change {filter_format}.format and {filter}.format into varchar. | File: modules/filter/filter.install | function filter_update_7010() {
db_change_field('filter_format', 'format', 'format', array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'description' => 'Primary Key: Unique machine name of the format.',
));
db_change_field('filter', 'format', 'format', array(
'type' => 'varchar'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9d4c8486e4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.form.inc/function/field_add_more_js/7.x | Implement `field_add_more_js($form, $form_state)` in PHP for Drupal 7. Required behavior: Ajax callback in response to a new empty widget being added to the form. | This returns the new page content to replace the page content made obsolete by the form submission.
File: modules/field/field.form.inc | function field_add_more_js($form, $form_state) {
$button = $form_state['triggering_element'];
// Go one level up in the form, to the widgets container.
$element = drupal_array_get_nested_value($form, array_slice($button['#array_parents'], 0, -1));
$field_name = $element['#field_name'];
$langcode = $element['... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9d593c3544 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21locale.inc/function/locale_language_from_browser/7.x | I need the code for `locale_language_from_browser($languages)` in Drupal 7 (includes/locale.inc). It must do this: Identify language from the Accept-language HTTP header we got. | We perform browser accept-language parsing only if page cache is disabled, otherwise we would cache a user-specific preference.
Parameters:
- $languages: An array of language objects for enabled languages ordered by weight.
Returns: A valid language code on success, FALSE otherwise.
File: includes/locale.inc | function locale_language_from_browser($languages) {
if (empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
return FALSE;
}
// The Accept-Language header contains information about the language
// preferences configured in the user's browser / operating system.
// RFC 2616 (section 14.4) defines the Accept-Langua... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9d74f4cff4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_form_validate/7.x | I need the code for `comment_form_validate($form, &$form_state)` in Drupal 7 (modules/comment/comment.module). It must do this: Validate comment form submissions. | File: modules/comment/comment.module | function comment_form_validate($form, &$form_state) {
global $user;
entity_form_field_validate('comment', $form, $form_state);
if (!empty($form_state['values']['cid'])) {
// Verify the name in case it is being changed from being anonymous.
$account = user_load_by_name($form_state['values']['name']);
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9da66ec77a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/filter_modules_enabled/7.x | I need the code for `filter_modules_enabled($modules)` in Drupal 7 (modules/filter/filter.module). It must do this: Implements hook_modules_enabled(). | File: modules/filter/filter.module | function filter_modules_enabled($modules) {
// Reset the static cache of module-provided filters, in case any of the
// newly enabled modules defines a new filter or alters existing ones.
drupal_static_reset('filter_get_filters');
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-9de1db1267 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21blog%21blog.install/function/blog_install/7.x | Implement `blog_install()` in PHP for Drupal 7. Required behavior: Implements hook_install(). | File: modules/blog/blog.install | function blog_install() {
// Ensure the blog node type is available.
node_types_rebuild();
$types = node_type_get_types();
node_add_body_field($types['blog']);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-9dec252bc8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_cron_settings/7.x | In Drupal 7, write the function `system_cron_settings()` (file modules/system/system.admin.inc) so that it does the following: Form builder; Cron form. | File: modules/system/system.admin.inc | function system_cron_settings() {
global $base_url;
$form['description'] = array(
'#markup' => '<p>' . t('Cron takes care of running periodic tasks like checking for updates and indexing content for search.') . '</p>',
);
$form['run'] = array(
'#type' => 'submit',
'#value' => t('Run cron'),
'#su... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9df21002b7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_user_cancel/7.x | Implement `comment_user_cancel($edit, $account, $method)` in PHP for Drupal 7. Required behavior: Implements hook_user_cancel(). | File: modules/comment/comment.module | function comment_user_cancel($edit, $account, $method) {
switch ($method) {
case 'user_cancel_block_unpublish':
$comments = comment_load_multiple(array(), array('uid' => $account->uid));
foreach ($comments as $comment) {
$comment->status = 0;
comment_save($comment);
}
break... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-9df443caec | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21path%21path.admin.inc/function/path_admin_filter_form/7.x | I need the code for `path_admin_filter_form($form, &$form_state, $keys = '')` in Drupal 7 (modules/path/path.admin.inc). It must do this: Form constructor for the path admin overview filter form. | File: modules/path/path.admin.inc | function path_admin_filter_form($form, &$form_state, $keys = '') {
$form['#attributes'] = array('class' => array('search-form'));
$form['basic'] = array('#type' => 'fieldset',
'#title' => t('Filter aliases'),
'#attributes' => array('class' => array('container-inline')),
);
$form['basic']['filter'] = arr... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9e1a17dc23 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21comment%21comment.install/function/comment_update_7002/7.x | In Drupal 7, write the function `comment_update_7002()` (file modules/comment/comment.install) so that it does the following: Rename {comments} table to {comment} and upgrade it. | File: modules/comment/comment.install | function comment_update_7002() {
db_rename_table('comments', 'comment');
// Add user-related indexes. These may already exist from Drupal 6.
if (!db_index_exists('comment', 'comment_uid')) {
db_add_index('comment', 'comment_uid', array('uid'));
db_add_index('node_comment_statistics', 'last_comment_uid', ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9e3e46a4ae | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_uid_optional_to_arg/7.x | In Drupal 7, write the function `user_uid_optional_to_arg($arg)` (file modules/user/user.module) so that it does the following: Returns $arg or the user ID of the current user if $arg is '%' or empty. | File: modules/user/user.module | function user_uid_optional_to_arg($arg) {
// Give back the current user uid when called from eg. tracker, aka.
// with an empty arg. Also use the current user uid when called from
// the menu with a % for the current account link.
return empty($arg) || $arg == '%' ? $GLOBALS['user']->uid : $arg;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9e40a55880 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_load/7.x | I need the code for `node_load($nid = NULL, $vid = NULL, $reset = FALSE)` in Drupal 7 (modules/node/node.module). It must do this: Loads a node object from the database. | Parameters:
- $nid: The node ID.
- $vid: The revision ID.
- $reset: Whether to reset the node_load_multiple cache.
Returns: A fully-populated node object, or FALSE if the node is not found.
File: modules/node/node.module | function node_load($nid = NULL, $vid = NULL, $reset = FALSE) {
$nids = (isset($nid) ? array($nid) : array());
$conditions = (isset($vid) ? array('vid' => $vid) : array());
$node = node_load_multiple($nids, $conditions, $reset);
return $node ? reset($node) : FALSE;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9e46440c73 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/update.php/function/update_results_page/7.x | In Drupal 7, write the function `update_results_page()` (file update.php) so that it does the following: Displays results of the update script with any accompanying errors. | File: update.php | function update_results_page() {
drupal_set_title('Drupal database update');
$links = update_helpful_links();
update_task_list();
// Report end result.
if (module_exists('dblog') && user_access('access site reports')) {
$log_message = ' All errors have been <a href="' . base_path() . '?q=admin/reports/db... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9e5baa2592 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21theme.api.php/function/hook_preprocess_HOOK/7.x | In Drupal 7, show an example implementation for `hook_preprocess_HOOK(&$variables)` (modules/system/theme.api.php): Preprocess theme variables for a specific theme hook. | This hook allows modules to preprocess theme variables for a specific theme hook. It should only be used if a module needs to override or add to the theme preprocessing for a theme hook it didn't define.
For more detailed information, see theme().
Parameters:
- $variables: The variables array (modify in place).
File... | function hook_preprocess_HOOK(&$variables) {
// This example is from rdf_preprocess_image(). It adds an RDF attribute
// to the image hook's variables.
$variables['attributes']['typeof'] = array('foaf:Image');
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-9e81c5051e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.core.inc/function/install_verify_completed_task/7.x | In Drupal 7, write the function `install_verify_completed_task()` (file includes/install.core.inc) so that it does the following: Verifies and returns the last installation task that was completed. | Returns: The last completed task, if there is one. An exception is thrown if Drupal is already installed.
File: includes/install.core.inc | function install_verify_completed_task() {
try {
if ($result = db_query("SELECT value FROM {variable} WHERE name = :name", array('name' => 'install_task'))) {
$task = unserialize($result->fetchField());
}
}
// Do not trigger an error if the database query fails, since the database
// might not be ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9e91c5c17c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_update_7071/7.x | I need the code for `system_update_7071()` in Drupal 7 (modules/system/system.install). It must do this: Add index missed during upgrade, and fix field default. | File: modules/system/system.install | function system_update_7071() {
db_drop_index('date_format_type', 'title');
db_add_index('date_format_type', 'title', array('title'));
db_change_field('registry', 'filename', 'filename', array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
));
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9ea3957068 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/themes%21garland%21theme-settings.php/function/garland_form_system_theme_settings_alter/7.x | I need the code for `garland_form_system_theme_settings_alter(&$form, &$form_state)` in Drupal 7 (themes/garland/theme-settings.php). It must do this: Implements hook_form_FORM_ID_alter(). | Parameters:
- $form: The form.
- $form_state: The form state.
File: themes/garland/theme-settings.php | function garland_form_system_theme_settings_alter(&$form, &$form_state) {
$form['garland_width'] = array(
'#type' => 'radios',
'#title' => t('Content width'),
'#options' => array(
'fluid' => t('Fluid width'),
'fixed' => t('Fixed width'),
),
'#default_value' => theme_get_setting('garla... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-9ea620f818 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_date_formats_rebuild/7.x | Implement `system_date_formats_rebuild()` in PHP for Drupal 7. Required behavior: Resets the database cache of date formats and saves all new date formats. | File: modules/system/system.module | function system_date_formats_rebuild() {
drupal_static_reset('system_get_date_formats');
$date_formats = system_get_date_formats(NULL);
foreach ($date_formats as $type => $formats) {
foreach ($formats as $format => $info) {
system_date_format_save($info);
}
}
// Rebuild configured date formats... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9eb2353afa | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.module/function/theme_aggregator_block_item/7.x | In Drupal 7, write the function `theme_aggregator_block_item($variables)` (file modules/aggregator/aggregator.module) so that it does the following: Returns HTML for an individual feed item for display in the block. | Parameters:
- $variables: An associative array containing: - item: The item to be displayed. - feed: Not used.
File: modules/aggregator/aggregator.module | function theme_aggregator_block_item($variables) {
// Display the external link to the item.
return '<a href="' . check_url($variables['item']->link) . '">' . check_plain($variables['item']->title) . "</a>\n";
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9ecc2b58c4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.admin.inc/function/shortcut_set_customize/7.x | I need the code for `shortcut_set_customize($form, &$form_state, $shortcut_set)` in Drupal 7 (modules/shortcut/shortcut.admin.inc). It must do this: Form callback: builds the form for customizing shortcut sets. | Parameters:
- $form: An associative array containing the structure of the form.
- $form_state: An associative array containing the current state of the form.
- $shortcut_set: An object representing the shortcut set which is being edited.
Returns: An array representing the form definition.
File: modules/shortcut/short... | function shortcut_set_customize($form, &$form_state, $shortcut_set) {
$form['#shortcut_set_name'] = $shortcut_set->set_name;
$form['shortcuts'] = array(
'#tree' => TRUE,
'#weight' => -20,
'enabled' => array(),
'disabled' => array(),
);
foreach ($shortcut_set->links as $link) {
$mlid = $link... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9ed5407028 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.field.inc/function/file_field_displayed/7.x | I need the code for `file_field_displayed($item, $field)` in Drupal 7 (modules/file/file.field.inc). It must do this: Determines whether a file should be displayed when outputting field content. | Parameters:
- $item: A field item array.
- $field: A field array.
Returns (Boolean): TRUE if the file will be displayed, FALSE if the file is hidden.
File: modules/file/file.field.inc | function file_field_displayed($item, $field) {
if (!empty($field['settings']['display_field'])) {
return (bool) $item['display'];
}
return TRUE;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9ed994cc33 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_get_filetransfer_info/7.x | Implement `drupal_get_filetransfer_info()` in PHP for Drupal 7. Required behavior: Assembles the Drupal FileTransfer registry. | Returns: The Drupal FileTransfer class registry.
File: includes/common.inc | function drupal_get_filetransfer_info() {
$info = &drupal_static(__FUNCTION__);
if (!isset($info)) {
// Since we have to manually set the 'file path' default for each
// module separately, we can't use module_invoke_all().
$info = array();
foreach (module_implements('filetransfer_info') as $module) ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9edfa0d6f5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21field_sql_storage%21field_sql_storage.module/function/_field_sql_storage_tablealias/7.x | In Drupal 7, write the function `_field_sql_storage_tablealias($tablename, $field_key, EntityFieldQuery $query)` (file modules/field/modules/field_sql_storage/field_sql_storage.module) so that it does the following: Generates a table alias for a field data table. | The table alias is unique for each unique combination of field name (represented by $tablename), delta_group and language_group.
Parameters:
- $tablename: The name of the data table for this field.
- $field_key: The numeric key of this field in this query.
- $query: The EntityFieldQuery that is executed.
Returns: A s... | function _field_sql_storage_tablealias($tablename, $field_key, EntityFieldQuery $query) {
// No conditions present: use a unique alias.
if (empty($query->fieldConditions[$field_key])) {
return $tablename . $field_key;
}
// Find the delta and language condition values and append them to the alias.
$condit... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9eeda718c9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_default_style_save/7.x | In Drupal 7, write the function `image_default_style_save($style)` (file modules/image/image.module) so that it does the following: Saves a default image style to the database. | Returns: An image style array. The returned style array will include the new 'isid' assigned to the style.
File: modules/image/image.module | function image_default_style_save($style) {
$style = image_style_save($style);
$effects = array();
foreach ($style['effects'] as $effect) {
$effect['isid'] = $style['isid'];
$effect = image_effect_save($effect);
$effects[$effect['ieid']] = $effect;
}
$style['effects'] = $effects;
return $style;
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9f08ece787 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_themes_page/7.x | I need the code for `system_themes_page()` in Drupal 7 (modules/system/system.admin.inc). It must do this: Menu callback; displays a listing of all themes. | File: modules/system/system.admin.inc | function system_themes_page() {
// Get current list of themes.
$themes = system_rebuild_theme_data();
uasort($themes, 'system_sort_modules_by_info_name');
$theme_default = variable_get('theme_default', 'bartik');
$theme_groups = array();
foreach ($themes as &$theme) {
if (!empty($theme->info['hidden'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9f3b0bafba | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21errors.inc/function/drupal_error_levels/7.x | Implement `drupal_error_levels()` in PHP for Drupal 7. Required behavior: Maps PHP error constants to watchdog severity levels. | The error constants are documented at http://php.net/manual/errorfunc.constants.php
File: includes/errors.inc | function drupal_error_levels() {
$types = array(
E_ERROR => array('Error', WATCHDOG_ERROR),
E_WARNING => array('Warning', WATCHDOG_WARNING),
E_PARSE => array('Parse error', WATCHDOG_ERROR),
E_NOTICE => array('Notice', WATCHDOG_NOTICE),
E_CORE_ERROR => array('Core error', WATCHDOG_ERROR),
E_COR... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9f3f3c1525 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21book%21book.module/function/book_help/7.x | I need the code for `book_help($path, $arg)` in Drupal 7 (modules/book/book.module). It must do this: Implements hook_help(). | File: modules/book/book.module | function book_help($path, $arg) {
switch ($path) {
case 'admin/help#book':
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Book module is used for creating structured, multi-page content, such as site resource guides, manuals, and wikis. It allows you to create content that has chap... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-9f417a6a3a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.module/function/dashboard_theme/7.x | I need the code for `dashboard_theme()` in Drupal 7 (modules/dashboard/dashboard.module). It must do this: Implements hook_theme(). | File: modules/dashboard/dashboard.module | function dashboard_theme() {
return array(
'dashboard' => array(
'render element' => 'element',
),
'dashboard_admin' => array(
'render element' => 'element',
),
'dashboard_region' => array(
'render element' => 'element',
),
'dashboard_disabled_blocks' => array(
'var... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-9f694d531e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_storage_purge_field/7.x | In Drupal 7, show an example implementation for `hook_field_storage_purge_field($field)` (modules/field/field.api.php): Remove field storage information when a field record is purged. | Called from field_purge_field() to allow the field storage module to remove field information when a field is being purged.
Parameters:
- $field: The field being purged.
File: modules/field/field.api.php | function hook_field_storage_purge_field($field) {
$table_name = _field_sql_storage_tablename($field);
$revision_name = _field_sql_storage_revision_tablename($field);
db_drop_table($table_name);
db_drop_table($revision_name);
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-9f732efaca | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.api.php/function/hook_user_operations/7.x | Give me the example code for `hook_user_operations()` in Drupal 7. Hook description: Add mass user operations. | This hook enables modules to inject custom operations into the mass operations dropdown found at admin/people, by associating a callback function with the operation, which is called when the form is submitted. The callback function receives one initial argument, which is an array of the checked users.
Returns: An arra... | function hook_user_operations() {
$operations = array(
'unblock' => array(
'label' => t('Unblock the selected users'),
'callback' => 'user_user_operations_unblock',
),
'block' => array(
'label' => t('Block the selected users'),
'callback' => 'user_user_operations_block',
),
... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-9f822e0be2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/locale_translate_delete_form/7.x | In Drupal 7, write the function `locale_translate_delete_form($form, &$form_state, $source)` (file modules/locale/locale.admin.inc) so that it does the following: User interface for the string deletion confirmation screen. | File: modules/locale/locale.admin.inc | function locale_translate_delete_form($form, &$form_state, $source) {
$form['lid'] = array('#type' => 'value', '#value' => $source->lid);
return confirm_form($form, t('Are you sure you want to delete the string "%source"?', array('%source' => $source->source)), 'admin/config/regional/translate/translate', t('Deleti... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9f90c70f5d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.api.php/function/hook_shortcut_default_set/7.x | Give me the example code for `hook_shortcut_default_set($account)` in Drupal 7. Hook description: Return the name of a default shortcut set for the provided user account. | This hook allows modules to define default shortcut sets for a particular user that differ from the site-wide default (for example, a module may want to define default shortcuts on a per-role basis).
The default shortcut set is used only when the user does not have any other shortcut set explicitly assigned to them.
... | function hook_shortcut_default_set($account) {
// Use a special set of default shortcuts for administrators only.
if (in_array(variable_get('user_admin_role', 0), $account->roles)) {
return variable_get('mymodule_shortcut_admin_default_set');
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-9f97879d5a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21options%21options.module/function/_options_storage_to_form/7.x | In Drupal 7, write the function `_options_storage_to_form($items, $options, $column, $properties)` (file modules/field/modules/options/options.module) so that it does the following: Transforms stored field values into the format the widgets need. | File: modules/field/modules/options/options.module | function _options_storage_to_form($items, $options, $column, $properties) {
$items_transposed = options_array_transpose($items);
$values = (isset($items_transposed[$column]) && is_array($items_transposed[$column])) ? $items_transposed[$column] : array();
// Discard values that are not in the current list of opti... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9fe1f15ca8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/element_validate_integer/7.x | In Drupal 7, write the function `element_validate_integer($element, &$form_state)` (file includes/form.inc) so that it does the following: Form element validation handler for integer elements. | File: includes/form.inc | function element_validate_integer($element, &$form_state) {
$value = $element['#value'];
if ($value !== '' && (!is_numeric($value) || intval($value) != $value)) {
form_error($element, t('%name must be an integer.', array('%name' => $element['#title'])));
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9feee80182 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_actions_configure_submit/7.x | I need the code for `system_actions_configure_submit($form, &$form_state)` in Drupal 7 (modules/system/system.admin.inc). It must do this: Process system_actions_configure() form submissions. | File: modules/system/system.admin.inc | function system_actions_configure_submit($form, &$form_state) {
$function = actions_function_lookup($form_state['values']['actions_action']);
$submit_function = $function . '_submit';
// Action will return keyed array of values to store.
$params = $submit_function($form, $form_state);
$aid = isset($form_stat... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9fefc33e4c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.pages.inc/function/node_revision_overview/7.x | Implement `node_revision_overview($node)` in PHP for Drupal 7. Required behavior: Generates an overview table of older revisions of a node. | Parameters:
- $node: A node object.
Returns (array): An array as expected by drupal_render().
File: modules/node/node.pages.inc | function node_revision_overview($node) {
drupal_set_title(t('Revisions for %title', array('%title' => $node->title)), PASS_THROUGH);
$header = array(t('Revision'), array('data' => t('Operations'), 'colspan' => 2));
$revisions = node_revision_list($node);
$rows = array();
$revert_permission = FALSE;
if ((... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-9ff25b8c48 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.module/function/shortcut_current_displayed_set/7.x | In Drupal 7, write the function `shortcut_current_displayed_set($account = NULL)` (file modules/shortcut/shortcut.module) so that it does the following: Returns the current displayed shortcut set for the provided user account. | Parameters:
- $account: (optional) The user account whose shortcuts will be returned. Defaults to the currently logged-in user.
Returns: An object representing the shortcut set that should be displayed to the current user. If the user does not have an explicit shortcut set defined, the default set is returned.
File: ... | function shortcut_current_displayed_set($account = NULL) {
$shortcut_sets = &drupal_static(__FUNCTION__, array());
global $user;
if (!isset($account)) {
$account = $user;
}
// Try to return a shortcut set from the static cache.
if (isset($shortcut_sets[$account->uid])) {
return $shortcut_sets[$accou... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a002520a59 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.module/function/poll_cron/7.x | In Drupal 7, write the function `poll_cron()` (file modules/poll/poll.module) so that it does the following: Implements hook_cron(). | Closes polls that have exceeded their allowed runtime.
File: modules/poll/poll.module | function poll_cron() {
$nids = db_query('SELECT p.nid FROM {poll} p INNER JOIN {node} n ON p.nid = n.nid WHERE (n.created + p.runtime) < :request_time AND p.active = :active AND p.runtime <> :runtime', array(':request_time' => REQUEST_TIME, ':active' => 1, ':runtime' => 0))->fetchCol();
if (!empty($nids)) {
db_... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a067a19f53 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.default.inc/function/field_default_prepare_translation/7.x | Implement `field_default_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode)` in PHP for Drupal 7. Required behavior: Copies source field values into the entity to be prepared. | Parameters:
- $entity_type: The type of $entity; e.g. 'node' or 'user'.
- $entity: The entity to be prepared for translation.
- $field: The field structure for the operation.
- $instance: The instance structure for $field on $entity's bundle.
- $langcode: The language the entity has to be translated in.
- $entity ($ite... | function field_default_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) {
$field_name = $field['field_name'];
// If the field is untranslatable keep using LANGUAGE_NONE.
if ($langcode == LANGUAGE_NONE) {
$source_langcode = LANGUAGE_NONE;
}
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a06dc19cc7 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.module/function/block_block_info/7.x | Implement `block_block_info()` in PHP for Drupal 7. Required behavior: Implements hook_block_info(). | File: modules/block/block.module | function block_block_info() {
$blocks = array();
$result = db_query('SELECT bid, info FROM {block_custom} ORDER BY info');
foreach ($result as $block) {
$blocks[$block->bid]['info'] = $block->info;
// Not worth caching.
$blocks[$block->bid]['cache'] = DRUPAL_NO_CACHE;
}
return $blocks;
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a0a5d2474f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21ajax.inc/function/ajax_command_alert/7.x | Implement `ajax_command_alert($text)` in PHP for Drupal 7. Required behavior: Creates a Drupal Ajax 'alert' command. | The 'alert' command instructs the client to display a JavaScript alert dialog box.
This command is implemented by Drupal.ajax.prototype.commands.alert() defined in misc/ajax.js.
Parameters:
- $text: The message string to display to the user.
Returns: An array suitable for use with the ajax_render() function.
File: ... | function ajax_command_alert($text) {
return array(
'command' => 'alert',
'text' => $text,
);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a0be3e4b61 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_login/7.x | I need the code for `user_login($form, &$form_state)` in Drupal 7 (modules/user/user.module). It must do this: Form builder; the main user login form. | File: modules/user/user.module | function user_login($form, &$form_state) {
global $user;
// If we are already logged on, go to the user page instead.
if ($user->uid) {
drupal_goto('user/' . $user->uid);
}
// Display login form:
$form['name'] = array('#type' => 'textfield',
'#title' => t('Username'),
'#size' => 60,
'#maxl... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a0c253e1f1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_user_flood_control/7.x | Implement `user_user_flood_control($ip, $username = FALSE)` in PHP for Drupal 7. Required behavior: Implements hook_user_flood_control(). | File: modules/user/user.module | function user_user_flood_control($ip, $username = FALSE) {
if (variable_get('log_user_flood_control', TRUE)) {
if (!empty($username)) {
watchdog('user', 'Flood control blocked login attempt for %user from %ip.', array(
'%user' => $username,
'%ip' => $ip
));
}
else {
watch... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a0c60f4c42 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.admin.inc/function/theme_image_scale_summary/7.x | Implement `theme_image_scale_summary($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for a summary of an image scale effect. | Parameters:
- $variables: An associative array containing: - data: The current configuration for this scale effect.
File: modules/image/image.admin.inc | function theme_image_scale_summary($variables) {
$data = $variables['data'];
return theme('image_resize_summary', array('data' => $data)) . ' ' . ($data['upscale'] ? '(' . t('upscaling allowed') . ')' : '');
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a0ccefdc49 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/conf_path/7.x | I need the code for `conf_path($require_settings = TRUE, $reset = FALSE)` in Drupal 7 (includes/bootstrap.inc). It must do this: Returns the appropriate configuration directory. | Returns the configuration path based on the site's hostname, port, and pathname. See default.settings.php for examples on how the URL is converted to a directory.
Parameters:
- $require_settings (bool): Only configuration directories with an existing settings.php file will be recognized. Defaults to TRUE. During initi... | function conf_path($require_settings = TRUE, $reset = FALSE) {
$conf = &drupal_static(__FUNCTION__, '');
if ($conf && !$reset) {
return $conf;
}
$confdir = 'sites';
$sites = array();
if (file_exists(DRUPAL_ROOT . '/' . $confdir . '/sites.php')) {
// This will overwrite $sites with the desired map... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a0da834aa9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/_form_button_was_clicked/7.x | Implement `_form_button_was_clicked($element, &$form_state)` in PHP for Drupal 7. Required behavior: Determines if a given button triggered the form submission. | This detects button controls that trigger a form submission by being clicked and having the click processed by the browser rather than being captured by JavaScript. Essentially, it detects if the button's name and value are part of the POST data, but with extra code to deal with the convoluted way in which browsers sub... | function _form_button_was_clicked($element, &$form_state) {
// First detect normal 'vanilla' button clicks. Traditionally, all
// standard buttons on a form share the same name (usually 'op'),
// and the specific return value is used to determine which was
// clicked. This ONLY works as long as $form['#name'] p... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a0e246dd0c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_user_view/7.x | Implement `user_user_view($account)` in PHP for Drupal 7. Required behavior: Implements hook_user_view(). | File: modules/user/user.module | function user_user_view($account) {
$account->content['user_picture'] = array(
'#markup' => theme('user_picture', array('account' => $account)),
'#weight' => -10,
);
if (!isset($account->content['summary'])) {
$account->content['summary'] = array();
}
$account->content['summary'] += array(
'#t... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-a0e944154e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.install/function/locale_update_7002/7.x | Implement `locale_update_7002()` in PHP for Drupal 7. Required behavior: Updates URL language negotiation by adding the URL fallback detection method. | File: modules/locale/locale.install | function locale_update_7002() {
// language.inc may not have been included during bootstrap if there is not
// more than one language currently enabled.
require_once DRUPAL_ROOT . '/includes/language.inc';
$language_types_info = language_types_info();
$info = $language_types_info[LANGUAGE_TYPE_URL];
if (iss... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-a10f0e9c07 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_permission/7.x | In Drupal 7, write the function `system_permission()` (file modules/system/system.module) so that it does the following: Implements hook_permission(). | File: modules/system/system.module | function system_permission() {
return array(
'administer modules' => array(
'title' => t('Administer modules'),
),
'administer site configuration' => array(
'title' => t('Administer site configuration'),
'restrict access' => TRUE,
),
'administer themes' => array(
'title' =>... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.