public static function register()
 {
     // require the class for the theme options
     require_once dirname(__FILE__) . '/lib/options.php';
     // get the theme options
     $options = ltp_options::get_options();
     // require the class to log user actions
     require_once dirname(__FILE__) . '/lib/data.php';
     // require the class to change the login function
     require_once dirname(__FILE__) . '/lib/login.php';
     // require the class to provide filters for profile form
     require_once dirname(__FILE__) . '/lib/filters.php';
     // require the class to provide template related stuff
     require_once dirname(__FILE__) . '/lib/template.php';
     // hide admin bar from front end
     add_filter('show_admin_bar', '__return_false');
     // theme installation and updates
     add_action('init', array(__CLASS__, 'upgrade'));
     // theme uninstallation
     add_action('switch_theme', array(__CLASS__, 'uninstall'));
     // make dasicons available to theme
     add_action('wp_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'));
     // force ssl for site
     if (isset($options["debug_ssl"]) && $options["debug_ssl"]) {
         add_action('plugins_loaded', array(__CLASS__, 'force_ssl'));
     }
 }
Beispiel #2
0
 function prepare_items()
 {
     /* set up the columns */
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     /* set paging parameters */
     $per_page = ltp_options::get_admin_per_page('ltp_student_users_pp');
     $current_page = $this->get_pagenum();
     $offset = ($current_page - 1) * $per_page;
     /* set ordering parameters */
     $poss_orderby = array('first_name', 'last_name', 'user_login', 'user_email');
     $orderby = isset($_REQUEST["orderby"]) && in_array($_REQUEST["orderby"], $poss_orderby) ? $_REQUEST["orderby"] : 'last_name';
     $order = isset($_REQUEST["order"]) && in_array(strtoupper($_REQUEST["order"]), array('ASC', 'DESC')) ? strtoupper($_REQUEST["order"]) : 'ASC';
     $searchterm = isset($_REQUEST["s"]) && trim($_REQUEST["s"]) !== '' ? trim($_REQUEST["s"]) : '';
     /* build arguments to user query */
     $args = array('role' => 'student', 'number' => $per_page, 'offset' => $offset, 'fields' => 'all_with_meta', 'count_total' => true);
     if ($searchterm !== '') {
         $args['meta_query'] = array('relation' => 'OR', array('key' => 'first_name', 'value' => $searchterm, 'compare' => 'LIKE'), array('key' => 'last_name', 'value' => $searchterm, 'compare' => 'LIKE'));
     }
     if ($orderby) {
         switch ($orderby) {
             case 'first_name':
             case 'last_name':
                 $args['orderby'] = 'meta_value';
                 $args['meta_key'] = $orderby;
                 break;
             default:
                 $args['orderby'] = $orderby;
         }
         $args['order'] = $order;
     }
     /* query users */
     $user_query = new WP_User_Query($args);
     /* get total users */
     $total_items = $user_query->get_total();
     /* get results */
     $wpp_users = $user_query->get_results();
     /* get additional data */
     /* get people pages */
     $people_pages = get_posts(array('post_type' => 'people', 'numberposts' => -1, 'nopaging' => true, 'post_status' => 'any'));
     /* map people page IDs to usernames */
     $pages_map = array();
     foreach ($people_pages as $pp) {
         $wp_username = get_post_meta($pp->ID, 'wp_username', true);
         if ($wp_username) {
             $pages_map[$wp_username] = $pp;
         }
     }
     /* build items for table */
     $this->items = array();
     if (!empty($user_query->results)) {
         foreach ($user_query->results as $user) {
             $userdata = ltp_template::get_user_data($user);
             $student_user = array();
             $student_user["ID"] = $user->ID;
             $student_user["first_name"] = $user->first_name;
             $student_user["last_name"] = $user->last_name;
             $student_user["user_login"] = $user->user_login;
             $student_user["user_email"] = $user->user_email;
             $student_user["showcase_count"] = 0;
             $student_user["downloads_count"] = 0;
             $student_user["cv_uploaded"] = false;
             $student_user["profile_url"] = '';
             $student_user["profile_views"] = 0;
             /* get data related to profile publishing status */
             if (!isset($pages_map[$user->user_login])) {
                 $student_user["profile_status"] = "Not started";
             } else {
                 /* find out how much has been done on the profile */
                 for ($i = 1; $i < 4; $i++) {
                     if (trim($userdata["showcase" . $i . "_title"]) !== '' || trim($userdata["showcase" . $i . "_text"]) !== '' || trim($userdata["showcase" . $i . "_image"]) !== '' || trim($userdata["showcase" . $i . "_file"]) !== '' || trim($userdata["showcase" . $i . "_video"]) !== '') {
                         $student_user["showcase_count"]++;
                     }
                 }
                 if (!empty($userdata["cv"])) {
                     $student_user["cv_uploaded"] = true;
                     $student_user["downloads_count"] = ltp_data::get_downloads($pages_map[$user->user_login]->ID);
                 }
                 /* set status, view count and URL */
                 if ($pages_map[$user->user_login]->post_status == "publish") {
                     $student_user["profile_status"] = "Published";
                     $student_user["profile_url"] = get_permalink($pages_map[$user->user_login]->ID);
                 } else {
                     $student_user["profile_status"] = "Draft";
                 }
                 $student_user["profile_views"] = ltp_data::get_views($pages_map[$user->user_login]->ID);
             }
             //print('<pre>' . print_r($student_user, true) . '</pre>');
             array_push($this->items, $student_user);
         }
     }
 }
<?php

$options = ltp_options::get_options();
// redirect to https
if (!isset($_SERVER["HTTPS"]) && (isset($options["debug_ssl"]) && intval($options["debug_ssl"]) > 0)) {
    ltp_redirect_to("invalid-role");
}
if (is_user_logged_in()) {
    if (!ltp_is_admin()) {
        if (!ltp_is_student() && !ltp_is_wpp()) {
            ltp_redirect_to("invalid_role");
        } elseif (ltp_is_student()) {
            ltp_redirect_to("builder");
        } elseif (ltp_is_wpp()) {
            ltp_redirect_to("viewer");
        }
    } else {
        ltp_redirect_to("viewer");
    }
} else {
    ltp_redirect_to("login");
}
Beispiel #4
0
 /**
  * gets the login page URL
  */
 public static function login_page_url()
 {
     $options = ltp_options::get_options();
     if (isset($options["login_page_id"]) && !empty($options["login_page_id"])) {
         return get_permalink($options["login_page_id"]);
     } else {
         return false;
     }
 }