Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix error messages #3

Open
wants to merge 3 commits into
base: wordpress/3.0-5.0+
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletion upload/oa-social-login/includes/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,10 @@ function oa_social_login_settings_validate ($settings)
'plugin_shortcode_login_redirect_url',
'plugin_shortcode_register_redirect',
'plugin_shortcode_register_redirect_url',
'plugin_notify_admin'
'plugin_notify_admin',
'plugin_error_admin_address',
'plugin_error_message_fr',
'plugin_error_message_de'
) AS $key)
{
if (isset ($settings [$key]))
Expand Down Expand Up @@ -1510,6 +1513,54 @@ function oa_display_social_login_settings ()
</td>
</tr>
</table>

<table class="form-table oa_social_login_table">
<tr class="row_head">
<th>
<?php _e ('Error handling if linking a account fails', 'oa-social-login'); ?>
</th>
</tr>
<tr class="row_odd">
<td>
<strong><?php _e ('Error Message which should be shown for the user in german:', 'oa-social-login'); ?></strong>
</td>
</tr>
<tr class="row_even">
<td>
<?php
$plugin_error_message_de = (isset ($settings['plugin_error_message_de']) ? $settings['plugin_error_message_de'] : '');
?>
<input type="text" name="oa_social_login_settings[plugin_error_message_de]" size="90" value="<?php echo htmlspecialchars ($plugin_error_message_de); ?>" />
</td>
</tr>
<tr class="row_odd">
<td>
<strong><?php _e ('Error Message which should be shown for the user in french:', 'oa-social-login'); ?></strong>
</td>
</tr>
<tr class="row_even">
<td>
<?php
$plugin_error_message_fr = (isset ($settings['plugin_error_message_fr']) ? $settings['plugin_error_message_fr'] : '');
?>
<input type="text" name="oa_social_login_settings[plugin_error_message_fr]" size="90" value="<?php echo htmlspecialchars($plugin_error_message_fr); ?>" />
</td>
</tr>
<tr class="row_odd">
<td>
<strong><?php _e ('Administrator E-Mail address to send error:', 'oa-social-login'); ?></strong>
</td>
</tr>
<tr class="row_even">
<td>
<?php
$plugin_error_admin_address = (isset ($settings['plugin_error_admin_address']) ? $settings['plugin_error_admin_address'] : '');
?>
<input type="text" name="oa_social_login_settings[plugin_error_admin_address]" size="90" value="<?php echo htmlspecialchars($plugin_error_admin_address); ?>" />
</td>
</tr>
</table>

<p class="oa_social_login_buttons">
<input type="hidden" name="page" value="settings" />
<input type="submit" class="oa_social_login_btn oa_social_login_btn_success oa_social_login_btn_large" value="<?php _e ('Save Changes', 'oa-social-login') ?>" />
Expand Down
43 changes: 42 additions & 1 deletion upload/oa-social-login/includes/user_interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ function oa_social_login_render_link_form ($source, $user)
{
//Store the data being returned.
$output = '';
$errorOccured = false;
$errorCode = 0;

if (is_object ($user) AND property_exists ($user, 'data') AND !empty ($user->data->ID))
{
Expand Down Expand Up @@ -308,10 +310,23 @@ function oa_social_login_render_link_form ($source, $user)
$error_message = __ ('This social network account is already used by another user.', 'oa-social-login');
}
}
} else {
$errorOccured = true;
$errorCode = 1;
}
} else {
$errorOccured = true;
$errorCode = 2;
}
} else {
$errorOccured = true;
$errorCode = 4;
}
}
} /*else {
// User button should be shown
/*$errorOccured = true;
$errorCode = 5;
}*/

//Button Theme
$theme_id = (array_key_exists ('plugin_icon_theme', $settings) ? $settings['plugin_icon_theme'] : null);
Expand Down Expand Up @@ -376,9 +391,35 @@ function oa_social_login_render_link_form ($source, $user)
$output .= '<tr><td>' . $social_link . '</td></tr>';
$output .= '</table>';
}
} else {
$errorOccured = true;
$errorCode = 6;
}
} else {
$errorOccured = true;
$errorCode = 7;
}
} else {
$errorOccured = true;
$errorCode = 8;
}
} else {
$errorOccured = true;
$errorCode = 9;
}

if($errorOccured){
$settings = get_option('oa_social_login_settings');
$locale = get_locale();
if(substr($locale, 0, 2) == 'fr'){
$output = sprintf("<p stlye='color:red;'>%s</p>", $settings['plugin_error_message_fr']);
} else {
$output = sprintf("<p stlye='color:red;'>%s</p>", $settings['plugin_error_message_de']);
}
$emailSubject = sprintf("ErrorCode %d: An Error Occured while linking a Social User", $errorCode);
$emailText = sprintf("ErrorCode: %d <br> Wordpressuser-ID: %d", $errorCode, get_current_user_id());
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail($settings['plugin_error_admin_address'], $emailSubject, $emailText, $headers);
}
return $output;
}
Expand Down