$field_conf) { $field_info = field_info_field($field_id); if (!$field_info) { field_create_field($field_conf['field']); field_create_instance($field_conf['instance']); } } } /** * Implements hook_uninstall(). */ function ldap_authorization_uninstall() { foreach (ldap_authorization_user_entity_fields() as $field_id => $field_conf) { $instance = field_info_instance($field_conf['instance']['entity_type'], $field_conf['instance']['field_name'], $field_conf['instance']['bundle']); if ($instance) { field_delete_instance($instance); } $field_info = field_info_field($field_conf['field']['field_name']); if ($field_info) { field_delete_field($field_conf['field']['field_name']); } } module_load_include('inc', 'ldap_servers', 'ldap_servers.user_data_remove'); batch_set(ldap_severs_user_data_setup_batch()); $batch =& batch_get(); } /** * */ function ldap_authorization_user_entity_fields() { $fields = []; return $fields; } /** * Implements hook_schema(). */ function ldap_authorization_schema() { $schema['ldap_authorization'] = [ 'export' => [ 'key' => 'consumer_type', 'key name' => 'Mapping ID', 'identifier' => 'consumer_type', 'primary key' => 'numeric_consumer_conf_id', 'api' => [ 'owner' => 'ldap_authorization', 'api' => 'ldap_authorization', 'minimum_version' => 1, 'current_version' => 1, ], ], 'description' => "Data used to map users ldap entry to authorization rights.", 'primary key' => ['numeric_consumer_conf_id'], 'foreign keys' => [ 'sid' => [ 'table' => 'ldap_servers', 'columns' => ['sid' => 'sid'], ], ], ]; module_load_include('inc', 'ldap_servers', 'ldap_servers.functions'); module_load_include('php', 'ldap_authorization', 'LdapAuthorizationConsumerConfAdmin.class'); $fields = LdapAuthorizationConsumerConfAdmin::fields(); foreach ($fields as $name => $props) { if (isset($props['schema'])) { $schema['ldap_authorization']['fields'][$name] = $props['schema']; } } return $schema; } /** * Add 'create_consumers field to ldap_authorization table. */ function ldap_authorization_update_7100() { if (!db_field_exists('ldap_authorization', 'create_consumers')) { db_add_field('ldap_authorization', 'create_consumers', [ 'type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, ]); return t('"create_consumers" field added to ldap_authorization table'); } else { return t('No database changes made.'); } } /** * Add derive_from_attr_use_first_attr field to ldap_authorization table. */ function ldap_authorization_update_7101() { if (!db_field_exists('ldap_authorization', 'derive_from_attr_use_first_attr')) { db_add_field('ldap_authorization', 'derive_from_attr_use_first_attr', [ 'type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, ]); return t('"derive_from_attr_use_first_attr" field added to ldap_authorization table'); } else { return t('No database changes made.'); } } /** * Add derive_from_entry_search_all column to ldap_authorization. */ function ldap_authorization_update_7102() { if (!db_field_exists('ldap_authorization', 'derive_from_entry_search_all')) { db_add_field('ldap_authorization', 'derive_from_entry_search_all', [ 'type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, ]); return t('"derive_from_entry_search_all" field added to ldap_authorization table'); } else { return t('No database changes made.'); } } /** * Change derive_from_attr_attr and derive_from_entry fields to text instead of varchar 2555. */ function ldap_authorization_update_7103() { foreach (['derive_from_dn_attr', 'derive_from_attr_attr', 'derive_from_entry_entries'] as $field_name) { db_change_field('ldap_authorization', $field_name, $field_name, [ 'type' => 'text', 'not null' => FALSE, ]); } } /** * Change derive_from_attr_attr and derive_from_entry fields to text instead of varchar 2555 * applied second time because beta6 and 7 were wrong. */ function ldap_authorization_update_7104() { foreach (['derive_from_dn_attr', 'derive_from_attr_attr', 'derive_from_entry_entries'] as $field_name) { db_change_field('ldap_authorization', $field_name, $field_name, [ 'type' => 'text', 'not null' => FALSE, ]); } } /** * Add derive_from_entry_user_ldap_attr field to allow user specification of dn or other identifier. */ function ldap_authorization_update_7105() { if (!db_field_exists('ldap_authorization', 'derive_from_entry_user_ldap_attr')) { db_add_field('ldap_authorization', 'derive_from_entry_user_ldap_attr', [ 'type' => 'varchar', 'length' => 255, 'default' => NULL, ]); return t('"derive_from_entry_user_ldap_attr" field added to ldap_authorization table'); } else { return t('No database changes made.'); } } /** * Add nested checkboxes to derive from entry and attributes strategies. */ function ldap_authorization_update_7106() { if (!db_field_exists('ldap_authorization', 'derive_from_attr_nested')) { db_add_field('ldap_authorization', 'derive_from_attr_nested', [ 'type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, ]); $msg = t('"derive_from_attr_nested" field added to ldap_authorization table'); } if (!db_field_exists('ldap_authorization', 'derive_from_entry_nested')) { db_add_field('ldap_authorization', 'derive_from_entry_nested', [ 'type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, ]); $msg .= t('"derive_from_entry_nested" field added to ldap_authorization table'); } return ($msg) ? $msg : t('No database changes made.'); } /** * Add derive_from_entry_use_first_attr field to and remove description field from ldap_authorization table. */ function ldap_authorization_update_7107() { $changes = ''; if (!db_field_exists('ldap_authorization', 'derive_from_entry_use_first_attr')) { db_add_field('ldap_authorization', 'derive_from_entry_use_first_attr', [ 'type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, ]); $changes .= t('"derive_from_entry_use_first_attr" field added to ldap_authorization table'); } if (db_field_exists('ldap_authorization', 'description')) { db_drop_field('ldap_authorization', 'description'); $changes .= t('"description" field dropped from to ldap_authorization table'); } return ($changes) ? $changes : t('No database changes made.'); } /** * Add derive_from_entry_entries_attr field to allow user specification of attribute representing group in queries. */ function ldap_authorization_update_7108() { if (!db_field_exists('ldap_authorization', 'derive_from_entry_entries_attr')) { db_add_field('ldap_authorization', 'derive_from_entry_entries_attr', [ 'type' => 'varchar', 'length' => 255, 'default' => NULL, ]); return t('"derive_from_entry_entries_attr" field added to ldap_authorization table'); } else { return t('No database changes made.'); } _ldap_authorization_add_ldap_user_fields(); } /** * Moving some groups related fields into ldap server module. */ function ldap_authorization_update_7201() { // Need to merge 2 table fields (derive_from_entry_use_first_attr and derive_from_attr_use_first_attr into one field useFirstAttrAsGroupId) $results = ''; if (!db_field_exists('ldap_authorization', 'useFirstAttrAsGroupId')) { db_add_field('ldap_authorization', 'useFirstAttrAsGroupId', [ 'type' => 'int', 'size' => tiny, 'not null' => TRUE, 'default' => 0, ]); $results .= t('"useFirstAttrAsGroupId" field added to ldap_authorization table'); } if (!db_field_exists('ldap_authorization', 'searchAll')) { db_add_field('ldap_authorization', 'searchAll', [ 'type' => 'int', 'size' => tiny, 'not null' => TRUE, 'default' => 0, ]); $results .= t('"searchAll" field added to ldap_authorization table'); } } /** * Remove user ldap authorizations field. its in $user->data now. */ function ldap_authorization_update_7202() { $instance = [ 'field_name' => 'ldap_authorizations', 'entity_type' => 'user', 'bundle' => 'user', ]; field_delete_instance($instance, TRUE); field_delete_field('ldap_authorizations'); } /** * Make all schema field names lowercase in ldap server to deal with cronic case sensitivity issues. */ function ldap_authorization_update_7203() { if (db_field_exists('ldap_authorization', 'searchAll')) { db_drop_field('ldap_authorization', 'searchAll'); } $schema = ldap_authorization_schema(); $field_schema = $schema['ldap_authorization']['fields']['use_first_attr_as_groupid']; if (db_field_exists('ldap_authorization', 'useFirstAttrAsGroupId')) { if (db_field_exists('ldap_authorization', 'use_first_attr_as_groupid')) { db_drop_field('ldap_authorization', 'useFirstAttrAsGroupId'); } else { db_change_field('ldap_authorization', 'useFirstAttrAsGroupId', 'use_first_attr_as_groupid', $field_schema); } } } /** * Make all schema field names lowercase in ldap server to deal with cronic case sensitivity issues. */ function ldap_authorization_update_7204() { $schema = ldap_authorization_schema(); $field_schema = $schema['ldap_authorization']['fields']['mappings']; if (db_field_exists('ldap_authorization', 'mappings')) { db_change_field('ldap_authorization', 'mappings', 'mappings', $field_schema); } }