当前位置: 首页>>代码示例>>PHP>>正文


PHP print_context_name函数代码示例

本文整理汇总了PHP中print_context_name函数的典型用法代码示例。如果您正苦于以下问题:PHP print_context_name函数的具体用法?PHP print_context_name怎么用?PHP print_context_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了print_context_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: definition

 function definition()
 {
     $mform =& $this->_form;
     // First show fields specific to this type of block.
     $this->specific_definition($mform);
     // Then show the fields about where this block appears.
     $mform->addElement('header', 'whereheader', get_string('wherethisblockappears', 'block'));
     // If the current weight of the block is out-of-range, add that option in.
     $blockweight = $this->block->instance->weight;
     $weightoptions = array();
     if ($blockweight < -block_manager::MAX_WEIGHT) {
         $weightoptions[$blockweight] = $blockweight;
     }
     for ($i = -block_manager::MAX_WEIGHT; $i <= block_manager::MAX_WEIGHT; $i++) {
         $weightoptions[$i] = $i;
     }
     if ($blockweight > block_manager::MAX_WEIGHT) {
         $weightoptions[$blockweight] = $blockweight;
     }
     $first = reset($weightoptions);
     $weightoptions[$first] = get_string('bracketfirst', 'block', $first);
     $last = end($weightoptions);
     $weightoptions[$last] = get_string('bracketlast', 'block', $last);
     $regionoptions = $this->page->theme->get_all_block_regions();
     $parentcontext = get_context_instance_by_id($this->block->instance->parentcontextid);
     $mform->addElement('static', 'contextname', get_string('thisblockbelongsto', 'block'), print_context_name($parentcontext));
     $mform->addElement('selectyesno', 'bui_showinsubcontexts', get_string('appearsinsubcontexts', 'block'));
     $pagetypeoptions = matching_page_type_patterns($this->page->pagetype);
     $pagetypeoptions = array_combine($pagetypeoptions, $pagetypeoptions);
     $mform->addElement('select', 'bui_pagetypepattern', get_string('pagetypes', 'block'), $pagetypeoptions);
     if ($this->page->subpage) {
         $subpageoptions = array('%@NULL@%' => get_string('anypagematchingtheabove', 'block'), $this->page->subpage => get_string('thisspecificpage', 'block', $this->page->subpage));
         $mform->addElement('select', 'bui_subpagepattern', get_string('subpages', 'block'), $subpageoptions);
     }
     $defaultregionoptions = $regionoptions;
     $defaultregion = $this->block->instance->defaultregion;
     if (!array_key_exists($defaultregion, $defaultregionoptions)) {
         $defaultregionoptions[$defaultregion] = $defaultregion;
     }
     $mform->addElement('select', 'bui_defaultregion', get_string('defaultregion', 'block'), $defaultregionoptions);
     $mform->addElement('select', 'bui_defaultweight', get_string('defaultweight', 'block'), $weightoptions);
     // Where this block is positioned on this page.
     $mform->addElement('header', 'whereheader', get_string('onthispage', 'block'));
     $mform->addElement('selectyesno', 'bui_visible', get_string('visible', 'block'));
     $blockregion = $this->block->instance->region;
     if (!array_key_exists($blockregion, $regionoptions)) {
         $regionoptions[$blockregion] = $blockregion;
     }
     $mform->addElement('select', 'bui_region', get_string('region', 'block'), $regionoptions);
     $mform->addElement('select', 'bui_weight', get_string('weight', 'block'), $weightoptions);
     $pagefields = array('bui_visible', 'bui_region', 'bui_weight');
     if (!$this->block->user_can_edit()) {
         $mform->hardFreezeAllVisibleExcept($pagefields);
     }
     if (!$this->page->user_can_edit_blocks()) {
         $mform->hardFreeze($pagefields);
     }
     $this->add_action_buttons();
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:59,代码来源:edit_form.php

示例2: test_everything_in_accesslib


//.........这里部分代码省略.........
     $prevsize = context_inspection::test_context_cache_size();
     for ($i = 0; $i < 100; $i++) {
         context_user::instance($testusers[$i]);
         $this->assertEqual(context_inspection::test_context_cache_size(), $prevsize);
     }
     context_user::instance($testusers[102]);
     $this->assertEqual(context_inspection::test_context_cache_size(), $prevsize + 1);
     unset($testusers);
     // =================================================================
     // ======= basic test of legacy functions ==========================
     // =================================================================
     // note: watch out, the fake site might be pretty borked already
     $this->assertIdentical(get_system_context(), context_system::instance());
     foreach ($DB->get_records('context') as $contextid => $record) {
         $context = context::instance_by_id($contextid);
         $this->assertIdentical(get_context_instance_by_id($contextid), $context);
         $this->assertIdentical(get_context_instance($record->contextlevel, $record->instanceid), $context);
         $this->assertIdentical(get_parent_contexts($context), $context->get_parent_context_ids());
         if ($context->id == SYSCONTEXTID) {
             $this->assertIdentical(get_parent_contextid($context), false);
         } else {
             $this->assertIdentical(get_parent_contextid($context), $context->get_parent_context()->id);
         }
     }
     $children = get_child_contexts($systemcontext);
     $this->assertEqual(count($children), $DB->count_records('context') - 1);
     unset($children);
     $DB->delete_records('context', array('contextlevel' => CONTEXT_BLOCK));
     create_contexts();
     $this->assertFalse($DB->record_exists('context', array('contextlevel' => CONTEXT_BLOCK)));
     $DB->set_field('context', 'depth', 0, array('contextlevel' => CONTEXT_BLOCK));
     build_context_path();
     $this->assertFalse($DB->record_exists('context', array('depth' => 0)));
     $lastcourse = $DB->get_field_sql("SELECT MAX(id) FROM {course}");
     $DB->delete_records('course', array('id' => $lastcourse));
     $lastcategory = $DB->get_field_sql("SELECT MAX(id) FROM {course_categories}");
     $DB->delete_records('course_categories', array('id' => $lastcategory));
     $lastuser = $DB->get_field_sql("SELECT MAX(id) FROM {user} WHERE deleted=0");
     $DB->delete_records('user', array('id' => $lastuser));
     $DB->delete_records('block_instances', array('parentcontextid' => $frontpagepagecontext->id));
     $DB->delete_records('course_modules', array('id' => $frontpagepagecontext->instanceid));
     cleanup_contexts();
     $count = 1;
     //system
     $count += $DB->count_records('user', array('deleted' => 0));
     $count += $DB->count_records('course_categories');
     $count += $DB->count_records('course');
     $count += $DB->count_records('course_modules');
     $count += $DB->count_records('block_instances');
     $this->assertEqual($DB->count_records('context'), $count);
     context_helper::reset_caches();
     preload_course_contexts($SITE->id);
     $this->assertEqual(context_inspection::test_context_cache_size(), 1);
     context_helper::reset_caches();
     list($select, $join) = context_instance_preload_sql('c.id', CONTEXT_COURSECAT, 'ctx');
     $sql = "SELECT c.id {$select} FROM {course_categories} c {$join}";
     $records = $DB->get_records_sql($sql);
     foreach ($records as $record) {
         context_instance_preload($record);
         $record = (array) $record;
         $this->assertEqual(1, count($record));
         // only id left
     }
     $this->assertEqual(count($records), context_inspection::test_context_cache_size());
     accesslib_clear_all_caches(true);
     $DB->delete_records('cache_flags', array());
     mark_context_dirty($systemcontext->path);
     $dirty = get_cache_flags('accesslib/dirtycontexts', time() - 2);
     $this->assertTrue(isset($dirty[$systemcontext->path]));
     accesslib_clear_all_caches(false);
     $DB->delete_records('cache_flags', array());
     $course = $DB->get_record('course', array('id' => $testcourses[2]));
     $context = get_context_instance(CONTEXT_COURSE, $course->id);
     $oldpath = $context->path;
     $miscid = $DB->get_field_sql("SELECT MIN(id) FROM {course_categories}");
     $categorycontext = context_coursecat::instance($miscid);
     $course->category = $miscid;
     $DB->update_record('course', $course);
     context_moved($context, $categorycontext);
     $context = get_context_instance(CONTEXT_COURSE, $course->id);
     $this->assertIdentical($context->get_parent_context(), $categorycontext);
     $this->assertTrue($DB->record_exists('context', array('contextlevel' => CONTEXT_COURSE, 'instanceid' => $testcourses[2])));
     delete_context(CONTEXT_COURSE, $testcourses[2]);
     $this->assertFalse($DB->record_exists('context', array('contextlevel' => CONTEXT_COURSE, 'instanceid' => $testcourses[2])));
     $name = get_contextlevel_name(CONTEXT_COURSE);
     $this->assertFalse(empty($name));
     $context = get_context_instance(CONTEXT_COURSE, $testcourses[2]);
     $name = print_context_name($context);
     $this->assertFalse(empty($name));
     $url = get_context_url($coursecontext);
     $this->assertFalse($url instanceof modole_url);
     $page = $DB->get_record('page', array('id' => $testpages[7]));
     $context = get_context_instance(CONTEXT_MODULE, $page->id);
     $coursecontext = get_course_context($context);
     $this->assertEqual($coursecontext->contextlevel, CONTEXT_COURSE);
     $this->assertEqual(get_courseid_from_context($context), $page->course);
     $caps = fetch_context_capabilities($systemcontext);
     $this->assertTrue(is_array($caps));
     unset($caps);
 }
