Пример #1
0
/**
 * bp_course_nav_menu()
 * Navigation menu for BuddyPress course
 */
function bp_course_nav_menu()
{
    $nav = bp_course_get_nav_permalinks();
    $defaults = array('' => array('id' => 'home', 'label' => __('Home', 'vibe'), 'action' => '', 'link' => bp_get_course_permalink()), 'curriculum' => array('id' => 'curriculum', 'label' => __('Curriculum', 'vibe'), 'can_view' => 1, 'action' => empty($nav['curriculum_slug']) ? __('curriculum', 'vibe') : $nav['curriculum_slug'], 'link' => bp_get_course_permalink()), 'members' => array('id' => 'members', 'label' => __('Members', 'vibe'), 'can_view' => 1, 'action' => empty($nav['members_slug']) ? __('members', 'vibe') : $nav['members_slug'], 'link' => bp_get_course_permalink()), 'activity' => array('id' => 'activity', 'label' => __('Activity', 'vibe'), 'can_view' => 1, 'action' => empty($nav['activity_slug']) ? __('activity', 'vibe') : $nav['activity_slug'], 'link' => bp_get_course_permalink()));
    global $post;
    if ($post->post_type == 'course') {
        if (function_exists('bp_is_active') && bp_is_active('groups')) {
            $vgroup = get_post_meta(get_the_ID(), 'vibe_group', true);
            if (!empty($vgroup)) {
                $group = groups_get_group(array('group_id' => $vgroup));
                $defaults['group'] = array('id' => 'group', 'label' => __('Group', 'vibe'), 'action' => 'group', 'can_view' => 1, 'link' => bp_get_group_permalink($group), 'external' => true);
            }
        }
        if (in_array('bbpress/bbpress.php', apply_filters('active_plugins', get_option('active_plugins'))) || function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('bbpress/bbpress.php')) {
            $forum = get_post_meta(get_the_ID(), 'vibe_forum', true);
            if (!empty($forum)) {
                $defaults['forum'] = array('id' => 'forum', 'label' => __('Forum', 'vibe'), 'action' => 'forum', 'can_view' => 1, 'link' => get_permalink($forum), 'external' => true);
            }
        }
    }
    $nav_menu = apply_filters('wplms_course_nav_menu', $defaults);
    global $bp;
    $action = bp_current_action();
    if (empty($action)) {
        !empty($_GET['action']) ? $action = $_GET['action'] : ($action = '');
    }
    if (is_array($nav_menu)) {
        foreach ($nav_menu as $key => $menu_item) {
            $menu_item['action'] = str_replace('/', '', $menu_item['action']);
            if ($key == $action) {
                $class = 'class="current"';
            } else {
                $class = '';
            }
            global $wp_query;
            if (!empty($nav[$menu_item['id'] . '_slug'])) {
                echo '<li id="' . $menu_item['id'] . '" ' . $class . '><a href="' . $menu_item['link'] . '' . (isset($menu_item['action']) && !isset($menu_item['external']) ? $menu_item['action'] : '') . '">' . $menu_item['label'] . '</a></li>';
            } else {
                echo '<li id="' . $menu_item['id'] . '" ' . $class . '><a href="' . $menu_item['link'] . '' . (!empty($menu_item['action']) && !isset($menu_item['external']) ? (strpos($menu_item['link'], '?') ? '&' : '?') . 'action=' . $menu_item['action'] : '') . '">' . $menu_item['label'] . '</a></li>';
            }
        }
    }
    if (is_super_admin() || is_instructor()) {
        $admin_slug = empty($nav['admin_slug']) ? _x('admin', 'course admin slug', 'vibe') : $nav['admin_slug'];
        $admin_slug = apply_filters('wplms_course_admin_slug', str_replace('/', '', $admin_slug));
        ?>
      <li id="admin" class="<?php 
        echo !empty($action) && ($action == 'admin' || $action == 'submission' || $action == 'stats') ? 'selected current' : '';
        ?>
"><a href="<?php 
        bp_course_permalink();
        echo $admin_slug;
        ?>
"><?php 
        _e('Admin', 'vibe');
        ?>
</a></li>
      <?php 
    }
}
 function student_message_quiz_evaluation($quiz_id, $marks, $user_id, $max)
 {
     $sender_id = get_post_field('post_author', $quiz_id);
     $permalinks = bp_course_get_nav_permalinks();
     $message = sprintf(__('You obtained %d out of %s in Quiz : ', 'vibe'), $marks, $max, '<a href="' . trailingslashit(bp_core_get_user_domain($user_id)) . BP_COURSE_SLUG . '/' . BP_COURSE_RESULTS_SLUG . '/?action=' . $quiz_id . '">' . get_the_title($quiz_id) . '</a>');
     if (bp_is_active('messages')) {
         messages_new_message(array('sender_id' => $sender_id, 'subject' => __('Quiz results available', 'vibe'), 'content' => $message, 'recipients' => $user_id));
     }
 }
