Example #1
0
 public static function get_vcard($student, $page_id, $latest)
 {
     global $current_user;
     $vcard = '';
     $filter_attr = array("experience", "region", "desired_region", "expertise");
     $classes = $latest ? "latest " : "";
     foreach ($filter_attr as $att) {
         if (isset($student[$att]) && is_array($student[$att]) && count($student[$att])) {
             foreach ($student[$att] as $val) {
                 $classes .= $att . '-' . preg_replace('/[^a-zA-Z0-9]+/', '', $val) . ' ';
             }
         }
     }
     if (ltp_data::is_saved($current_user->ID, $page_id)) {
         $classes .= ' saved';
     }
     $vcard .= sprintf('<div id="ltp_profile_wrap_%s" class="ltp-profile-wrap %s"><div class="vcard">', $page_id, trim($classes));
     // get full name
     $fullname = $student["firstname"] . " " . $student["surname"];
     if (isset($student['photo']) && intval($student['photo']) > 0) {
         $photo_thumb = wp_get_attachment_image_src($student['photo'], 'thumbnail');
         $vcard .= sprintf('<div class="photo"><img title="%s" src="%s"></div>', esc_attr($fullname), $photo_thumb[0]);
     }
     $vcard .= sprintf('<h2 class="full-name">%s</h2>', $fullname);
     $vcard .= sprintf('<p><strong>Email:</strong> <a href="mailto:%s" title="Email %s">%s</a></p>', $student["user"]->data->user_email, esc_attr($fullname), $student["user"]->data->user_email);
     if (isset($student['qualifications']) && $student['qualifications'] !== '') {
         $vcard .= sprintf('<p><strong>Qualifications:</strong> %s</p>', $student['qualifications']);
     }
     if (is_array($student['region']) && count($student['region']) && $student['region'][0] !== 'null') {
         $vcard .= sprintf('<p><strong>Current location:</strong> %s</p>', $student['region'][0]);
     }
     if (is_array($student['desired_region']) && count($student['desired_region'])) {
         $vcard .= sprintf('<p><strong>Willing to work in:</strong> %s</p>', implode(", ", $student['desired_region']));
     }
     if (is_array($student['experience']) && count($student['experience']) && $student['experience'][0] !== 'null') {
         $vcard .= sprintf('<p><strong>Experience (years):</strong> %s</p>', $student['experience'][0]);
     }
     if (is_array($student['expertise']) && count($student['expertise'])) {
         $vcard .= sprintf('<p><strong>Expertise:</strong> %s</p>', implode(", ", $student['expertise']));
     }
     $cv_url = false;
     if ($student['cv'] !== '') {
         $cv_url = wp_get_attachment_url($student['cv']);
     }
     if (ltp_is_wpp()) {
         $vcard .= self::wpp_profile_buttons($current_user->ID, $page_id, $cv_url);
     }
     $vcard .= '</div></div>';
     return $vcard;
 }
<?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");
}
 $user = false;
 if (!empty($username)) {
     $user = get_user_by('login', $username);
 }
 $options = ltp_options::get_options();
 /* start profile output */
 print '<div class="ltp-profile-viewer">';
 // se if a CV has been uploaded
 $cv_URL = '';
 $cv_ID = get_user_meta($user->ID, 'cv', true);
 if ($cv_ID !== '') {
     $cv_URL = wp_get_attachment_url($cv_ID);
 }
 // start toolbar output
 print '<div class="section sticky toolbar">';
 if (ltp_is_wpp()) {
     // WPP users toolbar
     print ltp_template::wpp_profile_toolbar($current_user->ID, $post->ID, $cv_URL);
 } elseif ($current_user->ID == $user->ID) {
     // student toolbar
     printf('<div class="status">Profile views: %d | Profile saves: %d | CV downloads: %d</div>', ltp_data::get_views($post->ID), ltp_data::get_saves($post->ID), ltp_data::get_downloads($post->ID));
     printf('<form action="%s" method="post">', get_permalink($options["builder_page_id"]));
     print '<button name="return" class="ppt-button ppt-return-button">Return to profile builder</button>';
     if ($post->post_status !== 'publish') {
         print '<button name="publish" class="ppt-button ppt-publish-button">Publish</button>';
     } else {
         print '<button name="unpublish" class="ppt-button ppt-unpublish-button">Un-publish</button>';
     }
     print '<p><em>This is how recruiters will see your profile</em></p>';
     print '</form>';
 }
Example #4
0
 public static function redirect_after_login($redirect, $redirect_to, $user)
 {
     $options = ltp_options::get_options();
     // make sure we have a valid user
     if ($user && is_object($user) && is_a($user, 'WP_User')) {
         if ($user->has_cap('administrator')) {
             return admin_url();
         }
         if (!ltp_is_student() && !ltp_is_wpp()) {
             return ltp_get_page_url("invalid_role");
         } elseif (ltp_is_student()) {
             return ltp_get_page_url("builder");
         } elseif (ltp_is_wpp()) {
             return ltp_get_page_url("viewer");
         }
     } else {
         $login_url = self::login_page_url();
         if ($login_url) {
             return $login_url;
         }
     }
     return $redirect;
 }
<?php

/*
Template Name: Profile Viewer Page
*/
$options = ltp_options::get_options();
if (!isset($_SERVER["HTTPS"]) && (isset($options["debug_ssl"]) && intval($options["debug_ssl"]) > 0)) {
    ltp_redirect_to("viewer");
}
// redirect users with incorrect roles
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");
        }
    }
} else {
    ltp_redirect_to('login');
}
// get the people pages - admins see drafts as well
$post_status = ltp_is_admin() ? array('publish', 'draft') : 'publish';
$people_pages = get_posts(array('post_type' => 'people', 'nopaging' => true, 'post_status' => $post_status, 'orderby' => 'modified'));
ltp_data::save_actions();
get_header();
print '<div class="section sticky toolbar">';
global $current_user;
$previous_login_date = ltp_data::get_previous_login($current_user->ID);
$profiles_added = ltp_data::get_profiles_added_since($previous_login_date);
print ltp_template::wpp_toolbar($current_user->ID, $previous_login_date, $profiles_added);