function wpu_user_mapper() { global $wpUnited, $phpbbForum; ?> <div class="wrap" id="wp-united-setup"> <img id="panellogo" src="<?php echo wpu_get_settings_logo(); ?> " /> <?php screen_icon('options-general'); ?> <h2> <?php _e('WP-United User Integration Mapping', 'wp-united'); ?> </h2> <p><?php _e('Integrated users have an account both in WordPress and phpBB. The user mapper tool allows you to manually control which accounts are mapped together.', 'wp-united'); ?> </p> <?php if ($wpUnited->get_setting('integcreatewp')) { ?> <p><?php _e('In addition, you need to tell WP-United how to allocate WordPress roles to users when WordPress accounts are automatically given to them.', 'wp-united'); ?> </p> <p><?php _e('Select a tab below to get started.', 'wp-united'); ?> </p> <?php } ?> <div id="wputabs"> <?php if ($wpUnited->get_setting('integcreatewp')) { ?> <ul> <li><a href="#wpumaptab-map"><?php _e('User Mapping', 'wp-united'); ?> </a></li> <li><a href="#wpumaptab-perms"><?php _e('New User Permissions', 'wp-united'); ?> </a></li> </ul> <?php } if ($wpUnited->get_setting('integcreatewp')) { ?> <div id="wpumaptab-perms"> <p><?php _e('Unintegrated phpBB users are automatically given accounts if they have WP-United permissions. These can be set in the phpBB Administration Control Panel, but this tool makes them easier to set and visualise.', 'wp-united'); ?> </p> <p><?php _e('phpBB groups are linked to WordPress roles by dragging connections. Blue connections grant permissions. However, since phpBB users can belong to more than one group, you may want to apply "Never" connections. These red connections take priority over blue connections and mean that this mapping can NEVER occur.', 'wp-united'); ?> </p> <p><?php _e('This gives you complete control over who does what in WordPress. For some example permissions recipes, visit wp-united.com ', 'wp-united'); ?> </p> <p><?php _e('Remember that these mappings only affect users who don\'t have WordPress accounts yet. You should map existing accounts together using the User Mapping tool.', 'wp-united'); ?> </p> <p><?php _e(' Connect a phpBB group on the left to an appropriate WordPress role by dragging the blue dots. Connect the red squares if you want to ensure a mapping <em>never</em> happens.When happy, click "Apply"', 'wp-united'); ?> </p> <?php global $db; $phpbbForum->foreground(); $groupTypes = array(__('Built-In', 'wp-united'), __('User-Defined', 'wp-united')); $numUserDefined = 0; // Get all the groups, and associated info $sqlArr = array('SELECT' => 'COUNT(ug.user_id) AS count, g.group_id, g.group_type, g.group_name', 'FROM' => array(GROUPS_TABLE => 'g'), 'LEFT_JOIN' => array(array('FROM' => array(USER_GROUP_TABLE => 'ug'), 'ON' => 'g.group_id = ug.group_id')), 'GROUP_BY' => 'g.group_id', 'ORDER_BY' => 'g.group_type DESC, g.group_name ASC'); $sql = $db->sql_build_query('SELECT', $sqlArr); $result = $db->sql_query($sql); $groupData = array(); while ($row = $db->sql_fetchrow($result)) { $groupData[$row['group_id']] = array('type' => $row['group_type'] == GROUP_SPECIAL ? __('Built-In', 'wp-united') : __('User-Defined', 'wp-united'), 'name' => !empty($phpbbForum->lang['G_' . $row['group_name']]) ? $phpbbForum->lang['G_' . $row['group_name']] : $row['group_name'], 'db_name' => $row['group_name'], 'total_members' => $row['count'], 'url' => $phpbbForum->append_sid($phpbbForum->get_board_url() . 'adm/index.php?i=permissions&mode=setting_group_global&group_id[0]=' . $row['group_id'])); if ($groupData[$row['group_id']]['type'] == __('User-Defined', 'wp-united')) { $numUserDefined++; } } $db->sql_freeresult($result); ?> <table class="widefat fixed"> <?php foreach (array('thead', 'tfoot') as $tblHead) { ?> <<?php echo $tblHead; ?> > <tr class="thead"> <th scope="col"><?php _e('phpBB Group', 'wp-united'); ?> </th> <th scope="col" style="text-align: right;"><?php _e('WordPress Role', 'wp-united'); ?> </th> </tr> </<?php echo $tblHead; ?> > <?php } ?> <tbody><tr><td colspan="2"> <div id="wpuplumbcanvas" class="wpuplumbcanvas" id="wpuplumb"> <?php $perms = wpu_permissions_list(); $newUserGroups = $phpbbForum->get_newuser_group(); $linkages = array(); $neverLinkages = array(); $elsL = array(); $elsR = array(); ?> <div class="wpuplumbleft"><?php foreach ($groupTypes as $type) { if ($type == __('Built-In', 'wp-united') || $numUserDefined > 0) { $effectivePerms = wpu_assess_perms('', false, false); //wpu_get_wp_role_for_group(); $nevers = wpu_assess_perms('', false, true); foreach ($groupData as $group_id => $row) { if ($row['type'] == $type) { $blockIdL = 'wpuperml-' . str_replace(array('+', '=', '/'), array('_pls', '_eq', '_sl'), base64_encode($row['db_name'])); $elsL[] = $blockIdL; ?> <div class="wpuplumbgroupl ui-widget-header ui-corner-all" id="<?php echo $blockIdL; ?> "> <p><strong><?php echo $row['name']; ?> </strong> <?php if (in_array($row['db_name'], $newUserGroups)) { echo ' <span style="color: red;">*</span>'; } ?> <?php echo '<br /><small><strong>' . __('No. of members: ', 'wp-united') . '</strong>' . $row['total_members']; ?> <br /> <?php echo '<strong>' . __('Group type: ', 'wp-united') . '</strong>' . $type; ?> </small></p> <?php if (isset($effectivePerms[$row['name']])) { foreach ($effectivePerms[$row['name']] as $permItem) { $linkages[$blockIdL] = 'wpupermr-' . str_replace(array('+', '=', '/'), array('_pls', '_eq', '_sl'), base64_encode($permItem)); } } if (isset($nevers[$row['name']])) { foreach ($nevers[$row['name']] as $neverItem) { $neverLinkages[$blockIdL] = 'wpupermr-' . str_replace(array('+', '=', '/'), array('_pls', '_eq', '_sl'), base64_encode($neverItem)); } } ?> </div> <?php } } } } ?> </div><?php $phpbbForum->background(); ?> <div class="wpuplumbright"> <?php foreach ($perms as $permSetting => $wpName) { $blockIdR = 'wpupermr-' . str_replace(array('+', '=', '/'), array('_pls', '_eq', '_sl'), base64_encode($permSetting)); $elsR[] = $blockIdR; ?> <div class="wpuplumbgroupr ui-widget-header ui-corner-all" id="<?php echo $blockIdR; ?> "> <strong><?php echo 'WordPress ' . $wpName; ?> </strong> </div> <?php } ?> </div> <br style="clear: both;" /> </div> </td></tr></tbody> </table> <small><em><span style="color: red;">* </span><?php _e('Default new user group for new phpBB users', 'wp-united'); ?> </em></small> <div id="wpupermactions"> <button class="wpuprocess" onclick="return wpuApplyPerms();"><?php _e('Apply', 'wp-united'); ?> </button> <button class="wpuclear" onclick="return wpuClearPerms();"><?php _e('Reset', 'wp-united'); ?> </button> </div> <script type="text/javascript"> // <[CDATA[ function initPlumbing() { <?php $var = 0; $varLookups = array(); foreach ($elsL as $el) { $var++; $varLookups[$el] = $var; echo "var wpuPlumb{$var} = jsPlumb.addEndpoint(\$wpu('#{$el}'), {anchor: [1,0.25,1,0], maxConnections: 1, isSource: true}, wpuEndPoint);"; echo "var wpunPlumb{$var} = jsPlumb.addEndpoint(\$wpu('#{$el}'), {anchor: [1,0.75,1,0], maxConnections: 1, isSource: true}, wpuNeverEndPoint);"; } foreach ($elsR as $el) { $var++; $varLookups[$el] = $var; echo "var wpuPlumb{$var} = jsPlumb.addEndpoint(\$wpu('#{$el}'), {anchor: [0,0.25,-1,0], maxConnections: 10, isTarget: true}, wpuEndPoint);"; echo "var wpunPlumb{$var} = jsPlumb.addEndpoint(\$wpu('#{$el}'), {anchor: [0,0.75,-1,0], maxConnections: 10, isTarget: true}, wpuNeverEndPoint);"; } foreach ($linkages as $linkL => $linkR) { ?> jsPlumb.connect({ source: <?php echo "wpuPlumb{$varLookups[$linkL]}"; ?> , target: <?php echo "wpuPlumb{$varLookups[$linkR]}"; ?> }); <?php } foreach ($neverLinkages as $linkL => $linkR) { ?> jsPlumb.connect({ source: <?php echo "wpunPlumb{$varLookups[$linkL]}"; ?> , target: <?php echo "wpunPlumb{$varLookups[$linkR]}"; ?> }); <?php } ?> } // ]]> </script> </div> <?php } ?> <div id="wpumaptab-map"> <p><?php _e('All your WordPress or phpBB users are shown on the left below, together with their integration status. On the right, you can see their corresponding integrated user, or – if they are not integrated – some suggestions for users they could integrate to.', 'wp-united'); ?> </p> <p><?php _e('Choose the actions you wish to take, and then click "Process Actions" in the pop-up panel to apply them..', 'wp-united'); ?> </p> <div class="ui-widget-header ui-corner-all wpumaptoolbar"> <form name="wpumapdisp" id="wpumapdisp" onsubmit="return false;"> <fieldset> <label for="wpumapside"><?php _e('Show on left: ', 'wp-united'); ?> </label> <select id="wpumapside" name="wpumapside"> <option value="wp"><?php _e('WordPress users', 'wp-united'); ?> </option> <option value="phpbb"><?php _e('phpBB users', 'wp-united'); ?> </option> </select> <label for="wpunumshow"><?php _e('Number to show: ', 'wp-united'); ?> </label> <select id="wpunumshow" name="wpunumshow"> <option value="1">1</option> <option value="5">5</option> <option value="10" selected="selected">10</option> <option value="20">20</option> <option value="50">50</option> <option value="100">100</option> <option value="250">250</option> <!--<option value="500">500</option> <option value="1000">1000</option>--> </select> <label for="wputypeshow"><?php _e('Show: ', 'wp-united'); ?> </label> <select id="wputypeshow" name="wputypeshow"> <option value="all"><?php _e('All', 'wp-united'); ?> </option> <option value="int"><?php _e('All Integrated', 'wp-united'); ?> </option> <option value="unint"><?php _e('All Unintegrated', 'wp-united'); ?> </option> <option value="posts"><?php _e('All With Posts', 'wp-united'); ?> </option> <option value="noposts"><?php _e('All Without Posts', 'wp-united'); ?> </option> </select> <span id="wpumapsrcharea"> <label for="wpumapsearchbox"><?php _e('or search for user: '******'wp-united'); ?> </label> <input type="text" id="wpumapsearchbox" name="wpumapsearchbox"></input> </span> <input type="hidden" name="wpufirstitem" id="wpufirstitem" value="0" /> </fieldset> </form> <div id="wpumappaginate1" class="wpumappaginate"> </div> </div> <div id="wpumapcontainer"> <div id="wpumapscreen"> <div class="wpuloading"> <p><?php _e('Loading...', 'wp-united'); ?> </p> <img src="<?php echo $wpUnited->get_plugin_url(); ?> images/settings/wpuldg.gif" /> </div> </div> <div id="wpumappanel" class="ui-widget"> <h3 class="ui-widget-header ui-corner-all"><?php _e('Actions to process', 'wp-united'); ?> </h3> <ul id="wpupanelactionlist"> </ul> <div id="wpupanelactions"> <small> <button class="wpuprocess" onclick="return wpuProcess();"><?php _e('Process actions', 'wp-united'); ?> </button> <button class="wpuclear" onclick="return wpuMapClearAll();"><?php _e('Clear all', 'wp-united'); ?> </button> </small> </div> </div> </div> <div class="ui-widget-header ui-corner-all wpumaptoolbar"> <div id="wpumappaginate2" class="wpumappaginate"> </div> </div> </div> </div> </div> <div id="wpuoffscreen"> </div> <div id="wpu-reload" title="Message" style="display: none;"> <p id="wpu-desc"> </p><img id="wpuldgimg" src="<?php echo $wpUnited->get_plugin_url(); ?> images/settings/wpuldg.gif" /> </div> <script type="text/javascript"> // <![CDATA[ var mapNonce = '<?php echo wp_create_nonce('wp-united-map'); ?> '; var autofillNonce = '<?php echo wp_create_nonce('wp-united-usersearch'); ?> '; var firstMapActionNonce = '<?php echo wp_create_nonce('wp-united-mapaction'); ?> '; var imgLdg = '<?php echo $wpUnited->get_plugin_url(); ?> images/settings/wpuldg.gif'; var currWpUser = '******'current_user']->ID; ?> '; var currPhpbbUser = '******'user_id'); ?> '; var wpText = '<?php wpu_js_translate(__('WordPress', 'wp-united')); ?> '; var phpbbText = '<?php wpu_js_translate(__('phpBB', 'wp-united')); ?> '; var mapEditTitle = '<?php wpu_js_translate(__('Editing user. When you are finished, close this screen.', 'wp-united')); ?> '; var mapProfileTitle = '<?php wpu_js_translate(__('Viewing user profile. When you are finished, close this screen.', 'wp-united')); ?> '; var actionBreak = '<?php wpu_js_translate(__('Break integration', 'wp-united')); ?> '; var actionBreakDets = '<?php wpu_js_translate(__('between %1$s and %2$s', 'wp-united')); ?> '; var actionSync = '<?php wpu_js_translate(__('Synchronize profiles', 'wp-united')); ?> '; var actionSyncDets = '<?php wpu_js_translate(__('between %1$s and %2$s', 'wp-united')); ?> '; var actionDelBoth = '<?php wpu_js_translate(__('Delete ', 'wp-united')); ?> '; var actionDelBothDets = '<?php wpu_js_translate(__('%1$s from %2$s and %3$s from %4$s', 'wp-united')); ?> '; var actionDel = '<?php wpu_js_translate(__('Delete ', 'wp-united')); ?> '; var actionDelDets = '<?php wpu_js_translate(__('%1$s from %2$s', 'wp-united')); ?> '; var actionCreate = '<?php wpu_js_translate(__('Create ', 'wp-united')); ?> '; var actionCreateDets = '<?php wpu_js_translate(__('integrated counterpart for %1$s in %2$s', 'wp-united')); ?> '; var actionIntegrate = '<?php wpu_js_translate(__('Integrate ', 'wp-united')); ?> '; var actionIntegrateDets = '<?php wpu_js_translate(__('%1$s user %2$s to %3$s user %4$s', 'wp-united')); ?> '; var wpuProcessingText = '<?php wpu_js_translate(__('Processing permission mappings...', 'wp-united')); ?> '; var wpuWaitText = '<?php wpu_js_translate(__('Please wait...', 'wp-united')); ?> '; var wpuConnectingText = '<?php wpu_js_translate(__('Connecting...', 'wp-united')); ?> '; var wpuClearingText = '<?php wpu_js_translate(__('Clearing changes', 'wp-united')); ?> '; var wpuLoading = '<?php wpu_js_translate(__('Loading...', 'wp-united')); ?> '; var wpuReloading = '<?php wpu_js_translate(__('Reloading settings from phpBB...', 'wp-united')); ?> '; var acpPopupTitle = '<?php wpu_js_translate(__('phpBB Administration Panel. After saving your settings, close this window to return to WP-United.', 'wp-united')); ?> '; function wpu_hardened_init_tail() { <?php if ($wpUnited->get_setting('integcreatewp')) { // re-call jsPlumb init, in case it failed on document.ready ?> jsPlumb.init(); wpuSetupPermsMapper(); <?php } ?> setupUserMapperPage(); } // ]]> </script> <?php add_action('admin_footer', 'wpu_hardened_script_init'); }
function wpu_get_wp_role_for_group($groupList = '') { $permArr = wpu_assess_perms($groupList, false); $result = array(); $wpuPerms = array_keys(wpu_permissions_list()); // get the highest role for the given group(s), as nothing else really matters foreach ($permArr as $group => $roleArr) { foreach ($wpuPerms as $wpuPerm) { if (in_array($wpuPerm, $roleArr)) { $result[$group] = $wpuPerm; } } } return $result; }