开发者ID:rolandovanegas,项目名称:moodle,代码行数:101,代码来源:fulltestaccesslib.php

示例3: print_simple_box_end

    include 'assign.html';
    print_simple_box_end();
    if (!empty($errors)) {
        $msg = '<p>';
        foreach ($errors as $e) {
            $msg .= $e . '<br />';
        }
        $msg .= '</p>';
        print_simple_box_start('center');
        notify($msg);
        print_simple_box_end();
    }
    //Back to Assign Roles button
    echo "<br/>";
    echo "<div class='continuebutton'>";
    print_single_button('assign.php', array('contextid' => $contextid), get_string('assignrolesin', 'role', print_context_name($context)));
    echo "</div>";
} else {
    // Print overview table
    // sync metacourse enrolments if needed
    if ($inmeta) {
        sync_metacourse($course);
    }
    // Get the names of role holders for roles with between 1 and MAX_USERS_TO_LIST_PER_ROLE users,
    // and so determine whether to show the extra column.
    $rolehodlercount = array();
    $rolehodlernames = array();
    $strmorethanten = get_string('morethan', 'role', MAX_USERS_TO_LIST_PER_ROLE);
    $showroleholders = false;
    foreach ($assignableroles as $roleid => $rolename) {
        $countusers = count_role_users($roleid, $context);
开发者ID:kai707,项目名称:ITSA-backup,代码行数:31,代码来源:assign.php

示例4: optional_param

$courseid = optional_param('courseid', 0, PARAM_INT);
// needed for user tabs
/// Get the base URL for this and related pages into a convenient variable.
$baseurl = $CFG->wwwroot . '/' . $CFG->admin . '/roles/override.php?contextid=' . $contextid;
if (!empty($userid)) {
    $baseurl .= '&amp;userid=' . $userid;
}
if ($courseid && $courseid != SITEID) {
    $baseurl .= '&amp;courseid=' . $courseid;
}
/// Validate the contextid parameter.
if (!($context = $DB->get_record('context', array('id' => $contextid)))) {
    print_error('wrongcontextid', 'error');
}
$isfrontpage = $context->contextlevel == CONTEXT_COURSE && $context->instanceid == SITEID;
$contextname = print_context_name($context);
if ($context->contextlevel == CONTEXT_SYSTEM) {
    print_error('cannotoverridebaserole', 'error');
}
/// Validate the courseid parameter.
if ($context->contextlevel == CONTEXT_COURSE) {
    $courseid = $context->instanceid;
    if (!($course = $DB->get_record('course', array('id' => $courseid)))) {
        print_error('invalidcourse');
    }
}
if ($courseid) {
    // we need this for user tabs in user context
    if (!($course = $DB->get_record('course', array('id' => $courseid)))) {
        print_error('invalidcourse');
    }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:override.php

示例5: debug_summary

 /**
  * @return string a description of this page. Normally displayed in the footer in
  * developer debug mode.
  */
 public function debug_summary() {
     $summary = '';
     $summary .= 'General type: ' . $this->pagelayout . '. ';
     if (!during_initial_install()) {
         $summary .= 'Context ' . print_context_name($this->_context) . ' (context id ' . $this->_context->id . '). ';
     }
     $summary .= 'Page type ' . $this->pagetype .  '. ';
     if ($this->subpage) {
         'Sub-page ' . $this->subpage .  '. ';
     }
     return $summary;
 }
开发者ID:nottmoo,项目名称:moodle,代码行数:16,代码来源:pagelib.php

示例6: get_category_options

 protected function get_category_options($currentcontextid)
 {
     $displaylist = array();
     $parentlist = array();
     make_categories_list($displaylist, $parentlist, 'moodle/cohort:manage');
     $options = array();
     $syscontext = context_system::instance();
     if (has_capability('moodle/cohort:manage', $syscontext)) {
         $options[$syscontext->id] = print_context_name($syscontext);
     }
     foreach ($displaylist as $cid => $name) {
         $context = context_coursecat::instance($cid);
         $options[$context->id] = $name;
     }
     // always add current - this is not likely, but if the logic gets changed it might be a problem
     if (!isset($options[$currentcontextid])) {
         $context = get_context_instance_by_id($currentcontextid, MUST_EXIST);
         $options[$context->id] = print_context_name($syscontext);
     }
     return $options;
 }
开发者ID:nigeli,项目名称:moodle,代码行数:21,代码来源:edit_form.php

示例7: report_security_check_riskbackup

/**
 * Lists all roles that have the ability to backup user data, as well as users
 * @param bool $detailed
 * @return object result
 */
function report_security_check_riskbackup($detailed = false)
{
    global $CFG;
    $result = new object();
    $result->issue = 'report_security_check_riskbackup';
    $result->name = get_string('check_riskbackup_name', 'report_security');
    $result->info = null;
    $result->details = null;
    $result->status = null;
    $result->link = null;
    $syscontext = get_context_instance(CONTEXT_SYSTEM);
    $systemroles = get_records_sql("SELECT DISTINCT r.*\n           FROM {$CFG->prefix}role r\n           JOIN {$CFG->prefix}role_capabilities rc ON rc.roleid = r.id\n          WHERE rc.capability = 'moodle/backup:userinfo' AND rc.contextid = {$syscontext->id} AND rc.permission = " . CAP_ALLOW . "");
    $overriddenroles = get_records_sql("SELECT DISTINCT r.*, rc.contextid\n           FROM {$CFG->prefix}role r\n           JOIN {$CFG->prefix}role_capabilities rc ON rc.roleid = r.id\n          WHERE rc.capability = 'moodle/backup:userinfo' AND rc.contextid <> {$syscontext->id} AND rc.permission = " . CAP_ALLOW . "");
    // list of users that are able to backup personal info
    // note: "sc" is context where is role assigned,
    //       "c" is context where is role overriden or system context if in role definition
    $sqluserinfo = "\n        FROM (SELECT rcx.*\n                FROM {$CFG->prefix}role_capabilities rcx\n               WHERE rcx.permission = " . CAP_ALLOW . " AND rcx.capability = 'moodle/backup:userinfo') rc,\n             {$CFG->prefix}context c,\n             {$CFG->prefix}context sc,\n             {$CFG->prefix}role_assignments ra,\n             {$CFG->prefix}user u\n       WHERE c.id = rc.contextid\n             AND (sc.path = c.path OR sc.path LIKE " . sql_concat('c.path', "'/%'") . " OR c.path LIKE " . sql_concat('sc.path', "'/%'") . ")\n             AND u.id = ra.userid AND u.deleted = 0\n             AND ra.contextid = sc.id AND ra.roleid = rc.roleid\n             AND sc.contextlevel <= " . CONTEXT_COURSE . " AND c.contextlevel <= " . CONTEXT_COURSE . "";
    $usercount = count_records_sql("SELECT COUNT('x') FROM (SELECT DISTINCT u.id {$sqluserinfo}) userinfo");
    $systemrolecount = empty($systemroles) ? 0 : count($systemroles);
    $overriddenrolecount = empty($overriddenroles) ? 0 : count($overriddenroles);
    $result->status = REPORT_SECURITY_WARNING;
    // there is always at least one admin
    $a = (object) array('rolecount' => $systemrolecount, 'overridecount' => $overriddenrolecount, 'usercount' => $usercount);
    $result->info = get_string('check_riskbackup_warning', 'report_security', $a);
    if ($detailed) {
        $result->details = '';
        // Will be added to later
        // Make a list of roles
        if ($systemroles) {
            $links = array();
            foreach ($systemroles as $role) {
                $role->url = "{$CFG->wwwroot}/{$CFG->admin}/roles/manage.php?action=edit&amp;roleid={$role->id}";
                $links[] = '<li>' . get_string('check_riskbackup_editrole', 'report_security', $role) . '</li>';
            }
            $links = '<ul>' . implode($links) . '</ul>';
            $result->details .= get_string('check_riskbackup_details_systemroles', 'report_security', $links);
        }
        // Make a list of overrides to roles
        $rolelinks2 = array();
        if ($overriddenroles) {
            $links = array();
            foreach ($overriddenroles as $role) {
                $context = get_context_instance_by_id($role->contextid);
                if ($context->contextlevel == CONTEXT_COURSE) {
                    $role->name = role_get_name($role, $context);
                }
                $role->contextname = print_context_name($context);
                $role->url = "{$CFG->wwwroot}/{$CFG->admin}/roles/override.php?contextid={$role->contextid}&amp;roleid={$role->id}";
                $links[] = '<li>' . get_string('check_riskbackup_editoverride', 'report_security', $role) . '</li>';
            }
            $links = '<ul>' . implode($links) . '</ul>';
            $result->details .= get_string('check_riskbackup_details_overriddenroles', 'report_security', $links);
        }
        // Get a list of affected users as well
        $rs = get_recordset_sql("SELECT DISTINCT u.id, u.firstname, u.lastname, u.picture, u.imagealt, u.email, ra.contextid, ra.roleid\n            {$sqluserinfo} ORDER BY u.lastname, u.firstname");
        $users = array();
        while ($user = rs_fetch_next_record($rs)) {
            $context = get_context_instance_by_id($user->contextid);
            $url = "{$CFG->wwwroot}/{$CFG->admin}/roles/assign.php?contextid={$user->contextid}&amp;roleid={$user->roleid}";
            $a = (object) array('fullname' => fullname($user), 'url' => $url, 'email' => $user->email, 'contextname' => print_context_name($context));
            $users[] = '<li>' . get_string('check_riskbackup_unassign', 'report_security', $a) . '</li>';
        }
        rs_close($rs);
        if (!empty($users)) {
            $users = '<ul>' . implode($users) . '</ul>';
            $result->details .= get_string('check_riskbackup_details_users', 'report_security', $users);
        }
    }
    return $result;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:75,代码来源:lib.php

示例8: array

$crumbs[] = array('name' => $strmovingquestions, 'link' => '', 'type' => 'title');
$navigation = build_navigation($crumbs);
print_header_simple($strmovingquestions, '', $navigation, "", "", true, $strupdatemodule);
// print tabs
if ($cm !== null) {
    $currenttab = 'edit';
    $mode = 'questions';
    ${$cm->modname} = $module;
    include $CFG->dirroot . "/mod/{$cm->modname}/tabs.php";
} else {
    $currenttab = 'questions';
    include 'tabs.php';
}
//parameter for get_string
$questionsstr = new object();
$questionsstr->tocontext = print_context_name($tocat->context);
$questionsstr->fromareaname = $fromareaname;
//comma seperated string "'xx', 'cx', 'sdf' and 'fgdhfg'"
$questionnamestojoin = array();
foreach ($questions as $question) {
    $questionnamestojoin[] = $question->name;
}
$tojoincount = count($questionnamestojoin);
if ($tojoincount > 1) {
    $a = new object();
    $a->one = $questionnamestojoin[$tojoincount - 2] . '"</strong>';
    $a->two = '<strong>"' . $questionnamestojoin[$tojoincount - 1];
    $questionnamestojoin[$tojoincount - 2] = get_string('and', '', $a);
    unset($questionnamestojoin[$tojoincount - 1]);
}
$questionsstr->questions = '<strong>"' . join($questionnamestojoin, '"</strong>, <strong>"') . '"</strong>';
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:contextmoveq.php

示例9: get_field

                }
            }
            $rolename = get_field('role', 'name', 'id', $roleid);
            add_to_log($course->id, 'role', 'unassign', 'admin/roles/assign.php?contextid=' . $context->id . '&roleid=' . $roleid, $rolename, '', $USER->id);
        } else {
            if ($showall) {
                $searchtext = '';
                $previoussearch = 0;
            }
        }
    }
}
if ($context->contextlevel == CONTEXT_COURSE and $context->instanceid == SITEID) {
    print_heading_with_help(get_string('frontpageroles', 'admin'), 'assignroles');
} else {
    print_heading_with_help(get_string('assignrolesin', 'role', print_context_name($context)), 'assignroles');
}
if ($context->contextlevel == CONTEXT_SYSTEM) {
    print_box(get_string('globalroleswarning', 'role'));
}
if ($roleid) {
    /// prints a form to swap roles
    /// Get all existing participants in this context.
    // Why is this not done with get_users???
    if (!($contextusers = get_role_users($roleid, $context, false, 'u.id, u.firstname, u.lastname, u.email, ra.hidden'))) {
        $contextusers = array();
    }
    $select = "username <> 'guest' AND deleted = 0 AND confirmed = 1";
    $usercount = count_records_select('user', $select) - count($contextusers);
    $searchtext = trim($searchtext);
    if ($searchtext !== '') {
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:assign.php

示例10: output_edit_lists

    /**
     * Outputs a list to allow editing/rearranging of existing categories
     *
     * $this->initialize() must have already been called
     *
     */
    public function output_edit_lists() {
        global $OUTPUT;

        echo $OUTPUT->heading_with_help(get_string('editcategories', 'question'), 'editcategories', 'question');

        foreach ($this->editlists as $context => $list){
            $listhtml = $list->to_html(0, array('str'=>$this->str));
            if ($listhtml){
                echo $OUTPUT->box_start('boxwidthwide boxaligncenter generalbox questioncategories contextlevel' . $list->context->contextlevel);
                echo $OUTPUT->heading(get_string('questioncatsfor', 'question', print_context_name(context::instance_by_id($context))), 3);
                echo $listhtml;
                echo $OUTPUT->box_end();
            }
        }
        echo $list->display_page_numbers();
     }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:22,代码来源:category_class.php

示例11: item_name

 public function item_name()
 {
     return print_context_name($this->record);
 }
开发者ID:ndunand,项目名称:moodle-qtype_ddmarker,代码行数:4,代码来源:questionlists.php

示例12: question_make_default_categories

/**
 * Gets the default category in the most specific context.
 * If no categories exist yet then default ones are created in all contexts.
 *
 * @param array $contexts  The context objects for this context and all parent contexts.
 * @return object The default category - the category in the course context
 */
function question_make_default_categories($contexts)
{
    global $DB;
    static $preferredlevels = array(CONTEXT_COURSE => 4, CONTEXT_MODULE => 3, CONTEXT_COURSECAT => 2, CONTEXT_SYSTEM => 1);
    $toreturn = null;
    $preferredness = 0;
    // If it already exists, just return it.
    foreach ($contexts as $key => $context) {
        if (!($exists = $DB->record_exists("question_categories", array('contextid' => $context->id)))) {
            // Otherwise, we need to make one
            $category = new stdClass();
            $contextname = print_context_name($context, false, true);
            $category->name = get_string('defaultfor', 'question', $contextname);
            $category->info = get_string('defaultinfofor', 'question', $contextname);
            $category->contextid = $context->id;
            $category->parent = 0;
            // By default, all categories get this number, and are sorted alphabetically.
            $category->sortorder = 999;
            $category->stamp = make_unique_id_code();
            $category->id = $DB->insert_record('question_categories', $category);
        } else {
            $category = question_get_default_category($context->id);
        }
        $thispreferredness = $preferredlevels[$context->contextlevel];
        if (has_any_capability(array('moodle/question:usemine', 'moodle/question:useall'), $context)) {
            $thispreferredness += 10;
        }
        if ($thispreferredness > $preferredness) {
            $toreturn = $category;
            $preferredness = $thispreferredness;
        }
    }
    if (!is_null($toreturn)) {
        $toreturn = clone $toreturn;
    }
    return $toreturn;
}
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:44,代码来源:questionlib.php

示例13: get_recordset_sql

     /// so that the number of available users is right and we save time looping later
     $availableusers = get_recordset_sql('SELECT id, firstname, lastname, email
                                             FROM ' . $CFG->prefix . 'user
                                             WHERE ' . $select . '
                                             AND id NOT IN (
                                                 SELECT u.id
                                                 FROM ' . $CFG->prefix . 'role_assignments r,
                                                 ' . $CFG->prefix . 'user u
                                                 WHERE r.contextid = ' . $contextid . '
                                                 AND u.id = r.userid
                                                 AND r.roleid = ' . $roleid . '
                                                 ' . $selectsql . ')
                                             ORDER BY lastname ASC, firstname ASC');
     $usercount = count_records_select('user', $select) - count($contextusers);
 }
 echo '<div style="text-align:center">' . $strcurrentcontext . ': ' . print_context_name($context) . '<br/>';
 $assignableroles = array('0' => get_string('listallroles', 'role') . '...') + $assignableroles;
 popup_form("{$CFG->wwwroot}/{$CFG->admin}/roles/assign.php?userid={$userid}&amp;courseid={$courseid}&amp;contextid={$contextid}&amp;roleid=", $assignableroles, 'switchrole', $roleid, '', '', '', false, 'self', $strroletoassign);
 echo '</div>';
 print_simple_box_start('center');
 include 'assign.html';
 print_simple_box_end();
 if (!empty($errors)) {
     $msg = '<p>';
     foreach ($errors as $e) {
         $msg .= $e . '<br />';
     }
     $msg .= '</p>';
     print_simple_box_start('center');
     notify($msg);
     print_simple_box_end();
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:assign.php

示例14: array

    }
    global $SESSION;
    $SESSION->user_filtering = array();
    // Redirect to calling page
    redirect('pick.php?courseid=' . $courseid, get_string('changessaved'));
}
$PAGE->set_url('/blocks/pick_students/assign.php');
$PAGE->set_pagelayout('base');
$title = print_context_name($context) . ' - ';
$strtitle = get_string('enrolledusers', 'enrol');
$PAGE->set_title($strtitle);
$PAGE->set_heading($title . $strtitle);
$PAGE->navbar->add(get_string('pick_students', 'block_pick_students'));
$PAGE->navbar->add($strtitle);
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('assignrolesin', 'role', print_context_name($context)), 2);
echo '<form method="post" action="assign.php?courseid=' . $courseid . '" name="form">';
echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />';
echo '<input type="hidden" name="assign_course" value="' . $assign_course . '" />';
echo '<input type="hidden" name="assign_roleid" value="' . $assign_roleid . '" />';
if (isset($_POST['users']) && count($_POST['users']) > 0) {
    $table->head = array(get_string('fullname'), get_string('email'), get_string('institution'), get_string('department'), get_string('city'), "");
    $table->align = array('left', 'left', 'left', 'left', 'left', 'center');
    $table->width = "100%";
    foreach ($_POST['users'] as $userid => $username) {
        // Simply skip users not existing
        if (!($user = $DB->get_record("user", array('id' => $userid)))) {
            continue;
        }
        $message = 'ok';
        $isok = true;
开发者ID:stepsgithub,项目名称:moodle-block_pick_students,代码行数:31,代码来源:assign.php

示例15: has_capability

$canassign = has_capability('moodle/cohort:assign', $context);
if (!$manager) {
    require_capability('moodle/cohort:view', $context);
}
$strcohorts = get_string('cohorts', 'cohort');
if ($category) {
    $PAGE->set_pagelayout('report');
    $PAGE->set_context($context);
    $PAGE->set_url('/cohort/index.php', array('contextid' => $context->id));
    $PAGE->set_title($strcohorts);
    $PAGE->set_heading($COURSE->fullname);
} else {
    admin_externalpage_setup('cohorts', '', null, '', array('pagelayout' => 'report'));
}
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('cohortsin', 'cohort', print_context_name($context)));
// add search form
$search = html_writer::start_tag('form', array('id' => 'searchcohortquery', 'method' => 'get'));
$search .= html_writer::start_tag('div');
$search .= html_writer::label(get_string('searchcohort', 'cohort') . ':', 'cohort_search_q');
$search .= html_writer::empty_tag('input', array('id' => 'cohort_search_q', 'type' => 'text', 'name' => 'search', 'value' => $searchquery));
$search .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('search', 'cohort')));
$search .= html_writer::end_tag('div');
$search .= html_writer::end_tag('form');
echo $search;
$cohorts = cohort_get_cohorts($context->id, $page, 25, $searchquery);
// output pagination bar
$params = array('page' => $page);
if ($contextid) {
    $params['contextid'] = $contextid;
}
开发者ID:nigeli,项目名称:moodle,代码行数:31,代码来源:index.php


注:本文中的print_context_name函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。