Example #1
0
function include_professors()
{
    $admin_id = get_user_id_from_string(get_blog_option($current_blog->blog_id, 'admin_email'));
    $blog_major = get_user_major();
    //get_the_user_major($admin_id);
    //var_dump($blog_major);
    if ($GLOBALS['blog_id'] != 1) {
        //makes sure it's not the root blog
        $args = array('blog_id' => 1, 'role' => 'professor');
        $professors = get_users($args);
        //get all profs from root blog
        //loop through profs, add as user if same major, delete if different major
        foreach ($professors as $professor) {
            $prof_major = get_the_user_major($professor->ID);
            //var_dump($prof_major);
            if ($prof_major == $blog_major) {
                $current_role = get_the_user_role($professor);
                if ($current_role != 'Administrator') {
                    $result = add_existing_user_to_blog(array('user_id' => $professor->ID, 'role' => 'professor'));
                }
            } else {
                $result = remove_user_from_blog($professor->ID, $current_blog->blog_id);
            }
        }
    }
    //end if
}
Example #2
0
function folios2eval_profpage($atts)
{
    global $wpdb;
    $user = wp_get_current_user();
    $major = get_the_user_major($user->ID);
    $eval_table_name = 'wp_seufolios_evaluations';
    $max_evals = 2;
    //!!HARD CODED!!!
    $return = '';
    $folio_ids = $wpdb->get_results("SELECT blogid FROM wp_seufolios_folios2eval WHERE deptid=" . $major);
    foreach ($folio_ids as $id) {
        $folios[] = get_blog_details($id->blogid);
    }
    $return .= "<style>.folios li{color: #666;}.callout-right{font-size:0.85em;margin:2em;padding:0.5em;float:right; background-color:white;border:thin solid #ccc; width:250px;max-width:40%;box-shadow: 5px 5px 3px #888888;}</style>\n";
    $time = date('Y-m-d H:i:s', time() - 7776000);
    $sql = "SELECT id FROM {$eval_table_name} WHERE profid=" . $user->ID . " AND submittime>'" . $time . "'";
    $result = $wpdb->get_results($sql);
    $return .= "<p>Hi {$user->user_nicename},</p><p>";
    if ($wpdb->num_rows) {
        $return .= "Congratulations! ";
    }
    $return .= "You've completed <strong>" . $wpdb->num_rows . "</strong> evaluations so far this semester";
    $sql = "SELECT id FROM {$eval_table_name} WHERE profid=" . $user->ID;
    $result = $wpdb->get_results($sql);
    $return .= " (and <strong>" . $wpdb->num_rows . "</strong> all time).</p>\n<hr>\n";
    $temp_return = "<p class='callout-right'>When you're ready to give feedback on the portfolio click the <em>Evaluate</em> link in the black admin bar at the top of the screen.<br><br>Oh, and once you've opened the evaluation form please either complete the evaluation or delete your feedback. Otherwise we assume you'll finish it and won't assign it to anyone else.</p>\n\t<p>There's still work to be done, though. The portfoios below need to be evaluated. Mind doing one?</p>\n<ul class='folios'>\n";
    $count = 0;
    foreach ($folios as $folio) {
        $student = get_user_by('email', get_blog_option($folio->blog_id, 'admin_email'));
        $result = $wpdb->get_results("SELECT id FROM {$eval_table_name} WHERE studentid=" . $student->ID);
        if ($max_evals - $wpdb->num_rows > 0) {
            $temp_return .= "<li><a href='http://" . $folio->domain . $folio->path . "' target='_blank'>" . $student->user_nicename . " - " . get_blog_option($folio->blog_id, 'blogname') . "</a>&nbsp;&nbsp;(Needs <strong>" . ($max_evals - $wpdb->num_rows) . "</strong> more evaluation" . ($max_evals - $wpdb->num_rows > 1 ? "s)" : ")") . "</li>\n";
            $count++;
        }
    }
    $temp_return .= "</ul>";
    if ($count) {
        $return .= $temp_return;
    } else {
        $return .= "<p>Looks like the portfolios have all been evaluated this year. You're done!</p>";
    }
    //favorites
    $star_table_name = "wp_seufolios_starred";
    $portfolios = $wpdb->get_results("SELECT * FROM {$star_table_name} WHERE deptid={$major}");
    if ($portfolios) {
        $return .= "<h2>Department's Favorites</h2>\n<ul>";
        //$return .= print_r($portfolios, true);
        foreach ($portfolios as $p) {
            $profs = unserialize($p->profids);
            $p_url = parse_url($p->blogurl);
            if (strlen($p_url['path'])) {
                if (substr($p_url['path'], -1) != '/') {
                    $p_url['path'] = $p_url['path'] . '/';
                }
                $p_blog = get_blog_details(get_blog_id_from_url($p_url['host'], $p_url['path']));
            } else {
                $p_blog = get_blog_details(get_blog_id_from_url($p_url['host']));
            }
            $plist[]['txt'] = "<li><a href='{$p->blogurl}'>{$p_blog->blogname}</a> (" . count($profs) . " favorite" . (count($profs) > 1 ? "s)" : ")") . "</li>";
            $plist[]['count'] = count($profs);
        }
        usort($plist, "cmp_plist");
        foreach ($plist as $pl) {
            $return .= $pl['txt'];
        }
        $return .= "</ul>";
    }
    return $return;
}