本文整理汇总了PHP中coursecat::get方法的典型用法代码示例。如果您正苦于以下问题:PHP coursecat::get方法的具体用法?PHP coursecat::get怎么用?PHP coursecat::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coursecat
的用法示例。
在下文中一共展示了coursecat::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_category_tree
private function get_category_tree($id)
{
global $DB;
$category = $DB->get_record('course_categories', array('id' => $id));
if ($id && !$category) {
cli_error("Wrong category '{$id}'");
} elseif (!$id) {
$category = NULL;
}
$parentcategory = \coursecat::get($id);
if ($parentcategory->has_children()) {
$parentschildren = $parentcategory->get_children();
foreach ($parentschildren as $singlecategory) {
if ($singlecategory->has_children()) {
$childcategories = $this->get_category_tree($singlecategory->id);
$category->categories[] = $childcategories;
} else {
// coursecat variables are protected, need to get data from db
$singlecategory = $DB->get_record('course_categories', array('id' => $singlecategory->id));
$category->categories[] = $singlecategory;
}
}
}
return $category;
}
示例2: theme_campus_get_top_level_categories
/**
* Campus theme with the underlying Bootstrap theme.
*
* @package theme
* @subpackage campus
* @copyright © 2014-onwards G J Barnard in respect to modifications of the Clean theme.
* @copyright © 2014-onwards Work undertaken for David Bogner of Edulabs.org.
* @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195}
* @author Based on code originally written by Mary Evans, Bas Brands, Stuart Lamour and David Scotson.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function theme_campus_get_top_level_categories()
{
global $CFG;
include_once $CFG->libdir . '/coursecatlib.php';
$categoryids = array();
$categories = coursecat::get(0)->get_children();
// Parent = 0 i.e. top-level categories only.
foreach ($categories as $category) {
$categoryids[$category->id] = $category->name;
}
return $categoryids;
}
示例3: execute
public function execute()
{
global $CFG, $DB;
require_once $CFG->dirroot . '/course/lib.php';
require_once $CFG->dirroot . '/lib/coursecatlib.php';
foreach ($this->arguments as $argument) {
$this->expandOptionsManually(array($argument));
}
$this->expandOptions();
$options = $this->expandedOptions;
$params = NULL;
$sql = "SELECT c.id,c.category,";
if ($options['idnumber']) {
$sql .= "c.idnumber,";
}
if ($options['empty'] == 'yes' || $options['empty'] == 'no') {
$sql .= "COUNT(c.id) AS modules,";
}
$sql .= "c.shortname,c.fullname,c.visible FROM {course} c ";
if ($options['empty'] == 'yes' || $options['empty'] == 'no') {
$sql .= " LEFT JOIN {course_modules} m ON c.id=m.course ";
}
if ($options['categorysearch'] !== null) {
$category = \coursecat::get($options['categorysearch']);
$categories = $this->get_categories($category);
list($where, $params) = $DB->get_in_or_equal(array_keys($categories));
$sql .= "WHERE c.category {$where}";
}
if (isset($this->arguments[0]) && $this->arguments[0]) {
$sql .= " AND (" . $this->arguments[0] . ")";
}
if ($options['empty'] == 'yes') {
$sql .= " GROUP BY c.id HAVING modules < 2";
}
if ($options['empty'] == 'no') {
$sql .= " GROUP BY c.id HAVING modules > 1";
}
//echo "$sql\n"; var_dump($params);
$courses = $DB->get_records_sql($sql, $params);
// Filter out any that have any section information (summary)
if ($options['empty'] == 'yes') {
$sql = "SELECT COUNT(*) AS C FROM {course_sections} WHERE course = ? AND summary <> ''";
foreach ($courses as $k => $course) {
$sections = $DB->get_record_sql($sql, array($course->id));
if ($sections->c > 0) {
unset($courses[$k]);
}
}
}
// @TODO: If empty == no, then add those that have no modules but some modification to sections
$this->display($courses);
}
示例4: test_pre_course_category_delete_hook
/**
* Check that our hook is called when a course is deleted.
*/
public function test_pre_course_category_delete_hook()
{
global $DB;
// Should have nothing in the recycle bin.
$this->assertEquals(0, $DB->count_records('tool_recyclebin_category'));
delete_course($this->course, false);
// Check the course is now in the recycle bin.
$this->assertEquals(1, $DB->count_records('tool_recyclebin_category'));
// Now let's delete the course category.
$category = coursecat::get($this->course->category);
$category->delete_full(false);
// Check that the course was deleted from the category recycle bin.
$this->assertEquals(0, $DB->count_records('tool_recyclebin_category'));
}
示例5: search_listitem
/**
* Renderers a search result course list item.
*
* This function will be called for every course being displayed by course_listing.
*
* @param course_in_list $course The course to produce HTML for.
* @param int $selectedcourse The id of the currently selected course.
* @return string
*/
public function search_listitem(course_in_list $course, $selectedcourse)
{
$text = $course->get_formatted_name();
$attributes = array('class' => 'listitem listitem-course', 'data-id' => $course->id, 'data-selected' => $selectedcourse == $course->id ? '1' : '0', 'data-visible' => $course->visible ? '1' : '0');
$bulkcourseinput = array('type' => 'checkbox', 'name' => 'bc[]', 'value' => $course->id, 'class' => 'bulk-action-checkbox');
$viewcourseurl = new moodle_url($this->page->url, array('courseid' => $course->id));
$categoryname = coursecat::get($course->category)->get_formatted_name();
$html = html_writer::start_tag('li', $attributes);
$html .= html_writer::start_div('clearfix');
$html .= html_writer::start_div('float-left');
$html .= html_writer::empty_tag('input', $bulkcourseinput) . ' ';
$html .= html_writer::end_div();
$html .= html_writer::link($viewcourseurl, $text, array('class' => 'float-left coursename'));
$html .= html_writer::tag('span', $categoryname, array('class' => 'float-left categoryname'));
$html .= html_writer::start_div('float-right');
$html .= $this->search_listitem_actions($course);
$html .= html_writer::tag('span', s($course->idnumber), array('class' => 'dimmed idnumber'));
$html .= html_writer::end_div();
$html .= html_writer::end_div();
$html .= html_writer::end_tag('li');
return $html;
}
示例6: frontpage_available_courses
public function frontpage_available_courses()
{
/* available courses */
global $CFG, $OUTPUT, $PAGE;
require_once $CFG->libdir . '/coursecatlib.php';
$chelper = new coursecat_helper();
$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->set_courses_display_options(array('recursive' => true, 'limit' => $CFG->frontpagecourselimit, 'viewmoreurl' => new moodle_url('/course/index.php'), 'viewmoretext' => new lang_string('fulllistofcourses')));
$chelper->set_attributes(array('class' => 'frontpage-course-list-all'));
$courses = coursecat::get(0)->get_courses($chelper->get_courses_display_options());
$totalcount = coursecat::get(0)->get_courses_count($chelper->get_courses_display_options());
$rcourseids = array_keys($courses);
$acourseids = array_chunk($rcourseids, 5);
$newcourse = get_string('availablecourses');
$header = '<div id="frontpage-course-list">
<h2>' . $newcourse . '</h2>
<div class="courses frontpage-course-list-all">';
$footer = '
</div>
</div>';
$content = '';
if (count($rcourseids) > 0) {
foreach ($acourseids as $courseids) {
$content .= '<div class="row-fluid">';
$rowcontent = '';
foreach ($courseids as $courseid) {
$course = get_course($courseid);
$no = get_config('theme_pioneer', 'patternselect');
$nimgp = empty($no) || $no == "default" ? 'no-image' : 'cs0' . $no . '/no-image';
$summary = theme_pioneer_strip_html_tags($course->summary);
$summary = theme_pioneer_course_trim_char($summary, 20);
$trimtitle = theme_pioneer_course_trim_char($course->fullname, 25);
$noimgurl = $OUTPUT->pix_url($nimgp, 'theme');
$courseurl = new moodle_url('/course/view.php', array('id' => $courseid));
if ($course instanceof stdClass) {
require_once $CFG->libdir . '/coursecatlib.php';
$course = new course_in_list($course);
}
$imgurl = '';
$context = context_course::instance($course->id);
foreach ($course->get_course_overviewfiles() as $file) {
$isimage = $file->is_valid_image();
$imgurl = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage);
if (!$isimage) {
$imgurl = $noimgurl;
}
}
if (empty($imgurl)) {
$imgurl = $PAGE->theme->setting_file_url('headerbackgroundimage', 'headerbackgroundimage', true);
if (!$imgurl) {
$imgurl = $noimgurl;
}
}
$rowcontent .= '
<div style="background-image: url(' . $imgurl . ');background-repeat: no-repeat;background-size:cover; background-position:center;" class="fp-avail-courses">
<div class="fp-coursebox">
<div class="fp-courseinfo">
<p><a href="' . $courseurl . '" id="button" data-toggle="tooltip" data-placement="top" title="' . $course->fullname . '" >' . $trimtitle . '</a></p>
</div>
</div>
</div>
';
}
$content .= $rowcontent;
$content .= '</div>';
}
}
$coursehtml = $header . $content . $footer;
echo $coursehtml;
if (!$totalcount && !$this->page->user_is_editing() && has_capability('moodle/course:create', context_system::instance())) {
// Print link to create a new course, for the 1st available category.
echo $this->add_new_course_button();
}
}
示例7: coursecat_coursebox_content
protected function coursecat_coursebox_content(coursecat_helper $chelper, $course)
{
global $CFG;
if ($chelper->get_show_courses() < self::COURSECAT_SHOW_COURSES_EXPANDED) {
return '';
}
if ($course instanceof stdClass) {
require_once $CFG->libdir . '/coursecatlib.php';
$course = new course_in_list($course);
}
$content = '';
// Display course overview files.
$contentimages = $contentfiles = '';
foreach ($course->get_course_overviewfiles() as $file) {
$isimage = $file->is_valid_image();
$url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage);
if ($isimage) {
$contentimages .= html_writer::start_tag('div', array('class' => 'imagebox'));
$images = html_writer::empty_tag('img', array('src' => $url, 'alt' => 'Course Image ' . $course->fullname, 'class' => 'courseimage'));
$contentimages .= html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $images);
$contentimages .= html_writer::end_tag('div');
} else {
$image = $this->output->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle');
$filename = html_writer::tag('span', $image, array('class' => 'fp-icon')) . html_writer::tag('span', $file->get_filename(), array('class' => 'fp-filename'));
$contentfiles .= html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'coursefile fp-filename-icon'));
}
}
$content .= $contentimages . $contentfiles;
// Display course summary.
if ($course->has_summary()) {
$content .= $chelper->get_course_formatted_summary($course);
}
// Display course contacts. See course_in_list::get_course_contacts().
if ($course->has_course_contacts()) {
$content .= html_writer::start_tag('ul', array('class' => 'teachers'));
foreach ($course->get_course_contacts() as $userid => $coursecontact) {
$name = $coursecontact['rolename'] . ': ' . html_writer::link(new moodle_url('/user/view.php', array('id' => $userid, 'course' => SITEID)), $coursecontact['username']);
$content .= html_writer::tag('li', $name);
}
$content .= html_writer::end_tag('ul');
// End .teachers div.
}
// Display course category if necessary (for example in search results).
if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT) {
require_once $CFG->libdir . '/coursecatlib.php';
if ($cat = coursecat::get($course->category, IGNORE_MISSING)) {
$content .= html_writer::start_tag('div', array('class' => 'coursecat'));
$content .= get_string('category') . ': ' . html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $cat->id)), $cat->get_formatted_name(), array('class' => $cat->visible ? '' : 'dimmed'));
$content .= html_writer::end_tag('div');
// End .coursecat div.
}
}
return $content;
}
示例8: get_course_public_information
/**
* Return the course information that is public (visible by every one)
*
* @param course_in_list $course course in list object
* @param stdClass $coursecontext course context object
* @return array the course information
* @since Moodle 3.2
*/
protected static function get_course_public_information(course_in_list $course, $coursecontext)
{
static $categoriescache = array();
// Category information.
if (!array_key_exists($course->category, $categoriescache)) {
$categoriescache[$course->category] = coursecat::get($course->category, IGNORE_MISSING);
}
$category = $categoriescache[$course->category];
// Retrieve course overview used files.
$files = array();
foreach ($course->get_course_overviewfiles() as $file) {
$fileurl = moodle_url::make_webservice_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), null, $file->get_filepath(), $file->get_filename())->out(false);
$files[] = array('filename' => $file->get_filename(), 'fileurl' => $fileurl, 'filesize' => $file->get_filesize(), 'filepath' => $file->get_filepath(), 'mimetype' => $file->get_mimetype(), 'timemodified' => $file->get_timemodified());
}
// Retrieve the course contacts,
// we need here the users fullname since if we are not enrolled can be difficult to obtain them via other Web Services.
$coursecontacts = array();
foreach ($course->get_course_contacts() as $contact) {
$coursecontacts[] = array('id' => $contact['user']->id, 'fullname' => $contact['username']);
}
// Allowed enrolment methods (maybe we can self-enrol).
$enroltypes = array();
$instances = enrol_get_instances($course->id, true);
foreach ($instances as $instance) {
$enroltypes[] = $instance->enrol;
}
// Format summary.
list($summary, $summaryformat) = external_format_text($course->summary, $course->summaryformat, $coursecontext->id, 'course', 'summary', null);
$displayname = get_course_display_name_for_list($course);
$coursereturns = array();
$coursereturns['id'] = $course->id;
$coursereturns['fullname'] = external_format_string($course->fullname, $coursecontext->id);
$coursereturns['displayname'] = external_format_string($displayname, $coursecontext->id);
$coursereturns['shortname'] = external_format_string($course->shortname, $coursecontext->id);
$coursereturns['categoryid'] = $course->category;
$coursereturns['categoryname'] = $category == null ? '' : $category->name;
$coursereturns['summary'] = $summary;
$coursereturns['summaryformat'] = $summaryformat;
$coursereturns['summaryfiles'] = external_util::get_area_files($coursecontext->id, 'course', 'summary', false, false);
$coursereturns['overviewfiles'] = $files;
$coursereturns['contacts'] = $coursecontacts;
$coursereturns['enrollmentmethods'] = $enroltypes;
return $coursereturns;
}
示例9: print_courses
/**
* Print courses in category. If category is 0 then all courses are printed.
*
* @deprecated since 2.5
*
* To print a generic list of courses use:
* $renderer = $PAGE->get_renderer('core', 'course');
* echo $renderer->courses_list($courses);
*
* To print list of all courses:
* $renderer = $PAGE->get_renderer('core', 'course');
* echo $renderer->frontpage_available_courses();
*
* To print list of courses inside category:
* $renderer = $PAGE->get_renderer('core', 'course');
* echo $renderer->course_category($category); // this will also print subcategories
*
* @param int|stdClass $category category object or id.
* @return bool true if courses found and printed, else false.
*/
function print_courses($category)
{
global $CFG, $OUTPUT, $PAGE;
require_once $CFG->libdir . '/coursecatlib.php';
debugging('Function print_courses() is deprecated, please use course renderer', DEBUG_DEVELOPER);
if (!is_object($category) && $category == 0) {
$courses = coursecat::get(0)->get_courses(array('recursive' => true, 'summary' => true, 'coursecontacts' => true));
} else {
$courses = coursecat::get($category->id)->get_courses(array('summary' => true, 'coursecontacts' => true));
}
if ($courses) {
$renderer = $PAGE->get_renderer('core', 'course');
echo $renderer->courses_list($courses);
} else {
echo $OUTPUT->heading(get_string("nocoursesyet"));
$context = context_system::instance();
if (has_capability('moodle/course:create', $context)) {
$options = array();
if (!empty($category->id)) {
$options['category'] = $category->id;
} else {
$options['category'] = $CFG->defaultrequestcategory;
}
echo html_writer::start_tag('div', array('class' => 'addcoursebutton'));
echo $OUTPUT->single_button(new moodle_url('/course/edit.php', $options), get_string("addnewcourse"));
echo html_writer::end_tag('div');
return false;
}
}
return true;
}
示例10: moodle_url
if ($down && empty($searchcriteria)) {
$url = new moodle_url($baseurl, array('movedown' => $acourse->id));
$icons[] = $OUTPUT->action_icon($url, new pix_icon('t/down', get_string('movedown')));
}
$abletomovecourses = true;
}
$table->data[] = new html_table_row(array(
new html_table_cell($coursename),
new html_table_cell(join('', $icons)),
new html_table_cell(html_writer::empty_tag('input', array('type' => 'checkbox', 'name' => 'c'.$acourse->id)))
));
if (!empty($searchcriteria)) {
// add 'Category' column
$category = coursecat::get($acourse->category, IGNORE_MISSING, true);
$cell = new html_table_cell($category->get_formatted_name());
$cell->attributes['class'] = $category->visible ? '' : 'dimmed_text';
array_splice($table->data[count($table->data) - 1]->cells, 1, 0, array($cell));
}
}
if ($abletomovecourses) {
$movetocategories = coursecat::make_categories_list('moodle/category:manage');
$movetocategories[$id] = get_string('moveselectedcoursesto');
$cell = new html_table_cell();
$cell->colspan = 3;
$cell->attributes['class'] = 'mdl-right';
$cell->text = html_writer::label(get_string('moveselectedcoursesto'), 'movetoid', false, array('class' => 'accesshide'));
$cell->text .= html_writer::select($movetocategories, 'moveto', $id, null, array('id' => 'movetoid', 'class' => 'autosubmit'));
示例11: traverse_categories
private static function traverse_categories($categories, &$cid)
{
foreach ($categories as $category) {
$cid[] = $category->id;
$catchildren = \coursecat::get($category->id, IGNORE_MISSING, true)->get_children();
if ($catchildren) {
self::traverse_categories($catchildren, $cid);
}
}
}
示例12: course_overview
/**
* Construct contents of course_overview block
*
* @param array $courses list of courses in sorted order
* @param array $overviews list of course overviews
* @return string html to be displayed in course_overview block
*/
public function course_overview($courses, $overviews)
{
global $DB;
$html = '';
$config = get_config('block_course_overview');
if ($config->showcategories != BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_NONE) {
global $CFG;
require_once $CFG->libdir . '/coursecatlib.php';
}
/*echo '<pre>';
print_r($courses);*/
$ismovingcourse = false;
$courseordernumber = 0;
$maxcourses = count($courses);
$userediting = false;
// Intialise string/icon etc if user is editing and courses > 1
if ($this->page->user_is_editing() && count($courses) > 1) {
$userediting = true;
$this->page->requires->js_init_call('M.block_course_overview.add_handles');
// Check if course is moving
$ismovingcourse = optional_param('movecourse', FALSE, PARAM_BOOL);
$movingcourseid = optional_param('courseid', 0, PARAM_INT);
}
/**
* Indexador das categorias dos cursos
* @author Cássio Queiroz <Cruzz>
* @date 2015/12/26
*/
$catids = array();
foreach ($courses as $key => $course) {
$value = $DB->get_record_sql('SELECT id,name FROM {course_categories} WHERE id = ? ', array($course->category));
$catids[] = $value->id . '@' . $value->name;
}
$firstCat = explode("@", $catids[0]);
$catids = array_unique($catids);
// Render first movehere icon.
if ($ismovingcourse) {
// Remove movecourse param from url.
$this->page->ensure_param_not_in_url('movecourse');
// Show moving course notice, so user knows what is being moved.
$html .= $this->output->box_start('notice');
$a = new stdClass();
$a->fullname = $courses[$movingcourseid]->fullname;
$a->cancellink = html_writer::link($this->page->url, get_string('cancel'));
$html .= get_string('movingcourse', 'block_course_overview', $a);
$html .= $this->output->box_end();
$moveurl = new moodle_url('/blocks/course_overview/move.php', array('sesskey' => sesskey(), 'moveto' => 0, 'courseid' => $movingcourseid));
// Create move icon, so it can be used.
$movetofirsticon = html_writer::empty_tag('img', array('src' => $this->output->pix_url('movehere'), 'alt' => get_string('movetofirst', 'block_course_overview', $courses[$movingcourseid]->fullname), 'title' => get_string('movehere')));
$moveurl = html_writer::link($moveurl, $movetofirsticon);
$html .= html_writer::tag('div', $moveurl, array('class' => 'movehere'));
}
// @autor Cássio Queiroz <Cruzz>
$html .= html_writer::start_tag('div', array('class' => 'cat_navigation'));
$html .= html_writer::start_span('top-level') . 'Meus Cursos' . html_writer::end_span();
$html .= html_writer::start_tag('div', array('class' => 'cat_navs'));
$piper = '';
foreach ($catids as $cor) {
$name = explode('@', $cor);
$html .= $piper . html_writer::start_span('allcat category-' . $name[0]) . $name[1] . html_writer::end_span();
$piper = ' | ';
}
$html .= html_writer::end_tag('div');
// END cat_navs
$html .= html_writer::end_tag('div');
// END cat_navigation
foreach ($courses as $key => $course) {
// If moving course, then don't show course which needs to be moved.
if ($ismovingcourse && $course->id == $movingcourseid) {
continue;
}
$html .= html_writer::start_tag('div', array('class' => 'all cat_' . $course->category));
// @autor Cássio Queiroz <Cruzz>
$html .= $this->output->box_start('coursebox', "course-{$course->id}");
$html .= html_writer::start_tag('div', array('class' => 'course_title'));
// If user is editing, then add move icons.
if ($userediting && !$ismovingcourse) {
$moveicon = html_writer::empty_tag('img', array('src' => $this->pix_url('t/move')->out(false), 'alt' => get_string('movecourse', 'block_course_overview', $course->fullname), 'title' => get_string('move')));
$moveurl = new moodle_url($this->page->url, array('sesskey' => sesskey(), 'movecourse' => 1, 'courseid' => $course->id));
$moveurl = html_writer::link($moveurl, $moveicon);
$html .= html_writer::tag('div', $moveurl, array('class' => 'move'));
}
// No need to pass title through s() here as it will be done automatically by html_writer.
$attributes = array('title' => $course->fullname);
if ($course->id > 0) {
if (empty($course->visible)) {
$attributes['class'] = 'dimmed';
}
$courseurl = new moodle_url('/course/view.php', array('id' => $course->id));
$coursefullname = format_string(get_course_display_name_for_list($course), true, $course->id);
$link = html_writer::link($courseurl, $coursefullname, $attributes);
$html .= $this->output->heading($link, 2, 'title');
} else {
//.........这里部分代码省略.........
示例13: get_categorycti_catid
/**
* Gets the category course title image category id for the given category or 0 if not found.
* Walks up the parent tree if the current category does not have an image.
*
* @return int Category id.
*/
protected function get_categorycti_catid()
{
$catid = 0;
$currentcatid = $this->get_current_category();
if ($currentcatid) {
$image = $this->get_setting('categoryct' . $currentcatid . 'image');
if ($image) {
$catid = $currentcatid;
} else {
$imageurl = $this->get_setting('categoryctimageurl' . $currentcatid);
if ($imageurl) {
$catid = $currentcatid;
} else {
global $CFG;
require_once $CFG->libdir . '/coursecatlib.php';
$parents = array_reverse(\coursecat::get($currentcatid, IGNORE_MISSING, true)->get_parents());
foreach ($parents as $parent) {
$image = $this->get_setting('categoryct' . $parent . 'image');
if ($image) {
$catid = $parent;
break;
}
$imageurl = $this->get_setting('categoryctimageurl' . $parent);
if ($imageurl) {
$catid = $parent;
break;
}
}
}
}
}
return $catid;
}
示例14: require_login
* When called with an id parameter, edits the category with that id.
* Otherwise it creates a new category with default parent from the parent
* parameter, which may be 0.
*
* @package core_course
* @copyright 2007 Nicolas Connault
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../config.php';
require_once $CFG->dirroot . '/course/lib.php';
require_once $CFG->libdir . '/coursecatlib.php';
require_login();
$id = optional_param('id', 0, PARAM_INT);
$url = new moodle_url('/course/editcategory.php');
if ($id) {
$coursecat = coursecat::get($id, MUST_EXIST, true);
$category = $coursecat->get_db_record();
$context = context_coursecat::instance($id);
$url->param('id', $id);
$strtitle = new lang_string('editcategorysettings');
$itemid = 0;
// Initialise itemid, as all files in category description has item id 0.
$title = $strtitle;
$fullname = $coursecat->get_formatted_name();
} else {
$parent = required_param('parent', PARAM_INT);
$url->param('parent', $parent);
if ($parent) {
$DB->record_exists('course_categories', array('id' => $parent), '*', MUST_EXIST);
$context = context_coursecat::instance($parent);
} else {
示例15: emarking_get_categories_childs
/**
* Obtains all categories that are children to a specific one
*
* @param unknown $id_category
* @return Ambigous <string, unknown>
*/
function emarking_get_categories_childs($id_category)
{
$coursecat = coursecat::get($id_category);
$ids = array();
$ids[] = $id_category;
foreach ($coursecat->get_children() as $id => $childcategory) {
$ids[] = $id;
}
return $ids;
}