Пример #3
0
        function widget($args, $instance)
        {
            extract($args);
            echo $before_widget;
            if (is_user_logged_in()) {
                do_action('bp_before_sidebar_me');
                ?>
				<div id="sidebar-me">
					<div id="bpavatar">
						<?php 
                bp_loggedin_user_avatar('type=full');
                ?>
					</div>
					<ul>
						<li id="username"><a href="<?php 
                bp_loggedin_user_link();
                ?>
"><?php 
                bp_loggedin_user_fullname();
                ?>
</a></li>
						<li><a href="<?php 
                echo bp_loggedin_user_domain() . BP_XPROFILE_SLUG;
                ?>
/" title="<?php 
                _e('View profile', 'vibe');
                ?>
"><?php 
                _e('View profile', 'vibe');
                ?>
</a></li>
						<li id="vbplogout"><a href="<?php 
                echo wp_logout_url(get_permalink());
                ?>
" id="destroy-sessions" rel="nofollow" class="logout" title="<?php 
                _e('Log Out', 'vibe');
                ?>
"><i class="icon-close-off-2"></i> <?php 
                _e('LOGOUT', 'vibe');
                ?>
</a></li>
						<li id="admin_panel_icon"><?php 
                if (current_user_can("edit_posts")) {
                    echo '<a href="' . vibe_site_url() . 'wp-admin/" title="' . __('Access admin panel', 'vibe') . '"><i class="icon-settings-1"></i></a>';
                }
                ?>
					  </li>
					</ul>	
					<ul>
            <?php 
                $nav = '';
                if (function_exists('bp_course_get_nav_permalinks')) {
                    $nav = bp_course_get_nav_permalinks();
                }
                $loggedin_menu = array('courses' => array('icon' => 'icon-book-open-1', 'label' => __('Courses', 'vibe'), 'link' => bp_loggedin_user_domain() . BP_COURSE_SLUG), 'stats' => array('icon' => 'icon-analytics-chart-graph', 'label' => __('Stats', 'vibe'), 'link' => bp_loggedin_user_domain() . BP_COURSE_SLUG . '/' . BP_COURSE_STATS_SLUG));
                if (bp_is_active('messages')) {
                    $loggedin_menu['messages'] = array('icon' => 'icon-letter-mail-1', 'label' => __('Inbox', 'vibe') . (messages_get_unread_count() ? ' <span>' . messages_get_unread_count() . '</span>' : ''), 'link' => bp_loggedin_user_domain() . BP_MESSAGES_SLUG);
                    $n = bp_notifications_get_unread_notification_count(bp_loggedin_user_id());
                    $loggedin_menu['notifications'] = array('icon' => 'icon-exclamation', 'label' => __('Notifications', 'vibe') . ($n ? ' <span>' . $n . '</span>' : ''), 'link' => bp_loggedin_user_domain() . BP_NOTIFICATIONS_SLUG);
                }
                if (bp_is_active('groups')) {
                    $loggedin_menu['groups'] = array('icon' => 'icon-myspace-alt', 'label' => __('Groups', 'vibe'), 'link' => bp_loggedin_user_domain() . BP_GROUPS_SLUG);
                }
                $loggedin_menu['settings'] = array('icon' => 'icon-settings', 'label' => __('Settings', 'vibe'), 'link' => bp_loggedin_user_domain() . BP_SETTINGS_SLUG);
                $loggedin_menu = apply_filters('wplms_logged_in_top_menu', $loggedin_menu);
                foreach ($loggedin_menu as $item) {
                    echo '<li><a href="' . $item['link'] . '"><i class="' . $item['icon'] . '"></i>' . $item['label'] . '</a></li>';
                }
                ?>
					</ul>
				
				<?php 
                do_action('bp_sidebar_me');
                ?>
				</div>
				<?php 
                do_action('bp_after_sidebar_me');
                /***** If the user is not logged in, show the log form and account creation link *****/
            } else {
                if (!isset($user_login)) {
                    $user_login = '';
                }
                do_action('bp_before_sidebar_login_form');
                ?>
				
				
				<form name="login-form" id="vbp-login-form" class="standard-form" action="<?php 
                echo apply_filters('wplms_login_widget_action', vibe_site_url('wp-login.php', 'login-post'));
                ?>
" method="post">
					<label><?php 
                _e('Username', 'vibe');
                ?>
<br />
					<input type="text" name="log" id="side-user-login" class="input" tabindex="1" value="<?php 
                echo esc_attr(stripslashes($user_login));
                ?>
" /></label>
					
					<label><?php 
                _e('Password', 'vibe');
                ?>
 <a href="<?php 
                echo wp_lostpassword_url(get_permalink());
                ?>
" tabindex="5" class="tip" title="<?php 
                _e('Forgot Password', 'vibe');
                ?>
"><i class="icon-question"></i></a><br />
					<input type="password" tabindex="2" name="pwd" id="sidebar-user-pass" class="input" value="" /></label>
					
          <div class="checkbox small">
            <input type="checkbox" name="sidebar-rememberme" id="sidebar-rememberme" value="forever" /><label for="sidebar-rememberme"><?php 
                _e('Remember Me', 'vibe');
                ?>
</label>
          </div>
					
					<?php 
                do_action('bp_sidebar_login_form');
                ?>
					<input type="submit" name="user-submit" id="sidebar-wp-submit" value="<?php 
                _e('Log In', 'vibe');
                ?>
" tabindex="100" />
					<input type="hidden" name="user-cookie" value="1" />
					<?php 
                if (bp_get_signup_allowed()) {
                    $registration_link = apply_filters('wplms_buddypress_registration_link', site_url(BP_REGISTER_SLUG . '/'));
                    printf(__('<a href="%s" class="vbpregister" title="' . __('Create an account', 'vibe') . '" tabindex="5" >' . __('Sign Up', 'vibe') . '</a> ', 'vibe'), $registration_link);
                }
                ?>
          <?php 
                do_action('login_form');
                //BruteProtect FIX
                ?>
				</form>
				
				
				<?php 
                do_action('bp_after_sidebar_login_form');
            }
            echo $after_widget;
        }