? 486370-language-bug.patch ? 490846-admin.patch ? 490846-user-enable.patch ? 490846-user-management.patch ? domain_views/485762-views.patch Index: INSTALL.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/domain/INSTALL.txt,v retrieving revision 1.21 diff -u -p -r1.21 INSTALL.txt --- INSTALL.txt 7 Jun 2009 19:03:10 -0000 1.21 +++ INSTALL.txt 14 Jun 2009 19:25:13 -0000 @@ -17,6 +17,7 @@ CONTENTS 2.2 Server Configuration 2.3 Setting DOMAIN_INSTALL_RULE 2.4 Setting DOMAIN_SITE_GRANT +2.5 Setting DOMAIN_ASSIGN_USERS 3. Installing the Module 3.1 After Installation 4. Configuring settings.php @@ -202,6 +203,29 @@ be viewable on all domains. Normally, you will not need to edit this value. ---- +2.5 Setting DOMAIN_ASSIGN_USERS + +At the top of the domain.module file, you will find this line: + + define('DOMAIN_ASSIGN_USERS', TRUE); + +After you install the Domain Access module, all new users who +register will automatically be assign to the domain from which +their account was created. This value is used to determine +advanced editing access and can be used by modules such as +Domain Strict. + +On install, setting this value to TRUE will assign all current users +to be members of the default domain. Set the value to FALSE +and the module will not assign users to any domains. + +Normally, you will not need to edit this value. + +After installation and configuration, users with the appropriate +permissions may batch assign users to domains from +Administer > User Management > Users. + +---- 3. Installing the Module After you have prepared your server and made any edits to the Index: README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/domain/README.txt,v retrieving revision 1.59 diff -u -p -r1.59 README.txt --- README.txt 13 Jun 2009 18:31:27 -0000 1.59 +++ README.txt 14 Jun 2009 19:25:14 -0000 @@ -56,6 +56,7 @@ CONTENTS 4.8.2 Domain Node Types 4.9 Batch Updating 4.10 Assigning Users to Domains +4.11 Batch Assignment of Users to Domains 5. Blocks 5.1 Block -- Domain Switcher 5.2 Block -- Domain Access Information @@ -931,6 +932,28 @@ Settings for the 'new user' are permanen See http://drupal.org/node/313629 for some background about this feature. ---- +4.11 Batch Assignment of Users to Domains + +In 6.x.2 and higher, users with the 'administer users' and 'assign domain +editors' permissions may use the User administration page to batch assign +users to domains. + +This feature is useful if you need to convert a group of editorial users to +become domain editors. + +To use this feature, navigate to Administer > User management > Users. +Look for the 'Assign users to domains' option in the 'Update options' select +form. Choose this operation and then use the 'Affiliate editor options' +fieldset to select the domains you wish to assgin users to. + +Select the desired users and hit the Update button. + +Note that this form also shows you a list of domains that a user is +currently assigned to. + +If these elements do not appear, you do not have the proper permissions. + +---- 5. Blocks The Domain Access module provides two blocks, which can be used to help you Index: domain.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain.admin.inc,v retrieving revision 1.29 diff -u -p -r1.29 domain.admin.inc --- domain.admin.inc 13 Jun 2009 20:02:39 -0000 1.29 +++ domain.admin.inc 14 Jun 2009 19:25:16 -0000 @@ -818,6 +818,50 @@ function domain_batch_form($form_state, /** * FormsAPI */ +function theme_domain_admin_users_form($form) { + // Overview table: + $header = array( + theme('table_select_header_cell'), + array('data' => t('Username'), 'field' => 'u.name'), + array('data' => t('Status'), 'field' => 'u.status'), + t('Roles'), + t('Domains'), + array('data' => t('Member for'), 'field' => 'u.created', 'sort' => 'desc'), + array('data' => t('Last access'), 'field' => 'u.access'), + t('Operations') + ); + + $output = drupal_render($form['options']); + $output .= drupal_render($form['domain']); + if (isset($form['name']) && is_array($form['name'])) { + foreach (element_children($form['name']) as $key) { + $rows[] = array( + drupal_render($form['accounts'][$key]), + drupal_render($form['name'][$key]), + drupal_render($form['status'][$key]), + drupal_render($form['roles'][$key]), + drupal_render($form['user_domains'][$key]), + drupal_render($form['member_for'][$key]), + drupal_render($form['last_access'][$key]), + drupal_render($form['operations'][$key]), + ); + } + } + else { + $rows[] = array(array('data' => t('No users available.'), 'colspan' => '7')); + } + + $output .= theme('table', $header, $rows); + if ($form['pager']['#value']) { + $output .= drupal_render($form['pager']); + } + + $output .= drupal_render($form); + + return $output;} +/** + * FormsAPI + */ function theme_domain_batch_form($form) { $output = ''; $output = drupal_render($form['message']); Index: domain.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain.module,v retrieving revision 1.110 diff -u -p -r1.110 domain.module --- domain.module 13 Jun 2009 20:02:39 -0000 1.110 +++ domain.module 14 Jun 2009 19:25:18 -0000 @@ -20,12 +20,18 @@ define('DOMAIN_INSTALL_RULE', TRUE); /** - * Defines whether to show affiliated content on all domains.. + * Defines whether to show affiliated content on all domains. * You may alter this variable before installing the module. See README.txt. */ define('DOMAIN_SITE_GRANT', TRUE); /** + * Defines whether to assign users to the default domain on install. + * You may alter this variable before installing the module. See README.txt. + */ +define('DOMAIN_ASSIGN_USERS', TRUE); + +/** * Adds the domain user data to the $user object. */ function domain_boot() { @@ -211,6 +217,10 @@ function domain_perm() { */ function domain_theme() { $themes = array( + 'domain_admin_users_form' => array( + 'arguments' => array('form' => array()), + 'file' => 'domain.admin.inc', + ), 'domain_batch_form' => array( 'arguments' => array('form' => array()), 'file' => 'domain.admin.inc', @@ -426,6 +436,112 @@ function domain_user($op, &$edit, &$acco } /** + * Implement hook_user_operations(). + */ +function domain_user_operations() { + if (!user_access('assign domain editors')) { + return; + } + return array( + 'domain' => array( + 'label' => t('Assign users to domains'), + 'callback' => 'domain_user_operation_assign', + ), + ); +} + +/** + * Implement hook_form_alter(). + */ +function domain_form_user_admin_account_alter(&$form, $form_state) { + if (!user_access('assign domain editors')) { + return; + } + $options = array(); + foreach (domain_domains() as $data) { + // Cannot pass zero in checkboxes. + ($data['domain_id'] == 0) ? $key = -1 : $key = $data['domain_id']; + // The domain must be valid. + if ($data['valid'] || user_access('administer domains')) { + $options[$key] = check_plain($data['sitename']); + } + } + $form['domain'] = array( + '#type' => 'fieldset', + '#title' => t('Affiliate editor options'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#prefix' => '
'. t('If you select Assign users to domains above, you should confirm the Affiliate editor options settings below.') .'
', + '#weight' => -1, + ); + $form['domain']['domains'] = array( + '#type' => 'checkboxes', + '#title' => t('Assign to'), + '#options' => $options, + '#required' => FALSE, + '#description' => t('Select which affiliates these users should belong to. Note: this will erase any current assignment for the selsected users.'), + '#default_value' => array(($_domain['domain_id'] == 0) ? -1 : $_domain['domain_id']), // Can't use 0 as a checkbox value. + ); + // Add our domain elements. + foreach (array_keys($form['name']) as $uid) { + $form['user_domains'][$uid][0] = array('#value' => theme('item_list', _domain_user_list($uid))); + } + $form['#theme'] = 'domain_admin_users_form'; + $form['#submit'][] = 'domain_update_users'; +} + +/** + * Helper function to get the names of all domains for a user. + * + * @param $uid + * The user id. + * @return + * An array of domain names. + */ +function _domain_user_list($uid) { + $temp_account = new stdClass; + $temp_account->uid = $uid; + $list = domain_get_user_domains($temp_account, FALSE); + $domains = array(); + foreach ($list as $domain_id) { + if ($domain_id == -1) { + $domain_id = 0; + } + $domains[] = check_plain(db_result(db_query("SELECT sitename FROM {domain} WHERE domain_id = %d ORDER BY domain_id ASC", $domain_id))); + } + return $domains; +} + +/** + * Callback for domain_content_node_operations(). + * + * This callback is required, but we actually do our action inside + * of domain_update_users(). + */ +function domain_user_operation_assign($accounts) { +} + +/** + * FormsAPI to handle the batch update of users. + */ +function domain_update_users($form, &$form_state) { + $values = $form_state['values']; + if ($values['operation'] != 'domain') { + return; + } + foreach ($values['accounts'] as $uid) { + db_query("DELETE FROM {domain_editor} WHERE uid = %d", $uid); + foreach (array_filter($values['domains']) as $domain_id) { + // Cannot use 0 as a checkbox. + if ($domain_id == -1) { + $domain_id = 0; + } + db_query("INSERT INTO {domain_editor} (uid, domain_id) VALUES (%d, %d)", $uid, $domain_id); + } + } +} + + /** * Implement hook_cron() * * This function invokes hook_domaincron() and allows @@ -1195,15 +1311,16 @@ function domain_set_default_grant() { /** * Upon enabling this module, store the default view grant - * in the {node_access} table. + * in the {node_access} table. Then it assigns all users to + * the primary domain. */ function domain_enable() { // Set the default 'domain_all' grant for special pages. domain_set_default_grant(); // Thanks to the new way that batch processing of node grants is handled, we have to // manually define our records if none are present. - $count = db_result(db_query("SELECT COUNT(*) FROM {domain_access}")); - if ($count == 0) { + $count = (bool) db_result(db_query("SELECT COUNT(*) FROM {domain_access}")); + if (empty($count)) { $rule = variable_get('domain_behavior', DOMAIN_INSTALL_RULE); $site = DOMAIN_SITE_GRANT; $nids = db_query("SELECT nid FROM {node}"); @@ -1217,6 +1334,17 @@ function domain_enable() { } } } + // Add users to the {domain_editor} table, but skip user 0. + if (!DOMAIN_ASSIGN_USERS) { + return; + } + $result = db_query("SELECT uid FROM {users} WHERE uid > 0"); + while ($data = db_fetch_object($result)) { + $check = (bool) db_result(db_query("SELECT COUNT(*) FROM {domain_editor} WHERE uid = %d", $data->uid)); + if (empty($check)) { + db_query("INSERT INTO {domain_editor} VALUES (%d, %d)", $data->uid, 0); + } + } } /**