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-37e5d5f24c
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21modules%21number%21number.module/function/number_field_formatter_view/7.x
I need the code for `number_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)` in Drupal 7 (modules/field/modules/number/number.module). It must do this: Implements hook_field_formatter_view().
File: modules/field/modules/number/number.module
function number_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { $element = array(); $settings = $display['settings']; switch ($display['type']) { case 'number_integer': case 'number_decimal': foreach ($items as $delta => $item) { $output = numbe...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-37f753a6e9
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.admin.inc/function/_shortcut_link_form_elements/7.x
Implement `_shortcut_link_form_elements($shortcut_link = NULL)` in PHP for Drupal 7. Required behavior: Helper function for building a form for adding or editing shortcut links.
Parameters: - $shortcut_link: (optional) An array representing the shortcut link that will be edited. If not provided, a new link will be created. Returns: An array of form elements. File: modules/shortcut/shortcut.admin.inc
function _shortcut_link_form_elements($shortcut_link = NULL) { if (!isset($shortcut_link)) { $shortcut_link = array( 'link_title' => '', 'link_path' => '' ); } else { $shortcut_link['link_path'] = ($shortcut_link['link_path'] == '<front>') ? '' : drupal_get_path_alias($shortcut_link['link_...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-38066245d2
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21locale%21locale.install/function/locale_update_7004/7.x
I need the code for `locale_update_7004()` in Drupal 7 (modules/locale/locale.install). It must do this: Remove duplicates in {locales_source}.
File: modules/locale/locale.install
function locale_update_7004() { // Look up all duplicates. For each set of duplicates, we select the row // with the lowest lid as the "master" that will be preserved. $result_source = db_query("SELECT MIN(lid) AS lid, source, context FROM {locales_source} WHERE textgroup = 'default' GROUP BY source, context HAVI...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-38068e66fb
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21modules%21field_sql_storage%21field_sql_storage.module/function/_field_sql_storage_schema/7.x
I need the code for `_field_sql_storage_schema($field)` in Drupal 7 (modules/field/modules/field_sql_storage/field_sql_storage.module). It must do this: Return the database schema for a field. This may contain one or more tables. Each table will contain the columns relevant for the specified field. Leave the $field's '...
Parameters: - $field: The field structure for which to generate a database schema. Returns: One or more tables representing the schema for the field. File: modules/field/modules/field_sql_storage/field_sql_storage.module
function _field_sql_storage_schema($field) { $deleted = $field['deleted'] ? 'deleted ' : ''; $current = array( 'description' => "Data storage for {$deleted}field {$field['id']} ({$field['field_name']})", 'fields' => array( 'entity_type' => array( 'type' => 'varchar', 'length' => 128, ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-383201f226
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_permission/7.x
In Drupal 7, write the function `node_permission()` (file modules/node/node.module) so that it does the following: Implements hook_permission().
File: modules/node/node.module
function node_permission() { $perms = array( 'bypass node access' => array( 'title' => t('Bypass content access control'), 'description' => t('View, edit and delete all content regardless of permission restrictions.'), 'restrict access' => TRUE, ), 'administer content types' => array( ...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3837dc3d84
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21form.inc/function/form_type_image_button_value/7.x
In Drupal 7, write the function `form_type_image_button_value($form, $input, $form_state)` (file includes/form.inc) so that it does the following: Determines the value for an image button form element.
Parameters: - $form: The form element whose value is being populated. - $input: The incoming input to populate the form element. If this is FALSE, the element's default value should be returned. - $form_state: A keyed array containing the current state of the form. Returns: The data that will appear in $form_state['va...
function form_type_image_button_value($form, $input, $form_state) { if ($input !== FALSE) { if (!empty($input)) { // If we're dealing with Mozilla or Opera, we're lucky. It will // return a proper value, and we can get on with things. return $form['#return_value']; } else { // Unfo...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-38397b0901
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21comment%21comment.admin.inc/function/comment_confirm_delete_submit/7.x
In Drupal 7, write the function `comment_confirm_delete_submit($form, &$form_state)` (file modules/comment/comment.admin.inc) so that it does the following: Process comment_confirm_delete form submissions.
File: modules/comment/comment.admin.inc
function comment_confirm_delete_submit($form, &$form_state) { $comment = $form['#comment']; // Delete the comment and its replies. comment_delete($comment->cid); drupal_set_message(t('The comment and all its replies have been deleted.')); watchdog('content', 'Deleted comment @cid and its replies.', array('@ci...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3855d293e6
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.install/function/node_update_7012/7.x
Implement `node_update_7012()` in PHP for Drupal 7. Required behavior: Switches body fields to untranslatable while upgrading from D6 and makes them language neutral.
File: modules/node/node.install
function node_update_7012() { // If we are upgrading from D6, then body fields should be set back to // untranslatable, as D6 did not know about the idea of translating fields, // but only nodes. If a D7 > D7 update is running we need to skip this update, // as it is a valid use case to have translatable body f...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-38688dbc40
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21menu%21menu.install/function/menu_update_7001/7.x
In Drupal 7, write the function `menu_update_7001()` (file modules/menu/menu.install) so that it does the following: Rename "Primary Links" and "Secondary Links" to their Drupal 7 equivalents.
File: modules/menu/menu.install
function menu_update_7001() { // Migrate D6 menu_primary_links_source to D7 menu_main_links_source (without // renaming). if (variable_get('menu_primary_links_source') !== NULL) { variable_set('menu_main_links_source', variable_get('menu_primary_links_source')); variable_del('menu_primary_links_source'); ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3876a20d2e
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.install/function/taxonomy_update_7010/7.x
I need the code for `taxonomy_update_7010()` in Drupal 7 (modules/taxonomy/taxonomy.install). It must do this: Change {taxonomy_index}.created to support signed int.
File: modules/taxonomy/taxonomy.install
function taxonomy_update_7010() { db_change_field('taxonomy_index', 'created', 'created', array( 'description' => 'The Unix timestamp when the node was created.', 'type' => 'int', 'unsigned' => FALSE, 'not null' => TRUE, 'default'=> 0, )); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-388ad4824d
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21theme.inc/function/drupal_theme_rebuild/7.x
Implement `drupal_theme_rebuild()` in PHP for Drupal 7. Required behavior: Forces the system to rebuild the theme registry.
This function should be called when modules are added to the system, or when a dynamic system needs to add more theme hooks. File: includes/theme.inc
function drupal_theme_rebuild() { drupal_static_reset('theme_get_registry'); cache_clear_all('theme_registry', 'cache', TRUE); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-389a566d48
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.crud.inc/function/field_purge_batch/7.x
In Drupal 7, write the function `field_purge_batch($batch_size)` (file modules/field/field.crud.inc) so that it does the following: Purges a batch of deleted Field API data, instances, or fields.
This function will purge deleted field data in batches. The batch size is defined as an argument to the function, and once each batch is finished, it continues with the next batch until all have completed. If a deleted field instance with no remaining data records is found, the instance itself will be purged. If a dele...
function field_purge_batch($batch_size) { // Retrieve all deleted field instances. We cannot use field_info_instances() // because that function does not return deleted instances. $instances = field_read_instances(array('deleted' => 1), array('include_deleted' => 1)); foreach ($instances as $instance) { //...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-38a86c952b
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21openid%21openid.module/function/openid_user_insert/7.x
I need the code for `openid_user_insert(&$edit, $account, $category)` in Drupal 7 (modules/openid/openid.module). It must do this: Implements hook_user_insert().
File: modules/openid/openid.module
function openid_user_insert(&$edit, $account, $category) { if (!empty($edit['openid_claimed_id'])) { // The user has registered after trying to log in via OpenID. if (variable_get('user_email_verification', TRUE)) { drupal_set_message(t('Once you have verified your e-mail address, you may log in via Ope...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-38bf2455df
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_role_permissions/7.x
In Drupal 7, write the function `user_role_permissions($roles = array())` (file modules/user/user.module) so that it does the following: Determine the permissions for one or more roles.
Parameters: - $roles: An array whose keys are the role IDs of interest, such as $user->roles. Returns: If $roles is a non-empty array, an array indexed by role ID is returned. Each value is an array whose keys are the permission strings for the given role ID. If $roles is empty nothing is returned. File: modules/user...
function user_role_permissions($roles = array()) { $cache = &drupal_static(__FUNCTION__, array()); $role_permissions = $fetch = array(); if ($roles) { foreach ($roles as $rid => $name) { if (isset($cache[$rid])) { $role_permissions[$rid] = $cache[$rid]; } else { // Add this...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-38fe1a96eb
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21dblog%21dblog.admin.inc/function/dblog_clear_log_submit/7.x
I need the code for `dblog_clear_log_submit()` in Drupal 7 (modules/dblog/dblog.admin.inc). It must do this: Form submission handler for dblog_clear_log_form().
File: modules/dblog/dblog.admin.inc
function dblog_clear_log_submit() { $_SESSION['dblog_overview_filter'] = array(); db_truncate('watchdog')->execute(); drupal_set_message(t('Database log cleared.')); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-390e86c086
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_unserialize/7.x
In Drupal 7, write the function `menu_unserialize($data, $map)` (file includes/menu.inc) so that it does the following: Unserializes menu data, using a map to replace path elements.
The menu system stores various path-related information (such as the 'page arguments' and 'access arguments' components of a menu item) in the database using serialized arrays, where integer values in the arrays represent arguments to be replaced by values from the path. This function first unserializes such menu infor...
function menu_unserialize($data, $map) { if ($data = unserialize($data)) { foreach ($data as $k => $v) { if (is_int($v)) { $data[$k] = isset($map[$v]) ? $map[$v] : ''; } } return $data; } else { return array(); } }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-391940e549
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_date_formats_alter/7.x
Give me the example code for `hook_date_formats_alter(&$formats)` in Drupal 7. Hook description: Alter date formats declared by another module.
Called by _system_date_format_types_build() to allow modules to alter the return values from implementations of hook_date_formats(). File: modules/system/system.api.php
function hook_date_formats_alter(&$formats) { foreach ($formats as $id => $format) { $formats[$id]['locales'][] = 'en-ca'; } }
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-391963d5c4
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.api.php/function/hook_taxonomy_vocabulary_load/7.x
In Drupal 7, show an example implementation for `hook_taxonomy_vocabulary_load($vocabularies)` (modules/taxonomy/taxonomy.api.php): Act on taxonomy vocabularies when loaded.
Modules implementing this hook can act on the vocabulary objects before they are returned by taxonomy_vocabulary_load_multiple(). Parameters: - $vocabulary: An array of taxonomy vocabulary objects. File: modules/taxonomy/taxonomy.api.php
function hook_taxonomy_vocabulary_load($vocabularies) { $result = db_select('mytable', 'm') ->fields('m', array('vid', 'foo')) ->condition('m.vid', array_keys($vocabularies), 'IN') ->execute(); foreach ($result as $record) { $vocabularies[$record->vid]->foo = $record->foo; } }
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-393fe8a2bb
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.install/function/node_update_7011/7.x
In Drupal 7, write the function `node_update_7011()` (file modules/node/node.install) so that it does the following: Update the database from Drupal 6 to match the schema.
File: modules/node/node.install
function node_update_7011() { // Drop node moderation field. db_drop_field('node', 'moderate'); db_drop_index('node', 'node_moderate'); // Change {node_revision}.status field to default to 1. db_change_field('node_revision', 'status', 'status', array( 'type' => 'int', 'not null' => TRUE, 'default...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-39416e2ae0
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21image%21image.admin.inc/function/image_effect_scale_validate/7.x
Implement `image_effect_scale_validate($element, &$form_state)` in PHP for Drupal 7. Required behavior: Element validate handler to ensure that either a height or a width is specified.
File: modules/image/image.admin.inc
function image_effect_scale_validate($element, &$form_state) { if (empty($element['width']['#value']) && empty($element['height']['#value'])) { form_error($element, t('Width and height can not both be blank.')); } }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-394f5cd7c6
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_hmac_base64/7.x
I need the code for `drupal_hmac_base64($data, $key)` in Drupal 7 (includes/bootstrap.inc). It must do this: Calculates a base-64 encoded, URL-safe sha-256 hmac.
Parameters: - $data (string): String to be validated with the hmac. - $key (string): A secret string key. Returns (string): A base-64 encoded sha-256 hmac, with + replaced with -, / with _ and any = padding characters removed. File: includes/bootstrap.inc
function drupal_hmac_base64($data, $key) { // Casting $data and $key to strings here is necessary to avoid empty string // results of the hash function if they are not scalar values. As this // function is used in security-critical contexts like token validation it is // important that it never returns an empty...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-395dbd086d
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21session.inc/function/_drupal_session_read/7.x
Implement `_drupal_session_read($sid)` in PHP for Drupal 7. Required behavior: Reads an entire session from the database (internal use only).
Also initializes the $user object for the user associated with the session. This function is registered with session_set_save_handler() to support database-backed sessions. It is called on every page load when PHP sets up the $_SESSION superglobal. This function is an internal function and must not be called directly....
function _drupal_session_read($sid) { global $user, $is_https; // Write and Close handlers are called after destructing objects // since PHP 5.0.5. // Thus destructors can use sessions but session handler can't use objects. // So we are moving session closure before destructing objects. drupal_register_shu...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3964654ccb
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21locale%21locale.module/function/locale_language_list/7.x
I need the code for `locale_language_list($field = 'name', $all = FALSE)` in Drupal 7 (modules/locale/locale.module). It must do this: Returns array of language names
Parameters: - $field: 'name' => names in current language, localized 'native' => native names - $all: Boolean to return all languages or only enabled ones File: modules/locale/locale.module
function locale_language_list($field = 'name', $all = FALSE) { if ($all) { $languages = language_list(); } else { $languages = language_list('enabled'); $languages = $languages[1]; } $list = array(); foreach ($languages as $language) { $list[$language->language] = ($field == 'name') ? t($lan...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3977392dcf
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21book%21book.module/function/book_node_view_link/7.x
I need the code for `book_node_view_link($node, $view_mode)` in Drupal 7 (modules/book/book.module). It must do this: Adds relevant book links to the node's links.
Parameters: - $node: The book page node to add links to. - $view_mode: The view mode of the node. File: modules/book/book.module
function book_node_view_link($node, $view_mode) { $links = array(); if (isset($node->book['depth'])) { if ($view_mode == 'full' && node_is_page($node)) { $child_type = variable_get('book_child_type', 'book'); if ((user_access('add content to books') || user_access('administer book outlines')) && no...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-39833e7fe9
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21openid%21openid.module/function/openid_menu_site_status_alter/7.x
In Drupal 7, write the function `openid_menu_site_status_alter(&$menu_site_status, $path)` (file modules/openid/openid.module) so that it does the following: Implements hook_menu_site_status_alter().
File: modules/openid/openid.module
function openid_menu_site_status_alter(&$menu_site_status, $path) { // Allow access to openid/authenticate even if site is in offline mode. if ($menu_site_status == MENU_SITE_OFFLINE && user_is_anonymous() && $path == 'openid/authenticate') { $menu_site_status = MENU_SITE_ONLINE; } }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3988371ab4
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21modules%21list%21list.module/function/list_help/7.x
Implement `list_help($path, $arg)` in PHP for Drupal 7. Required behavior: Implements hook_help().
File: modules/field/modules/list/list.module
function list_help($path, $arg) { switch ($path) { case 'admin/help#list': $output = ''; $output .= '<h3>' . t('About') . '</h3>'; $output .= '<p>' . t('The List module defines various fields for storing a list of items, for use with the Field module. Usually these items are entered through a se...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-39abbe8ce6
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_access/7.x
I need the code for `user_access($string, $account = NULL)` in Drupal 7 (modules/user/user.module). It must do this: Determine whether the user has a given privilege.
Parameters: - $string: The permission, such as "administer nodes", being checked for. - $account: (optional) The account to check, if not given use currently logged in user. Returns (Boolean): TRUE if the user has the requested permission. All permission checks in Drupal should go through this function. This way, we g...
function user_access($string, $account = NULL) { global $user; if (!isset($account)) { $account = $user; } // User #1 has all privileges: if ($account->uid == 1) { return TRUE; } // To reduce the number of SQL queries, we cache the user's permissions // in a static variable. // Use the adva...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-39aed2dea9
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21image.gd.inc/function/image_gd_check_settings/7.x
In Drupal 7, write the function `image_gd_check_settings()` (file modules/system/image.gd.inc) so that it does the following: Verify GD2 settings (that the right version is actually installed).
Returns: A boolean indicating if the GD toolkit is available on this machine. File: modules/system/image.gd.inc
function image_gd_check_settings() { // GD2 support is available. return function_exists('imagegd2'); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-39f1cbe0e1
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/registry_update/7.x
I need the code for `registry_update()` in Drupal 7 (includes/bootstrap.inc). It must do this: Updates the registry based on the latest files listed in the database.
This function should be used when system_rebuild_module_data() does not need to be called, because it is already known that the list of files in the {system} table matches those in the file system. Returns: TRUE if the registry was rebuilt, FALSE if another thread was rebuilding in parallel and the current thread just...
function registry_update() { // install_system_module() calls module_enable() which calls into this // function during initial system installation, so the lock system is neither // loaded nor does its storage exist yet. $in_installer = drupal_installation_attempted(); if (!$in_installer && !lock_acquire(__FUN...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-39f683ebf6
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21comment%21comment.api.php/function/hook_comment_presave/7.x
Give me the example code for `hook_comment_presave($comment)` in Drupal 7. Hook description: The comment passed validation and is about to be saved.
Modules may make changes to the comment before it is saved to the database. Parameters: - $comment: The comment object. File: modules/comment/comment.api.php
function hook_comment_presave($comment) { // Remove leading & trailing spaces from the comment subject. $comment->subject = trim($comment->subject); }
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-39fe15054a
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_implode_tags/7.x
Implement `taxonomy_implode_tags($tags, $vid = NULL)` in PHP for Drupal 7. Required behavior: Implodes a list of tags of a certain vocabulary into a string.
File: modules/taxonomy/taxonomy.module
function taxonomy_implode_tags($tags, $vid = NULL) { $typed_tags = array(); foreach ($tags as $tag) { // Extract terms belonging to the vocabulary in question. if (!isset($vid) || $tag->vid == $vid) { // Make sure we have a completed loaded taxonomy term. if (isset($tag->name)) { // Comm...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3a054b0101
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21language.inc/function/language_negotiation_info/7.x
In Drupal 7, write the function `language_negotiation_info()` (file includes/language.inc) so that it does the following: Returns all the defined language negotiation providers.
Returns: An array of language negotiation providers. File: includes/language.inc
function language_negotiation_info() { $language_providers = &drupal_static(__FUNCTION__); if (!isset($language_providers)) { // Collect all the module-defined language negotiation providers. $language_providers = module_invoke_all('language_negotiation_info'); // Add the default language negotiation ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3a0e5ab98e
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21path%21path.module/function/path_menu/7.x
I need the code for `path_menu()` in Drupal 7 (modules/path/path.module). It must do this: Implements hook_menu().
File: modules/path/path.module
function path_menu() { $items['admin/config/search/path'] = array( 'title' => 'URL aliases', 'description' => "Change your site's URL paths by aliasing them.", 'page callback' => 'path_admin_overview', 'access arguments' => array('administer url aliases'), 'weight' => -5, 'file' => 'path.admin...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3a165b29ff
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21color%21color.module/function/color_theme/7.x
In Drupal 7, write the function `color_theme()` (file modules/color/color.module) so that it does the following: Implements hook_theme().
File: modules/color/color.module
function color_theme() { return array( 'color_scheme_form' => array( 'render element' => 'form', ), ); }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3a19cfb799
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21form.inc/function/form_process_machine_name/7.x
In Drupal 7, write the function `form_process_machine_name($element, &$form_state)` (file includes/form.inc) so that it does the following: Processes a machine-readable name form element.
Parameters: - $element: The form element to process. Properties used: - #machine_name: An associative array containing: - exists: A function name to invoke for checking whether a submitted machine name value already exists. The submitted value is passed as argument. In most cases, an existing API or menu argument loade...
function form_process_machine_name($element, &$form_state) { // Apply default form element properties. $element += array( '#title' => t('Machine-readable name'), '#description' => t('A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.'), '#machine_name' => array...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3a25424b44
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_query_alter/7.x
Give me the example code for `hook_query_alter(QueryAlterableInterface $query)` in Drupal 7. Hook description: Perform alterations to a structured query.
Structured (aka dynamic) queries that have tags associated may be altered by any module before the query is executed. Parameters: - $query: A Query object describing the composite parts of a SQL query. File: modules/system/system.api.php
function hook_query_alter(QueryAlterableInterface $query) { if ($query->hasTag('micro_limit')) { $query->range(0, 2); } }
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-3a4124d13b
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21modules%21options%21options.module/function/options_array_flatten/7.x
Implement `options_array_flatten($array)` in PHP for Drupal 7. Required behavior: Flattens an array of allowed values.
Parameters: - $array: A single or multidimensional array. Returns: A flattened array. File: modules/field/modules/options/options.module
function options_array_flatten($array) { $result = array(); if (is_array($array)) { foreach ($array as $key => $value) { if (is_array($value)) { $result += options_array_flatten($value); } else { $result[$key] = $value; } } } return $result; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3a4670911a
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21filter%21filter.admin.inc/function/filter_admin_format_form/7.x
I need the code for `filter_admin_format_form($form, &$form_state, $format)` in Drupal 7 (modules/filter/filter.admin.inc). It must do this: Form constructor for the text format add/edit form.
Parameters: - $format: A format object having the properties: - format: A machine-readable name representing the ID of the text format to save. If this corresponds to an existing text format, that format will be updated; otherwise, a new format will be created. - name: The title of the text format. - cache: An integer ...
function filter_admin_format_form($form, &$form_state, $format) { $is_fallback = ($format->format == filter_fallback_format()); $form['#format'] = $format; $form['#tree'] = TRUE; $form['#attached']['js'][] = drupal_get_path('module', 'filter') . '/filter.admin.js'; $form['#attached']['css'][] = drupal_get_pa...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3a49b08e3b
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_image_style_save/7.x
I need the code for `image_image_style_save($style)` in Drupal 7 (modules/image/image.module). It must do this: Implements hook_image_style_save().
File: modules/image/image.module
function image_image_style_save($style) { if (isset($style['old_name']) && $style['old_name'] != $style['name']) { $instances = field_read_instances(); // Loop through all fields searching for image fields. foreach ($instances as $instance) { if ($instance['widget']['module'] == 'image') { $...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3a4d95e0f1
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21rdf%21rdf.module/function/rdf_modules_installed/7.x
I need the code for `rdf_modules_installed($modules)` in Drupal 7 (modules/rdf/rdf.module). It must do this: Implements hook_modules_installed().
Checks if the installed modules have any RDF mapping definitions to declare and stores them in the rdf_mapping table. While both default entity mappings and specific bundle mappings can be defined in hook_rdf_mapping(), default entity mappings are not stored in the database. Only overridden mappings are stored in the ...
function rdf_modules_installed($modules) { foreach ($modules as $module) { $function = $module . '_rdf_mapping'; if (function_exists($function)) { foreach ($function() as $mapping) { // Only the bundle mappings are saved in the database. if ($mapping['bundle'] !== RDF_DEFAULT_BUNDLE) { ...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3a545b64a3
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21path%21path.admin.inc/function/path_admin_form_validate/7.x
In Drupal 7, write the function `path_admin_form_validate($form, &$form_state)` (file modules/path/path.admin.inc) so that it does the following: Form validation handler for path_admin_form().
File: modules/path/path.admin.inc
function path_admin_form_validate($form, &$form_state) { $source = &$form_state['values']['source']; $source = drupal_get_normal_path($source); $alias = $form_state['values']['alias']; $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0; // Language is only set if locale module is en...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3a564d7c27
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21tracker%21tracker.module/function/tracker_help/7.x
Implement `tracker_help($path, $arg)` in PHP for Drupal 7. Required behavior: Implements hook_help().
File: modules/tracker/tracker.module
function tracker_help($path, $arg) { switch ($path) { case 'admin/help#tracker': $output = '<h3>' . t('About') . '</h3>'; $output .= '<p>' . t('The Tracker module displays the most recently added and updated content on your site, and allows you to follow new content created by each user. This module h...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3a5ac6c638
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21tracker%21tracker.pages.inc/function/tracker_page/7.x
Implement `tracker_page($account = NULL, $set_title = FALSE)` in PHP for Drupal 7. Required behavior: Page callback: prints a listing of active nodes on the site.
Queries the database for info, adds RDFa info if applicable, and generates the render array that will be used to render the page. File: modules/tracker/tracker.pages.inc
function tracker_page($account = NULL, $set_title = FALSE) { if ($account) { $query = db_select('tracker_user', 't')->extend('PagerDefault'); $query->condition('t.uid', $account->uid); if ($set_title) { // When viewed from user/%user/track, display the name of the user // as page title -- the...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3a9d8df120
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21actions.inc/function/actions_synchronize/7.x
Implement `actions_synchronize($delete_orphans = FALSE)` in PHP for Drupal 7. Required behavior: Synchronizes actions that are provided by modules in hook_action_info().
Actions provided by modules in hook_action_info() implementations are synchronized with actions that are stored in the actions database table. This is necessary so that actions that do not require configuration can receive action IDs. Parameters: - $delete_orphans: If TRUE, any actions that exist in the database but a...
function actions_synchronize($delete_orphans = FALSE) { $actions_in_code = actions_list(TRUE); $actions_in_db = db_query("SELECT aid, callback, label FROM {actions} WHERE parameters = ''")->fetchAllAssoc('callback', PDO::FETCH_ASSOC); // Go through all the actions provided by modules. foreach ($actions_in_code...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3a9e066dec
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21openid%21openid.inc/function/_openid_is_xri/7.x
In Drupal 7, write the function `_openid_is_xri($identifier)` (file modules/openid/openid.inc) so that it does the following: Determine if the given identifier is an XRI ID.
File: modules/openid/openid.inc
function _openid_is_xri($identifier) { // Strip the xri:// scheme from the identifier if present. if (stripos($identifier, 'xri://') === 0) { $identifier = substr($identifier, 6); } // Test whether the identifier starts with an XRI global context symbol or (. $firstchar = substr($identifier, 0, 1); if ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3aa7e5d7e1
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21openid%21openid.api.php/function/hook_openid/7.x
Give me the example code for `hook_openid($op, $request)` in Drupal 7. Hook description: Allow modules to modify the OpenID request parameters.
Parameters: - $op: The operation to be performed. Possible values: - request: Modify parameters before they are sent to the OpenID provider. - $request: An associative array of parameter defaults to which to modify or append. Returns: An associative array of parameters to be merged with the default list. File: module...
function hook_openid($op, $request) { if ($op == 'request') { $request['openid.identity'] = 'http://myname.myopenid.com/'; } return $request; }
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-3ab85fd817
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21locale%21locale.admin.inc/function/locale_languages_delete_form_submit/7.x
Implement `locale_languages_delete_form_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Process language deletion submissions.
File: modules/locale/locale.admin.inc
function locale_languages_delete_form_submit($form, &$form_state) { $languages = language_list(); if (isset($languages[$form_state['values']['langcode']])) { // Remove translations first. db_delete('locales_target') ->condition('language', $form_state['values']['langcode']) ->execute(); cach...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3ad30cef64
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_block_configure/7.x
Implement `comment_block_configure($delta = '')` in PHP for Drupal 7. Required behavior: Implements hook_block_configure().
File: modules/comment/comment.module
function comment_block_configure($delta = '') { $form['comment_block_count'] = array( '#type' => 'select', '#title' => t('Number of recent comments'), '#default_value' => variable_get('comment_block_count', 10), '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3ade200e0d
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.install/function/_update_7000_node_get_types/7.x
Implement `_update_7000_node_get_types()` in PHP for Drupal 7. Required behavior: Utility function: fetch the node types directly from the database.
This function is valid for a database schema version 7000. File: modules/node/node.install
function _update_7000_node_get_types() { $node_types = db_query('SELECT * FROM {node_type}')->fetchAllAssoc('type', PDO::FETCH_OBJ); // Create default settings for orphan nodes. $all_types = db_query('SELECT DISTINCT type FROM {node}')->fetchCol(); $extra_types = array_diff($all_types, array_keys($node_types))...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3ae8f3f780
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_field_delete_instance/7.x
Implement `image_field_delete_instance($instance)` in PHP for Drupal 7. Required behavior: Implements hook_field_delete_instance().
File: modules/image/image.module
function image_field_delete_instance($instance) { // Only act on image fields. $field = field_read_field($instance['field_name']); if ($field['type'] != 'image') { return; } // The value of a managed_file element can be an array if the #extended // property is set to TRUE. $fid = $instance['settings'...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3b32e98b20
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_has_role/7.x
Implement `user_has_role($rid, $account = NULL)` in PHP for Drupal 7. Required behavior: Checks if a user has a role.
Parameters: - $rid (int): A role ID. - $account (object|null): (optional) A user account. Defaults to the current user. Returns (bool): TRUE if the user has the role, or FALSE if not. File: modules/user/user.module
function user_has_role($rid, $account = NULL) { if (!$account) { $account = $GLOBALS['user']; } return isset($account->roles[$rid]); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3b45393038
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21menu.inc/function/_menu_item_localize/7.x
Implement `_menu_item_localize(&$item, $map, $link_translate = FALSE)` in PHP for Drupal 7. Required behavior: Localizes the router item title using t() or another callback.
Translate the title and description to allow storage of English title strings in the database, yet display of them in the language required by the current user. Parameters: - $item: A menu router item or a menu link item. - $map: The path as an array with objects already replaced. E.g., for path node/123 $map would be...
function _menu_item_localize(&$item, $map, $link_translate = FALSE) { $callback = $item['title_callback']; $item['localized_options'] = $item['options']; // All 'class' attributes are assumed to be an array during rendering, but // links stored in the database may use an old string value. // @todo In order to...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3b535edb82
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_secondary_menu/7.x
In Drupal 7, write the function `menu_secondary_menu()` (file includes/menu.inc) so that it does the following: Returns an array of links to be rendered as the Secondary links.
File: includes/menu.inc
function menu_secondary_menu() { // If the secondary menu source is set as the primary menu, we display the // second level of the primary menu. if (variable_get('menu_secondary_links_source', 'user-menu') == variable_get('menu_main_links_source', 'main-menu')) { return menu_navigation_links(variable_get('me...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3b676a07f4
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_access_write_grants/7.x
In Drupal 7, write the function `node_access_write_grants($node, $grants, $realm = NULL, $delete = TRUE)` (file modules/node/node.module) so that it does the following: Writes a list of grants to the database, deleting any previously saved ones.
If a realm is provided, it will only delete grants from that realm, but it will always delete a grant from the 'all' realm. Modules that utilize node_access() can use this function when doing mass updates due to widespread permission changes. Note: Don't call this function directly from a contributed module. Call node...
function node_access_write_grants($node, $grants, $realm = NULL, $delete = TRUE) { if ($delete) { $query = db_delete('node_access')->condition('nid', $node->nid); if ($realm) { $query->condition('realm', array($realm, 'all'), 'IN'); } $query->execute(); } // Only perform work when node_acce...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3b7f59d5d6
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21image%21image.module/function/image_style_effects/7.x
I need the code for `image_style_effects($style)` in Drupal 7 (modules/image/image.module). It must do this: Loads all the effects for an image style.
Parameters: - $style (array): An image style array containing: - isid: The unique image style ID that contains this image effect. Returns (array): An array of image effects associated with specified image style in the format array('isid' => array()), or an empty array if the specified style has no effects. File: modu...
function image_style_effects($style) { $effects = image_effects(); $style_effects = array(); foreach ($effects as $effect) { if ($style['isid'] == $effect['isid']) { $style_effects[$effect['ieid']] = $effect; } } return $style_effects; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3b827d46f9
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21dashboard%21dashboard.module/function/dashboard_is_visible/7.x
In Drupal 7, write the function `dashboard_is_visible()` (file modules/dashboard/dashboard.module) so that it does the following: Determines if the dashboard should be displayed on the current page.
This function checks if the user is currently viewing the dashboard and has access to see it. It is used by other functions in the dashboard module to decide whether or not the dashboard content should be displayed to the current user. Although the menu system normally handles the above tasks, it only does so for the ...
function dashboard_is_visible() { static $is_visible; if (!isset($is_visible)) { // If the current menu item represents the page on which we want to display // the dashboard, and if the current user has access to see it, return // TRUE. $menu_item = menu_get_item(); $is_visible = isset($menu_ite...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3b84c2b25d
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21block%21block.api.php/function/hook_block_info_alter/7.x
Give me the example code for `hook_block_info_alter(&$blocks, $theme, $code_blocks)` in Drupal 7. Hook description: Change block definition before saving to the database.
Parameters: - $blocks: A multidimensional array of blocks keyed by the defining module and delta; the values are blocks returned by hook_block_info(). This hook is fired after the blocks are collected from hook_block_info() and the database, right before saving back to the database. - $theme: The theme these blocks bel...
function hook_block_info_alter(&$blocks, $theme, $code_blocks) { // Disable the login block. $blocks['user']['login']['status'] = 0; }
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-3b8f7b6331
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21menu%21menu.module/function/menu_form_node_form_alter/7.x
Implement `menu_form_node_form_alter(&$form, $form_state)` in PHP for Drupal 7. Required behavior: Implements hook_form_BASE_FORM_ID_alter().
Adds menu item fields to the node form. File: modules/menu/menu.module
function menu_form_node_form_alter(&$form, $form_state) { // Generate a list of possible parents (not including this link or descendants). // @todo This must be handled in a #process handler. $link = $form['#node']->menu; $type = $form['#node']->type; // menu_parent_options() is goofy and can actually handle ...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3b98d047ff
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21node%21node.install/function/node_update_7009/7.x
In Drupal 7, write the function `node_update_7009()` (file modules/node/node.install) so that it does the following: Convert node languages from the empty string to LANGUAGE_NONE.
File: modules/node/node.install
function node_update_7009() { db_update('node') ->fields(array('language' => LANGUAGE_NONE)) ->condition('language', '') ->execute(); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3ba04720b1
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.admin.inc/function/theme_system_themes_page/7.x
Implement `theme_system_themes_page($variables)` in PHP for Drupal 7. Required behavior: Returns HTML for the Appearance page.
Parameters: - $variables: An associative array containing: - theme_groups: An associative array containing groups of themes. File: modules/system/system.admin.inc
function theme_system_themes_page($variables) { $theme_groups = $variables['theme_groups']; $output = '<div id="system-themes-page">'; foreach ($variables['theme_group_titles'] as $state => $title) { if (!count($theme_groups[$state])) { // Skip this group of themes if no theme is there. continue...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3ba3661dcf
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21update%21update.authorize.inc/function/update_authorize_batch_copy_project/7.x
Implement `update_authorize_batch_copy_project($project, $updater_name, $local_url, $filetransfer, &$context)` in PHP for Drupal 7. Required behavior: Implements callback_batch_operation().
Copies project to its proper place when authorized to do so. Parameters: - $project (string): The canonical short name of the project being installed. - $updater_name (string): The name of the Updater class to use for installing this project. - $local_url (string): The URL to the locally installed temp directory where...
function update_authorize_batch_copy_project($project, $updater_name, $local_url, $filetransfer, &$context) { // Initialize some variables in the Batch API $context array. if (!isset($context['results']['log'])) { $context['results']['log'] = array(); } if (!isset($context['results']['log'][$project])) { ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3ba450fe57
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21rdf%21rdf.module/function/rdf_help/7.x
Implement `rdf_help($path, $arg)` in PHP for Drupal 7. Required behavior: Implements hook_help().
File: modules/rdf/rdf.module
function rdf_help($path, $arg) { switch ($path) { case 'admin/help#rdf': $output = ''; $output .= '<h3>' . t('About') . '</h3>'; $output .= '<p>' . t('The RDF module enriches your content with metadata to let other applications (e.g., search engines, aggregators, and so on) better understand its...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3bba9f2c96
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21menu.inc/function/_menu_check_rebuild/7.x
I need the code for `_menu_check_rebuild()` in Drupal 7 (includes/menu.inc). It must do this: Checks whether a menu_rebuild() is necessary.
File: includes/menu.inc
function _menu_check_rebuild() { // To absolutely ensure that the menu rebuild is required, re-load the // variables in case they were set by another process. $variables = variable_initialize(); if (empty($variables['menu_rebuild_needed']) && !empty($variables['menu_masks'])) { unset($GLOBALS['conf']['menu_...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3be1f90c7c
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_tab_root_path/7.x
Implement `menu_tab_root_path()` in PHP for Drupal 7. Required behavior: Returns the router path, or the path for a default local task's parent.
File: includes/menu.inc
function menu_tab_root_path() { $links = menu_local_tasks(); return $links['root_path']; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3bec1ca1af
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21aggregator%21aggregator.pages.inc/function/theme_aggregator_page_rss/7.x
Implement `theme_aggregator_page_rss($variables)` in PHP for Drupal 7. Required behavior: Prints the RSS page for a feed.
Parameters: - $variables: An associative array containing: - feeds: An array of the feeds to theme. - category: A common category, if any, for all the feeds. Returns (void) File: modules/aggregator/aggregator.pages.inc
function theme_aggregator_page_rss($variables) { $feeds = $variables['feeds']; $category = $variables['category']; drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8'); $items = ''; $feed_length = variable_get('feed_item_length', 'fulltext'); foreach ($feeds as $feed) { switch ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3bf519d6e6
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21trigger%21trigger.admin.inc/function/trigger_assign_form_validate/7.x
Implement `trigger_assign_form_validate($form, $form_state)` in PHP for Drupal 7. Required behavior: Form validation handler for trigger_assign_form().
Makes sure that the user is not re-assigning an action to an event. File: modules/trigger/trigger.admin.inc
function trigger_assign_form_validate($form, $form_state) { $form_values = $form_state['values']; if (!empty($form_values['aid'])) { $aid = actions_function_lookup($form_values['aid']); $aid_exists = db_query("SELECT aid FROM {trigger_assignments} WHERE hook = :hook AND aid = :aid", array( ':hook' => ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3bfb63ac26
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_get_html_head/7.x
In Drupal 7, write the function `drupal_get_html_head()` (file includes/common.inc) so that it does the following: Retrieves output to be displayed in the HEAD tag of the HTML page.
File: includes/common.inc
function drupal_get_html_head() { $elements = drupal_add_html_head(); drupal_alter('html_head', $elements); return drupal_render($elements); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3c039ed05b
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/function/taxonomy_file_download_access/7.x
Implement `taxonomy_file_download_access($field, $entity_type, $entity)` in PHP for Drupal 7. Required behavior: Implements hook_file_download_access().
File: modules/taxonomy/taxonomy.module
function taxonomy_file_download_access($field, $entity_type, $entity) { if ($entity_type == 'taxonomy_term') { return user_access('access content'); } }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3c2a2815b2
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21statistics%21statistics.module/function/statistics_block_view/7.x
I need the code for `statistics_block_view($delta = '')` in Drupal 7 (modules/statistics/statistics.module). It must do this: Implements hook_block_view().
File: modules/statistics/statistics.module
function statistics_block_view($delta = '') { if (user_access('access content')) { $content = array(); $daytop = variable_get('statistics_block_top_day_num', 0); if ($daytop && ($result = statistics_title_list('daycount', $daytop)) && ($node_title_list = node_title_list($result, t("Today's:")))) { ...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3c35df2f22
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_schema_alter/7.x
In Drupal 7, show an example implementation for `hook_field_schema_alter(&$schema, $field)` (modules/field/field.api.php): Allow modules to alter the schema for a field.
Parameters: - $schema (array): The schema definition as returned by hook_field_schema(). - $field (array): The field definition. File: modules/field/field.api.php
function hook_field_schema_alter(&$schema, $field) { if ($field['type'] == 'image') { // Alter the length of a field. $schema['columns']['alt']['length'] = 2048; // Add an additional column of data. $schema['columns']['additional_column'] = array( 'description' => "Additional column added to ima...
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-3c4bfca4b2
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21image%21image.admin.inc/function/image_rotate_form/7.x
Implement `image_rotate_form($data)` in PHP for Drupal 7. Required behavior: Form structure for the image rotate form.
Note that this is not a complete form, it only contains the portion of the form for configuring the rotate options. Therefore it does not not need to include metadata about the effect, nor a submit button. Parameters: - $data: The current configuration for this rotate effect. File: modules/image/image.admin.inc
function image_rotate_form($data) { $form['degrees'] = array( '#type' => 'textfield', '#default_value' => (isset($data['degrees'])) ? $data['degrees'] : 0, '#title' => t('Rotation angle'), '#description' => t('The number of degrees the image should be rotated. Positive numbers are clockwise, negative ...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3c753fa585
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21update%21update.module/function/_update_message_text/7.x
Implement `_update_message_text($msg_type, $msg_reason, $report_link = FALSE, $language = NULL)` in PHP for Drupal 7. Required behavior: Returns the appropriate message text when site is out of date or not secure.
These error messages are shared by both update_requirements() for the site-wide status report at admin/reports/status and in the body of the notification e-mail messages generated by update_cron(). Parameters: - $msg_type: String to indicate what kind of message to generate. Can be either 'core' or 'contrib'. - $msg_r...
function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $language = NULL) { $langcode = isset($language) ? $language->language : NULL; $text = ''; switch ($msg_reason) { case UPDATE_NOT_SECURE: if ($msg_type == 'core') { $text = t('There is a security update available for you...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3c75d4055a
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.info.inc/function/_field_info_prepare_field/7.x
In Drupal 7, write the function `_field_info_prepare_field($field)` (file modules/field/field.info.inc) so that it does the following: Prepares a field definition for the current run-time context.
The functionality has moved to the FieldInfo class. This function is kept as a backwards-compatibility layer. See http://drupal.org/node/1915646. File: modules/field/field.info.inc
function _field_info_prepare_field($field) { $cache = _field_info_field_cache(); return $cache->prepareField($field); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3c8ed71af0
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_admin_paths/7.x
I need the code for `system_admin_paths()` in Drupal 7 (modules/system/system.module). It must do this: Implements hook_admin_paths().
File: modules/system/system.module
function system_admin_paths() { $paths = array( 'admin' => TRUE, 'admin/*' => TRUE, 'batch' => TRUE, // This page should not be treated as administrative since it outputs its // own content (outside of any administration theme). 'admin/reports/status/php' => FALSE, ); return $paths; }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3cae48a6d1
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21install.core.inc/function/install_configure_form_validate/7.x
I need the code for `install_configure_form_validate($form, &$form_state)` in Drupal 7 (includes/install.core.inc). It must do this: Form validation handler for install_configure_form().
File: includes/install.core.inc
function install_configure_form_validate($form, &$form_state) { if ($error = user_validate_name($form_state['values']['account']['name'])) { form_error($form['admin_account']['account']['name'], $error); } if ($error = user_validate_mail($form_state['values']['account']['mail'])) { form_error($form['admin...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3cbf3c5011
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21field%21field.info.inc/function/_field_info_prepare_extra_fields/7.x
Implement `_field_info_prepare_extra_fields($extra_fields, $entity_type, $bundle)` in PHP for Drupal 7. Required behavior: Prepares 'extra fields' for the current run-time context.
The functionality has moved to the FieldInfo class. This function is kept as a backwards-compatibility layer. See http://drupal.org/node/1915646. File: modules/field/field.info.inc
function _field_info_prepare_extra_fields($extra_fields, $entity_type, $bundle) { $cache = _field_info_field_cache(); return $cache->prepareExtraFields($extra_fields, $entity_type, $bundle); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3cc6b58698
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21help%21help.module/function/help_help/7.x
I need the code for `help_help($path, $arg)` in Drupal 7 (modules/help/help.module). It must do this: Implements hook_help().
File: modules/help/help.module
function help_help($path, $arg) { switch ($path) { case 'admin/help': $output = '<p>' . t('Follow these steps to set up and start using your website:') . '</p>'; $output .= '<ol>'; $output .= '<li>' . t('<strong>Configure your website</strong> Once logged in, visit the <a href="@admin">administr...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3ccf854aeb
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21locale%21locale.install/function/locale_install/7.x
In Drupal 7, write the function `locale_install()` (file modules/locale/locale.install) so that it does the following: Implements hook_install().
File: modules/locale/locale.install
function locale_install() { // locales_source.source and locales_target.target are not used as binary // fields; non-MySQL database servers need to ensure the field type is text // and that LIKE produces a case-sensitive comparison. db_insert('languages') ->fields(array( 'language' => 'en', 'na...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3cd6526a59
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_links/7.x
Implement `comment_links($comment, $node)` in PHP for Drupal 7. Required behavior: Helper function, build links for an individual comment.
Adds reply, edit, delete etc. depending on the current user permissions. Parameters: - $comment: The comment object. - $node: The node the comment is attached to. Returns: A structured array of links. File: modules/comment/comment.module
function comment_links($comment, $node) { $links = array(); if ($node->comment == COMMENT_NODE_OPEN) { if (user_access('administer comments') && user_access('post comments')) { $links['comment-delete'] = array( 'title' => t('delete'), 'href' => "comment/$comment->cid/delete", 'html...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3d04e2a095
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21file.inc/function/file_usage_list/7.x
In Drupal 7, write the function `file_usage_list(stdClass $file)` (file includes/file.inc) so that it does the following: Determines where a file is used.
Parameters: - $file: A file object. Returns: A nested array with usage data. The first level is keyed by module name, the second by object type and the third by the object id. The value of the third level contains the usage count. File: includes/file.inc
function file_usage_list(stdClass $file) { $result = db_select('file_usage', 'f') ->fields('f', array('module', 'type', 'id', 'count')) ->condition('fid', $file->fid) ->condition('count', 0, '>') ->execute(); $references = array(); foreach ($result as $usage) { $references[$usage->module][$usa...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3d0c380fb6
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/filter_permission/7.x
Implement `filter_permission()` in PHP for Drupal 7. Required behavior: Implements hook_permission().
File: modules/filter/filter.module
function filter_permission() { $perms['administer filters'] = array( 'title' => t('Administer text formats and filters'), 'description' => t('Define how text is handled by combining filters into <a href="@url">text formats</a>.', array('@url' => url('admin/config/content/formats'))), 'restrict access' => ...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3d1c906116
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21install.core.inc/function/install_verify_pdo/7.x
Implement `install_verify_pdo()` in PHP for Drupal 7. Required behavior: Verifies the PDO library.
File: includes/install.core.inc
function install_verify_pdo() { // PDO was moved to PHP core in 5.2.0, but the old extension (targeting 5.0 // and 5.1) is still available from PECL, and can still be built without // errors. To verify that the correct version is in use, we check the // PDO::ATTR_DEFAULT_FETCH_MODE constant, which is not availa...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3d5af1bb29
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21install.inc/function/install_profile_info/7.x
In Drupal 7, write the function `install_profile_info($profile, $locale = 'en')` (file includes/install.inc) so that it does the following: Retrieves information about an installation profile from its .info file.
The information stored in a profile .info file is similar to that stored in a normal Drupal module .info file. For example: - name: The real name of the installation profile for display purposes. - description: A brief description of the profile. - dependencies: An array of shortnames of other modules that this install...
function install_profile_info($profile, $locale = 'en') { $cache = &drupal_static(__FUNCTION__, array()); if (!isset($cache[$profile])) { // Set defaults for module info. $defaults = array( 'dependencies' => array(), 'description' => '', 'distribution_name' => 'Drupal', 'version' =>...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3d6b826132
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21dblog%21dblog.admin.inc/function/dblog_event/7.x
In Drupal 7, write the function `dblog_event($id)` (file modules/dblog/dblog.admin.inc) so that it does the following: Page callback: Displays details about a specific database log message.
Parameters: - $id (int): Unique ID of the database log message. Returns (array|string): If the ID is located in the Database Logging table, a build array in the format expected by drupal_render(); otherwise, an empty string. File: modules/dblog/dblog.admin.inc
function dblog_event($id) { $severity = watchdog_severity_levels(); $result = db_query('SELECT w.*, u.name, u.uid FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid WHERE w.wid = :id', array(':id' => $id))->fetchObject(); if ($dblog = $result) { $rows = array( array( array('data' => t('Type...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3d7617655d
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21user%21user.admin.inc/function/user_admin_role_delete_confirm_submit/7.x
Implement `user_admin_role_delete_confirm_submit($form, &$form_state)` in PHP for Drupal 7. Required behavior: Form submit handler for user_admin_role_delete_confirm().
File: modules/user/user.admin.inc
function user_admin_role_delete_confirm_submit($form, &$form_state) { user_role_delete((int) $form_state['values']['rid']); drupal_set_message(t('The role has been deleted.')); $form_state['redirect'] = 'admin/people/permissions/roles'; }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3d82cb6760
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/entity_info_cache_clear/7.x
I need the code for `entity_info_cache_clear()` in Drupal 7 (includes/common.inc). It must do this: Resets the cached information about entity types.
File: includes/common.inc
function entity_info_cache_clear() { drupal_static_reset('entity_get_info'); // Clear all languages. cache_clear_all('entity_info:', 'cache', TRUE); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3d8d8f016d
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/parse_size/7.x
Implement `parse_size($size)` in PHP for Drupal 7. Required behavior: Parses a given byte count.
Parameters: - $size: A size expressed as a number of bytes with optional SI or IEC binary unit prefix (e.g. 2, 3K, 5MB, 10G, 6GiB, 8 bytes, 9mbytes). Returns: An integer representation of the size in bytes. File: includes/common.inc
function parse_size($size) { $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size. $size = (float) preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size. if ($unit) { // Find the position of the unit in the ordered string which...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3d9ec84069
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21filter%21filter.module/function/_filter_autop_tips/7.x
In Drupal 7, write the function `_filter_autop_tips($filter, $format, $long = FALSE)` (file modules/filter/filter.module) so that it does the following: Implements callback_filter_tips().
Provides help for the auto-paragraph filter. File: modules/filter/filter.module
function _filter_autop_tips($filter, $format, $long = FALSE) { if ($long) { return t('Lines and paragraphs are automatically recognized. The &lt;br /&gt; line break, &lt;p&gt; paragraph and &lt;/p&gt; close paragraph tags are inserted automatically. If paragraphs are not recognized simply add a couple blank lines...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3da392478e
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21contact%21contact.module/function/contact_form_user_admin_settings_alter/7.x
In Drupal 7, write the function `contact_form_user_admin_settings_alter(&$form, &$form_state)` (file modules/contact/contact.module) so that it does the following: Implements hook_form_FORM_ID_alter().
Add the default personal contact setting on the user settings page. File: modules/contact/contact.module
function contact_form_user_admin_settings_alter(&$form, &$form_state) { $form['contact'] = array( '#type' => 'fieldset', '#title' => t('Contact settings'), '#weight' => 0, ); $form['contact']['contact_default_status'] = array( '#type' => 'checkbox', '#title' => t('Enable the personal contact f...
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3db2995f72
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_check_directory/7.x
In Drupal 7, write the function `system_check_directory($form_element)` (file modules/system/system.module) so that it does the following: Checks the existence of the directory specified in $form_element.
This function is called from the system_settings form to check all core file directories (file_public_path, file_private_path, file_temporary_path). Parameters: - $form_element: The form element containing the name of the directory to check. File: modules/system/system.module
function system_check_directory($form_element) { $directory = $form_element['#value']; if (strlen($directory) == 0) { return $form_element; } if (!is_dir($directory) && !drupal_mkdir($directory, NULL, TRUE)) { // If the directory does not exists and cannot be created. form_set_error($form_element['...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3dc483b365
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21file.inc/function/file_save_data/7.x
Implement `file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAME)` in PHP for Drupal 7. Required behavior: Saves a file to the specified destination and creates a database entry.
Parameters: - $data: A string containing the contents of the file. - $destination: A string containing the destination URI. This must be a stream wrapper URI. If no value is provided, a randomized name will be generated and the file will be saved using Drupal's default files scheme, usually "public://". - $replace: Rep...
function file_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAME) { global $user; if (empty($destination)) { $destination = file_default_scheme() . '://'; } if (!file_valid_uri($destination)) { watchdog('file', 'The data could not be saved because the destination %destination is invali...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3dcb9098fd
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_get_query_parameters/7.x
In Drupal 7, write the function `drupal_get_query_parameters(array $query = NULL, array $exclude = array('q'), $parent = '')` (file includes/common.inc) so that it does the following: Processes a URL query parameter array to remove unwanted elements.
Parameters: - $query: (optional) An array to be processed. Defaults to $_GET. - $exclude: (optional) A list of $query array keys to remove. Use "parent[child]" to exclude nested items. Defaults to array('q'). - $parent: Internal use only. Used to build the $query array key for nested items. Returns: An array containin...
function drupal_get_query_parameters(array $query = NULL, array $exclude = array('q'), $parent = '') { // Set defaults, if none given. if (!isset($query)) { $query = $_GET; } // If $exclude is empty, there is nothing to filter. if (empty($exclude)) { return $query; } elseif (!$parent) { $exclu...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3de14a8c41
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.admin.inc/function/shortcut_admin_add_link/7.x
In Drupal 7, write the function `shortcut_admin_add_link($shortcut_link, &$shortcut_set, $limit = NULL)` (file modules/shortcut/shortcut.admin.inc) so that it does the following: Adds a link to the end of a shortcut set, keeping within a prescribed limit.
Parameters: - $link: An array representing a shortcut link. - $shortcut_set: An object representing the shortcut set which the link will be added to. The links in the shortcut set will be re-weighted so that the new link is at the end, and some existing links may be disabled (if the $limit parameter is provided). - $li...
function shortcut_admin_add_link($shortcut_link, &$shortcut_set, $limit = NULL) { if (isset($limit)) { // Disable any existing links at the end of the list that would cause the // limit to be exceeded. Take into account whether or not the new link will // be enabled and count towards the total. $numbe...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3de2b723c9
7
drupal_api_code
https://api.drupal.org/api/drupal/includes%21session.inc/function/drupal_session_regenerate/7.x
In Drupal 7, write the function `drupal_session_regenerate()` (file includes/session.inc) so that it does the following: Called when an anonymous user becomes authenticated or vice-versa.
File: includes/session.inc
function drupal_session_regenerate() { global $user, $is_https; // Nothing to do if we are not allowed to change the session. if (!drupal_save_session()) { return; } if ($is_https && variable_get('https', FALSE)) { $insecure_session_name = substr(session_name(), 1); if (!isset($GLOBALS['lazy_sess...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3de8ca8782
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21trigger%21trigger.module/function/trigger_user_cancel/7.x
I need the code for `trigger_user_cancel($edit, $account, $method)` in Drupal 7 (modules/trigger/trigger.module). It must do this: Implements hook_user_cancel().
File: modules/trigger/trigger.module
function trigger_user_cancel($edit, $account, $method) { switch ($method) { case 'user_cancel_reassign': _trigger_user('user_delete', $edit, $account, $method); break; } }
[ "code-task", "hook-implementation" ]
2026-09-30T00:00:00
api-drupal7-3dff2e2b0e
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21shortcut%21shortcut.admin.inc/function/shortcut_set_switch/7.x
I need the code for `shortcut_set_switch($form, &$form_state, $account = NULL)` in Drupal 7 (modules/shortcut/shortcut.admin.inc). It must do this: Form callback: builds the form for switching shortcut sets.
Parameters: - $form: An associative array containing the structure of the form. - $form_state: An associative array containing the current state of the form. - $account: (optional) The user account whose shortcuts will be switched. Defaults to the current logged-in user. Returns: An array representing the form definit...
function shortcut_set_switch($form, &$form_state, $account = NULL) { global $user; if (!isset($account)) { $account = $user; } // Prepare the list of shortcut sets. $sets = shortcut_sets(); $current_set = shortcut_current_displayed_set($account); $options = array(); foreach ($sets as $name => $set...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3e01b960f3
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_page_delivery_callback_alter/7.x
In Drupal 7, show an example implementation for `hook_page_delivery_callback_alter(&$callback)` (modules/system/system.api.php): Alters the delivery callback used to send the result of the page callback to the browser.
Called by drupal_deliver_page() to allow modules to alter how the page is delivered to the browser. This hook is intended for altering the delivery callback based on information unrelated to the path of the page accessed. For example, it can be used to set the delivery callback based on a HTTP request header (as shown...
function hook_page_delivery_callback_alter(&$callback) { // jQuery sets a HTTP_X_REQUESTED_WITH header of 'XMLHttpRequest'. // If a page would normally be delivered as an html page, and it is called // from jQuery, deliver it instead as an Ajax response. if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER[...
[ "code-task", "hook-definition" ]
2026-09-30T00:00:00
api-drupal7-3e0944fae1
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21system%21system.module/function/system_date_format_type_delete/7.x
I need the code for `system_date_format_type_delete($type)` in Drupal 7 (modules/system/system.module). It must do this: Deletes a date type from the database.
Parameters: - $type: The machine-readable name of the date type. File: modules/system/system.module
function system_date_format_type_delete($type) { db_delete('date_formats') ->condition('type', $type) ->execute(); db_delete('date_format_type') ->condition('type', $type) ->execute(); db_delete('date_format_locale') ->condition('type', $type) ->execute(); }
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3e530c440c
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21forum%21forum.admin.inc/function/forum_form_forum/7.x
I need the code for `forum_form_forum($form, &$form_state, $edit = array())` in Drupal 7 (modules/forum/forum.admin.inc). It must do this: Form constructor for adding and editing a forum.
Parameters: - $edit: (optional) Associative array containing a forum term to be added or edited. Defaults to an empty array. File: modules/forum/forum.admin.inc
function forum_form_forum($form, &$form_state, $edit = array()) { $edit += array( 'name' => '', 'description' => '', 'tid' => NULL, 'weight' => 0, ); $form['name'] = array('#type' => 'textfield', '#title' => t('Forum name'), '#default_value' => $edit['name'], '#maxlength' => 255, '...
[ "code-task", "function" ]
2026-09-30T00:00:00
api-drupal7-3e63b7cb92
7
drupal_api_code
https://api.drupal.org/api/drupal/modules%21forum%21forum.admin.inc/function/forum_form_container/7.x
Implement `forum_form_container($form, &$form_state, $edit = array())` in PHP for Drupal 7. Required behavior: Form constructor for adding and editing forum containers.
Parameters: - $edit: (optional) Associative array containing a container term to be added or edited. Defaults to an empty array. File: modules/forum/forum.admin.inc
function forum_form_container($form, &$form_state, $edit = array()) { $edit += array( 'name' => '', 'description' => '', 'tid' => NULL, 'weight' => 0, ); // Handle a delete operation. $form['name'] = array( '#title' => t('Container name'), '#type' => 'textfield', '#default_value' => ...
[ "code-task", "function" ]
2026-09-30T00:00:00