Ejemplo n.º 1
0
 /**
  * Creates an "Add to Group" drop-down list to do bulk actions on the users page
  * @return string HTML
  */
 public static function render_bulk_add_to_group()
 {
     $addtogrp = __('Add to group', 'contexture-page-security') . '…';
     $groups = CTXPS_Queries::get_groups();
     //First, add our default option...
     $html = sprintf('<option value="">%s</option>', $addtogrp);
     //Then, add the rest of our groups as options
     foreach ($groups as $group) {
         if ($group->group_system_id !== 'CPS01') {
             //Dont include Registered Users group
             $html .= CTX_Helper::gen('option', array('value' => $group->ID), $group->group_title);
         }
     }
     //Now, lets wrap that in a select list
     $html = CTX_Helper::gen('select', array('name' => 'psc_group_add', 'id' => 'psc_group_add', 'style' => 'margin-left:5px;margin-right:5px;'), $html);
     //Add a label before the select
     $html = sprintf('<label class="screen-reader-text" for="psc_group_add">%s</label>', $addtogrp) . $html;
     //Add a button after the select
     $html .= sprintf('<input type="button" name="enrollit" id="enrollit" class="button-secondary" value="%s"/>', __('Add', 'contexture-page-security'));
     //Finally, wrap all that in a div and return
     return CTX_Helper::gen('div', array('class' => 'alignleft actions'), $html);
 }
Ejemplo n.º 2
0
/**
 * Used for
 */
function gd_display_teacher_groups($user)
{
    if (current_user_can('manage_options')) {
        $user_type = get_user_meta($user->ID, 'rpr_user_type', true);
        $teacher_groups = get_user_meta($user->ID, 'gd_teacher_groups', true);
        if ($user_type === 'Teacher') {
            ?>
        <h3>Great Disease Teacher Groups</h3>
        <p>Select groups that belong to <?php 
            echo $user->display_name;
            ?>
:</p>
        <?php 
            if (class_exists('CTXPS_Queries')) {
                $groups = CTXPS_Queries::get_groups();
                foreach ($groups as $group) {
                    if ($group->ID > 1) {
                        $checked = in_array($group->ID, $teacher_groups) ? 'checked' : '';
                        echo '<input type="checkbox" id="gd-group[]" name="gd-group[]" ' . $checked . ' value="' . $group->ID . '">';
                        echo $group->group_title;
                        echo '<br />';
                    }
                }
            }
            ?>
    <?php 
        }
        // end user type check
    }
}
Ejemplo n.º 3
0
    echo '<form id="gd-avatar-upload" method="post" enctype="multipart/form-data">';
    echo '<input type="file" name="simple-local-avatar" id="simple-local-avatar" style="display: none;"/>';
    //echo '<input type="submit">';
    echo wp_nonce_field('simple_local_avatar_nonce', '_simple_local_avatar_nonce', false, false);
    echo '</form>';
}
?>
            </div>
            <h1><?php 
printf(__('%s', 'twentytwelve'), get_the_author_meta('display_name', $user_obj->ID));
?>
</h1>
            <?php 
// get the team the user belongs to ...
if (class_exists('CTXPS_Queries')) {
    $groups = CTXPS_Queries::get_groups($user_obj->ID);
    $usr_group = new stdClass();
    if (count($groups) > 0) {
        $usr_group = $groups[0];
    }
    $team_page_id = get_option('gd_team_page_id');
    $team_page_permalink = get_permalink($team_page_id);
    echo '<h1>Team: <a href="' . $team_page_permalink . '?team_id=' . $usr_group->ID . '">' . $usr_group->group_title . '</a></h1>';
    // Display team role
    $roles = get_option('gd-team-roles');
    $user_role = (int) get_user_meta($user_obj->ID, 'gd-team-role', true);
    if (is_array($roles) && isset($roles[$user_role])) {
        echo '<h1>Role: ' . $roles[$user_role] . '</h1>';
    }
}
?>
 ******************************************************************************/
$txt_h3_restrict = __('Restrict Access', 'contexture-page-security');
$txt_label_protect = __('Protect Term', 'contexture-page-security');
$txt_prottext = __('Protect this term and any content associated with it.', 'contexture-page-security');
$txt_addgroup = __('Add group...', 'contexture-page-security');
$txt_subtitle_table = __('Groups With Access', 'contexture-page-security');
/**
 * LOGIC
 ******************************************************************************/
//Determined if this term is protected
$protected_status = CTXPS_Queries::get_term_protection($_REQUEST['tag_ID']);
//Determine how protected status alters display
$echo_protcheck = $protected_status ? 'checked="checked"' : '';
$echo_tlist_style = $protected_status ? 'display:block;' : '';
//Get list of all groups
$all_groups = CTXPS_Queries::get_groups();
//Start with an empty array for $term_groups
$term_groups = CTXPS_Queries::get_groups_by_object('term', $_REQUEST['tag_ID']);
//Build $term_groups manually so that the array index uses id (to make it easier to sort)
$term_groups_simple = CTXPS_Queries::process_group_array($term_groups, 'names');
//Set default option
$ddl_group_opts = sprintf('<option value="0">%s</option>', $txt_addgroup);
//Loop through all groups in the db to populate the drop-down list
foreach ($all_groups as $group) {
    //Generate the option HTML, hiding it if it's already in our $currentGroups array
    $ddl_group_opts .= CTX_Helper::gen('option', array('class' => isset($term_groups_simple[$group->ID]) ? 'detach' : '', 'value' => $group->ID), $group->group_title);
}
//Put all those options into the select box
$selectbox = CTX_Helper::gen('select', array('id' => 'ctxps-grouplist-ddl', 'name' => 'ctxps-grouplist-ddl'), $ddl_group_opts);
/*
echo '<pre>
Ejemplo n.º 5
0
        <div id="post-content">
            <?php 
if (is_user_logged_in()) {
    if (class_exists('CTXPS_Queries')) {
        if (isset($_GET['team_id'])) {
            // get team id from $_GET query
            $team_id = (int) $_GET['team_id'];
            // check if user belongs to group if not administrator
            if (!current_user_can('manage_options')) {
                $is_member = CTXPS_Queries::check_membership(get_current_user_id(), $team_id);
            } else {
                $current_group = CTXPS_Queries::get_group_info($team_id);
                $is_member = true;
            }
        } else {
            $groups = CTXPS_Queries::get_groups(get_current_user_id());
            $current_group = new stdClass();
            if (count($groups) > 0) {
                $current_group = $groups[0];
            }
            $team_id = $current_group->ID;
            $is_member = true;
        }
        ?>
                <?php 
        if ($is_member) {
            ?>
                    <!-- team header -->
                    <div id="team-<?php 
            echo $team_id;
            ?>