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-0efa9298c3
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21file.inc/function/file_ensure_htaccess/7.x
Implement `file_ensure_htaccess()` in PHP for Drupal 7. Required behavior: Creates a .htaccess file in each Drupal files directory if it is missing.
File: includes/file.inc
function file_ensure_htaccess() { file_create_htaccess('public://', FALSE); if (variable_get('file_private_path', FALSE)) { file_create_htaccess('private://', TRUE); } file_create_htaccess('temporary://', TRUE); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-0efadf6fc7
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21filter%21filter.admin.inc/function/filter_admin_format_form_submit/7.x
Implement `filter_admin_format_form_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form submission handler for filter_admin_format_form().
File: modules/filter/filter.admin.inc
function filter_admin_format_form_submit($form, &$form_state) { // Remove unnecessary values. form_state_values_clean($form_state); // Add the submitted form values to the text format, and save it. $format = $form['#format']; foreach ($form_state['values'] as $key => $value) { $format->$key = $value; }...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-0f0ee11b76
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.module/function/shortcut_link_access/7.x
I need the code for `shortcut_link_access($menu_link)` in Drupal 7 (modules/shortcut/shortcut.module). It must do this: Access callback for editing a link in a shortcut set.
File: modules/shortcut/shortcut.module
function shortcut_link_access($menu_link) { // The link must belong to a shortcut set that the current user has access // to edit. if ($shortcut_set = shortcut_set_load($menu_link['menu_name'])) { return shortcut_set_edit_access($shortcut_set); } return FALSE; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-0f19652f68
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_tablesort_indicator/7.x
Implement `theme_tablesort_indicator($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for a sort icon.
Parameters: - $variables: An associative array containing: - style: Set to either 'asc' or 'desc', this determines which icon to show. File: includes/theme.inc
function theme_tablesort_indicator($variables) { if ($variables['style'] == "asc") { return theme('image', array('path' => 'misc/arrow-asc.png', 'width' => 13, 'height' => 13, 'alt' => t('sort ascending'), 'title' => t('sort ascending'))); } else { return theme('image', array('path' => 'misc/arrow-desc.pn...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-0f1ac72280
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21file.inc/function/_drupal_mkdir_call/7.x
I need the code for `_drupal_mkdir_call($uri, $mode, $recursive, $context)` in Drupal 7 (includes/file.inc). It must do this: Helper function. Ensures we don't pass a NULL as a context resource to mkdir().
File: includes/file.inc
function _drupal_mkdir_call($uri, $mode, $recursive, $context) { if (is_null($context)) { return mkdir($uri, $mode, $recursive); } else { return mkdir($uri, $mode, $recursive, $context); } }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-0f2caf83e5
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_update_7057/7.x
In Drupal 7, write the function `system_update_7057()` (file modules/system/system.install) so that it does the following: Increase the size of session-ids.
File: modules/system/system.install
function system_update_7057() { $spec = array( 'description' => "A session ID. The value is generated by PHP's Session API.", 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '', ); db_change_field('sessions', 'sid', 'sid', $spec); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-0f37209f97
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.pages.inc/function/node_revision_revert_confirm/7.x
I need the code for `node_revision_revert_confirm($form, $form_state, $node_revision)` in Drupal 7 (modules/node/node.pages.inc). It must do this: Asks for confirmation of the reversion to prevent against CSRF attacks.
Parameters: - $node_revision (int): The node revision ID. Returns (array): An array as expected by drupal_render(). File: modules/node/node.pages.inc
function node_revision_revert_confirm($form, $form_state, $node_revision) { $form['#node_revision'] = $node_revision; return confirm_form($form, t('Are you sure you want to revert to the revision from %revision-date?', array('%revision-date' => format_date($node_revision->revision_timestamp))), 'node/' . $node_revi...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-0f3acc69a3
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_add_html_head/7.x
I need the code for `drupal_add_html_head($data = NULL, $key = NULL)` in Drupal 7 (includes/common.inc). It must do this: Adds output to the HEAD tag of the HTML page.
This function can be called as long as the headers aren't sent. Pass no arguments (or NULL for both) to retrieve the currently stored elements. Parameters: - $data: A renderable array. If the '#type' key is not set then 'html_tag' will be added as the default '#type'. - $key: A unique string key to allow implementatio...
function drupal_add_html_head($data = NULL, $key = NULL) { $stored_head = &drupal_static(__FUNCTION__); if (!isset($stored_head)) { // Make sure the defaults, including Content-Type, come first. $stored_head = _drupal_default_html_head(); } if (isset($data) && isset($key)) { if (!isset($data['#typ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-0f4e6b753c
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21update.inc/function/update_finished/7.x
Implement `update_finished($success, $results, $operations)` in PHP for Drupal 7. Required behavior: Implements callback_batch_finished().
Finishes the update process and stores the results for eventual display. After the updates run, all caches are flushed. The update results are stored into the session (for example, to be displayed on the update results page in update.php). Additionally, if the site was off-line, now that the update process is complete...
function update_finished($success, $results, $operations) { // Remove the D6 upgrade flag variable so that subsequent update runs do not // get the wrong context. variable_del('update_d6'); // Clear the caches in case the data has been updated. drupal_flush_all_caches(); $_SESSION['update_results'] = $res...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-0f585e4a8b
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_form_submit_build_comment/7.x
I need the code for `comment_form_submit_build_comment($form, &$form_state)` in Drupal 7 (modules/comment/comment.module). It must do this: Updates the form state's comment entity by processing this submission's values.
This is the default builder function for the comment form. It is called during the "Save" and "Preview" submit handlers to retrieve the entity to save or preview. This function can also be called by a "Next" button of a wizard to update the form state's entity with the current step's values before proceeding to the nex...
function comment_form_submit_build_comment($form, &$form_state) { $comment = $form_state['comment']; entity_form_submit_build_entity('comment', $comment, $form, $form_state); comment_submit($comment); return $comment; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-0f7324b0e3
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.admin.inc/function/node_filter_form/7.x
In Drupal 7, write the function `node_filter_form()` (file modules/node/node.admin.inc) so that it does the following: Returns the node administration filters form array to node_admin_content().
File: modules/node/node.admin.inc
function node_filter_form() { $session = isset($_SESSION['node_overview_filter']) ? $_SESSION['node_overview_filter'] : array(); $filters = node_filters(); $i = 0; $form['filters'] = array( '#type' => 'fieldset', '#title' => t('Show only items where'), '#theme' => 'exposed_filters__node', ); fo...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-0f868f955c
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_field_extra_fields/7.x
In Drupal 7, write the function `taxonomy_field_extra_fields()` (file modules/taxonomy/taxonomy.module) so that it does the following: Implements hook_field_extra_fields().
File: modules/taxonomy/taxonomy.module
function taxonomy_field_extra_fields() { $return = array(); $info = entity_get_info('taxonomy_term'); foreach (array_keys($info['bundles']) as $bundle) { $return['taxonomy_term'][$bundle] = array( 'form' => array( 'name' => array( 'label' => t('Name'), 'description' => t('Ter...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-0fa2a11c00
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.info.inc/function/field_info_formatter_types/7.x
Implement `field_info_formatter_types($formatter_type = NULL)` in PHP for Drupal 7. Required behavior: Returns information about field formatters from hook_field_formatter_info().
Parameters: - $formatter_type: (optional) A formatter type name. If omitted, all formatter types will be returned. Returns: Either a single formatter type description, as provided by hook_field_formatter_info(), or an array of all existing formatter types, keyed by formatter type name. File: modules/field/field.info....
function field_info_formatter_types($formatter_type = NULL) { $info = _field_info_collate_types(); $formatter_types = $info['formatter types']; if ($formatter_type) { if (isset($formatter_types[$formatter_type])) { return $formatter_types[$formatter_type]; } } else { return $formatter_types;...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-0fb3b51ade
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/entity_extract_ids/7.x
In Drupal 7, write the function `entity_extract_ids($entity_type, $entity)` (file includes/common.inc) so that it does the following: Helper function to extract id, vid, and bundle name from an entity.
Parameters: - $entity_type: The entity type; e.g. 'node' or 'user'. - $entity: The entity from which to extract values. Returns: A numerically indexed array (not a hash table) containing these elements: - 0: Primary ID of the entity. - 1: Revision ID of the entity, or NULL if $entity_type is not versioned. - 2: Bundle...
function entity_extract_ids($entity_type, $entity) { $info = entity_get_info($entity_type); // Objects being created might not have id/vid yet. if (!empty($info)) { $id = isset($entity->{$info['entity keys']['id']}) ? $entity->{$info['entity keys']['id']} : NULL; $vid = ($info['entity keys']['revision'] ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-0fca7e9725
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21install.core.inc/function/install_begin_request/7.x
In Drupal 7, write the function `install_begin_request(&$install_state)` (file includes/install.core.inc) so that it does the following: Begins an installation request, modifying the installation state as needed.
This function performs commands that must run at the beginning of every page request. It throws an exception if the installation should not proceed. Parameters: - $install_state: An array of information about the current installation state. This is modified with information gleaned from the beginning of the page reque...
function install_begin_request(&$install_state) { // Add any installation parameters passed in via the URL. $install_state['parameters'] += $_GET; // Validate certain core settings that are used throughout the installation. if (!empty($install_state['parameters']['profile'])) { $install_state['parameters']...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-0fdc77838a
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/_filter_tips/7.x
I need the code for `_filter_tips($format_id, $long = FALSE)` in Drupal 7 (modules/filter/filter.module). It must do this: Retrieves the filter tips.
Parameters: - $format_id: The ID of the text format for which to retrieve tips, or -1 to return tips for all formats accessible to the current user. - $long: (optional) Boolean indicating whether the long form of tips should be returned. Defaults to FALSE. Returns: An associative array of filtering tips, keyed by filt...
function _filter_tips($format_id, $long = FALSE) { global $user; $formats = filter_formats($user); $filter_info = filter_get_filters(); $tips = array(); // If only listing one format, extract it from the $formats array. if ($format_id != -1) { $formats = array($formats[$format_id]); } foreach ($...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-0fdd6f2bac
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21mail.inc/function/drupal_wrap_mail/7.x
I need the code for `drupal_wrap_mail($text, $indent = '')` in Drupal 7 (includes/mail.inc). It must do this: Performs format=flowed soft wrapping for mail (RFC 3676).
We use delsp=yes wrapping, but only break non-spaced languages when absolutely necessary to avoid compatibility issues. We deliberately use LF rather than CRLF, see drupal_mail(). Parameters: - $text (string): The plain text to process. - $indent (string): (optional) A string to indent the text with. Only '>' charact...
function drupal_wrap_mail($text, $indent = '') { // Convert CRLF into LF. $text = str_replace("\r", '', $text); // See if soft-wrapping is allowed. $clean_indent = _drupal_html_to_text_clean($indent); $soft = strpos($clean_indent, ' ') === FALSE; // Check if the string has line breaks. if (strpos($text, "...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-0fdf7d31a1
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21modules%21options%21options.api.php/function/hook_options_list/7.x
In Drupal 7, show an example implementation for `hook_options_list($field, $instance, $entity_type, $entity)` (modules/field/modules/options/options.api.php): Returns the list of options to be displayed for a field.
Field types willing to enable one or several of the widgets defined in options.module (select, radios/checkboxes, on/off checkbox) need to implement this hook to specify the list of options to display in the widgets. Parameters: - $field: The field definition. - $instance: (optional) The instance definition. The hook ...
function hook_options_list($field, $instance, $entity_type, $entity) { // Sample structure. $options = array( 0 => t('Zero'), 1 => t('One'), 2 => t('Two'), 3 => t('Three'), ); // Sample structure with groups. Only one level of nesting is allowed. This // is only supported by the 'options_sele...
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-0fee0ac873
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.module/function/field_get_default_value/7.x
I need the code for `field_get_default_value($entity_type, $entity, $field, $instance, $langcode = NULL)` in Drupal 7 (modules/field/field.module). It must do this: Helper function to get the default value for a field on an entity.
Parameters: - $entity_type: The type of $entity; e.g., 'node' or 'user'. - $entity: The entity for the operation. - $field: The field structure. - $instance: The instance structure. - $langcode: The field language to fill-in with the default value. File: modules/field/field.module
function field_get_default_value($entity_type, $entity, $field, $instance, $langcode = NULL) { $items = array(); if (!empty($instance['default_value_function'])) { $function = $instance['default_value_function']; if (function_exists($function)) { $items = $function($entity_type, $entity, $field, $inst...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-10103df661
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_permission_get_modules/7.x
I need the code for `user_permission_get_modules()` in Drupal 7 (modules/user/user.module). It must do this: Determine the modules that permissions belong to.
Returns: An associative array in the format $permission => $module. File: modules/user/user.module
function user_permission_get_modules() { $permissions = array(); foreach (module_implements('permission') as $module) { $perms = module_invoke($module, 'permission'); foreach ($perms as $key => $value) { $permissions[$key] = $module; } } return $permissions; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-1022b39a8d
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21filter%21filter.api.php/function/callback_filter_tips/7.x
In Drupal 7, show an example implementation for `callback_filter_tips($filter, $format, $long)` (modules/filter/filter.api.php): Return help text for a filter.
Callback for hook_filter_info(). A filter's tips should be informative and to the point. Short tips are preferably one-liners. Parameters: - $filter: An object representing the filter. - $format: An object representing the text format the filter is contained in. - $long: Whether this callback should return a short ti...
function callback_filter_tips($filter, $format, $long) { if ($long) { return t('Lines and paragraphs are automatically recognized. The <br /> line break, <p> paragraph and </p> close paragraph tags are inserted automatically. If paragraphs are not recognized simply add a couple blank lines.'); ...
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-1052739fbd
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_image_style_save/7.x
In Drupal 7, write the function `user_image_style_save($style)` (file modules/user/user.module) so that it does the following: Implements hook_image_style_save().
File: modules/user/user.module
function user_image_style_save($style) { // If a style is renamed, update the variables that use it. if (isset($style['old_name']) && $style['old_name'] == variable_get('user_picture_style', '')) { variable_set('user_picture_style', $style['name']); } }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-1070f29cac
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21simpletest%21simpletest.pages.inc/function/simpletest_result_form/7.x
In Drupal 7, write the function `simpletest_result_form($form, &$form_state, $test_id)` (file modules/simpletest/simpletest.pages.inc) so that it does the following: Test results form for $test_id.
File: modules/simpletest/simpletest.pages.inc
function simpletest_result_form($form, &$form_state, $test_id) { // Make sure there are test results to display and a re-run is not being performed. $results = array(); if (is_numeric($test_id) && !$results = simpletest_result_get($test_id)) { drupal_set_message(t('No test results to display.'), 'error'); ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-10a002a840
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_field_display_node_alter/7.x
Implement `node_field_display_node_alter(&$display, $context)` in PHP for Drupal 7. Required behavior: Implements hook_field_display_ENTITY_TYPE_alter().
File: modules/node/node.module
function node_field_display_node_alter(&$display, $context) { // Hide field labels in search index. if ($context['view_mode'] == 'search_index') { $display['label'] = 'hidden'; } }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-10a83b7d12
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.admin.inc/function/field_ui_display_overview_form_submit/7.x
In Drupal 7, write the function `field_ui_display_overview_form_submit($form, &$form_state)` (file modules/field_ui/field_ui.admin.inc) so that it does the following: Form submission handler for field_ui_display_overview_form().
File: modules/field_ui/field_ui.admin.inc
function field_ui_display_overview_form_submit($form, &$form_state) { $form_values = $form_state['values']; $entity_type = $form['#entity_type']; $bundle = $form['#bundle']; $view_mode = $form['#view_mode']; // Save data for 'regular' fields. foreach ($form['#fields'] as $field_name) { // Retrieve the ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-10cbac5acc
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.attach.inc/function/field_attach_load/7.x
I need the code for `field_attach_load($entity_type, $entities, $age = FIELD_LOAD_CURRENT, $options = array())` in Drupal 7 (modules/field/field.attach.inc). It must do this: Loads fields for the current revisions of a group of entities.
Loads all fields for each entity object in a group of a single entity type. The loaded field values are added directly to the entity objects. field_attach_load() is automatically called by the default entity controller class, and thus, in most cases, doesn't need to be explicitly called by the entity type module. Par...
function field_attach_load($entity_type, $entities, $age = FIELD_LOAD_CURRENT, $options = array()) { $load_current = $age == FIELD_LOAD_CURRENT; // Merge default options. $default_options = array( 'deleted' => FALSE, ); $options += $default_options; $info = entity_get_info($entity_type); // Only the...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-10da9b175e
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21file.inc/function/file_validate_is_image/7.x
I need the code for `file_validate_is_image(stdClass $file)` in Drupal 7 (includes/file.inc). It must do this: Checks that the file is recognized by image_get_info() as an image.
Parameters: - $file: A Drupal file object. Returns: An array. If the file is not an image, it will contain an error message. File: includes/file.inc
function file_validate_is_image(stdClass $file) { $errors = array(); $info = image_get_info($file->uri); if (!$info || empty($info['extension'])) { $errors[] = t('The image file is invalid or the image type is not allowed. Allowed types: %allowed_types', array('%allowed_types' => t('Only JPEG, PNG and GIF im...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-10f1179b89
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21install.core.inc/function/_install_module_batch/7.x
I need the code for `_install_module_batch($module, $module_name, &$context)` in Drupal 7 (includes/install.core.inc). It must do this: Implements callback_batch_operation().
Performs batch installation of modules. File: includes/install.core.inc
function _install_module_batch($module, $module_name, &$context) { // Install and enable the module right away, so that the module will be // loaded by drupal_bootstrap in subsequent batch requests, and other // modules possibly depending on it can safely perform their installation // steps. module_enable(arr...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-10fd4c04ec
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_insert/7.x
In Drupal 7, show an example implementation for `hook_node_insert($node)` (modules/node/node.api.php): Respond to creation of a new node.
This hook is invoked from node_save() after the database query that will insert the node into the node table is scheduled for execution, after the type-specific hook_insert() is invoked, and after field_attach_insert() is called. Note that when this hook is invoked, the changes have not yet been written to the databas...
function hook_node_insert($node) { db_insert('mytable') ->fields(array( 'nid' => $node->nid, 'extra' => $node->extra, )) ->execute(); }
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-110d0618c7
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21trigger%21trigger.module/function/trigger_theme/7.x
In Drupal 7, write the function `trigger_theme()` (file modules/trigger/trigger.module) so that it does the following: Implements hook_theme().
File: modules/trigger/trigger.module
function trigger_theme() { return array( 'trigger_display' => array( 'render element' => 'element', 'file' => 'trigger.admin.inc', ), ); }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-111d0b6887
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.form.inc/function/field_default_form_errors/7.x
I need the code for `field_default_form_errors($entity_type, $entity, $field, $instance, $langcode, $items, $form, &$form_state)` in Drupal 7 (modules/field/field.form.inc). It must do this: Transfer field-level validation errors to widgets.
File: modules/field/field.form.inc
function field_default_form_errors($entity_type, $entity, $field, $instance, $langcode, $items, $form, &$form_state) { $field_state = field_form_get_state($form['#parents'], $field['field_name'], $langcode, $form_state); if (!empty($field_state['errors'])) { // Locate the correct element in the form. $elem...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-1122125179
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21filter%21filter.install/function/filter_update_7001/7.x
In Drupal 7, write the function `filter_update_7001()` (file modules/filter/filter.install) so that it does the following: Break out "escape HTML filter" option to its own filter.
File: modules/filter/filter.install
function filter_update_7001() { $result = db_query("SELECT format FROM {filter_format}")->fetchCol(); $insert = db_insert('filters')->fields(array('format', 'module', 'delta', 'weight')); foreach ($result as $format_id) { // Deprecated constants FILTER_HTML_STRIP = 1 and FILTER_HTML_ESCAPE = 2. if (varia...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-11386ab91a
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21poll%21poll.module/function/poll_theme/7.x
In Drupal 7, write the function `poll_theme()` (file modules/poll/poll.module) so that it does the following: Implements hook_theme().
File: modules/poll/poll.module
function poll_theme() { $theme_hooks = array( 'poll_vote' => array( 'template' => 'poll-vote', 'render element' => 'form', ), 'poll_choices' => array( 'render element' => 'form', ), 'poll_results' => array( 'template' => 'poll-results', 'variables' => array('raw_title...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-115c617cfc
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_admin_index/7.x
Implement `system_admin_index()` in PHP for Drupal 7. Required behavior: Menu callback; prints a listing of admin tasks, organized by module.
File: modules/system/system.admin.inc
function system_admin_index() { $module_info = system_get_info('module'); foreach ($module_info as $module => $info) { $module_info[$module] = new stdClass(); $module_info[$module]->info = $info; } uasort($module_info, 'system_sort_modules_by_info_name'); $menu_items = array(); foreach ($module_inf...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-1171dde0e9
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21poll%21poll.module/function/poll_permission/7.x
Implement `poll_permission()` in PHP for Drupal 7. Required behavior: Implements hook_permission().
File: modules/poll/poll.module
function poll_permission() { $perms = array( 'vote on polls' => array( 'title' => t('Vote on polls'), ), 'cancel own vote' => array( 'title' => t('Cancel and change own votes'), ), 'inspect all votes' => array( 'title' => t('View details for all votes'), ), ); return $pe...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-117541de64
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.module/function/shortcut_set_save/7.x
In Drupal 7, write the function `shortcut_set_save(&$shortcut_set)` (file modules/shortcut/shortcut.module) so that it does the following: Saves a shortcut set.
Parameters: - $shortcut_set: An object containing the following properties: - 'title': The title of the shortcut set. - 'set_name': (optional) The internal name of the shortcut set. If omitted, a new shortcut set will be created, and the 'set_name' property will be added to the passed-in object. - 'links': (optional) A...
function shortcut_set_save(&$shortcut_set) { // First save the shortcut set itself. if (isset($shortcut_set->set_name)) { $return = drupal_write_record('shortcut_set', $shortcut_set, 'set_name'); } else { $shortcut_set->set_name = shortcut_set_get_unique_name(); $return = drupal_write_record('shortc...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-11844c1239
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_load/7.x
In Drupal 7, show an example implementation for `hook_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age)` (modules/field/field.api.php): Define custom load behavior for this module's field types.
Unlike most other field hooks, this hook operates on multiple entities. The $entities, $instances and $items parameters are arrays keyed by entity ID. For performance reasons, information for all available entity should be loaded in a single query where possible. Note that the changes made to the field values get cach...
function hook_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) { // Sample code from text.module: precompute sanitized strings so they are // stored in the field cache. foreach ($entities as $id => $entity) { foreach ($items[$id] as $delta => $item) { // Only process ite...
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-11949cf866
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21menu%21menu.module/function/menu_node_save/7.x
I need the code for `menu_node_save($node)` in Drupal 7 (modules/menu/menu.module). It must do this: Helper for hook_node_insert() and hook_node_update().
File: modules/menu/menu.module
function menu_node_save($node) { if (isset($node->menu)) { $link = &$node->menu; if (empty($link['enabled'])) { if (!empty($link['mlid'])) { menu_link_delete($link['mlid']); } } elseif (trim($link['link_title'])) { $link['link_title'] = trim($link['link_title']); $link[...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-11a02c1583
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.tokens.inc/function/taxonomy_token_info/7.x
In Drupal 7, write the function `taxonomy_token_info()` (file modules/taxonomy/taxonomy.tokens.inc) so that it does the following: Implements hook_token_info().
File: modules/taxonomy/taxonomy.tokens.inc
function taxonomy_token_info() { $types['term'] = array( 'name' => t("Taxonomy terms"), 'description' => t("Tokens related to taxonomy terms."), 'needs-data' => 'term', ); $types['vocabulary'] = array( 'name' => t("Vocabularies"), 'description' => t("Tokens related to taxonomy vocabularies."),...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-11b71fb675
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21toolbar%21toolbar.module/function/toolbar_get_menu_tree/7.x
Implement `toolbar_get_menu_tree()` in PHP for Drupal 7. Required behavior: Gets only the top level items below the 'admin' path.
Returns: An array containing a menu tree of top level items below the 'admin' path. File: modules/toolbar/toolbar.module
function toolbar_get_menu_tree() { $tree = array(); $admin_link = db_query('SELECT * FROM {menu_links} WHERE menu_name = :menu_name AND module = :module AND link_path = :path', array(':menu_name' => 'management', ':module' => 'system', ':path' => 'admin'))->fetchAssoc(); if ($admin_link) { $tree = menu_build_...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-11c81a3d41
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_cookie_save/7.x
In Drupal 7, write the function `user_cookie_save(array $values)` (file modules/user/user.module) so that it does the following: Saves visitor information as a cookie so it can be reused.
Parameters: - $values: An array of key/value pairs to be saved into a cookie. File: modules/user/user.module
function user_cookie_save(array $values) { foreach ($values as $field => $value) { // Set cookie for 365 days. setrawcookie('Drupal.visitor.' . $field, rawurlencode($value), REQUEST_TIME + 31536000, '/'); } }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-11d4621dea
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21user%21user.pages.inc/function/user_cancel_confirm_form_submit/7.x
In Drupal 7, write the function `user_cancel_confirm_form_submit($form, &$form_state)` (file modules/user/user.pages.inc) so that it does the following: Submit handler for the account cancellation confirm form.
File: modules/user/user.pages.inc
function user_cancel_confirm_form_submit($form, &$form_state) { global $user; $account = $form_state['values']['_account']; // Cancel account immediately, if the current user has administrative // privileges, no confirmation mail shall be sent, and the user does not // attempt to cancel the own account. if...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-12043cc227
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_file_move/7.x
I need the code for `image_file_move($file, $source)` in Drupal 7 (modules/image/image.module). It must do this: Implements hook_file_move().
File: modules/image/image.module
function image_file_move($file, $source) { // Delete any image derivatives at the original image path. image_path_flush($source->uri); }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-1205e12899
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_unpromote_action/7.x
I need the code for `node_unpromote_action($node, $context = array())` in Drupal 7 (modules/node/node.module). It must do this: Sets the promote property of a node to 0.
Parameters: - $node: A node object. - $context: (optional) Array of additional information about what triggered the action. Not used for this action. File: modules/node/node.module
function node_unpromote_action($node, $context = array()) { $node->promote = NODE_NOT_PROMOTED; watchdog('action', 'Removed @type %title from front page.', array('@type' => node_type_get_name($node), '%title' => $node->title)); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-12285a478d
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21file.inc/function/file_validate/7.x
Implement `file_validate(stdClass &$file, $validators = array())` in PHP for Drupal 7. Required behavior: Checks that a file meets the criteria specified by the validators.
After executing the validator callbacks specified hook_file_validate() will also be called to allow other modules to report errors about the file. Parameters: - $file: A Drupal file object. - $validators: An optional, associative array of callback functions used to validate the file. The keys are function names and th...
function file_validate(stdClass &$file, $validators = array()) { // Call the validation functions specified by this function's caller. $errors = array(); foreach ($validators as $function => $args) { if (function_exists($function)) { array_unshift($args, $file); $errors = array_merge($errors, call...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-122b6394de
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21color%21color.module/function/_color_hue2rgb/7.x
I need the code for `_color_hue2rgb($m1, $m2, $h)` in Drupal 7 (modules/color/color.module). It must do this: Helper function for _color_hsl2rgb().
File: modules/color/color.module
function _color_hue2rgb($m1, $m2, $h) { $h = ($h < 0) ? $h + 1 : (($h > 1) ? $h - 1 : $h); if ($h * 6 < 1) return $m1 + ($m2 - $m1) * $h * 6; if ($h * 2 < 1) return $m2; if ($h * 3 < 2) return $m1 + ($m2 - $m1) * (0.66666 - $h) * 6; return $m1; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-1239d3b7ba
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21openid%21openid.inc/function/_openid_signature/7.x
I need the code for `_openid_signature($association, $message_array, $keys_to_sign)` in Drupal 7 (modules/openid/openid.inc). It must do this: Sign certain keys in a message
Parameters: - $association: - object loaded from openid_association or openid_server_association table - important fields are ->assoc_type and ->mac_key - $message_array: - array of entire message about to be sent - $keys_to_sign: - keys in the message to include in signature (without 'openid.' appended) File: modules...
function _openid_signature($association, $message_array, $keys_to_sign) { $signature = ''; $sign_data = array(); foreach ($keys_to_sign as $key) { if (isset($message_array['openid.' . $key])) { $sign_data[$key] = $message_array['openid.' . $key]; } } $message = _openid_create_message($sign_dat...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-123b976c20
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21book%21book.module/function/book_form_node_delete_confirm_alter/7.x
I need the code for `book_form_node_delete_confirm_alter(&$form, $form_state)` in Drupal 7 (modules/book/book.module). It must do this: Implements hook_form_FORM_ID_alter() for node_delete_confirm().
Alters the confirm form for a single node deletion. File: modules/book/book.module
function book_form_node_delete_confirm_alter(&$form, $form_state) { $node = node_load($form['nid']['#value']); if (isset($node->book) && $node->book['has_children']) { $form['book_warning'] = array( '#markup' => '<p>' . t('%title is part of a book outline, and has associated child pages. If you proceed w...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-1247a00f89
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21comment%21comment.install/function/comment_update_7005/7.x
I need the code for `comment_update_7005()` in Drupal 7 (modules/comment/comment.install). It must do this: Create the comment_body field.
File: modules/comment/comment.install
function comment_update_7005() { // Create comment body field. $field = array( 'field_name' => 'comment_body', 'type' => 'text_long', 'module' => 'text', 'entity_types' => array( 'comment', ), 'settings' => array(), 'cardinality' => 1, ); _update_7000_field_create_field($field)...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-1284174995
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.admin.inc/function/shortcut_set_add_form/7.x
Implement `shortcut_set_add_form($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form callback: builds the form for adding a shortcut set.
Parameters: - $form: An associative array containing the structure of the form. - $form_state: An associative array containing the current state of the form. Returns: An array representing the form definition. File: modules/shortcut/shortcut.admin.inc
function shortcut_set_add_form($form, &$form_state) { $form['new'] = array( '#type' => 'textfield', '#title' => t('Set name'), '#description' => t('The new set is created by copying items from your default shortcut set.'), '#required' => TRUE, ); $form['actions'] = array('#type' => 'actions'); ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-12aca333a5
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21forum%21forum.module/function/forum_permission/7.x
Implement `forum_permission()` in PHP for Drupal 7. Required behavior: Implements hook_permission().
File: modules/forum/forum.module
function forum_permission() { $perms = array( 'administer forums' => array( 'title' => t('Administer forums'), ), ); return $perms; }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-12b375dae3
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21update%21update.module/function/_update_manager_extract_directory/7.x
I need the code for `_update_manager_extract_directory($create = TRUE)` in Drupal 7 (modules/update/update.module). It must do this: Returns the directory where update archive files should be extracted.
Parameters: - $create: (optional) Whether to attempt to create the directory if it does not already exist. Defaults to TRUE. Returns: The full path to the temporary directory where update file archives should be extracted. File: modules/update/update.module
function _update_manager_extract_directory($create = TRUE) { $directory = &drupal_static(__FUNCTION__, ''); if (empty($directory)) { $directory = 'temporary://update-extraction-' . _update_manager_unique_identifier(); if ($create && !file_exists($directory)) { mkdir($directory); } } return $di...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-12c1eebb08
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_block_save/7.x
Implement `node_block_save($delta = '', $edit = array())` in PHP for Drupal 7. Required behavior: Implements hook_block_save().
File: modules/node/node.module
function node_block_save($delta = '', $edit = array()) { if ($delta == 'recent') { variable_set('node_recent_block_count', $edit['node_recent_block_count']); } }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-12caa3dd5f
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_block_save/7.x
In Drupal 7, write the function `user_block_save($delta = '', $edit = array())` (file modules/user/user.module) so that it does the following: Implements hook_block_save().
File: modules/user/user.module
function user_block_save($delta = '', $edit = array()) { global $user; switch ($delta) { case 'new': variable_set('user_block_whois_new_count', $edit['user_block_whois_new_count']); break; case 'online': variable_set('user_block_seconds_online', $edit['user_block_seconds_online']); ...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-12cd1c618b
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/locale_translation_filter_form_submit/7.x
In Drupal 7, write the function `locale_translation_filter_form_submit($form, &$form_state)` (file modules/locale/locale.admin.inc) so that it does the following: Process result from locale translation filter form.
File: modules/locale/locale.admin.inc
function locale_translation_filter_form_submit($form, &$form_state) { $op = $form_state['values']['op']; $filters = locale_translation_filters(); switch ($op) { case t('Filter'): foreach ($filters as $name => $filter) { if (isset($form_state['values'][$name])) { $_SESSION['locale_trans...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-12dea37f2c
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21form.inc/function/_form_set_class/7.x
Implement `_form_set_class(&$element, $class = array())` in PHP for Drupal 7. Required behavior: Sets a form element's class attribute.
Adds 'required' and 'error' classes as needed. Parameters: - $element: The form element. - $name: Array of new class names to be added. File: includes/form.inc
function _form_set_class(&$element, $class = array()) { if (!empty($class)) { if (!isset($element['#attributes']['class'])) { $element['#attributes']['class'] = array(); } $element['#attributes']['class'] = array_merge($element['#attributes']['class'], $class); } // This function is invoked from...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-12f91297a5
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.info.inc/function/field_info_instance_settings/7.x
I need the code for `field_info_instance_settings($type)` in Drupal 7 (modules/field/field.info.inc). It must do this: Returns a field type's default instance settings.
Parameters: - $type: A field type name. Returns: The field type's default instance settings, as provided by hook_field_info(), or an empty array if type or settings are not defined. File: modules/field/field.info.inc
function field_info_instance_settings($type) { $info = field_info_field_types($type); return isset($info['instance_settings']) ? $info['instance_settings'] : array(); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-13084f1e4b
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/theme_locale_languages_overview_form/7.x
Implement `theme_locale_languages_overview_form($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for the language overview form.
Parameters: - $variables: An associative array containing: - form: A render element representing the form. File: modules/locale/locale.admin.inc
function theme_locale_languages_overview_form($variables) { $form = $variables['form']; $default = language_default(); foreach ($form['name'] as $key => $element) { // Do not take form control structures. if (is_array($element) && element_child($key)) { // Disable checkbox for the default language, ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-130bec09bd
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.module/function/theme_node_search_admin/7.x
Implement `theme_node_search_admin($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for the content ranking part of the search settings admin page.
Parameters: - $variables: An associative array containing: - form: A render element representing the form. File: modules/node/node.module
function theme_node_search_admin($variables) { $form = $variables['form']; $output = drupal_render($form['info']); $header = array(t('Factor'), t('Influence')); foreach (element_children($form['factors']) as $key) { $row = array(); $row[] = $form['factors'][$key]['#title']; $form['factors'][$key][...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-130e69584b
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_permissions_get_configured_types/7.x
In Drupal 7, write the function `node_permissions_get_configured_types()` (file modules/node/node.module) so that it does the following: Returns an array of node types that should be managed by permissions.
By default, this will include all node types in the system. To exclude a specific node from getting permissions defined for it, set the node_permissions_$type variable to 0. Core does not provide an interface for doing so. However, contrib modules may exclude their own nodes in hook_install(). Alternatively, contrib mo...
function node_permissions_get_configured_types() { $configured_types = array(); foreach (node_type_get_types() as $type => $info) { if (variable_get('node_permissions_' . $type, 1)) { $configured_types[] = $type; } } return $configured_types; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-130f7f31a4
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.install/function/aggregator_update_7003/7.x
Implement `aggregator_update_7003()` in PHP for Drupal 7. Required behavior: Increase the length of {aggregator_feed}.url.
File: modules/aggregator/aggregator.install
function aggregator_update_7003() { db_drop_unique_key('aggregator_feed', 'url'); db_change_field('aggregator_feed', 'url', 'url', array('type' => 'text', 'not null' => TRUE, 'description' => 'URL to the feed.')); db_change_field('aggregator_feed', 'link', 'link', array('type' => 'text', 'not null' => TRUE, 'desc...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-1322e008c7
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21file.inc/function/file_transfer/7.x
In Drupal 7, write the function `file_transfer($uri, $headers)` (file includes/file.inc) so that it does the following: Transfers a file to the client using HTTP.
Pipes a file through Drupal to the client. Parameters: - $uri: String specifying the file URI to transfer. - $headers: An array of HTTP headers to send along with file. File: includes/file.inc
function file_transfer($uri, $headers) { if (ob_get_level()) { ob_end_clean(); } foreach ($headers as $name => $value) { drupal_add_http_header($name, $value); } drupal_send_headers(); $scheme = file_uri_scheme($uri); // Transfer file in 1024 byte chunks to save memory usage. if ($scheme && fil...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-13454f02fa
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_configure_date_formats_form/7.x
In Drupal 7, write the function `system_configure_date_formats_form($form, &$form_state, $dfid = 0)` (file modules/system/system.admin.inc) so that it does the following: Allow users to add additional date formats.
File: modules/system/system.admin.inc
function system_configure_date_formats_form($form, &$form_state, $dfid = 0) { $ajax_path = 'admin/config/regional/date-time/formats/lookup'; $js_settings = array( 'type' => 'setting', 'data' => array( 'dateTime' => array( 'date-format' => array( 'text' => t('Displayed as'), ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-134a2eeeb2
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21toolbar%21toolbar.module/function/_toolbar_is_collapsed/7.x
In Drupal 7, write the function `_toolbar_is_collapsed()` (file modules/toolbar/toolbar.module) so that it does the following: Determines the current state of the toolbar drawer's visibility.
Returns: TRUE when drawer is collapsed, FALSE when it is expanded. File: modules/toolbar/toolbar.module
function _toolbar_is_collapsed() { // PHP converts dots into underscores in cookie names to avoid problems with // its parser, so we use a converted cookie name. return isset($_COOKIE['Drupal_toolbar_collapsed']) ? $_COOKIE['Drupal_toolbar_collapsed'] : 0; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-134f7b885c
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21update%21update.manager.inc/function/_update_manager_check_backends/7.x
In Drupal 7, write the function `_update_manager_check_backends(&$form, $operation)` (file modules/update/update.manager.inc) so that it does the following: Checks for file transfer backends and prepares a form fragment about them.
Parameters: - $form (array): Reference to the form array we're building. - $operation (string): The update manager operation we're in the middle of. Can be either 'update' or 'install'. Use to provide operation-specific interface text. Returns: TRUE if the update manager should continue to the next step in the workflo...
function _update_manager_check_backends(&$form, $operation) { // If file transfers will be performed locally, we do not need to display any // warnings or notices to the user and should automatically continue the // workflow, since we won't be using a FileTransfer backend that requires // user input or a specif...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-1395db8baa
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21menu%21menu.admin.inc/function/menu_reset_item_confirm_submit/7.x
Implement `menu_reset_item_confirm_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Process menu reset item form submissions.
File: modules/menu/menu.admin.inc
function menu_reset_item_confirm_submit($form, &$form_state) { $item = $form_state['values']['item']; $new_item = menu_reset_item($item); drupal_set_message(t('The menu link was reset to its default settings.')); $form_state['redirect'] = 'admin/structure/menu/manage/' . $new_item['menu_name']; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-13a5b838cd
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_preview/7.x
In Drupal 7, write the function `comment_preview($comment)` (file modules/comment/comment.module) so that it does the following: Generate a comment preview.
File: modules/comment/comment.module
function comment_preview($comment) { global $user; drupal_set_title(t('Preview comment'), PASS_THROUGH); $node = node_load($comment->nid); if (!form_get_errors()) { $comment_body = field_get_items('comment', $comment, 'comment_body'); $comment->format = $comment_body[0]['format']; // Attach the u...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-13d3c31d08
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_field_formatter_info/7.x
I need the code for `taxonomy_field_formatter_info()` in Drupal 7 (modules/taxonomy/taxonomy.module). It must do this: Implements hook_field_formatter_info().
File: modules/taxonomy/taxonomy.module
function taxonomy_field_formatter_info() { return array( 'taxonomy_term_reference_link' => array( 'label' => t('Link'), 'field types' => array('taxonomy_term_reference'), ), 'taxonomy_term_reference_plain' => array( 'label' => t('Plain text'), 'field types' => array('taxonomy_term_...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-1401b80cf9
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21book%21book.module/function/book_update_bid/7.x
Implement `book_update_bid($book_link)` in PHP for Drupal 7. Required behavior: Updates the book ID of a page and its children when it moves to a new book.
Parameters: - $book_link: A fully loaded menu link that is part of the book hierarchy. File: modules/book/book.module
function book_update_bid($book_link) { $query = db_select('menu_links'); $query->addField('menu_links', 'mlid'); for ($i = 1; $i <= MENU_MAX_DEPTH && $book_link["p$i"]; $i++) { $query->condition("p$i", $book_link["p$i"]); } $mlids = $query->execute()->fetchCol(); if ($mlids) { db_update('book') ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-141bab8b69
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21book%21book.module/function/book_link_load/7.x
Implement `book_link_load($mlid)` in PHP for Drupal 7. Required behavior: Gets a book menu link by its menu link ID.
Like menu_link_load(), but adds additional data from the {book} table. Do not call when loading a node, since this function may call node_load(). Parameters: - $mlid: The menu link ID of the menu item. Returns: A menu link, with the link translated for rendering and data added from the {book} table. FALSE if there i...
function book_link_load($mlid) { if ($item = db_query("SELECT * FROM {menu_links} ml INNER JOIN {book} b ON b.mlid = ml.mlid LEFT JOIN {menu_router} m ON m.path = ml.router_path WHERE ml.mlid = :mlid", array( ':mlid' => $mlid, ))->fetchAssoc()) { _menu_link_translate($item); return $item; } ret...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-142430f006
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21blog%21blog.module/function/blog_page_user_access/7.x
I need the code for `blog_page_user_access($account)` in Drupal 7 (modules/blog/blog.module). It must do this: Access callback for user blog pages.
File: modules/blog/blog.module
function blog_page_user_access($account) { // The visitor must be able to access the site's content. // For a blog to 'exist' the user must either be able to // create new blog entries, or it must have existing posts. return $account->uid && user_access('access content') && (user_access('create blog content', $...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-142d653364
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21color%21color.module/function/_color_shift/7.x
Implement `_color_shift($given, $ref1, $ref2, $target)` in PHP for Drupal 7. Required behavior: Shifts a given color, using a reference pair and a target blend color.
Note: this function is significantly different from the JS version, as it is written to match the blended images perfectly. Constraint: if (ref2 == target + (ref1 - target) * delta) for some fraction delta then (return == target + (given - target) * delta). Loose constraint: Preserve relative positions in saturation ...
function _color_shift($given, $ref1, $ref2, $target) { // We assume that ref2 is a blend of ref1 and target and find // delta based on the length of the difference vectors. // delta = 1 - |ref2 - ref1| / |white - ref1| $target = _color_unpack($target, TRUE); $ref1 = _color_unpack($ref1, TRUE); $ref2 = _col...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-142fb8a55c
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.pages.inc/function/aggregator_page_opml/7.x
Implement `aggregator_page_opml($cid = NULL)` in PHP for Drupal 7. Required behavior: Page callback: Generates an OPML representation of all feeds.
Parameters: - $cid: (optional) If set, feeds are exported only from a category with this ID. Otherwise, all feeds are exported. Defaults to NULL. Returns: An OPML formatted string. File: modules/aggregator/aggregator.pages.inc
function aggregator_page_opml($cid = NULL) { if ($cid) { $result = db_query('SELECT f.title, f.url FROM {aggregator_feed} f LEFT JOIN {aggregator_category_feed} c on f.fid = c.fid WHERE c.cid = :cid ORDER BY title', array(':cid' => $cid)); } else { $result = db_query('SELECT * FROM {aggregator_feed} ORDER...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-143622373a
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.admin.inc/function/taxonomy_overview_terms_submit/7.x
I need the code for `taxonomy_overview_terms_submit($form, &$form_state)` in Drupal 7 (modules/taxonomy/taxonomy.admin.inc). It must do this: Submit handler for terms overview form.
Rather than using a textfield or weight field, this form depends entirely upon the order of form elements on the page to determine new weights. Because there might be hundreds or thousands of taxonomy terms that need to be ordered, terms are weighted from 0 to the number of terms in the vocabulary, rather than the sta...
function taxonomy_overview_terms_submit($form, &$form_state) { if ($form_state['triggering_element']['#value'] == t('Reset to alphabetical')) { // Execute the reset action. if ($form_state['values']['reset_alphabetical'] === TRUE) { return taxonomy_vocabulary_confirm_reset_alphabetical_submit($form, $fo...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-143d741c1e
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_update_7011/7.x
I need the code for `system_update_7011()` in Drupal 7 (modules/system/system.install). It must do this: Split the 'bypass node access' permission from 'administer nodes'.
File: modules/system/system.install
function system_update_7011() { // Get existing roles that can 'administer nodes'. $rids = array(); $rids = db_query("SELECT rid FROM {role_permission} WHERE permission = :perm", array(':perm' => 'administer nodes'))->fetchCol(); // None found. if (empty($rids)) { return; } $insert = db_insert('role_p...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-145c74a706
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21overlay%21overlay.module/function/overlay_system_info_alter/7.x
In Drupal 7, write the function `overlay_system_info_alter(&$info, $file, $type)` (file modules/overlay/overlay.module) so that it does the following: Implements hook_system_info_alter().
Add default regions for the overlay. File: modules/overlay/overlay.module
function overlay_system_info_alter(&$info, $file, $type) { if ($type == 'theme') { $info['overlay_regions'][] = 'content'; $info['overlay_regions'][] = 'help'; } }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-147ab3383c
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_widget_properties_ENTITY_TYPE_alter/7.x
In Drupal 7, show an example implementation for `hook_field_widget_properties_ENTITY_TYPE_alter(&$widget, $context)` (modules/field/field.api.php): Alters the widget properties of a field instance on a given entity type before it gets displayed.
Modules can implement hook_field_widget_properties_ENTITY_TYPE_alter() to alter the widget properties for fields on a specific entity type, rather than implementing hook_field_widget_properties_alter(). This hook is called once per field per displayed widget entity. If the result of the hook involves reading from the ...
function hook_field_widget_properties_ENTITY_TYPE_alter(&$widget, $context) { // Change a widget's type according to the time of day. $field = $context['field']; if ($field['field_name'] == 'field_foo') { $time = date('H'); $widget['type'] = $time < 12 ? 'widget_am' : 'widget_pm'; } }
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-14a02c5008
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.admin.inc/function/taxonomy_form_term_submit/7.x
In Drupal 7, write the function `taxonomy_form_term_submit($form, &$form_state)` (file modules/taxonomy/taxonomy.admin.inc) so that it does the following: Submit handler to insert or update a term.
File: modules/taxonomy/taxonomy.admin.inc
function taxonomy_form_term_submit($form, &$form_state) { if ($form_state['triggering_element']['#value'] == t('Delete')) { // Execute the term deletion. if ($form_state['values']['delete'] === TRUE) { return taxonomy_term_confirm_delete_submit($form, $form_state); } // Rebuild the form to confi...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-14a3f128d6
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.module/function/dashboard_show_block_content/7.x
In Drupal 7, write the function `dashboard_show_block_content($module, $delta)` (file modules/dashboard/dashboard.module) so that it does the following: Ajax callback: Displays the rendered contents of a specific block.
Parameters: - $module: The block's module name. - $delta: The block's delta. File: modules/dashboard/dashboard.module
function dashboard_show_block_content($module, $delta) { drupal_theme_initialize(); global $theme_key; $blocks = array(); $block_object = db_query("SELECT * FROM {block} WHERE theme = :theme AND module = :module AND delta = :delta", array( ":theme" => $theme_key, ":module" => $module, ":delta" => $...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-14a7608afd
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21openid%21openid.pages.inc/function/openid_user_identities/7.x
I need the code for `openid_user_identities($account)` in Drupal 7 (modules/openid/openid.pages.inc). It must do this: Menu callback; Manage OpenID identities for the specified user.
File: modules/openid/openid.pages.inc
function openid_user_identities($account) { drupal_set_title(format_username($account)); drupal_add_css(drupal_get_path('module', 'openid') . '/openid.css'); // Check to see if we got a response $result = openid_complete(); if ($result['status'] == 'success') { $identity = $result['openid.claimed_id']; ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-14c13cd102
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21batch.inc/function/_batch_do/7.x
I need the code for `_batch_do()` in Drupal 7 (includes/batch.inc). It must do this: Does one execution pass with JavaScript and returns progress to the browser.
File: includes/batch.inc
function _batch_do() { // Perform actual processing. list($percentage, $message) = _batch_process(); drupal_json_output(array('status' => TRUE, 'percentage' => $percentage, 'message' => $message)); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-14c9103bbc
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21overlay%21overlay.module/function/overlay_admin_paths/7.x
I need the code for `overlay_admin_paths()` in Drupal 7 (modules/overlay/overlay.module). It must do this: Implements hook_admin_paths().
File: modules/overlay/overlay.module
function overlay_admin_paths() { $paths = array( // This is marked as an administrative path so that if it is visited from // within the overlay, the user will stay within the overlay while the // callback is being processed. 'overlay/dismiss-message' => TRUE, ); return $paths; }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-14d92fb8bc
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21modules%21field_sql_storage%21field_sql_storage.module/function/_field_sql_storage_write_compare_filter/7.x
I need the code for `_field_sql_storage_write_compare_filter($field, $array)` in Drupal 7 (modules/field/modules/field_sql_storage/field_sql_storage.module). It must do this: Cleanup field values for later values comparison.
Parameters: - $field (array): Field info as returned by field_info_field_by_id(). - $array (array): Field values to cleanup. Returns (array): Filtered values. File: modules/field/modules/field_sql_storage/field_sql_storage.module
function _field_sql_storage_write_compare_filter($field, $array) { foreach ($array as $language => $items) { if (empty($items)) { unset($array[$language]); } else { foreach ($items as $delta => $item) { // This should not happen but some modules provide invalid data to the // f...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-1539b58479
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_revision_delete/7.x
In Drupal 7, show an example implementation for `hook_node_revision_delete($node)` (modules/node/node.api.php): Respond to deletion of a node revision.
This hook is invoked from node_revision_delete() after the revision has been removed from the node_revision table, and before field_attach_delete_revision() is called. Parameters: - $node: The node revision (node object) that is being deleted. File: modules/node/node.api.php
function hook_node_revision_delete($node) { db_delete('mytable') ->condition('vid', $node->vid) ->execute(); }
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-153abb3694
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21forum%21forum.module/function/template_preprocess_forum_icon/7.x
In Drupal 7, write the function `template_preprocess_forum_icon(&$variables)` (file modules/forum/forum.module) so that it does the following: Preprocesses variables for forum-icon.tpl.php.
Parameters: - $variables: An array containing the following elements: - new_posts: Indicates whether or not the topic contains new posts. - num_posts: The total number of posts in all topics. - comment_mode: An integer indicating whether comments are open, closed, or hidden. - sticky: Indicates whether the topic is sti...
function template_preprocess_forum_icon(&$variables) { $variables['hot_threshold'] = variable_get('forum_hot_topic', 15); if ($variables['num_posts'] > $variables['hot_threshold']) { $variables['icon_class'] = $variables['new_posts'] ? 'hot-new' : 'hot'; $variables['icon_title'] = $variables['new_posts'] ? ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-153ac71423
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_file_mimetype_mapping_alter/7.x
In Drupal 7, show an example implementation for `hook_file_mimetype_mapping_alter(&$mapping)` (modules/system/system.api.php): Alter MIME type mappings used to determine MIME type from a file extension.
This hook is run when file_mimetype_mapping() is called. It is used to allow modules to add to or modify the default mapping from file_default_mimetype_mapping(). Parameters: - $mapping: An array of mimetypes correlated to the extensions that relate to them. The array has 'mimetypes' and 'extensions' elements, each of...
function hook_file_mimetype_mapping_alter(&$mapping) { // Add new MIME type 'drupal/info'. $mapping['mimetypes']['example_info'] = 'drupal/info'; // Add new extension '.info' and map it to the 'drupal/info' MIME type. $mapping['extensions']['info'] = 'example_info'; // Override existing extension mapping for ...
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-155aeb674b
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.form.inc/function/field_form_element_after_build/7.x
I need the code for `field_form_element_after_build($element, &$form_state)` in Drupal 7 (modules/field/field.form.inc). It must do this: #after_build callback for field elements in a form.
This stores the final location of the field within the form structure so that field_default_form_errors() can assign validation errors to the right form element. File: modules/field/field.form.inc
function field_form_element_after_build($element, &$form_state) { $parents = $element['#field_parents']; $field_name = $element['#field_name']; $langcode = $element['#language']; $field_state = field_form_get_state($parents, $field_name, $langcode, $form_state); $field_state['array_parents'] = $element['#arr...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-1568c1037e
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_access_records_alter/7.x
In Drupal 7, show an example implementation for `hook_node_access_records_alter(&$grants, $node)` (modules/node/node.api.php): Alter permissions for a node before it is written to the database.
Node access modules establish rules for user access to content. Node access records are stored in the {node_access} table and define which permissions are required to access a node. This hook is invoked after node access modules returned their requirements via hook_node_access_records(); doing so allows modules to modi...
function hook_node_access_records_alter(&$grants, $node) { // Our module allows editors to mark specific articles with the 'is_preview' // field. If the node being saved has a TRUE value for that field, then only // our grants are retained, and other grants are removed. Doing so ensures // that our rules are en...
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-157166beac
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21blog%21blog.pages.inc/function/blog_feed_user/7.x
In Drupal 7, write the function `blog_feed_user($account)` (file modules/blog/blog.pages.inc) so that it does the following: Menu callback; displays an RSS feed containing recent blog entries of a given user.
File: modules/blog/blog.pages.inc
function blog_feed_user($account) { $nids = db_select('node', 'n') ->fields('n', array('nid', 'created')) ->condition('type', 'blog') ->condition('uid', $account->uid) ->condition('status', 1) ->orderBy('created', 'DESC') ->range(0, variable_get('feed_default_items', 10)) ->addTag('node_a...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-158d0ab056
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21image%21image.field.inc/function/image_field_settings_form/7.x
In Drupal 7, write the function `image_field_settings_form($field, $instance)` (file modules/image/image.field.inc) so that it does the following: Implements hook_field_settings_form().
File: modules/image/image.field.inc
function image_field_settings_form($field, $instance) { $defaults = field_info_field_settings($field['type']); $settings = array_merge($defaults, $field['settings']); $scheme_options = array(); foreach (file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE) as $scheme => $stream_wrapper) { $scheme_options...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-15b66b6333
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21image%21image.field.inc/function/image_field_formatter_view/7.x
Implement `image_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)` in PHP for Drupal 7. Required behavior: Implements hook_field_formatter_view().
File: modules/image/image.field.inc
function image_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { $element = array(); // Check if the formatter involves a link. if ($display['settings']['image_link'] == 'content') { $uri = entity_uri($entity_type, $entity); } elseif ($display['settings']['imag...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-15df82f9a7
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_form_search_form_alter/7.x
I need the code for `node_form_search_form_alter(&$form, $form_state)` in Drupal 7 (modules/node/node.module). It must do this: Implements hook_form_FORM_ID_alter().
File: modules/node/node.module
function node_form_search_form_alter(&$form, $form_state) { if (isset($form['module']) && $form['module']['#value'] == 'node' && user_access('use advanced search')) { // Keyword boxes: $form['advanced'] = array( '#type' => 'fieldset', '#title' => t('Advanced search'), '#collapsible' => TRUE,...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-15f4912a5d
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21modules%21number%21number.module/function/number_field_validate/7.x
I need the code for `number_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors)` in Drupal 7 (modules/field/modules/number/number.module). It must do this: Implements hook_field_validate().
Possible error codes: - 'number_min': The value is less than the allowed minimum value. - 'number_max': The value is greater than the allowed maximum value. File: modules/field/modules/number/number.module
function number_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) { foreach ($items as $delta => $item) { if ($item['value'] != '') { if (is_numeric($instance['settings']['min']) && $item['value'] < $instance['settings']['min']) { $errors[$field['field_name']][$la...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-16140fa440
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_get_default_module_info/7.x
Implement `search_get_default_module_info()` in PHP for Drupal 7. Required behavior: Returns information about the default search module.
Returns: The search_get_info() array element for the default search module, if any. File: modules/search/search.module
function search_get_default_module_info() { $info = search_get_info(); $default = variable_get('search_default_module', 'node'); if (isset($info[$default])) { return $info[$default]; } // The variable setting does not match any active module, so just return // the info for the first active module (if an...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-1626708163
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21rdf%21rdf.module/function/_rdf_get_default_mapping/7.x
Implement `_rdf_get_default_mapping($type)` in PHP for Drupal 7. Required behavior: Helper function to get the default RDF mapping for a given entity type.
Parameters: - $type: An entity type, e.g. 'node' or 'comment'. Returns: The RDF mapping or an empty array if no mapping is defined for this entity type. File: modules/rdf/rdf.module
function _rdf_get_default_mapping($type) { $default_mappings = &drupal_static(__FUNCTION__); if (!isset($default_mappings)) { // Get all of the modules that implement hook_rdf_mapping(). $modules = module_implements('rdf_mapping'); // Only consider the default entity mapping definitions. foreach (...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-162b03b993
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21update%21update.report.inc/function/update_status/7.x
I need the code for `update_status()` in Drupal 7 (modules/update/update.report.inc). It must do this: Page callback: Generates a page about the update status of projects.
File: modules/update/update.report.inc
function update_status() { if ($available = update_get_available(TRUE)) { module_load_include('inc', 'update', 'update.compare'); $data = update_calculate_project_data($available); return theme('update_report', array('data' => $data)); } else { return theme('update_report', array('data' => _update...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-16426cc551
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_parse_info_format/7.x
In Drupal 7, write the function `drupal_parse_info_format($data)` (file includes/common.inc) so that it does the following: Parses data in Drupal's .info format.
Data should be in an .ini-like format to specify values. White-space generally doesn't matter, except inside values: Parameters: - $data: A string to parse. Returns: The info array. File: includes/common.inc
function drupal_parse_info_format($data) { $info = array(); if (preg_match_all(' @^\s* # Start at the beginning of a line, ignoring leading whitespace ((?: [^=;\[\]]| # Key names cannot contain equal signs, semi-colons or square brackets, \[[^\[\]]*\...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-16518d26ee
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_setcookie/7.x
I need the code for `drupal_setcookie($name, $value, $options)` in Drupal 7 (includes/bootstrap.inc). It must do this: Drupal's wrapper around PHP's setcookie() function.
This allows the cookie's $value and $options to be altered. Parameters: - $name: The name of the cookie. - $value: The value of the cookie. - $options: An associative array which may have any of the keys expires, path, domain, secure, httponly, samesite. File: includes/bootstrap.inc
function drupal_setcookie($name, $value, $options) { $options = _drupal_cookie_params($options); if (\PHP_VERSION_ID >= 70300) { setcookie($name, $value, $options); } else { $defaults = array( 'expires' => 0, 'path' => '', 'domain' => '', 'secure' => FALSE, 'httponly' => FA...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-1653c3f8cd
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21tracker%21tracker.install/function/tracker_uninstall/7.x
I need the code for `tracker_uninstall()` in Drupal 7 (modules/tracker/tracker.install). It must do this: Implements hook_uninstall().
File: modules/tracker/tracker.install
function tracker_uninstall() { variable_del('tracker_index_nid'); variable_del('tracker_batch_size'); }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-16752de564
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_image_toolkit_settings/7.x
In Drupal 7, write the function `system_image_toolkit_settings()` (file modules/system/system.admin.inc) so that it does the following: Form builder; Configure site image toolkit usage.
File: modules/system/system.admin.inc
function system_image_toolkit_settings() { $toolkits_available = image_get_available_toolkits(); $current_toolkit = image_get_toolkit(); if (count($toolkits_available) == 0) { variable_del('image_toolkit'); $form['image_toolkit_help'] = array( '#markup' => t("No image toolkits were detected. Drupal...
[ "code-task", "function" ]
2026-09-30T00:00:00