Commit 55d9f080 authored by Dave Lane's avatar Dave Lane
Browse files

improved 'login to register for courses' options and automatic trigging of a login form

parent 27831a3d
...@@ -7,7 +7,7 @@ Plugin Name: Blog Feed Finder ...@@ -7,7 +7,7 @@ Plugin Name: Blog Feed Finder
Plugin URI: https://github.com/oeru/bff Plugin URI: https://github.com/oeru/bff
Description: Provides a widget that helps a user figure out the valid URL for Description: Provides a widget that helps a user figure out the valid URL for
their personal course blog feed their personal course blog feed
Version: 1.0.2 Version: 1.0.3
Author: Dave Lane Author: Dave Lane
Author URI: https://oeru.org, http://WikiEducator.org/User:Davelane Author URI: https://oeru.org, http://WikiEducator.org/User:Davelane
License: AGPLv3 or later License: AGPLv3 or later
...@@ -30,7 +30,7 @@ along with this program; if not, write to the Free Software ...@@ -30,7 +30,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
define( 'BFF_VERSION', '1.0.2' ); define( 'BFF_VERSION', '1.0.3' );
// plugin computer name // plugin computer name
define('BFF_NAME', 'BFF'); define('BFF_NAME', 'BFF');
// current version // current version
...@@ -48,6 +48,8 @@ define('BFF_MENU', 'BFF'); ...@@ -48,6 +48,8 @@ define('BFF_MENU', 'BFF');
define('BFF_SHORTCODE', 'bff_form'); define('BFF_SHORTCODE', 'bff_form');
define('BFF_ID', 'blog-feed-finder'); define('BFF_ID', 'blog-feed-finder');
define('BFF_CLASS', 'bff-form'); define('BFF_CLASS', 'bff-form');
define('BFF_OERU_THEME_NAME', 'OERu Course');
define('BFF_REGISTER_ENROL_PLUGIN', 'register-enrol/register-enrol.php');
// support link for users of this plugin... // support link for users of this plugin...
define('BFF_SUPPORT_FORUM', 'https://forums.oeru.org/t/blog-feed-finder'); define('BFF_SUPPORT_FORUM', 'https://forums.oeru.org/t/blog-feed-finder');
define('BFF_SUPPORT_BLOG', 'https://course.oeru.org/support/studying-courses/course-blog/'); define('BFF_SUPPORT_BLOG', 'https://course.oeru.org/support/studying-courses/course-blog/');
...@@ -58,7 +60,7 @@ define('BFF_ADMIN_MENU', 'BFF Settings'); ...@@ -58,7 +60,7 @@ define('BFF_ADMIN_MENU', 'BFF Settings');
// other useful parameters // other useful parameters
define('BFF_MAX_FILE_READ_CHAR', 1000000); // limit max size of the file to read to 1mb define('BFF_MAX_FILE_READ_CHAR', 1000000); // limit max size of the file to read to 1mb
// turn on debugging with true, off with false // turn on debugging with true, off with false
define('BFF_DEBUG', false); define('BFF_DEBUG', true);
define('LOG_STREAM', getenv('LOG_STREAM')); define('LOG_STREAM', getenv('LOG_STREAM'));
// include the dependencies // include the dependencies
......
...@@ -17,13 +17,30 @@ class BFFCourse extends BFFFinder { ...@@ -17,13 +17,30 @@ class BFFCourse extends BFFFinder {
// show the user info if they're not logged in... // show the user info if they're not logged in...
public function alert_anon_user() { public function alert_anon_user() {
?> $message = '<p class="bff-notice">You are not currently logged in. As such, you will not be able to link any blog feed addresses you find to your profile.</p>';
<div id="bff-unauth-notice" class="bff-auth bff-info bff-alert-box"> // if this is a multisite, recommend a user log in to get the most functionality from the plugin.
<p class="bff-notice">You are not currently logged in. As such, you will not be able to link any blog feed addresses you find to your profile.<br/>You can <a if ( function_exists( 'is_multisite' ) && is_multisite() ) {
data-toggle="modal" title="Click to log in or register for OERu Courses" data-target="#userModal"><span if ($this->is_using_oeru_theme() && is_plugin_active(BFF_REGISTER_ENROL_PLUGIN)) {
class="glyphicon glyphicon-user"></span> log in or register</a> to link your feed(s) to any OERu courses for which you're registered.</p> $message .= '<p class="bff-notice">You can <a data-toggle="modal" title="Click to log in or register for Courses" href="/'.BFF_SLUG.'#login" onclick="login();"><span
</div> class="glyphicon glyphicon-user"></span>log in</a> to link your feed(s) to any courses for which you\'re registered.</p>';
<?php } else {
$message .= '<p class="bff-notice">You can <a title="Click to log in or register for Courses" href="'.wp_login_url(BFF_SLUG).'"><span
class="glyphicon glyphicon-user"></span>log in or register</a> to link your feed(s) to any courses for which you\'re registered.</p>';
}
}
// put out
echo '<div id="bff-unauth-notice" class="bff-auth bff-info bff-alert-box">'.$message.'</div>';
}
protected function is_using_oeru_theme() {
$theme = wp_get_theme();
$theme_name = $theme->get('Name');
$this->log(' theme name: '.$theme_name);
if ($theme_name == BFF_OERU_THEME_NAME) {
$this->log('We\'re using the theme: '.BFF_OERU_THEME_NAME);
return true;
}
return false;
} }
// show the user info if they are logged in... // show the user info if they are logged in...
......
...@@ -133,6 +133,13 @@ function get_course_id(str) { ...@@ -133,6 +133,13 @@ function get_course_id(str) {
return id; return id;
} }
// https://stackoverflow.com/questions/13770741/reload-page-with-different-anchor
function login() {
console.log('reload this window with #login');
window.location.hash = '#login';
window.location.reload(true);
}
// jQuery selectors and related functions in that context // jQuery selectors and related functions in that context
jQuery(document).ready(function() { jQuery(document).ready(function() {
var $ = jQuery; var $ = jQuery;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment