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


PHP core_collator类代码示例

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


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

示例1: definition

 /**
  * Form definition.
  *
  * @return void
  */
 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $mform->disable_form_change_checker();
     $mform->addElement('header', 'search', get_string('search', 'search'));
     // Help info depends on the selected search engine.
     $mform->addElement('text', 'q', get_string('enteryoursearchquery', 'search'));
     $mform->addHelpButton('q', 'searchinfo', $this->_customdata['searchengine']);
     $mform->setType('q', PARAM_TEXT);
     $mform->addRule('q', get_string('required'), 'required', null, 'client');
     $mform->addElement('header', 'filtersection', get_string('filterheader', 'search'));
     $mform->setExpanded('filtersection', false);
     $mform->addElement('text', 'title', get_string('title', 'search'));
     $mform->setType('title', PARAM_TEXT);
     $search = \core_search\manager::instance();
     $searchareas = \core_search\manager::get_search_areas_list(true);
     $areanames = array();
     foreach ($searchareas as $areaid => $searcharea) {
         $areanames[$areaid] = $searcharea->get_visible_name();
     }
     // Sort the array by the text.
     \core_collator::asort($areanames);
     $options = array('multiple' => true, 'noselectionstring' => get_string('allareas', 'search'));
     $mform->addElement('autocomplete', 'areaids', get_string('searcharea', 'search'), $areanames, $options);
     $options = array('multiple' => true, 'limittoenrolled' => !is_siteadmin(), 'noselectionstring' => get_string('allcourses', 'search'));
     $mform->addElement('course', 'courseids', get_string('courses', 'core'), $options);
     $mform->setType('courseids', PARAM_INT);
     $mform->addElement('date_time_selector', 'timestart', get_string('fromtime', 'search'), array('optional' => true));
     $mform->setDefault('timestart', 0);
     $mform->addElement('date_time_selector', 'timeend', get_string('totime', 'search'), array('optional' => true));
     $mform->setDefault('timeend', 0);
     $this->add_action_buttons(false, get_string('search', 'search'));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:39,代码来源:search.php

