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-ec7e3240f0 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.pages.inc/function/poll_votes/7.x | In Drupal 7, write the function `poll_votes($node)` (file modules/poll/poll.pages.inc) so that it does the following: Callback for the 'votes' tab for polls you can see other votes on | File: modules/poll/poll.pages.inc | function poll_votes($node) {
$votes_per_page = 20;
drupal_set_title($node->title);
$header[] = array('data' => t('Visitor'), 'field' => 'u.name');
$header[] = array('data' => t('Vote'), 'field' => 'pc.chtext');
$header[] = array('data' => t('Timestamp'), 'field' => 'pv.timestamp', 'sort' => 'desc');
$sele... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ec8564ec51 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21rdf%21rdf.module/function/rdf_preprocess_taxonomy_term/7.x | I need the code for `rdf_preprocess_taxonomy_term(&$variables)` in Drupal 7 (modules/rdf/rdf.module). It must do this: Implements MODULE_preprocess_HOOK(). | File: modules/rdf/rdf.module | function rdf_preprocess_taxonomy_term(&$variables) {
// Adds the RDF type of the term and the term name in a <meta> tag.
$term = $variables['term'];
$term_label_meta = array(
'#tag' => 'meta',
'#attributes' => array(
'about' => url('taxonomy/term/' . $term->tid),
'typeof' => $term->rdf... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ec98941ab1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.module/function/shortcut_sets/7.x | In Drupal 7, write the function `shortcut_sets()` (file modules/shortcut/shortcut.module) so that it does the following: Returns an array of all shortcut sets, keyed by the set name. | Returns: An array of shortcut sets. Note that only the basic shortcut set properties (name and title) are returned by this function, not the list of menu links that belong to the set.
File: modules/shortcut/shortcut.module | function shortcut_sets() {
return db_select('shortcut_set', 'ss')
->fields('ss')
->execute()
->fetchAllAssoc('set_name');
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ecb0ab2f04 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21color%21color.install/function/color_update_7001/7.x | Implement `color_update_7001()` in PHP for Drupal 7. Required behavior: Warn site administrator if unsafe CSS color codes are found in the database. | File: modules/color/color.install | function color_update_7001() {
$theme_palettes = db_query("SELECT name FROM {variable} WHERE name LIKE 'color_%_palette'")->fetchCol();
foreach ($theme_palettes as $name) {
$palette = variable_get($name, array());
foreach ($palette as $key => $color) {
if (!preg_match('/^#([a-f0-9]{3}){1,2}$/iD', $col... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ecb8a4f4f4 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_theme/7.x | Implement `taxonomy_theme()` in PHP for Drupal 7. Required behavior: Implements hook_theme(). | File: modules/taxonomy/taxonomy.module | function taxonomy_theme() {
return array(
'taxonomy_overview_vocabularies' => array(
'render element' => 'form',
),
'taxonomy_overview_terms' => array(
'render element' => 'form',
),
'taxonomy_term' => array(
'render element' => 'elements',
'template' => 'taxonomy-term',
... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-ecbecda44e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21database%21database.inc/function/db_truncate/7.x | I need the code for `db_truncate($table, array $options = array())` in Drupal 7 (includes/database/database.inc). It must do this: Returns a new TruncateQuery object for the active database. | Parameters:
- $table: The table from which to delete.
- $options: An array of options to control how the query operates.
Returns: TruncateQuery A new TruncateQuery object for this connection.
File: includes/database/database.inc | function db_truncate($table, array $options = array()) {
if (empty($options['target']) || $options['target'] == 'slave') {
$options['target'] = 'default';
}
return Database::getConnection($options['target'])->truncate($table, $options);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ecc1ead190 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_role_delete/7.x | Implement `user_role_delete($role)` in PHP for Drupal 7. Required behavior: Delete a user role from database. | Parameters:
- $role: A string with the role name, or an integer with the role ID.
File: modules/user/user.module | function user_role_delete($role) {
if (is_int($role)) {
$role = user_role_load($role);
}
else {
$role = user_role_load_by_name($role);
}
// If this is the administrator role, delete the user_admin_role variable.
if ($role->rid == variable_get('user_admin_role')) {
variable_del('user_admin_role'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ecc4a56728 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.manager.inc/function/update_manager_file_get/7.x | I need the code for `update_manager_file_get($url)` in Drupal 7 (modules/update/update.manager.inc). It must do this: Copies a file from the specified URL to the temporary directory for updates. | Returns the local path if the file has already been downloaded.
Parameters:
- $url: The URL of the file on the server.
Returns (string): Path to local file.
File: modules/update/update.manager.inc | function update_manager_file_get($url) {
$parsed_url = parse_url($url);
$remote_schemes = array('http', 'https', 'ftp', 'ftps', 'smb', 'nfs');
if (!in_array($parsed_url['scheme'], $remote_schemes)) {
// This is a local file, just return the path.
return drupal_realpath($url);
}
// Check the cache and... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ecf6828dad | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_make_unsticky_action/7.x | I need the code for `node_make_unsticky_action($node, $context = array())` in Drupal 7 (modules/node/node.module). It must do this: Sets the sticky-at-top-of-list 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_make_unsticky_action($node, $context = array()) {
$node->sticky = NODE_NOT_STICKY;
watchdog('action', 'Set @type %title to unsticky.', array('@type' => node_type_get_name($node), '%title' => $node->title));
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ed081e90be | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_add_date_formats_form_validate/7.x | I need the code for `system_add_date_formats_form_validate($form, &$form_state)` in Drupal 7 (modules/system/system.admin.inc). It must do this: Validate new date format string submission. | File: modules/system/system.admin.inc | function system_add_date_formats_form_validate($form, &$form_state) {
$formats = system_get_date_formats('custom');
$format = trim($form_state['values']['date_format']);
if (!empty($formats) && in_array($format, array_keys($formats)) && (!isset($form_state['values']['dfid']) || $form_state['values']['dfid'] != $f... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ed3f809cad | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21image.inc/function/image_crop/7.x | In Drupal 7, write the function `image_crop(stdClass $image, $x, $y, $width, $height)` (file includes/image.inc) so that it does the following: Crops an image to a rectangle specified by the given dimensions. | Parameters:
- $image: An image object returned by image_load().
- $x: The top left coordinate, in pixels, of the crop area (x axis value).
- $y: The top left coordinate, in pixels, of the crop area (y axis value).
- $width: The target width, in pixels.
- $height: The target height, in pixels.
Returns: TRUE on success,... | function image_crop(stdClass $image, $x, $y, $width, $height) {
$aspect = $image->info['height'] / $image->info['width'];
if (empty($height)) $height = $width / $aspect;
if (empty($width)) $width = $height * $aspect;
$width = (int) round($width);
$height = (int) round($height);
return image_toolkit_invoke... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ed71a260b6 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21menu%21menu.module/function/menu_load_all/7.x | Implement `menu_load_all()` in PHP for Drupal 7. Required behavior: Load all custom menu data. | Returns (Array): of custom menu data.
File: modules/menu/menu.module | function menu_load_all() {
$custom_menus = &drupal_static(__FUNCTION__);
if (!isset($custom_menus)) {
if ($cached = cache_get('menu_custom', 'cache_menu')) {
$custom_menus = $cached->data;
}
else {
$custom_menus = db_query('SELECT * FROM {menu_custom}')->fetchAllAssoc('menu_name', PDO::FETCH... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ed80a6380d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_tokens/7.x | In Drupal 7, show an example implementation for `hook_tokens($type, $tokens, array $data = array(), array $options = array())` (modules/system/system.api.php): Provide replacement values for placeholder tokens. | This hook is invoked when someone calls token_replace(). That function first scans the text for [type:token] patterns, and splits the needed tokens into groups by type. Then hook_tokens() is invoked on each token-type group, allowing your module to respond by providing replacement text for any of the tokens in the grou... | function hook_tokens($type, $tokens, array $data = array(), array $options = array()) {
$url_options = array('absolute' => TRUE);
if (isset($options['language'])) {
$url_options['language'] = $options['language'];
$language_code = $options['language']->language;
}
else {
$language_code = NULL;
}
... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-edadc1e5be | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.admin.inc/function/field_ui_field_delete_form_submit/7.x | Implement `field_ui_field_delete_form_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form submission handler for field_ui_field_delete_form(). | Removes a field instance from a bundle. If the field has no more instances, it will be marked as deleted too.
File: modules/field_ui/field_ui.admin.inc | function field_ui_field_delete_form_submit($form, &$form_state) {
$form_values = $form_state['values'];
$field_name = $form_values['field_name'];
$bundle = $form_values['bundle'];
$entity_type = $form_values['entity_type'];
$field = field_info_field($field_name);
$instance = field_info_instance($entity_typ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-edb020db49 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_module_implements_alter/7.x | In Drupal 7, show an example implementation for `hook_module_implements_alter(&$implementations, $hook)` (modules/system/system.api.php): Alter the registry of modules implementing a hook. | This hook is invoked during module_implements(). A module may implement this hook in order to reorder the implementing modules, which are otherwise ordered by the module's system weight.
Note that hooks invoked using drupal_alter() can have multiple variations (such as hook_form_alter() and hook_form_FORM_ID_alter()).... | function hook_module_implements_alter(&$implementations, $hook) {
if ($hook == 'rdf_mapping') {
// Move my_module_rdf_mapping() to the end of the list. module_implements()
// iterates through $implementations with a foreach loop which PHP iterates
// in the order that the items were added, so to move an i... | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-edb3afbf88 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.module/function/block_block_configure/7.x | I need the code for `block_block_configure($delta = 0)` in Drupal 7 (modules/block/block.module). It must do this: Implements hook_block_configure(). | File: modules/block/block.module | function block_block_configure($delta = 0) {
if ($delta) {
$custom_block = block_custom_block_get($delta);
}
else {
$custom_block = array();
}
return block_custom_block_form($custom_block);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-edb583a4da | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21profile%21profile.install/function/profile_schema/7.x | In Drupal 7, write the function `profile_schema()` (file modules/profile/profile.install) so that it does the following: Implements hook_schema(). | File: modules/profile/profile.install | function profile_schema() {
$schema['profile_field'] = array(
'description' => 'Stores profile field information.',
'fields' => array(
'fid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique profile field ID.',
),
'title' => array... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-edbeaa4e14 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21errors.inc/function/_drupal_get_last_caller/7.x | In Drupal 7, write the function `_drupal_get_last_caller($backtrace)` (file includes/errors.inc) so that it does the following: Gets the last caller from a backtrace. | Parameters:
- $backtrace: A standard PHP backtrace.
Returns: An associative array with keys 'file', 'line' and 'function'.
File: includes/errors.inc | function _drupal_get_last_caller($backtrace) {
// Errors that occur inside PHP internal functions do not generate
// information about file and line. Ignore black listed functions.
$blacklist = array('debug', '_drupal_error_handler', '_drupal_exception_handler', 'drupal_trigger_fatal_error');
while (($backtrace... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ede554d207 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21authorize.inc/function/_authorize_filetransfer_connection_settings/7.x | I need the code for `_authorize_filetransfer_connection_settings($backend)` in Drupal 7 (includes/authorize.inc). It must do this: Generates the Form API array for a given connection backend's settings. | Parameters:
- $backend: The name of the backend (e.g. 'ftp', 'ssh', etc).
Returns: Form API array of connection settings for the given backend.
File: includes/authorize.inc | function _authorize_filetransfer_connection_settings($backend) {
$defaults = variable_get('authorize_filetransfer_connection_settings_' . $backend, array());
$form = array();
// Create an instance of the file transfer class to get its settings form.
$filetransfer = authorize_get_filetransfer($backend);
if ($... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-edf4be0153 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.module/function/locale_form_comment_form_alter/7.x | I need the code for `locale_form_comment_form_alter(&$form, &$form_state, $form_id)` in Drupal 7 (modules/locale/locale.module). It must do this: Implements hook_form_FORM_ID_alter(). | File: modules/locale/locale.module | function locale_form_comment_form_alter(&$form, &$form_state, $form_id) {
// If a content type has multilingual support we set the content language as
// comment language.
if ($form['language']['#value'] == LANGUAGE_NONE && locale_multilingual_node_type($form['#node']->type)) {
global $language_content;
$... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-edf6b8debe | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_element_info_alter/7.x | In Drupal 7, show an example implementation for `hook_element_info_alter(&$type)` (modules/system/system.api.php): Alter the element type information returned from modules. | A module may implement this hook in order to alter the element type defaults defined by a module.
Parameters:
- $type: All element type defaults as collected by hook_element_info().
File: modules/system/system.api.php | function hook_element_info_alter(&$type) {
// Decrease the default size of textfields.
if (isset($type['textfield']['#size'])) {
$type['textfield']['#size'] = 40;
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-ee0119d366 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.attach.inc/function/field_attach_prepare_view/7.x | I need the code for `field_attach_prepare_view($entity_type, $entities, $view_mode, $langcode = NULL, $options = array())` in Drupal 7 (modules/field/field.attach.inc). It must do this: Prepare field data prior to display. | This function lets field types and formatters load additional data needed for display that is not automatically loaded during field_attach_load(). It accepts an array of entities to allow query optimisation when displaying lists of entities.
field_attach_prepare_view() and field_attach_view() are two halves of the sam... | function field_attach_prepare_view($entity_type, $entities, $view_mode, $langcode = NULL, $options = array()) {
// Validate $options since this is a new parameter added after Drupal 7 was
// released.
$options = is_array($options) ? $options : array();
$options['language'] = array();
// To ensure hooks are ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ee05967434 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/form_process_vertical_tabs/7.x | I need the code for `form_process_vertical_tabs($element, &$form_state)` in Drupal 7 (includes/form.inc). It must do this: Creates a group formatted as vertical tabs. | Parameters:
- $element: An associative array containing the properties and children of the fieldset.
- $form_state: The $form_state array for the form this vertical tab widget belongs to.
Returns: The processed element.
File: includes/form.inc | function form_process_vertical_tabs($element, &$form_state) {
// Inject a new fieldset as child, so that form_process_fieldset() processes
// this fieldset like any other fieldset.
$element['group'] = array(
'#type' => 'fieldset',
'#theme_wrappers' => array(),
'#parents' => $element['#parents'],
);
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ee24e3b6f2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21forum%21forum.module/function/forum_node_delete/7.x | In Drupal 7, write the function `forum_node_delete($node)` (file modules/forum/forum.module) so that it does the following: Implements hook_node_delete(). | File: modules/forum/forum.module | function forum_node_delete($node) {
if (_forum_node_check_node_type($node)) {
db_delete('forum')
->condition('nid', $node->nid)
->execute();
db_delete('forum_index')
->condition('nid', $node->nid)
->execute();
}
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-ee6ec12a29 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.module/function/poll_field_attach_prepare_translation_alter/7.x | In Drupal 7, write the function `poll_field_attach_prepare_translation_alter(&$entity, $context)` (file modules/poll/poll.module) so that it does the following: Implements hook_field_attach_prepare_translation_alter(). | File: modules/poll/poll.module | function poll_field_attach_prepare_translation_alter(&$entity, $context) {
if ($context['entity_type'] == 'node' && $entity->type == 'poll') {
$entity->choice = $context['source_entity']->choice;
foreach ($entity->choice as $i => $options) {
$entity->choice[$i]['chvotes'] = 0;
}
}
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-ee7c4df6f9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_login_name_validate/7.x | Implement `user_login_name_validate($form, &$form_state)` in PHP for Drupal 7. Required behavior: A FAPI validate handler. Sets an error if supplied username has been blocked. | File: modules/user/user.module | function user_login_name_validate($form, &$form_state) {
if (!empty($form_state['values']['name']) && user_is_blocked($form_state['values']['name'])) {
// Blocked in user administration.
form_set_error('name', t('The username %name has not been activated or is blocked.', array('%name' => $form_state['values']... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ee7d34b560 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_view/7.x | I need the code for `node_view($node, $view_mode = 'full', $langcode = NULL)` in Drupal 7 (modules/node/node.module). It must do this: Generates an array for rendering the given node. | Parameters:
- $node: A node object.
- $view_mode: View mode, e.g. 'full', 'teaser'...
- $langcode: (optional) A language code to use for rendering. Defaults to the global content language of the current request.
Returns: An array as expected by drupal_render().
File: modules/node/node.module | function node_view($node, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) {
$langcode = $GLOBALS['language_content']->language;
}
// Populate $node->content with a render() array.
node_build_content($node, $view_mode, $langcode);
$build = $node->content;
// We don't need duplicate rend... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ee901e530d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.module/function/_update_cache_clear/7.x | Implement `_update_cache_clear($cid = NULL, $wildcard = FALSE)` in PHP for Drupal 7. Required behavior: Invalidates cached data relating to update status. | Parameters:
- $cid: (optional) Cache ID of the record to clear from the private update module cache. If empty, all records will be cleared from the table except fetch tasks. Defaults to NULL.
- $wildcard: (optional) If TRUE, cache IDs starting with $cid are deleted in addition to the exact cache ID specified by $cid. D... | function _update_cache_clear($cid = NULL, $wildcard = FALSE) {
if (empty($cid)) {
db_delete('cache_update')
// Clear everything except fetch task information because these are used
// to ensure that the fetch task queue items are not added multiple times.
->condition('cid', 'fetch_task::%', 'NOT... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ee9d1b658e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.admin.inc/function/shortcut_set_add_form_validate/7.x | In Drupal 7, write the function `shortcut_set_add_form_validate($form, &$form_state)` (file modules/shortcut/shortcut.admin.inc) so that it does the following: Validation handler for shortcut_set_add_form(). | File: modules/shortcut/shortcut.admin.inc | function shortcut_set_add_form_validate($form, &$form_state) {
// Check to prevent a duplicate title.
if (shortcut_set_title_exists($form_state['values']['new'])) {
form_set_error('new', t('The shortcut set %name already exists. Choose another name.', array('%name' => $form_state['values']['new'])));
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-eea6e2c752 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.install/function/file_requirements/7.x | Implement `file_requirements($phase)` in PHP for Drupal 7. Required behavior: Implements hook_requirements(). | Display information about getting upload progress bars working.
File: modules/file/file.install | function file_requirements($phase) {
$requirements = array();
// Check the server's ability to indicate upload progress.
if ($phase == 'runtime') {
$description = NULL;
$implementation = file_progress_implementation();
// Test the web server identity.
$server_software = $_SERVER['SERVER_SOFTWARE'... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-eeacd9e251 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21install.core.inc/function/install_display_output/7.x | I need the code for `install_display_output($output, $install_state)` in Drupal 7 (includes/install.core.inc). It must do this: Displays themed installer output and ends the page request. | Installation tasks should use drupal_set_title() to set the desired page title, but otherwise this function takes care of theming the overall page output during every step of the installation.
Parameters:
- $output: The content to display on the main part of the page.
- $install_state: An array of information about th... | function install_display_output($output, $install_state) {
drupal_page_header();
// Prevent install.php from being indexed when installed in a sub folder.
// robots.txt rules are not read if the site is within domain.com/subfolder
// resulting in /subfolder/install.php being found through search engines.
// ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-eeb2d180d2 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_permission/7.x | Give me the example code for `hook_permission()` in Drupal 7. Hook description: Define user permissions. | This hook can supply permissions that the module defines, so that they can be selected on the user permissions page and used to grant or restrict access to actions the module performs.
Permissions are checked using user_access().
For a detailed usage example, see page_example.module.
Returns: An array whose keys are... | function hook_permission() {
return array(
'administer my module' => array(
'title' => t('Administer my module'),
'description' => t('Perform administration tasks for my module.'),
),
);
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-eeee1303ee | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21pager.inc/function/theme_pager_previous/7.x | Implement `theme_pager_previous($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for the "previous 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. - interval: The number of pages to move backward when the link is clicked. - parameters: An associative array of query string parameters ... | function theme_pager_previous($variables) {
$text = $variables['text'];
$element = $variables['element'];
$interval = $variables['interval'];
$parameters = $variables['parameters'];
global $pager_page_array;
$output = '';
// Nothing to do if there is no pager.
if (!isset($pager_page_array[$element])) {... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ef0d51e424 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/form_load_include/7.x | In Drupal 7, write the function `form_load_include(&$form_state, $type, $module, $name = NULL)` (file includes/form.inc) so that it does the following: Ensures an include file is loaded whenever the form is processed. | Example:
Parameters:
- $form_state: The current state of the form.
- $type: The include file's type (file extension).
- $module: The module to which the include file belongs.
- $name: (optional) The base file name (without the $type extension). If omitted, $module is used; i.e., resulting in "$module.$type" by default... | function form_load_include(&$form_state, $type, $module, $name = NULL) {
if (!isset($name)) {
$name = $module;
}
if (!isset($form_state['build_info']['files']["$module:$name.$type"])) {
// Only add successfully included files to the form state.
if ($result = module_load_include($type, $module, $name))... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ef3df3b187 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.admin.inc/function/taxonomy_vocabulary_confirm_delete_submit/7.x | I need the code for `taxonomy_vocabulary_confirm_delete_submit($form, &$form_state)` in Drupal 7 (modules/taxonomy/taxonomy.admin.inc). It must do this: Submit handler to delete a vocabulary after confirmation. | File: modules/taxonomy/taxonomy.admin.inc | function taxonomy_vocabulary_confirm_delete_submit($form, &$form_state) {
$status = taxonomy_vocabulary_delete($form_state['values']['vid']);
drupal_set_message(t('Deleted vocabulary %name.', array('%name' => $form_state['values']['name'])));
watchdog('taxonomy', 'Deleted vocabulary %name.', array('%name' => $for... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ef43ab4807 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_permission/7.x | Implement `taxonomy_permission()` in PHP for Drupal 7. Required behavior: Implements hook_permission(). | File: modules/taxonomy/taxonomy.module | function taxonomy_permission() {
$permissions = array(
'administer taxonomy' => array(
'title' => t('Administer vocabularies and terms'),
),
);
foreach (taxonomy_get_vocabularies() as $vocabulary) {
$permissions += array(
'edit terms in ' . $vocabulary->vid => array(
'title' => t('... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-ef493ed410 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/batch_process/7.x | Implement `batch_process($redirect = NULL, $url = 'batch', $redirect_callback = 'drupal_goto')` in PHP for Drupal 7. Required behavior: Processes the batch. | Unless the batch has been marked with 'progressive' = FALSE, the function issues a drupal_goto and thus ends page execution.
This function is generally not needed in form submit handlers; Form API takes care of batches that were set during form submission.
Parameters:
- $redirect: (optional) Path to redirect to when ... | function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = 'drupal_goto') {
$batch =& batch_get();
drupal_theme_initialize();
if (isset($batch)) {
// Add process information
$process_info = array(
'current_set' => 0,
'progressive' => TRUE,
'url' => $url,
'url_o... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ef50cd66ae | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21profile%21profile.admin.inc/function/profile_field_form_validate/7.x | In Drupal 7, write the function `profile_field_form_validate($form, &$form_state)` (file modules/profile/profile.admin.inc) so that it does the following: Validate profile_field_form submissions. | File: modules/profile/profile.admin.inc | function profile_field_form_validate($form, &$form_state) {
// Validate the 'field name':
if (preg_match('/[^a-zA-Z0-9_-]/', $form_state['values']['name'])) {
form_set_error('name', t('The specified form name contains one or more illegal characters. Spaces or any other special characters except dash (-) and und... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ef6160b107 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/_menu_link_find_parent/7.x | Implement `_menu_link_find_parent($menu_link, $parent_candidates = array())` in PHP for Drupal 7. Required behavior: Finds a possible parent for a given menu link. | Because the parent of a given link might not exist anymore in the database, we apply a set of heuristics to determine a proper parent:
- use the passed parent link if specified and existing.
- else, use the first existing link down the previous link hierarchy
- else, for system menu links (derived from hook_menu()),... | function _menu_link_find_parent($menu_link, $parent_candidates = array()) {
$parent = FALSE;
// This item is explicitely top-level, skip the rest of the parenting.
if (isset($menu_link['plid']) && empty($menu_link['plid'])) {
return $parent;
}
// If we have a parent link ID, try to use that.
$candidat... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ef619a764d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21tracker%21tracker.module/function/_tracker_calculate_changed/7.x | Implement `_tracker_calculate_changed($nid)` in PHP for Drupal 7. Required behavior: Determines the max timestamp between $node->changed and the last comment. | Parameters:
- $nid: A node ID.
Returns: The $node->changed timestamp, or most recent comment timestamp, whichever is the greatest.
File: modules/tracker/tracker.module | function _tracker_calculate_changed($nid) {
$changed = db_query('SELECT changed FROM {node} WHERE nid = :nid', array(':nid' => $nid), array('target' => 'slave'))->fetchField();
$latest_comment = db_query_range('SELECT cid, changed FROM {comment} WHERE nid = :nid AND status = :status ORDER BY changed DESC', 0, 1, ar... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ef7a27a55d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/themes%21garland%21template.php/function/garland_preprocess_page/7.x | In Drupal 7, write the function `garland_preprocess_page(&$variables)` (file themes/garland/template.php) so that it does the following: Override or insert variables into the page template. | File: themes/garland/template.php | function garland_preprocess_page(&$variables) {
// Move secondary tabs into a separate variable.
$variables['tabs2'] = array(
'#theme' => 'menu_local_tasks',
'#secondary' => $variables['tabs']['#secondary'],
);
unset($variables['tabs']['#secondary']);
if (isset($variables['main_menu'])) {
$variab... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ef9e5cfa71 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.install/function/_update_7000_field_delete_field/7.x | Implement `_update_7000_field_delete_field($field_name)` in PHP for Drupal 7. Required behavior: Utility function: delete a field stored in SQL storage directly from the database. | To protect user data, this function can only be used to delete fields once all information it stored is gone. Delete all data from the field_data_$field_name table before calling by either manually issuing delete queries against it or using _update_7000_field_delete_instance().
This function can be used for databases ... | function _update_7000_field_delete_field($field_name) {
$table_name = 'field_data_' . $field_name;
if (db_select($table_name)->range(0, 1)->countQuery()->execute()->fetchField()) {
$t = get_t();
throw new Exception($t('This function can only be used to delete fields without data'));
}
// Delete all inst... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-ef9eeb7134 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.module/function/field_modules_disabled/7.x | In Drupal 7, write the function `field_modules_disabled($modules)` (file modules/field/field.module) so that it does the following: Implements hook_modules_disabled(). | File: modules/field/field.module | function field_modules_disabled($modules) {
// Refresh the 'active' status of fields.
field_sync_field_status();
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-efa94438e8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.install/function/filter_update_7000/7.x | I need the code for `filter_update_7000()` in Drupal 7 (modules/filter/filter.install). It must do this: Upgrade the {filter_formats} table and rename it to {filter_format}. | File: modules/filter/filter.install | function filter_update_7000() {
db_rename_table('filter_formats', 'filter_format');
// Add the new {filter_format}.status and {filter_format}.weight column.
db_add_field('filter_format', 'status', array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
'size' => 'tiny'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-efbb76fc0c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.module/function/field_get_items/7.x | In Drupal 7, write the function `field_get_items($entity_type, $entity, $field_name, $langcode = NULL)` (file modules/field/field.module) so that it does the following: Returns the field items in the language they currently would be displayed. | Parameters:
- $entity_type: The type of $entity; e.g., 'node' or 'user'.
- $entity: The entity containing the data to be displayed.
- $field_name: The field to be displayed.
- $langcode: (optional) The language code $entity->{$field_name} has to be displayed in. Defaults to the current language.
Returns: An array of f... | function field_get_items($entity_type, $entity, $field_name, $langcode = NULL) {
$langcode = field_language($entity_type, $entity, $field_name, $langcode);
return isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : FALSE;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-efc961d306 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.pages.inc/function/user_logout_current_user/7.x | Implement `user_logout_current_user()` in PHP for Drupal 7. Required behavior: Logs the current user out. | File: modules/user/user.pages.inc | function user_logout_current_user() {
global $user;
watchdog('user', 'Session closed for %name.', array('%name' => $user->name));
module_invoke_all('user_logout', $user);
// Destroy the current session, and reset $user to the anonymous user.
session_destroy();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-efceef5cf8 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21unicode.inc/function/_unicode_check/7.x | I need the code for `_unicode_check()` in Drupal 7 (includes/unicode.inc). It must do this: Perform checks about Unicode support in PHP, and set the right settings if needed. | Because Drupal needs to be able to handle text in various encodings, we do not support mbstring function overloading. HTTP input/output conversion must be disabled for similar reasons.
Parameters:
- $errors: Whether to report any fatal errors with form_set_error().
File: includes/unicode.inc | function _unicode_check() {
// Ensure translations don't break during installation.
$t = get_t();
// Check for mbstring extension
if (!function_exists('mb_strlen')) {
return array(UNICODE_SINGLEBYTE, $t('Operations on Unicode strings are emulated on a best-effort basis. Install the <a href="@url">PHP mbstr... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-efd33c078d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.module/function/_update_cache_get/7.x | Implement `_update_cache_get($cid)` in PHP for Drupal 7. Required behavior: Retrieves data from the private update status cache table. | Parameters:
- $cid: The cache ID to retrieve.
Returns: An array of data for the given cache ID, or NULL if the ID was not found.
File: modules/update/update.module | function _update_cache_get($cid) {
$cache = db_query("SELECT data, created, expire, serialized FROM {cache_update} WHERE cid = :cid", array(':cid' => $cid))->fetchObject();
if (isset($cache->data)) {
if ($cache->serialized) {
$cache->data = unserialize($cache->data);
}
}
return $cache;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-efd4de6f52 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.admin.inc/function/_field_ui_field_overview_form_validate_add_new/7.x | Implement `_field_ui_field_overview_form_validate_add_new($form, &$form_state)` in PHP for Drupal 7. Required behavior: Validates the 'add new field' row of field_ui_field_overview_form(). | File: modules/field_ui/field_ui.admin.inc | function _field_ui_field_overview_form_validate_add_new($form, &$form_state) {
$field = $form_state['values']['fields']['_add_new_field'];
// Validate if any information was provided in the 'add new field' row.
if (array_filter(array($field['label'], $field['field_name'], $field['type'], $field['widget_type'])))... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-efdba5b901 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/form_validate_machine_name/7.x | In Drupal 7, write the function `form_validate_machine_name(&$element, &$form_state)` (file includes/form.inc) so that it does the following: Form element validation handler for machine_name elements. | Note that #maxlength is validated by _form_validate() already.
File: includes/form.inc | function form_validate_machine_name(&$element, &$form_state) {
// Verify that the machine name not only consists of replacement tokens.
if (preg_match('@^' . $element['#machine_name']['replace'] . '+$@', $element['#value'])) {
form_error($element, t('The machine-readable name must contain unique characters.'));... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-efe51e7fef | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/element_sort_by_title/7.x | In Drupal 7, write the function `element_sort_by_title($a, $b)` (file includes/common.inc) so that it does the following: Array sorting callback; sorts elements by title. | File: includes/common.inc | function element_sort_by_title($a, $b) {
$a_title = (is_array($a) && isset($a['#title'])) ? $a['#title'] : '';
$b_title = (is_array($b) && isset($b['#title'])) ? $b['#title'] : '';
return strnatcasecmp($a_title, $b_title);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-efeced151e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_process_attached/7.x | Implement `drupal_process_attached($elements, $group = JS_DEFAULT, $dependency_check = FALSE, $every_page = NULL)` in PHP for Drupal 7. Required behavior: Adds attachments to a render() structure. | Libraries, JavaScript, CSS and other types of custom structures are attached to elements using the #attached property. The #attached property is an associative array, where the keys are the attachment types and the values are the attached data. For example:
Parameters:
- $elements: The structured array describing the ... | function drupal_process_attached($elements, $group = JS_DEFAULT, $dependency_check = FALSE, $every_page = NULL) {
// Add defaults to the special attached structures that should be processed differently.
$elements['#attached'] += array(
'library' => array(),
'js' => array(),
'css' => array(),
);
// ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-eff546e17e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/_filter_html_settings/7.x | Implement `_filter_html_settings($form, &$form_state, $filter, $format, $defaults)` in PHP for Drupal 7. Required behavior: Implements callback_filter_settings(). | Filter settings callback for the HTML content filter.
File: modules/filter/filter.module | function _filter_html_settings($form, &$form_state, $filter, $format, $defaults) {
$filter->settings += $defaults;
$settings['allowed_html'] = array(
'#type' => 'textfield',
'#title' => t('Allowed HTML tags'),
'#default_value' => $filter->settings['allowed_html'],
'#maxlength' => 1024,
'#descri... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-eff7dd5950 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_array_get_nested_value/7.x | I need the code for `&drupal_array_get_nested_value(array &$array, array $parents, &$key_exists = NULL)` in Drupal 7 (includes/common.inc). It must do this: Retrieves a value from a nested array with variable depth. | This helper function should be used when the depth of the array element being retrieved may vary (that is, the number of parent keys is variable). It is primarily used for form structures and renderable arrays.
Without this helper function the only way to get a nested array value with variable depth in one line would ... | function &drupal_array_get_nested_value(array &$array, array $parents, &$key_exists = NULL) {
$ref = &$array;
foreach ($parents as $parent) {
if (is_array($ref) && (isset($ref[$parent]) || array_key_exists($parent, $ref))) {
$ref = &$ref[$parent];
}
else {
$key_exists = FALSE;
$null = ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-effbfca09b | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_date_delete_format_form_submit/7.x | In Drupal 7, write the function `system_date_delete_format_form_submit($form, &$form_state)` (file modules/system/system.admin.inc) so that it does the following: Delete a configured date format. | File: modules/system/system.admin.inc | function system_date_delete_format_form_submit($form, &$form_state) {
if ($form_state['values']['confirm']) {
$format = system_get_date_format($form_state['values']['dfid']);
system_date_format_delete($form_state['values']['dfid']);
drupal_set_message(t('Removed date format %format.', array('%format' => f... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f00cc5b3db | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.module/function/dashboard_help/7.x | In Drupal 7, write the function `dashboard_help($path, $arg)` (file modules/dashboard/dashboard.module) so that it does the following: Implements hook_help(). | File: modules/dashboard/dashboard.module | function dashboard_help($path, $arg) {
switch ($path) {
case 'admin/help#dashboard':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Dashboard module provides a <a href="@dashboard">Dashboard page</a> in the administrative interface for organizing administrative... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-f00daea13d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21overlay%21overlay.module/function/overlay_disable_message/7.x | In Drupal 7, write the function `overlay_disable_message()` (file modules/overlay/overlay.module) so that it does the following: Returns a renderable array representing a message for disabling the overlay. | If the current user can access the overlay and has not previously indicated that this message should be dismissed, this function returns a message containing a link to disable the overlay. Nothing is returned for anonymous users, because the links control per-user settings. Because some screen readers are unable to pro... | function overlay_disable_message() {
global $user;
if (!empty($user->uid) && empty($user->data['overlay_message_dismissed']) && (!isset($user->data['overlay']) || $user->data['overlay']) && user_access('access overlay')) {
$build = array(
'#theme' => 'overlay_disable_message',
'#weight' => -99,
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f0278a8e07 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/flood_is_allowed/7.x | In Drupal 7, write the function `flood_is_allowed($name, $threshold, $window = 3600, $identifier = NULL)` (file includes/common.inc) so that it does the following: Checks whether a user is allowed to proceed with the specified event. | Events can have thresholds saying that each user can only do that event a certain number of times in a time window. This function verifies that the current user has not exceeded this threshold.
Parameters:
- $name: The unique name of the event.
- $threshold: The maximum number of times each user can do this event per ... | function flood_is_allowed($name, $threshold, $window = 3600, $identifier = NULL) {
if (!isset($identifier)) {
$identifier = ip_address();
}
$number = db_query("SELECT COUNT(*) FROM {flood} WHERE event = :event AND identifier = :identifier AND timestamp > :timestamp", array(
':event' => $name,
':identi... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f0644b8a22 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_get_hash_salt/7.x | I need the code for `drupal_get_hash_salt()` in Drupal 7 (includes/bootstrap.inc). It must do this: Gets a salt useful for hardening against SQL injection. | Returns: A salt based on information in settings.php, not in the database.
File: includes/bootstrap.inc | function drupal_get_hash_salt() {
global $drupal_hash_salt, $databases;
// If the $drupal_hash_salt variable is empty, a hash of the serialized
// database credentials is used as a fallback salt.
return empty($drupal_hash_salt) ? hash('sha256', serialize($databases)) : $drupal_hash_salt;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f07bb9987f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.admin.inc/function/shortcut_link_edit_validate/7.x | I need the code for `shortcut_link_edit_validate($form, &$form_state)` in Drupal 7 (modules/shortcut/shortcut.admin.inc). It must do this: Validation handler for the shortcut link add and edit forms. | File: modules/shortcut/shortcut.admin.inc | function shortcut_link_edit_validate($form, &$form_state) {
if (!shortcut_valid_link($form_state['values']['shortcut_link']['link_path'])) {
form_set_error('shortcut_link][link_path', t('The link must correspond to a valid path on the site.'));
}
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f0a0c794ba | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_validate/7.x | Implement `node_validate($node, $form, &$form_state)` in PHP for Drupal 7. Required behavior: Implements hook_validate(). | Performs validation checks on the given node.
File: modules/node/node.module | function node_validate($node, $form, &$form_state) {
if (isset($node->nid) && (node_last_changed($node->nid) > $node->changed)) {
form_set_error('changed', t('The content on this page has either been modified by another user, or you have already submitted modifications using this form. As a result, your changes c... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-f0d38093df | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_get_info/7.x | In Drupal 7, write the function `search_get_info($all = FALSE)` (file modules/search/search.module) so that it does the following: Returns information about available search modules. | Parameters:
- $all: If TRUE, information about all enabled modules implementing hook_search_info() will be returned. If FALSE (default), only modules that have been set to active on the search settings page will be returned.
Returns (Array): of hook_search_info() return values, keyed by module name. The 'title' and 'p... | function search_get_info($all = FALSE) {
$search_hooks = &drupal_static(__FUNCTION__);
if (!isset($search_hooks)) {
foreach (module_implements('search_info') as $module) {
$search_hooks[$module] = call_user_func($module . '_search_info');
// Use module name as the default value.
$search_hooks... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f0e85e4290 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.api.php/function/hook_file_download_access/7.x | Give me the example code for `hook_file_download_access($file_item, $entity_type, $entity)` in Drupal 7. Hook description: Control download access to files. | The hook is typically implemented to limit access based on the entity the file is referenced, e.g., only users with access to a node should be allowed to download files attached to that node.
Parameters:
- $file_item (array): The array of information about the file to check access for.
- $entity_type: The type of $ent... | function hook_file_download_access($file_item, $entity_type, $entity) {
if ($entity_type == 'node') {
return node_access('view', $entity);
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-f10bbf5b43 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_validate_name/7.x | In Drupal 7, write the function `user_validate_name($name)` (file modules/user/user.module) so that it does the following: Verify the syntax of the given name. | File: modules/user/user.module | function user_validate_name($name) {
if (!$name) {
return t('You must enter a username.');
}
if (substr($name, 0, 1) == ' ') {
return t('The username cannot begin with a space.');
}
if (substr($name, -1) == ' ') {
return t('The username cannot end with a space.');
}
if (strpos($name, ' ') !==... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f1167dffb9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.default.inc/function/field_default_view/7.x | I need the code for `field_default_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)` in Drupal 7 (modules/field/field.default.inc). It must do this: Builds a renderable array for one field on one entity instance. | Parameters:
- $entity_type: The type of $entity; e.g. 'node' or 'user'.
- $entity: A single object of type $entity_type.
- $field: The field structure for the operation.
- $instance: An array containing each field on $entity's bundle.
- $langcode: The language associated to $items.
- $items: Array of field values alrea... | function field_default_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$addition = array();
// Prepare incoming display specifications.
if (is_string($display)) {
$view_mode = $display;
$display = field... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f1294e01ca | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/_drupal_samesite_cookie/7.x | Implement `_drupal_samesite_cookie($options)` in PHP for Drupal 7. Required behavior: Determine the value for the samesite cookie attribute, in the following order of precedence: | 1) A value explicitly passed to drupal_setcookie() 2) A value set in $conf['samesite_cookie_value'] 3) The setting from php ini 4) The default of None, or FALSE (no attribute) if the cookie is not Secure
Parameters:
- $options: An associative array as passed to drupal_setcookie().
Returns: The value for the samesite ... | function _drupal_samesite_cookie($options) {
if (isset($options['samesite'])) {
return $options['samesite'];
}
$override = variable_get('samesite_cookie_value', NULL);
if ($override !== NULL) {
return $override;
}
$ini_options = session_get_cookie_params();
if (isset($ini_options['samesite'])) {
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f1342b2f08 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.admin.inc/function/user_admin_role_delete_confirm/7.x | I need the code for `user_admin_role_delete_confirm($form, &$form_state, $role)` in Drupal 7 (modules/user/user.admin.inc). It must do this: Form to confirm role delete operation. | File: modules/user/user.admin.inc | function user_admin_role_delete_confirm($form, &$form_state, $role) {
$form['rid'] = array(
'#type' => 'value',
'#value' => $role->rid,
);
return confirm_form($form, t('Are you sure you want to delete the role %name ?', array('%name' => $role->name)), 'admin/people/permissions/roles', t('This action canno... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f150df2862 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21path.inc/function/path_is_admin/7.x | I need the code for `path_is_admin($path)` in Drupal 7 (includes/path.inc). It must do this: Determines whether a path is in the administrative section of the site. | By default, paths are considered to be non-administrative. If a path does not match any of the patterns in path_get_admin_paths(), or if it matches both administrative and non-administrative patterns, it is considered non-administrative.
Parameters:
- $path: A Drupal path.
Returns: TRUE if the path is administrative,... | function path_is_admin($path) {
$path_map = &drupal_static(__FUNCTION__);
if (!isset($path_map['admin'][$path])) {
$patterns = path_get_admin_paths();
$path_map['admin'][$path] = drupal_match_path($path, $patterns['admin']);
$path_map['non_admin'][$path] = drupal_match_path($path, $patterns['non_admin']... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f166314338 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21locale.inc/function/locale_get_localized_date_format/7.x | Implement `locale_get_localized_date_format($languages)` in PHP for Drupal 7. Required behavior: Select locale date format details from database. | Parameters:
- $languages: An array of language codes.
Returns: An array of date formats.
File: includes/locale.inc | function locale_get_localized_date_format($languages) {
$formats = array();
// Get list of different format types.
$format_types = system_get_date_types();
$short_default = variable_get('date_format_short', 'm/d/Y - H:i');
// Loop through each language until we find one with some date formats
// configure... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f16807c54d | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21image%21image.admin.inc/function/image_style_add_form_submit/7.x | Implement `image_style_add_form_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Submit handler for adding a new image style. | File: modules/image/image.admin.inc | function image_style_add_form_submit($form, &$form_state) {
$style = array(
'name' => $form_state['values']['name'],
'label' => $form_state['values']['label'],
);
$style = image_style_save($style);
drupal_set_message(t('Style %name was created.', array('%name' => $style['label'])));
$form_state['redir... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f175c39f5c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21search%21search.admin.inc/function/search_reindex_confirm/7.x | Implement `search_reindex_confirm()` in PHP for Drupal 7. Required behavior: Menu callback: confirm wiping of the index. | File: modules/search/search.admin.inc | function search_reindex_confirm() {
return confirm_form(array(), t('Are you sure you want to re-index the site?'),
'admin/config/search/settings', t('The search index is not cleared but systematically updated to reflect the new settings. Searching will continue to work but new content won\'t be inde... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f1829ed696 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_contextual_links/7.x | Implement `menu_contextual_links($module, $parent_path, $args)` in PHP for Drupal 7. Required behavior: Retrieves contextual links for a path based on registered local tasks. | This leverages the menu system to retrieve the first layer of registered local tasks for a given system path. All local tasks of the tab type MENU_CONTEXT_INLINE are taken into account.
For example, when considering the following registered local tasks:
- node/%node/view (default local task) with no 'context' defined
... | function menu_contextual_links($module, $parent_path, $args) {
static $path_empty = array();
$links = array();
// Performance: In case a previous invocation for the same parent path did not
// return any links, we immediately return here.
if (isset($path_empty[$parent_path]) && strpos($parent_path, '%') !== ... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f185c2f5d1 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/locale_translate_import_form/7.x | I need the code for `locale_translate_import_form($form)` in Drupal 7 (modules/locale/locale.admin.inc). It must do this: User interface for the translation import screen. | File: modules/locale/locale.admin.inc | function locale_translate_import_form($form) {
// Get all languages, except English
drupal_static_reset('language_list');
$names = locale_language_list('name');
unset($names['en']);
if (!count($names)) {
$languages = _locale_prepare_predefined_list();
$default = key($languages);
}
else {
$lan... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f18c55e602 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21blog%21blog.module/function/blog_node_view/7.x | I need the code for `blog_node_view($node, $view_mode)` in Drupal 7 (modules/blog/blog.module). It must do this: Implements hook_node_view(). | File: modules/blog/blog.module | function blog_node_view($node, $view_mode) {
if ($view_mode != 'rss') {
if ($node->type == 'blog' && (arg(0) != 'blog' || arg(1) != $node->uid)) {
// This goes to l(), which escapes !username in both title and attributes.
$links['blog_usernames_blog'] = array(
'title' => t("!username's blog", ... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-f19bdd3c46 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.pages.inc/function/user_pass/7.x | Implement `user_pass()` in PHP for Drupal 7. Required behavior: Form builder; Request a password reset. | File: modules/user/user.pages.inc | function user_pass() {
global $user;
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Username or e-mail address'),
'#size' => 60,
'#maxlength' => max(USERNAME_MAX_LENGTH, EMAIL_MAX_LENGTH),
'#required' => TRUE,
'#default_value' => isset($_GET['name']) ? $_GET['name'] : '',
)... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f1b62ff951 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21update%21update.manager.inc/function/update_manager_local_transfers_allowed/7.x | In Drupal 7, write the function `update_manager_local_transfers_allowed()` (file modules/update/update.manager.inc) so that it does the following: Determines if file transfers will be performed locally. | If the server is configured such that webserver-created files have the same owner as the configuration directory (e.g., sites/default) where new code will eventually be installed, the update manager can transfer files entirely locally, without changing their ownership (in other words, without prompting the user for FTP... | function update_manager_local_transfers_allowed() {
// Compare the owner of a webserver-created temporary file to the owner of
// the configuration directory to determine if local transfers will be
// allowed.
$temporary_file = drupal_tempnam('temporary://', 'update_');
$local_transfers_allowed = fileowner($t... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f1b99cda96 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/theme_radios/7.x | I need the code for `theme_radios($variables)` in Drupal 7 (includes/form.inc). It must do this: Returns HTML for a set of radio button form elements. | Parameters:
- $variables: An associative array containing: - element: An associative array containing the properties of the element. Properties used: #title, #value, #options, #description, #required, #attributes, #children.
File: includes/form.inc | function theme_radios($variables) {
$element = $variables['element'];
$attributes = array();
if (isset($element['#id'])) {
$attributes['id'] = $element['#id'];
}
$attributes['class'] = 'form-radios';
if (!empty($element['#attributes']['class'])) {
$attributes['class'] .= ' ' . implode(' ', $element[... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f1d7dc1646 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_get_rdf_namespaces/7.x | I need the code for `drupal_get_rdf_namespaces()` in Drupal 7 (includes/common.inc). It must do this: Returns a string containing RDF namespace declarations for use in XML and XHTML output. | File: includes/common.inc | function drupal_get_rdf_namespaces() {
$xml_rdf_namespaces = array();
// Serializes the RDF namespaces in XML namespace syntax.
if (function_exists('rdf_get_namespaces')) {
foreach (rdf_get_namespaces() as $prefix => $uri) {
$xml_rdf_namespaces[] = 'xmlns:' . $prefix . '="' . $uri . '"';
}
}
re... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f2297d121f | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21poll%21poll.module/function/poll_form/7.x | I need the code for `poll_form($node, &$form_state)` in Drupal 7 (modules/poll/poll.module). It must do this: Implements hook_form(). | File: modules/poll/poll.module | function poll_form($node, &$form_state) {
global $user;
$admin = user_access('bypass node access') || user_access('edit any poll content') || (user_access('edit own poll content') && $user->uid == $node->uid);
$type = node_type_get_type($node);
// The submit handlers to add more poll choices require that thi... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-f22aabf0ac | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21toolbar%21toolbar.module/function/toolbar_pre_render/7.x | I need the code for `toolbar_pre_render($toolbar)` in Drupal 7 (modules/toolbar/toolbar.module). It must do this: Prerender function for the toolbar. | Since building the toolbar takes some time, it is done just prior to rendering to ensure that it is built only if it will be displayed.
File: modules/toolbar/toolbar.module | function toolbar_pre_render($toolbar) {
$toolbar = array_merge($toolbar, toolbar_view());
return $toolbar;
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f242b4e291 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.module/function/aggregator_sanitize_configuration/7.x | In Drupal 7, write the function `aggregator_sanitize_configuration()` (file modules/aggregator/aggregator.module) so that it does the following: Checks and sanitizes the aggregator configuration. | Goes through all fetchers, parsers and processors and checks whether they are available. If one is missing, resets to standard configuration.
Returns: TRUE if this function resets the configuration; FALSE if not.
File: modules/aggregator/aggregator.module | function aggregator_sanitize_configuration() {
$reset = FALSE;
list($fetcher, $parser, $processors) = _aggregator_get_variables();
if (!module_exists($fetcher)) {
$reset = TRUE;
}
if (!module_exists($parser)) {
$reset = TRUE;
}
foreach ($processors as $processor) {
if (!module_exists($processo... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f2583f260c | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_term_view/7.x | In Drupal 7, write the function `taxonomy_term_view($term, $view_mode = 'full', $langcode = NULL)` (file modules/taxonomy/taxonomy.module) so that it does the following: Generate an array for rendering the given term. | Parameters:
- $term: A term object.
- $view_mode: View mode, e.g. 'full', 'teaser'...
- $langcode: (optional) A language code to use for rendering. Defaults to the global content language of the current request.
Returns: An array as expected by drupal_render().
File: modules/taxonomy/taxonomy.module | function taxonomy_term_view($term, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) {
$langcode = $GLOBALS['language_content']->language;
}
// Populate $term->content with a render() array.
taxonomy_term_build_content($term, $view_mode, $langcode);
$build = $term->content;
// We don't n... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f2837249aa | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/system_add_date_format_type_form/7.x | In Drupal 7, write the function `system_add_date_format_type_form($form, &$form_state)` (file modules/system/system.admin.inc) so that it does the following: Add new date type. | File: modules/system/system.admin.inc | function system_add_date_format_type_form($form, &$form_state) {
$form['date_type'] = array(
'#title' => t('Date type'),
'#type' => 'textfield',
'#required' => TRUE,
);
$form['machine_name'] = array(
'#type' => 'machine_name',
'#machine_name' => array(
'exists' => 'system_get_date_types'... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f296c2d879 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21openid%21openid.inc/function/_openid_nonce/7.x | Implement `_openid_nonce()` in PHP for Drupal 7. Required behavior: Return a nonce value - formatted per OpenID spec. | NOTE: This nonce is not cryptographically secure and only suitable for use by the test framework.
File: modules/openid/openid.inc | function _openid_nonce() {
// YYYY-MM-DDThh:mm:ssZ, plus some optional extra unique characters.
return gmdate('Y-m-d\TH:i:s\Z') .
chr(mt_rand(0, 25) + 65) .
chr(mt_rand(0, 25) + 65) .
chr(mt_rand(0, 25) + 65) .
chr(mt_rand(0, 25) + 65);
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f29afd929a | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21file%21file.field.inc/function/file_field_info/7.x | In Drupal 7, write the function `file_field_info()` (file modules/file/file.field.inc) so that it does the following: Implements hook_field_info(). | File: modules/file/file.field.inc | function file_field_info() {
return array(
'file' => array(
'label' => t('File'),
'description' => t('This field stores the ID of a file as an integer value.'),
'settings' => array(
'display_field' => 0,
'display_default' => 0,
'uri_scheme' => variable_get('file_default_s... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-f2a2286261 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.install/function/system_update_7021/7.x | I need the code for `system_update_7021()` in Drupal 7 (modules/system/system.install). It must do this: Change the PHP for settings permission. | File: modules/system/system.install | function system_update_7021() {
db_update('role_permission')
->fields(array('permission' => 'use PHP for settings'))
->condition('permission', 'use PHP for block visibility')
->execute();
} | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f2afb96214 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21locale.inc/function/_locale_import_parse_quoted/7.x | Implement `_locale_import_parse_quoted($string)` in PHP for Drupal 7. Required behavior: Parses a string in quotes | Parameters:
- $string: A string specified with enclosing quotes.
Returns: The string parsed from inside the quotes.
File: includes/locale.inc | function _locale_import_parse_quoted($string) {
if (substr($string, 0, 1) != substr($string, -1, 1)) {
return FALSE; // Start and end quotes must be the same
}
$quote = substr($string, 0, 1);
$string = substr($string, 1, -1);
if ($quote == '"') { // Double quotes: strip slashes
return stripcs... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f2bc70d41e | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.info.inc/function/field_info_cache_clear/7.x | I need the code for `field_info_cache_clear()` in Drupal 7 (modules/field/field.info.inc). It must do this: Clears the field info cache without clearing the field data cache. | This is useful when deleted fields or instances are purged. We need to remove the purged records, but no actual field data items are affected.
File: modules/field/field.info.inc | function field_info_cache_clear() {
drupal_static_reset('field_view_mode_settings');
drupal_static_reset('field_available_languages');
// @todo: Remove this when field_attach_*_bundle() bundle management
// functions are moved to the entity API.
entity_info_cache_clear();
_field_info_collate_types(TRUE);
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f2e87622e5 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_ajax_render_alter/7.x | Give me the example code for `hook_ajax_render_alter(&$commands)` in Drupal 7. Hook description: Alter the commands that are sent to the user through the Ajax framework. | Parameters:
- $commands: An array of all commands that will be sent to the user.
File: modules/system/system.api.php | function hook_ajax_render_alter(&$commands) {
// Inject any new status messages into the content area.
$commands[] = ajax_command_prepend('#block-system-main .content', theme('status_messages'));
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-f2f44a34e9 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.processor.inc/function/aggregator_aggregator_remove/7.x | In Drupal 7, write the function `aggregator_aggregator_remove($feed)` (file modules/aggregator/aggregator.processor.inc) so that it does the following: Implements hook_aggregator_remove(). | File: modules/aggregator/aggregator.processor.inc | function aggregator_aggregator_remove($feed) {
$iids = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchCol();
if ($iids) {
db_delete('aggregator_category_item')
->condition('iid', $iids, 'IN')
->execute();
}
db_delete('aggregator_item')
->con... | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-f2f9fbd9db | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21field.install/function/field_update_7000/7.x | I need the code for `field_update_7000()` in Drupal 7 (modules/field/field.install). It must do this: Field update version placeholder. | File: modules/field/field.install | function field_update_7000() {
// Some update helper functions (such as _update_7000_field_create_field())
// modify the database directly. They can be used safely only if the database
// schema matches the field module schema established for Drupal 7.0 (i.e.
// version 7000). This function exists solely to set... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f3193edf74 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21form.inc/function/form_process_password_confirm/7.x | Implement `form_process_password_confirm($element)` in PHP for Drupal 7. Required behavior: Expand a password_confirm field into two text boxes. | File: includes/form.inc | function form_process_password_confirm($element) {
$element['pass1'] = array(
'#type' => 'password',
'#title' => t('Password'),
'#value' => empty($element['#value']) ? NULL : $element['#value']['pass1'],
'#required' => $element['#required'],
'#attributes' => array('class' => array('password-field... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f32239f546 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21block%21block.admin.inc/function/block_admin_display/7.x | Implement `block_admin_display($theme = NULL)` in PHP for Drupal 7. Required behavior: Menu callback for admin/structure/block. | Parameters:
- $theme: The theme to display the administration page for. If not provided, defaults to the currently used theme.
File: modules/block/block.admin.inc | function block_admin_display($theme = NULL) {
global $theme_key;
drupal_theme_initialize();
if (!isset($theme)) {
// If theme is not specifically set, rehash for the current theme.
$theme = $theme_key;
}
// Fetch and sort blocks.
$blocks = block_admin_display_prepare_blocks($theme);
return dru... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f35770c3fb | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field%21modules%21number%21number.module/function/number_field_widget_info/7.x | In Drupal 7, write the function `number_field_widget_info()` (file modules/field/modules/number/number.module) so that it does the following: Implements hook_field_widget_info(). | File: modules/field/modules/number/number.module | function number_field_widget_info() {
return array(
'number' => array(
'label' => t('Text field'),
'field types' => array('number_integer', 'number_decimal', 'number_float'),
),
);
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-f3586e9415 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21system%21language.api.php/function/hook_language_switch_links_alter/7.x | In Drupal 7, show an example implementation for `hook_language_switch_links_alter(array &$links, $type, $path)` (modules/system/language.api.php): Perform alterations on language switcher links. | A language switcher link may need to point to a different path or use a translated link text before going through l(), which will just handle the path aliases.
Parameters:
- $links: Nested array of links keyed by language code.
- $type: The language type the links will switch.
- $path: The current path.
File: modules... | function hook_language_switch_links_alter(array &$links, $type, $path) {
global $language;
if ($type == LANGUAGE_TYPE_CONTENT && isset($links[$language->language])) {
foreach ($links[$language->language] as $link) {
$link['attributes']['class'][] = 'active-language';
}
}
} | [
"code-task",
"hook-definition"
] | 2026-09-30T00:00:00 |
api-drupal7-f387ef1676 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/watchdog_exception/7.x | I need the code for `watchdog_exception($type, Exception $exception, $message = NULL, $variables = array(), $severity = WATCHDOG_ERROR, $link = NULL)` in Drupal 7 (includes/bootstrap.inc). It must do this: Logs an exception. | This is a wrapper function for watchdog() which automatically decodes an exception.
Parameters:
- $type: The category to which this message belongs.
- $exception: The exception that is going to be logged.
- $message: The message to store in the log. If empty, a text that contains all useful information about the passe... | function watchdog_exception($type, Exception $exception, $message = NULL, $variables = array(), $severity = WATCHDOG_ERROR, $link = NULL) {
// Use a default value if $message is not set.
if (empty($message)) {
// The exception message is run through check_plain() by _drupal_decode_exception().
$message... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f3aac1c291 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21overlay%21overlay.module/function/overlay_user_presave/7.x | Implement `overlay_user_presave(&$edit, $account, $category)` in PHP for Drupal 7. Required behavior: Implements hook_user_presave(). | File: modules/overlay/overlay.module | function overlay_user_presave(&$edit, $account, $category) {
if (isset($edit['overlay'])) {
$edit['data']['overlay'] = $edit['overlay'];
}
} | [
"code-task",
"hook-implementation"
] | 2026-09-30T00:00:00 |
api-drupal7-f3b1a52567 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21field_ui%21field_ui.admin.inc/function/_field_ui_reduce_order/7.x | Implement `_field_ui_reduce_order($array, $a)` in PHP for Drupal 7. Required behavior: Determines the rendering order of an array representing a tree. | Callback for array_reduce() within field_ui_table_pre_render().
File: modules/field_ui/field_ui.admin.inc | function _field_ui_reduce_order($array, $a) {
$array = !isset($array) ? array() : $array;
if ($a['name']) {
$array[] = $a['name'];
}
if (!empty($a['children'])) {
uasort($a['children'], 'drupal_sort_weight');
$array = array_merge($array, array_reduce($a['children'], '_field_ui_reduce_order'));
}
... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f3e9151201 | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_role_revoke_permissions/7.x | I need the code for `user_role_revoke_permissions($rid, array $permissions = array())` in Drupal 7 (modules/user/user.module). It must do this: Revoke permissions from a user role. | Parameters:
- $rid: The ID of a user role to alter.
- $permissions: A list of permission names to revoke.
File: modules/user/user.module | function user_role_revoke_permissions($rid, array $permissions = array()) {
// Revoke permissions for the role.
db_delete('role_permission')
->condition('rid', $rid)
->condition('permission', $permissions, 'IN')
->execute();
// Clear the user access cache.
drupal_static_reset('user_access');
drup... | [
"code-task",
"function"
] | 2026-09-30T00:00:00 |
api-drupal7-f3f490a0ab | 7 | drupal_api_code | https://api.drupal.org/api/drupal/modules%21color%21color.module/function/_color_blend/7.x | In Drupal 7, write the function `_color_blend($img, $hex1, $hex2, $alpha)` (file modules/color/color.module) so that it does the following: Blends two hex colors and returns the GD color. | File: modules/color/color.module | function _color_blend($img, $hex1, $hex2, $alpha) {
$in1 = _color_unpack($hex1);
$in2 = _color_unpack($hex2);
$out = array($img);
for ($i = 0; $i < 3; ++$i) {
$out[] = (int) ($in1[$i] + ($in2[$i] - $in1[$i]) * $alpha);
}
return call_user_func_array('imagecolorallocate', $out);
} | [
"code-task",
"function"
] | 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.