' . __('Fatal G2 error:', 'wpg2') . '' . $ret; exit; } } // Remove the g2_user cap if($_GET['duser_id'] != "" && $_GET['dg2user_id'] == "") { $usercap = new WP_User($_GET['duser_id']); if ($usercap->has_cap('gallery2_user')) { ?>

add_cap('gallery2_user', false); g2_delete_user($_GET['duser_id']); } } // add the g2_user cap if($_GET['auser_id'] != "" && $_GET['ag2user_id'] == "" ) { $usercap = new WP_User($_GET['auser_id']); if (!$usercap->has_cap('gallery2_user')) { $usercap->add_cap('gallery2_user', true); ?>

has_cap('gallery2_admin')) { ?>

add_cap('gallery2_admin', false); } } // Add the g2_admin cap if($_GET['auser_id'] != "" && $_GET['ag2user_id'] != "" ) { $usercap = new WP_User($_GET['auser_id']); if (!$usercap->has_cap('gallery2_admin')) { $usercap->add_cap('gallery2_admin', true); ?>

$g2user['externalId'], 'entityType' => 'GalleryUser')); } } } // Get a List of all current WP Users $wpusers = $wpdb->get_results("SELECT ID FROM $wpdb->users ORDER BY ID"); $cnt = 0; foreach ($wpusers as $wpuser) { $wparray[$cnt] = $wpuser->ID; $cnt++; g2_create_user($wpuser->ID); g2_admin_user($wpuser->ID); } // Get G2 Mapping list ($ret, $g2users) = GalleryEmbed::getExternalIdMap('entityId'); if ($ret) { echo __('Fatal G2 error:', 'wpg2') . $ret->getAsHtml(); exit; } foreach ($g2users as $g2user) { if ( $g2user['entityType'] == "GalleryUser" ) { $ret = GalleryCoreApi::removeMapEntry( 'ExternalIdMap', array('externalId' => $g2array[$entity], 'entityType' => 'GalleryUser')); $g2entityarray[$g2user['externalId']] = $g2user['entityId']; } } echo '
'; echo '

'. __('Help', 'wpg2').'

'; echo '

' . __('Manage Mapped Gallery2 <> Wordpress Users', 'wpg2') . '

'; echo '

' . __('This page is for controlling the Gallery2 capabilities that are associated with each user.', 'wpg2') . '

'; // Wordpress Accounts Mapped to G2 $output = '
'; $output.= '' . __('Wordpress Users with Gallery2 admin accounts', 'wpg2') . ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; echo ''; foreach ($wpusers as $wpuser) { // Get WP & G2 Member Information $userdata = new WP_User($wpuser->ID); $wpuserid = $wpuser->ID; if ($userdata->has_cap('gallery2_user') && $userdata->has_cap('gallery2_admin') ) { if ($output) { echo $output; $style = ''; $output = ""; } // Output WP Infomation $url = $userdata->user_url; $email = $userdata->user_email; $short_url = str_replace('http://', '', $url); $short_url = str_replace('www.', '', $short_url); if ('/' == substr($short_url, -1)) $short_url = substr($short_url, 0, -1); if (strlen($short_url) > 35) $short_url = substr($short_url, 0, 32).'...'; $style = ('class="alternate"' == $style) ? '' : 'class="alternate"'; echo ""; echo ""; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; if ( current_user_can('gallery2_admin') && ($user_ID != $wpuserid )) echo ''; else echo ''; echo ''; } } echo '
' . __('WP ID', 'wpg2') . '' . __('G2 ID', 'wpg2') . '' . __('User Name', 'wpg2') . '' . __('Nickname', 'wpg2') . '' . __('Name', 'wpg2') . '' . __('Email', 'wpg2') . '' . __('Website', 'wpg2') . '' . __('Action', 'wpg2') . ' 
' . $userdata->ID . '' . $g2entityarray[$wpuserid] . '' . $userdata->user_login . '' . $userdata->nickname . '' . $userdata->user_firstname .' ' . $userdata->user_lastname . '' . $email . '' . $short_url . '' . __('Revoke G2 Admin', 'wpg2') . 'NA
'; $output = '
'; $output.= '' . __('Wordpress Users without Gallery2 admin accounts', 'wpg2') . ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; foreach ($wpusers as $wpuser) { // Get WP & G2 Member Information $userdata = new WP_User($wpuser->ID); $wpuserid = $wpuser->ID; if ($userdata->has_cap('gallery2_user') && !$userdata->has_cap('gallery2_admin') ) { if ($output) { echo $output; $style = ''; $output = ""; } // Output WP Infomation $url = $userdata->user_url; $email = $userdata->user_email; $short_url = str_replace('http://', '', $url); $short_url = str_replace('www.', '', $short_url); if ('/' == substr($short_url, -1)) $short_url = substr($short_url, 0, -1); if (strlen($short_url) > 35) $short_url = substr($short_url, 0, 32).'...'; $style = ('class="alternate"' == $style) ? '' : 'class="alternate"'; echo ""; echo ""; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; if ( current_user_can('gallery2_admin') ) { echo ''; } else { echo ''; } echo ''; } } echo '
' . __('WP ID', 'wpg2') . '' . __('G2 ID', 'wpg2') . '' . __('User Name', 'wpg2') . '' . __('Nickname', 'wpg2') . '' . __('Name', 'wpg2') . '' . __('Email', 'wpg2') . '' . __('Website', 'wpg2') . '' . __('Action', 'wpg2') . ' 
' . $userdata->ID . '' . $g2entityarray[$wpuserid] . '' . $userdata->user_login . '' . $userdata->nickname . '' . $userdata->user_firstname .' ' . $userdata->user_lastname . '' . $email . '' . $short_url . '' . __('Grant G2 Admin', 'wpg2') . ''; echo ' / ' . __('Revoke G2 User', 'wpg2') . '' . __('Revoke G2 User', 'wpg2') . '
'; // Wordpress Accounts Not mapped to G2 $output = '
'; $output.= '' . __('Wordpress Users without Gallery2 accounts', 'wpg2') . ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; $output.= ''; foreach ($wpusers as $wpuser) { // Get WP & G2 Member Information $userdata = new WP_User($wpuser->ID); if (!$userdata->has_cap('gallery2_user')) { if ($output) { echo $output; $style = ''; $output = ""; } // Output WP Infomation $url = $userdata->user_url; $email = $userdata->user_email; $short_url = str_replace('http://', '', $url); $short_url = str_replace('www.', '', $short_url); if ('/' == substr($short_url, -1)) $short_url = substr($short_url, 0, -1); if (strlen($short_url) > 35) $short_url = substr($short_url, 0, 32).'...'; $style = ('class="alternate"' == $style) ? '' : 'class="alternate"'; echo ""; echo ""; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } } echo '
' . __('WP ID', 'wpg2') . '' . __('G2 ID', 'wpg2') . '' . __('User Name', 'wpg2') . '' . __('Nickname', 'wpg2') . '' . __('Name', 'wpg2') . '' . __('Email', 'wpg2') . '' . __('Website', 'wpg2') . '' . __('Action', 'wpg2') . ' 
' . $userdata->ID . '' . __('NA', 'wpg2') . '' . $userdata->user_login . '' . $userdata->nickname . '' . $userdata->user_firstname . ' ' . $userdata->user_lastname . '' . $email . '' . $short_url . '' . __('Grant G2 User', 'wpg2') . '
'; echo '
'; $ret = GalleryEmbed::done(); ?>