示例2: get_list_of_timezones

 /**
  * Returns a localised list of timezones.
  * @param string $currentvalue
  * @param bool $include99 should the server timezone info be included?
  * @return array
  */
 public static function get_list_of_timezones($currentvalue = null, $include99 = false)
 {
     self::init_zones();
     // Localise first.
     $timezones = array();
     foreach (self::$goodzones as $tzkey => $ignored) {
         $timezones[$tzkey] = self::get_localised_timezone($tzkey);
     }
     core_collator::asort($timezones);
     // Add '99' if requested.
     if ($include99 or $currentvalue == 99) {
         $timezones['99'] = self::get_localised_timezone('99');
     }
     if (!isset($currentvalue) or isset($timezones[$currentvalue])) {
         return $timezones;
     }
     if (is_numeric($currentvalue)) {
         // UTC offset.
         $modifier = $currentvalue > 0 ? '+' : '';
         $a = 'UTC' . $modifier . number_format($currentvalue, 1);
         $timezones[$currentvalue] = get_string('timezoneinvalid', 'core_admin', $a);
     } else {
         // Some string we don't recognise.
         $timezones[$currentvalue] = get_string('timezoneinvalid', 'core_admin', $currentvalue);
     }
     return $timezones;
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:33,代码来源:date.php

示例3: filter

 function filter($text, array $options = array())
 {
     $coursectx = $this->context->get_course_context(false);
     if (!$coursectx) {
         return $text;
     }
     $courseid = $coursectx->instanceid;
     // Initialise/invalidate our trivial cache if dealing with a different course
     if (!isset(self::$cachedcourseid) || self::$cachedcourseid !== (int) $courseid) {
         self::$activitylist = null;
     }
     self::$cachedcourseid = (int) $courseid;
     /// It may be cached
     if (is_null(self::$activitylist)) {
         self::$activitylist = array();
         $modinfo = get_fast_modinfo($courseid);
         if (!empty($modinfo->cms)) {
             self::$activitylist = array();
             // We will store all the created filters here.
             // Create array of visible activities sorted by the name length (we are only interested in properties name and url).
             $sortedactivities = array();
             foreach ($modinfo->cms as $cm) {
                 // Exclude labels, hidden activities and activities for group members only.
                 if ($cm->visible and empty($cm->groupmembersonly) and $cm->has_view()) {
                     $sortedactivities[] = (object) array('name' => $cm->name, 'url' => $cm->url, 'id' => $cm->id, 'namelen' => strlen($cm->name));
                 }
             }
             core_collator::asort_objects_by_property($sortedactivities, 'namelen', SORT_NUMERIC);
             foreach ($sortedactivities as $cm) {
                 $title = s(trim(strip_tags($cm->name)));
                 $currentname = trim($cm->name);
                 $entitisedname = s($currentname);
                 // Avoid empty or unlinkable activity names.
                 if (!empty($title)) {
                     $href_tag_begin = html_writer::start_tag('a', array('class' => 'autolink', 'title' => $title, 'href' => $cm->url));
                     self::$activitylist[$cm->id] = new filterobject($currentname, $href_tag_begin, '</a>', false, true);
                     if ($currentname != $entitisedname) {
                         // If name has some entity (&amp; &quot; &lt; &gt;) add that filter too. MDL-17545.
                         self::$activitylist[$cm->id . '-e'] = new filterobject($entitisedname, $href_tag_begin, '</a>', false, true);
                     }
                 }
             }
         }
     }
     $filterslist = array();
     if (self::$activitylist) {
         $cmid = $this->context->instanceid;
         if ($this->context->contextlevel == CONTEXT_MODULE && isset(self::$activitylist[$cmid])) {
             // remove filterobjects for the current module
             $filterslist = array_values(array_diff_key(self::$activitylist, array($cmid => 1, $cmid . '-e' => 1)));
         } else {
             $filterslist = array_values(self::$activitylist);
         }
     }
     if ($filterslist) {
         return $text = filter_phrases($text, $filterslist);
     } else {
         return $text;
     }
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:60,代码来源:filter.php

示例4: get_javascript_init_params

 protected function get_javascript_init_params($course, \cm_info $cm = null, \section_info $section = null)
 {
     global $DB, $CFG;
     require_once $CFG->libdir . '/gradelib.php';
     require_once $CFG->dirroot . '/course/lib.php';
     // Get grades as basic associative array.
     $gradeoptions = array();
     $items = \grade_item::fetch_all(array('courseid' => $course->id));
     // For some reason the fetch_all things return null if none.
     $items = $items ? $items : array();
     foreach ($items as $id => $item) {
         // Don't include the grade item if it's linked with a module that is being deleted.
         if (course_module_instance_pending_deletion($item->courseid, $item->itemmodule, $item->iteminstance)) {
             continue;
         }
         // Do not include grades for current item.
         if ($cm && $cm->instance == $item->iteminstance && $cm->modname == $item->itemmodule && $item->itemtype == 'mod') {
             continue;
         }
         $gradeoptions[$id] = $item->get_name(true);
     }
     \core_collator::asort($gradeoptions);
     // Change to JS array format and return.
     $jsarray = array();
     foreach ($gradeoptions as $id => $name) {
         $jsarray[] = (object) array('id' => $id, 'name' => $name);
     }
     return array($jsarray);
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:29,代码来源:frontend.php

示例5: choice_user_complete

/**
 * Callback for the "Complete" report - prints the activity summary for the given user
 *
 * @param object $course
 * @param object $user
 * @param object $mod
 * @param object $choice
 */
function choice_user_complete($course, $user, $mod, $choice)
{
    global $DB;
    if ($answers = $DB->get_records('choice_answers', array("choiceid" => $choice->id, "userid" => $user->id))) {
        $info = [];
        foreach ($answers as $answer) {
            $info[] = "'" . format_string(choice_get_option_text($choice, $answer->optionid)) . "'";
        }
        core_collator::asort($info);
        echo get_string("answered", "choice") . ": " . join(', ', $info) . ". " . get_string("updated", '', userdate($answer->timemodified));
    } else {
        print_string("notanswered", "choice");
    }
}
开发者ID:jackdaniels79,项目名称:moodle,代码行数:22,代码来源:lib.php

示例6: get_javascript_init_params

 protected function get_javascript_init_params($course, \cm_info $cm = null, \section_info $section = null)
 {
     // Standard user fields.
     $standardfields = array('firstname' => get_user_field_name('firstname'), 'lastname' => get_user_field_name('lastname'), 'email' => get_user_field_name('email'), 'city' => get_user_field_name('city'), 'country' => get_user_field_name('country'), 'url' => get_user_field_name('url'), 'icq' => get_user_field_name('icq'), 'skype' => get_user_field_name('skype'), 'aim' => get_user_field_name('aim'), 'yahoo' => get_user_field_name('yahoo'), 'msn' => get_user_field_name('msn'), 'idnumber' => get_user_field_name('idnumber'), 'institution' => get_user_field_name('institution'), 'department' => get_user_field_name('department'), 'phone1' => get_user_field_name('phone1'), 'phone2' => get_user_field_name('phone2'), 'address' => get_user_field_name('address'));
     \core_collator::asort($standardfields);
     // Custom fields.
     $customfields = array();
     $options = array('context' => \context_course::instance($course->id));
     foreach (condition::get_custom_profile_fields() as $field) {
         $customfields[$field->shortname] = format_string($field->name, true, $options);
     }
     \core_collator::asort($customfields);
     // Make arrays into JavaScript format (non-associative, ordered) and return.
     return array(self::convert_associative_array_for_js($standardfields, 'field', 'display'), self::convert_associative_array_for_js($customfields, 'field', 'display'));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:15,代码来源:frontend.php

示例7: get_content

 function get_content()
 {
     global $CFG, $DB, $OUTPUT;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     $this->content->footer = '';
     $course = $this->page->course;
     require_once $CFG->dirroot . '/course/lib.php';
     $modinfo = get_fast_modinfo($course);
     $modfullnames = array();
     $archetypes = array();
     foreach ($modinfo->cms as $cm) {
         // Exclude activities which are not visible or have no link (=label)
         if (!$cm->uservisible or !$cm->has_view()) {
             continue;
         }
         if (array_key_exists($cm->modname, $modfullnames)) {
             continue;
         }
         if (!array_key_exists($cm->modname, $archetypes)) {
             $archetypes[$cm->modname] = plugin_supports('mod', $cm->modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
         }
         if ($archetypes[$cm->modname] == MOD_ARCHETYPE_RESOURCE) {
             if (!array_key_exists('resources', $modfullnames)) {
                 $modfullnames['resources'] = get_string('resources');
             }
         } else {
             $modfullnames[$cm->modname] = $cm->modplural;
         }
     }
     core_collator::asort($modfullnames);
     foreach ($modfullnames as $modname => $modfullname) {
         if ($modname === 'resources') {
             $icon = $OUTPUT->pix_icon('icon', '', 'mod_page', array('class' => 'icon'));
             $this->content->items[] = '<a href="' . $CFG->wwwroot . '/course/resources.php?id=' . $course->id . '">' . $icon . $modfullname . '</a>';
         } else {
             $icon = '<img src="' . $OUTPUT->pix_url('icon', $modname) . '" class="icon" alt="" />';
             $this->content->items[] = '<a href="' . $CFG->wwwroot . '/mod/' . $modname . '/index.php?id=' . $course->id . '">' . $icon . $modfullname . '</a>';
         }
     }
     return $this->content;
 }
开发者ID:bobpuffer,项目名称:moodleUCLA-LUTH,代码行数:46,代码来源:block_activity_modules.php

示例8: get_filter_options

 /**
  * Retrieve the list of available filter options.
  *
  * @return  array                   An array whose keys are the valid options
  *                                  And whose values are the values to display
  */
 public static function get_filter_options()
 {
     $allroles = role_get_names(null, ROLENAME_ALIAS);
     $roles = [];
     foreach ($allroles as $role) {
         if ($role->archetype === 'guest') {
             // No point in including the 'guest' role as it isn't possible to show tours to a guest.
             continue;
         }
         $roles[$role->shortname] = $role->localname;
     }
     // Add the Site Administrator pseudo-role.
     $roles[self::ROLE_SITEADMIN] = get_string('administrator', 'core');
     // Sort alphabetically too.
     \core_collator::asort($roles);
     return $roles;
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:23,代码来源:role.php

示例9: render_form_elements

 /**
  * This function renders the form elements when adding a customcert element.
  *
  * @param mod_customcert_edit_element_form $mform the edit_form instance
  */
 public function render_form_elements($mform)
 {
     // Get the user profile fields.
     $userfields = array('firstname' => get_user_field_name('firstname'), 'lastname' => get_user_field_name('lastname'), 'email' => get_user_field_name('email'), 'city' => get_user_field_name('city'), 'country' => get_user_field_name('country'), 'url' => get_user_field_name('url'), 'icq' => get_user_field_name('icq'), 'skype' => get_user_field_name('skype'), 'aim' => get_user_field_name('aim'), 'yahoo' => get_user_field_name('yahoo'), 'msn' => get_user_field_name('msn'), 'idnumber' => get_user_field_name('idnumber'), 'institution' => get_user_field_name('institution'), 'department' => get_user_field_name('department'), 'phone1' => get_user_field_name('phone1'), 'phone2' => get_user_field_name('phone2'), 'address' => get_user_field_name('address'));
     // Get the user custom fields.
     $arrcustomfields = \availability_profile\condition::get_custom_profile_fields();
     $customfields = array();
     foreach ($arrcustomfields as $key => $customfield) {
         $customfields[$customfield->id] = $key;
     }
     // Combine the two.
     $fields = $userfields + $customfields;
     core_collator::asort($fields);
     // Create the select box where the user field is selected.
     $mform->addElement('select', 'userfield', get_string('userfield', 'customcertelement_userfield'), $fields);
     $mform->setType('userfield', PARAM_ALPHANUM);
     $mform->addHelpButton('userfield', 'userfield', 'customcertelement_userfield');
     parent::render_form_elements($mform);
 }
开发者ID:rezaies,项目名称:moodle-mod_customcert,代码行数:24,代码来源:lib.php

示例10: message_get_history

/**
 * Retrieve the messages between two users
 *
 * @param object $user1 the current user
 * @param object $user2 the other user
 * @param int $limitnum the maximum number of messages to retrieve
 * @param bool $viewingnewmessages are we currently viewing new messages?
 */
function message_get_history($user1, $user2, $limitnum=0, $viewingnewmessages=false) {
    global $DB, $CFG;

    $messages = array();

    //we want messages sorted oldest to newest but if getting a subset of messages we need to sort
    //desc to get the last $limitnum messages then flip the order in php
    $sort = 'asc';
    if ($limitnum>0) {
        $sort = 'desc';
    }

    $notificationswhere = null;
    //we have just moved new messages to read. If theyre here to see new messages dont hide notifications
    if (!$viewingnewmessages && $CFG->messaginghidereadnotifications) {
        $notificationswhere = 'AND notification=0';
    }

    //prevent notifications of your own actions appearing in your own message history
    $ownnotificationwhere = ' AND NOT (useridfrom=? AND notification=1)';

    $sql = "((useridto = ? AND useridfrom = ? AND timeusertodeleted = 0) OR
        (useridto = ? AND useridfrom = ? AND timeuserfromdeleted = 0))";
    if ($messages_read = $DB->get_records_select('message_read', $sql . $notificationswhere . $ownnotificationwhere,
                                                    array($user1->id, $user2->id, $user2->id, $user1->id, $user1->id),
                                                    "timecreated $sort", '*', 0, $limitnum)) {
        foreach ($messages_read as $message) {
            $messages[] = $message;
        }
    }
    if ($messages_new = $DB->get_records_select('message', $sql . $ownnotificationwhere,
                                                    array($user1->id, $user2->id, $user2->id, $user1->id, $user1->id),
                                                    "timecreated $sort", '*', 0, $limitnum)) {
        foreach ($messages_new as $message) {
            $messages[] = $message;
        }
    }

    $result = core_collator::asort_objects_by_property($messages, 'timecreated', core_collator::SORT_NUMERIC);

    //if we only want the last $limitnum messages
    $messagecount = count($messages);
    if ($limitnum > 0 && $messagecount > $limitnum) {
        $messages = array_slice($messages, $messagecount - $limitnum, $limitnum, true);
    }

    return $messages;
}
开发者ID:nickbert77,项目名称:moodle,代码行数:56,代码来源:lib.php

示例11: block_add_block_ui

/**
 * Return a {@link block_contents} representing the add a new block UI, if
 * this user is allowed to see it.
 *
 * @return block_contents an appropriate block_contents, or null if the user
 * cannot add any blocks here.
 */
function block_add_block_ui($page, $output)
{
    global $CFG, $OUTPUT;
    if (!$page->user_is_editing() || !$page->user_can_edit_blocks()) {
        return null;
    }
    $bc = new block_contents();
    $bc->title = get_string('addblock');
    $bc->add_class('block_adminblock');
    $bc->attributes['data-block'] = 'adminblock';
    $missingblocks = $page->blocks->get_addable_blocks();
    if (empty($missingblocks)) {
        $bc->content = get_string('noblockstoaddhere');
        return $bc;
    }
    $menu = array();
    foreach ($missingblocks as $block) {
        $blockobject = block_instance($block->name);
        if ($blockobject !== false && $blockobject->user_can_addto($page)) {
            $menu[$block->name] = $blockobject->get_title();
        }
    }
    core_collator::asort($menu);
    $actionurl = new moodle_url($page->url, array('sesskey' => sesskey()));
    $select = new single_select($actionurl, 'bui_addblock', $menu, null, array('' => get_string('adddots')), 'add_block');
    $select->set_label(get_string('addblock'), array('class' => 'accesshide'));
    $bc->content = $OUTPUT->render($select);
    return $bc;
}
开发者ID:educakanchay,项目名称:campus,代码行数:36,代码来源:blocklib.php

示例12: get_import_export_formats

/**
 * Get list of available import or export formats
 * @param string $type 'import' if import list, otherwise export list assumed
 * @return array sorted list of import/export formats available
 */
function get_import_export_formats($type)
{
    global $CFG;
    require_once $CFG->dirroot . '/question/format.php';
    $formatclasses = core_component::get_plugin_list_with_class('qformat', '', 'format.php');
    $fileformatname = array();
    foreach ($formatclasses as $component => $formatclass) {
        $format = new $formatclass();
        if ($type == 'import') {
            $provided = $format->provide_import();
        } else {
            $provided = $format->provide_export();
        }
        if ($provided) {
            list($notused, $fileformat) = explode('_', $component, 2);
            $fileformatnames[$fileformat] = get_string('pluginname', $component);
        }
    }
    core_collator::asort($fileformatnames);
    return $fileformatnames;
}
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:26,代码来源:questionlib.php

示例13: sort_area_tree

 /**
  * Sorts the result of {@link file_storage::get_area_tree()}.
  *
  * @param array $tree Array of results provided by {@link file_storage::get_area_tree()}
  * @return array of sorted results
  */
 protected function sort_area_tree($tree)
 {
     foreach ($tree as $key => &$value) {
         if ($key == 'subdirs') {
             core_collator::ksort($value, core_collator::SORT_NATURAL);
             foreach ($value as $subdirname => &$subtree) {
                 $subtree = $this->sort_area_tree($subtree);
             }
         } else {
             if ($key == 'files') {
                 core_collator::ksort($value, core_collator::SORT_NATURAL);
             }
         }
     }
     return $tree;
 }
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:22,代码来源:file_storage.php

示例14: view_grading_table

 /**
  * View the grading table of all submissions for this assignment.
  *
  * @return string
  */
 protected function view_grading_table()
 {
     global $USER, $CFG;
     // Include grading options form.
     require_once $CFG->dirroot . '/mod/assign/gradingoptionsform.php';
     require_once $CFG->dirroot . '/mod/assign/quickgradingform.php';
     require_once $CFG->dirroot . '/mod/assign/gradingbatchoperationsform.php';
     $o = '';
     $cmid = $this->get_course_module()->id;
     $links = array();
     if (has_capability('gradereport/grader:view', $this->get_course_context()) && has_capability('moodle/grade:viewall', $this->get_course_context())) {
         $gradebookurl = '/grade/report/grader/index.php?id=' . $this->get_course()->id;
         $links[$gradebookurl] = get_string('viewgradebook', 'assign');
     }
     if ($this->is_any_submission_plugin_enabled() && $this->count_submissions()) {
         $downloadurl = '/mod/assign/view.php?id=' . $cmid . '&action=downloadall';
         $links[$downloadurl] = get_string('downloadall', 'assign');
     }
     if ($this->is_blind_marking() && has_capability('mod/assign:revealidentities', $this->get_context())) {
         $revealidentitiesurl = '/mod/assign/view.php?id=' . $cmid . '&action=revealidentities';
         $links[$revealidentitiesurl] = get_string('revealidentities', 'assign');
     }
     foreach ($this->get_feedback_plugins() as $plugin) {
         if ($plugin->is_enabled() && $plugin->is_visible()) {
             foreach ($plugin->get_grading_actions() as $action => $description) {
                 $url = '/mod/assign/view.php' . '?id=' . $cmid . '&plugin=' . $plugin->get_type() . '&pluginsubtype=assignfeedback' . '&action=viewpluginpage&pluginaction=' . $action;
                 $links[$url] = $description;
             }
         }
     }
     // Sort links alphabetically based on the link description.
     core_collator::asort($links);
     $gradingactions = new url_select($links);
     $gradingactions->set_label(get_string('choosegradingaction', 'assign'));
     $gradingmanager = get_grading_manager($this->get_context(), 'mod_assign', 'submissions');
     $perpage = get_user_preferences('assign_perpage', 10);
     $filter = get_user_preferences('assign_filter', '');
     $markerfilter = get_user_preferences('assign_markerfilter', '');
     $workflowfilter = get_user_preferences('assign_workflowfilter', '');
     $controller = $gradingmanager->get_active_controller();
     $showquickgrading = empty($controller);
     $quickgrading = get_user_preferences('assign_quickgrading', false);
     $showonlyactiveenrolopt = has_capability('moodle/course:viewsuspendedusers', $this->context);
     $markingallocation = $this->get_instance()->markingallocation && has_capability('mod/assign:manageallocations', $this->context);
     // Get markers to use in drop lists.
     $markingallocationoptions = array();
     if ($markingallocation) {
         $markers = get_users_by_capability($this->context, 'mod/assign:grade');
         $markingallocationoptions[''] = get_string('filternone', 'assign');
         foreach ($markers as $marker) {
             $markingallocationoptions[$marker->id] = fullname($marker);
         }
     }
     $markingworkflow = $this->get_instance()->markingworkflow;
     // Get marking states to show in form.
     $markingworkflowoptions = array();
     if ($markingworkflow) {
         $notmarked = get_string('markingworkflowstatenotmarked', 'assign');
         $markingworkflowoptions[''] = get_string('filternone', 'assign');
         $markingworkflowoptions[ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED] = $notmarked;
         $markingworkflowoptions = array_merge($markingworkflowoptions, $this->get_marking_workflow_states_for_current_user());
     }
     // Print options for changing the filter and changing the number of results per page.
     $gradingoptionsformparams = array('cm' => $cmid, 'contextid' => $this->context->id, 'userid' => $USER->id, 'submissionsenabled' => $this->is_any_submission_plugin_enabled(), 'showquickgrading' => $showquickgrading, 'quickgrading' => $quickgrading, 'markingworkflowopt' => $markingworkflowoptions, 'markingallocationopt' => $markingallocationoptions, 'showonlyactiveenrolopt' => $showonlyactiveenrolopt, 'showonlyactiveenrol' => $this->show_only_active_users());
     $classoptions = array('class' => 'gradingoptionsform');
     $gradingoptionsform = new mod_assign_grading_options_form(null, $gradingoptionsformparams, 'post', '', $classoptions);
     $batchformparams = array('cm' => $cmid, 'submissiondrafts' => $this->get_instance()->submissiondrafts, 'duedate' => $this->get_instance()->duedate, 'attemptreopenmethod' => $this->get_instance()->attemptreopenmethod, 'feedbackplugins' => $this->get_feedback_plugins(), 'context' => $this->get_context(), 'markingworkflow' => $markingworkflow, 'markingallocation' => $markingallocation);
     $classoptions = array('class' => 'gradingbatchoperationsform');
     $gradingbatchoperationsform = new mod_assign_grading_batch_operations_form(null, $batchformparams, 'post', '', $classoptions);
     $gradingoptionsdata = new stdClass();
     $gradingoptionsdata->perpage = $perpage;
     $gradingoptionsdata->filter = $filter;
     $gradingoptionsdata->markerfilter = $markerfilter;
     $gradingoptionsdata->workflowfilter = $workflowfilter;
     $gradingoptionsform->set_data($gradingoptionsdata);
     $actionformtext = $this->get_renderer()->render($gradingactions);
     $header = new assign_header($this->get_instance(), $this->get_context(), false, $this->get_course_module()->id, get_string('grading', 'assign'), $actionformtext);
     $o .= $this->get_renderer()->render($header);
     $currenturl = $CFG->wwwroot . '/mod/assign/view.php?id=' . $this->get_course_module()->id . '&action=grading';
     $o .= groups_print_activity_menu($this->get_course_module(), $currenturl, true);
     // Plagiarism update status apearring in the grading book.
     if (!empty($CFG->enableplagiarism)) {
         require_once $CFG->libdir . '/plagiarismlib.php';
         $o .= plagiarism_update_status($this->get_course(), $this->get_course_module());
     }
     // Load and print the table of submissions.
     if ($showquickgrading && $quickgrading) {
         $gradingtable = new assign_grading_table($this, $perpage, $filter, 0, true);
         $table = $this->get_renderer()->render($gradingtable);
         $quickformparams = array('cm' => $this->get_course_module()->id, 'gradingtable' => $table);
         $quickgradingform = new mod_assign_quick_grading_form(null, $quickformparams);
         $o .= $this->get_renderer()->render(new assign_form('quickgradingform', $quickgradingform));
     } else {
         $gradingtable = new assign_grading_table($this, $perpage, $filter, 0, false);
         $o .= $this->get_renderer()->render($gradingtable);
//.........这里部分代码省略.........
开发者ID:covex-nn,项目名称:moodle,代码行数:101,代码来源:locallib.php

示例15: message_get_recent_conversations


//.........这里部分代码省略.........
              FROM {message_read} message
              JOIN (
                        SELECT MAX(id) AS messageid,
                               matchedmessage.useridto,
                               matchedmessage.useridfrom
                         FROM {message_read} matchedmessage
                   INNER JOIN (
                               SELECT MAX(recentmessages.timecreated) timecreated,
                                      recentmessages.useridfrom,
                                      recentmessages.useridto
                                 FROM {message_read} recentmessages
                                WHERE (
                                      (recentmessages.useridfrom = :userid1 AND recentmessages.timeuserfromdeleted = 0) OR
                                      (recentmessages.useridto = :userid2   AND recentmessages.timeusertodeleted = 0)
                                      )
                             GROUP BY recentmessages.useridfrom, recentmessages.useridto
                              ) recent ON matchedmessage.useridto     = recent.useridto
                           AND matchedmessage.useridfrom   = recent.useridfrom
                           AND matchedmessage.timecreated  = recent.timecreated
                           WHERE (
                                 (matchedmessage.useridfrom = :userid6 AND matchedmessage.timeuserfromdeleted = 0) OR
                                 (matchedmessage.useridto = :userid7   AND matchedmessage.timeusertodeleted = 0)
                                 )
                      GROUP BY matchedmessage.useridto, matchedmessage.useridfrom
                   ) messagesubset ON messagesubset.messageid = message.id
              JOIN {user} otheruser ON (message.useridfrom = :userid4 AND message.useridto = otheruser.id)
                OR (message.useridto   = :userid5 AND message.useridfrom   = otheruser.id)
         LEFT JOIN {message_contacts} contact ON contact.userid  = :userid3 AND contact.contactid = otheruser.id
             WHERE otheruser.deleted = 0 AND message.notification = 0
          ORDER BY message.timecreated DESC";
    $params = array(
            'userid1' => $user->id,
            'userid2' => $user->id,
            'userid3' => $user->id,
            'userid4' => $user->id,
            'userid5' => $user->id,
            'userid6' => $user->id,
            'userid7' => $user->id
        );
    $read = $DB->get_records_sql($sql, $params, $limitfrom, $limitto);

    // We want to get the messages that have not been read. These are stored in the 'message' table. It is the
    // exact same query as the one above, except for the table we are querying. So, simply replace references to
    // the 'message_read' table with the 'message' table.
    $sql = str_replace('{message_read}', '{message}', $sql);
    $unread = $DB->get_records_sql($sql, $params, $limitfrom, $limitto);

    $unreadcountssql = 'SELECT useridfrom, count(*) as count
                          FROM {message}
                         WHERE useridto = :userid
                           AND timeusertodeleted = 0
                           AND notification = 0
                      GROUP BY useridfrom';
    $unreadcounts = $DB->get_records_sql($unreadcountssql, array('userid' => $user->id));

    // Union the 2 result sets together looking for the message with the most
    // recent timecreated for each other user.
    // $conversation->id (the array key) is the other user's ID.
    $conversations = array();
    $conversation_arrays = array($unread, $read);
    foreach ($conversation_arrays as $conversation_array) {
        foreach ($conversation_array as $conversation) {
            // Only consider it unread if $user has unread messages.
            if (isset($unreadcounts[$conversation->useridfrom])) {
                $conversation->isread = 0;
                $conversation->unreadcount = $unreadcounts[$conversation->useridfrom]->count;
            } else {
                $conversation->isread = 1;
            }

            if (!isset($conversations[$conversation->id])) {
                $conversations[$conversation->id] = $conversation;
            } else {
                $current = $conversations[$conversation->id];
                // We need to maintain the isread and unreadcount values from existing
                // parts of the conversation if we're replacing it.
                $conversation->isread = ($conversation->isread && $current->isread);
                if (isset($current->unreadcount) && !isset($conversation->unreadcount)) {
                    $conversation->unreadcount = $current->unreadcount;
                }

                if ($current->timecreated < $conversation->timecreated) {
                    $conversations[$conversation->id] = $conversation;
                } else if ($current->timecreated == $conversation->timecreated) {
                    if ($current->mid < $conversation->mid) {
                        $conversations[$conversation->id] = $conversation;
                    }
                }
            }
        }
    }

    // Sort the conversations by $conversation->timecreated, newest to oldest
    // There may be multiple conversations with the same timecreated
    // The conversations array contains both read and unread messages (different tables) so sorting by ID won't work
    $result = core_collator::asort_objects_by_property($conversations, 'timecreated', core_collator::SORT_NUMERIC);
    $conversations = array_reverse($conversations);

    return $conversations;
}
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:101,代码来源:lib.php


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