示例#1
0
function local_obu_forms_extend_navigation($navigation)
{
    global $CFG, $USER, $PAGE;
    if (!isloggedin() || isguestuser()) {
        return;
    }
    $context = context_system::instance();
    $staff_manager = has_capability('local/obu_forms:manage_pg', $context) || has_capability('local/obu_forms:manage_ump_staff', $context);
    $students_manager = has_capability('local/obu_forms:manage_pg', $context) || has_capability('local/obu_forms:manage_ump_students', $context);
    $manager = $staff_manager || $students_manager;
    $staff = is_staff($USER->username);
    // Has a 'p' number?
    $student = is_student($USER->id);
    // Enrolled on a PIP-based course (programme)?
    // Add the 'My Forms' option
    if ($manager || $staff || $student || !empty(get_form_data($USER->id))) {
        // Find the 'myprofile' node
        $nodeParent = $navigation->find('myprofile', navigation_node::TYPE_UNKNOWN);
        // Add the option to list their completed forms
        if ($nodeParent) {
            $node = $nodeParent->add(get_string('myforms', 'local_obu_forms'), '/local/obu_forms/index.php?userid=' . $USER->id);
        }
    }
    if (!$manager && !$staff && !$student) {
        // Move on now please, nothing more to see here...
        return;
    }
    // Find the 'forms' node
    $nodeParent = $navigation->find(get_string('forms', 'local_obu_forms'), navigation_node::TYPE_SYSTEM);
    // If necessary, add the 'forms' node to 'home'
    if (!$nodeParent) {
        $nodeHome = $navigation->children->get('1')->parent;
        if ($nodeHome) {
            $nodeParent = $nodeHome->add(get_string('forms', 'local_obu_forms'), null, navigation_node::TYPE_SYSTEM);
        }
    }
    if ($nodeParent) {
        // For form managers, add the privileged maintenance and enquiry options
        if ($manager) {
            $node = $nodeParent->add(get_string('settings_nav', 'local_obu_forms'), '/local/obu_forms/forms.php');
            $node = $nodeParent->add(get_string('template_nav', 'local_obu_forms'), '/local/obu_forms/template.php');
            $node = $nodeParent->add(get_string('auths_nav', 'local_obu_forms'), '/local/obu_forms/auths.php');
            $node = $nodeParent->add(get_string('sc_auths', 'local_obu_forms'), '/local/obu_forms/auths.php?authoriser=csa');
            $node = $nodeParent->add(get_string('list_users_forms', 'local_obu_forms'), '/local/obu_forms/list.php');
            $node = $nodeParent->add(get_string('formslist', 'local_obu_forms'), '/local/obu_forms/formslist.php');
        } else {
            // For other users, add the option(s) to list all the relevant forms
            if ($staff) {
                $node = $nodeParent->add(get_string('staff_forms', 'local_obu_forms'), '/local/obu_forms/formslist.php?type=staff');
            }
            $node = $nodeParent->add(get_string('student_forms', 'local_obu_forms'), '/local/obu_forms/formslist.php?type=student');
            // Both staff and students can view student forms
            if ($staff) {
                $node = $nodeParent->add(get_string('list_users_forms', 'local_obu_forms'), '/local/obu_forms/list.php');
            }
        }
    }
}
/**
 * Adds extra post classes
 *
 * @since 1.0.0
 * @param array $classes
 * @return array
 */
function wpcm_post_class($classes)
{
    if (is_sponsor()) {
        $classes[] = 'wpcm-single-sponsors';
    }
    if (is_club()) {
        $classes[] = 'wpcm-single-club';
    }
    if (is_player()) {
        $classes[] = 'wpcm-single-player';
    }
    if (is_staff()) {
        $classes[] = 'wpcm-single-staff';
    }
    if (is_match()) {
        $classes[] = 'wpcm-single-match';
    }
    return $classes;
}
/**
 * is_wpclubmanager - Returns true if on a page which uses WPClubManager templates (cart and checkout are standard pages with shortcodes and thus are not included)
 *
 * @access public
 * @return bool
 */
function is_wpclubmanager()
{
    return apply_filters('is_wpclubmanager', is_match() || is_club() || is_player() || is_staff() || is_sponsor() ? true : false);
}
示例#4
0
 * OBU Forms - Get a user ID and list all their forms
 *
 * @package    local_obu_forms
 * @author     Peter Welham
 * @copyright  2016, Oxford Brookes University
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 *
 */
require_once '../../config.php';
require_once './locallib.php';
require_once './db_update.php';
require_once './user_input.php';
require_login();
$home = new moodle_url('/');
// Can only list someone else's forms if we are a form manager or a member of staff
if (!is_manager() && !is_staff($USER->username)) {
    redirect($home);
}
$dir = $home . '/local/obu_forms/';
$program = $dir . 'list.php';
$heading = get_string('list_users_forms', 'local_obu_forms');
$PAGE->set_pagelayout('standard');
$PAGE->set_url($program);
$PAGE->set_context(context_system::instance());
$PAGE->set_heading($SITE->fullname);
$PAGE->set_title($heading);
$message = '';
$mform = new user_input(null, array());
if ($mform->is_cancelled()) {
    redirect($home);
} else {
示例#5
0
require_once './locallib.php';
require_login();
// Determine if the user can list the requested forms
if (!is_manager() && !is_staff($USER->username)) {
    // Students can only see their own forms
    $user = $USER;
} else {
    $user_id = optional_param('userid', 0, PARAM_INT);
    if ($user_id == 0 || $user_id == $USER->id) {
        $user = $USER;
    } else {
        $user = $DB->get_record('user', array('id' => $user_id));
        if (!$user) {
            print_error('invaliduserid');
        }
        if (is_staff($user->username) && !is_manager()) {
            // Only managers can view forms for other staff members
            $user = $USER;
        }
    }
}
$url = new moodle_url('/local/obu_forms/index.php', array('userid' => $user_id));
$redirect_form = new moodle_url('/local/obu_forms/redirect.php');
$PAGE->set_url($url);
$PAGE->set_pagelayout('standard');
if ($user->id == $USER->id) {
    $currentuser = true;
    $heading = get_string('myforms', 'local_obu_forms');
} else {
    $currentuser = false;
    // If we're looking at someone else's forms we may need to lock/remove some UI elements