• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP page_create_object函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: poll_results_link

 function poll_results_link()
 {
     global $USER;
     $page = page_create_object($this->instance->pagetype, $this->instance->pageid);
     $url = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'action' => 'responses', 'pid' => $this->poll->id));
     return "<hr />(<a href=\"{$url}\">" . get_string('responses', 'block_poll') . '</a>)';
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:7,代码来源:block_poll.php


示例2: display_course_blocks_start

 /**
  * Display the resource with the course blocks.
  */
 function display_course_blocks_start()
 {
     global $CFG;
     global $USER;
     global $THEME;
     require_once $CFG->libdir . '/blocklib.php';
     require_once $CFG->libdir . '/pagelib.php';
     require_once $CFG->dirroot . '/course/lib.php';
     //required by some blocks
     $PAGE = page_create_object(PAGE_COURSE_VIEW, $this->course->id);
     $this->PAGE = $PAGE;
     $pageblocks = blocks_setup($PAGE);
     $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
     /// Print the page header
     $edit = optional_param('edit', -1, PARAM_BOOL);
     if ($edit != -1 and $PAGE->user_allowed_editing()) {
         $USER->editing = $edit;
     }
     $morenavlinks = array($this->strresources => 'index.php?id=' . $this->course->id, $this->resource->name => '');
     $PAGE->print_header($this->course->shortname . ': %fullname%', $morenavlinks, "", "", update_module_button($this->cm->id, $this->course->id, $this->strresource));
     echo '<table id="layout-table"><tr>';
     $lt = empty($THEME->layouttable) ? array('left', 'middle', 'right') : $THEME->layouttable;
     foreach ($lt as $column) {
         $lt1[] = $column;
         if ($column == 'middle') {
             break;
         }
     }
     foreach ($lt1 as $column) {
         switch ($column) {
             case 'left':
                 if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing()) {
                     echo '<td style="width: ' . $blocks_preferred_width . 'px;" id="left-column">';
                     print_container_start();
                     blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
                     print_container_end();
                     echo '</td>';
                 }
                 break;
             case 'middle':
                 echo '<td id="middle-column">';
                 print_container_start(false, 'middle-column-wrap');
                 echo '<div id="resource">';
                 break;
             case 'right':
                 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing()) {
                     echo '<td style="width: ' . $blocks_preferred_width . 'px;" id="right-column">';
                     print_container_start();
                     blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
                     print_container_end();
                     echo '</td>';
                 }
                 break;
         }
     }
 }
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:59,代码来源:lib.php


示例3: page_print_add_mods_form

/**
 * This function displays the controls to add modules and blocks to a page
 *
 * @param object $page A fully populated page object
 * @param object $course A fully populated course object
 * @uses $USER;
 * @uses $CFG;
 */
function page_print_add_mods_form($page, $course)
{
    global $USER, $CFG, $PAGE;
    if (empty($PAGE)) {
        $PAGE = page_create_object(PAGE_COURSE_VIEW, $course->id);
    }
    print_box_start('centerpara addpageitems');
    // Add drop down to add blocks
    if ($blocks = get_records('block', 'visible', '1', 'name')) {
        $format = $PAGE->get_format_name();
        $options = array();
        foreach ($blocks as $b) {
            if (in_array($b->name, array('format_page', 'page_module'))) {
                continue;
            }
            if (!blocks_name_allowed_in_format($b->name, $format)) {
                continue;
            }
            $blockobject = block_instance($b->name);
            if ($blockobject !== false && $blockobject->user_can_addto($PAGE)) {
                $options[$b->id] = $blockobject->get_title();
            }
        }
        asort($options);
        print '<span class="addblock">';
        $common = $CFG->wwwroot . '/course/format/page/format.php?id=' . $course->id . '&amp;page=' . $page->id . '&amp;blockaction=add&amp;sesskey=' . sesskey() . '&amp;blockid=';
        popup_form($common, $options, 'addblock', '', get_string('addblock', 'format_page'));
        print '</span>&nbsp;';
    }
    // Add drop down to add existing module instances
    if ($modules = page_get_modules($course, 'name')) {
        // From our modules object we can build an existing module menu using separators
        $options = array();
        foreach ($modules as $modplural => $instances) {
            // Sets an optgroup which can't be selected/submitted
            $options[$modplural . '_group_start'] = "--{$modplural}";
            foreach ($instances as $cmid => $name) {
                $options[$cmid] = shorten_text($name);
            }
            // Ends an optgroup
            $options[$modplural . '_group_end'] = '--';
        }
        print '<span class="addexistingmodule">';
        $common = $CFG->wwwroot . '/course/format/page/format.php?id=' . $course->id . '&amp;page=' . $page->id . '&amp;blockaction=addmod&amp;sesskey=' . sesskey() . '&amp;instance=';
        popup_form($common, $options, 'addinstance', '', get_string('addexistingmodule', 'format_page'));
        print '</span>';
    }
    print_box_end();
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:57,代码来源:lib.php


示例4: get_content

    function get_content()
    {
        global $CFG, $USER, $COURSE;
        if (!empty($COURSE)) {
            $this->courseid = $COURSE->id;
        }
        if ($this->content !== NULL) {
            return $this->content;
        }
        $this->content = new stdClass();
        $choices = get_records_sql("SELECT id, name FROM {$CFG->prefix}choice where course={$COURSE->id}");
        if ($choices) {
            $this->content->text = "<SELECT id=\"selection\">";
            foreach ($choices as $choice) {
                $this->content->text .= "<option value={$choice->id}>{$choice->name}</option>";
            }
            $this->content->text .= '</select>';
            $this->content->text .= '
		  		<script type="text/javascript">
	          		function submitme(){
	    	      		document.getElementById("newsite").href="';
            $page = page_create_object($this->instance->pagetype, $this->instance->pageid);
            $this->content->text .= $page->url_get_path();
            $params = array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'create', 'id' => $this->courseid, 'section' => 'choice_to_group');
            $first = true;
            foreach ($params as $var => $value) {
                $this->content->text .= $first ? '?' : '&';
                $this->content->text .= $var . '=' . urlencode($value);
                $first = false;
            }
            $this->content->text .= "&selection=\"";
            $this->content->text .= '+document.getElementById("selection").value;
	    	      			return true;
	          			} 
	          			</script>';
            $this->content->text .= "<A ID=\"newsite\" HREF=\"\" onClick=\"return submitme()\">" . get_string("continue", "moodle") . "</A>";
        } else {
            $this->content->text .= get_string("no_choices", "block_choice_to_group");
        }
        $this->content->footer = '';
        return $this->content;
    }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:42,代码来源:block_choice_to_group.php


示例5: redirect

                redirect("{$CFG->wwwroot}/");
            case 'admin':
                redirect("{$CFG->wwwroot}/{$CFG->admin}/");
        }
    } else {
        $errormsg = get_string('errorwithsettings', 'admin');
        $firsterror = reset($adminroot->errors);
        $focus = $firsterror->id;
    }
    $adminroot =& admin_get_root(true);
    //reload tree
    $page =& $adminroot->locate($section);
}
/// very hacky page setup
page_map_class(PAGE_ADMIN, 'page_admin');
$PAGE = page_create_object(PAGE_ADMIN, 0);
// there must be any constant id number
$PAGE->init_extra($section);
$CFG->pagepath = 'admin/setting/' . $section;
if (!isset($USER->adminediting)) {
    $USER->adminediting = false;
}
if ($PAGE->user_allowed_editing()) {
    if ($adminediting == 1) {
        $USER->adminediting = true;
    } elseif ($adminediting == 0) {
        $USER->adminediting = false;
    }
}
/// print header stuff ------------------------------------------------------------
if (empty($SITE->fullname)) {
开发者ID:NextEinstein,项目名称:riverhills,代码行数:31,代码来源:settings.php


示例6: optional_param

$edit = optional_param('edit', -1, PARAM_BOOL);
$userpage = optional_param('userpage', 0, PARAM_INT);
// which page to show
$perpage = optional_param('perpage', 24, PARAM_INT);
if ($tagname) {
    $tag = tag_get('name', $tagname, '*');
} else {
    if ($tagid) {
        $tag = tag_get('id', $tagid, '*');
    }
}
if (empty($tag)) {
    redirect($CFG->wwwroot . '/tag/search.php');
}
//create a new page_tag object, defined in pagelib.php
$PAGE = page_create_object(PAGE_TAG_INDEX, $tag->id);
$pageblocks = blocks_setup($PAGE, BLOCKS_PINNED_BOTH);
$PAGE->tag_object = $tag;
if ($edit != -1 and $PAGE->user_allowed_editing()) {
    $USER->editing = $edit;
}
$PAGE->print_header();
// Manage all tags links
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
if (has_capability('moodle/tag:manage', $systemcontext)) {
    echo '<div class="managelink"><a href="' . $CFG->wwwroot . '/tag/manage.php">' . get_string('managetags', 'tag') . '</a></div>';
}
echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">';
echo '<tr valign="top">';
//----------------- left column -----------------
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:31,代码来源:index.php


示例7: array

//alhanumeric and -
$pagetypes = array(PAGE_MY_MOODLE => array('id' => PAGE_MY_MOODLE, 'lib' => '/my/pagelib.php', 'name' => get_string('mymoodle', 'admin')), PAGE_COURSE_VIEW => array('id' => PAGE_COURSE_VIEW, 'lib' => '/lib/pagelib.php', 'name' => get_string('stickyblockscourseview', 'admin')));
// for choose_from_menu
$options = array();
foreach ($pagetypes as $p) {
    $options[$p['id']] = $p['name'];
}
require_login();
require_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM, SITEID));
// first thing to do is print the dropdown menu
$strtitle = get_string('stickyblocks', 'admin');
$strheading = get_string('adminhelpstickyblocks');
if (!empty($pt)) {
    require_once $CFG->dirroot . $pagetypes[$pt]['lib'];
    define('ADMIN_STICKYBLOCKS', $pt);
    $PAGE = page_create_object($pt, SITEID);
    $blocks = blocks_setup($PAGE, BLOCKS_PINNED_TRUE);
    $blocks_preferred_width = bounded_number(180, blocks_preferred_width($blocks[BLOCK_POS_LEFT]), 210);
    $navlinks = array(array('name' => get_string('administration'), 'link' => "{$CFG->wwwroot}/{$CFG->admin}/index.php", 'type' => 'misc'));
    $navlinks[] = array('name' => $strtitle, 'link' => null, 'type' => 'misc');
    $navigation = build_navigation($navlinks);
    print_header($strtitle, $strtitle, $navigation);
    echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">';
    echo '<tr valign="top">';
    echo '<td valign="top" style="width: ' . $blocks_preferred_width . 'px;" id="left-column">';
    if (!empty($THEME->customcorners)) {
        print_custom_corners_start();
    }
    blocks_print_group($PAGE, $blocks, BLOCK_POS_LEFT);
    if (!empty($THEME->customcorners)) {
        print_custom_corners_end();
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:stickyblocks.php


示例8: empty

$rmax = empty($THEME->block_r_max_width) ? 210 : $THEME->block_r_max_width;
define('BLOCK_L_MIN_WIDTH', $lmin);
define('BLOCK_L_MAX_WIDTH', $lmax);
define('BLOCK_R_MIN_WIDTH', $rmin);
define('BLOCK_R_MAX_WIDTH', $rmax);
//_____________ new page class code ________
$pagetype = PAGE_BLOG_VIEW;
$pageclass = 'page_blog';
// map our page identifier to the actual name
// of the class which will be handling its operations.
page_map_class($pagetype, $pageclass);
// Now, create our page object.
if (empty($USER->id)) {
    $PAGE = page_create_object($pagetype);
} else {
    $PAGE = page_create_object($pagetype, $USER->id);
}
$PAGE->courseid = $courseid;
$PAGE->filtertype = $filtertype;
$PAGE->filterselect = $filterselect;
$PAGE->tagid = $tagid;
$PAGE->init_full();
//init the BlogInfo object and the courserecord object
$editing = false;
if ($PAGE->user_allowed_editing()) {
    $editing = $PAGE->user_is_editing();
}
// Calculate the preferred width for left, right and center (both center positions will use the same)
$preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), BLOCK_L_MAX_WIDTH);
$preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), BLOCK_R_MAX_WIDTH);
// Display the blocks and allow blocklib to handle any block action requested
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:31,代码来源:header.php


示例9: backup_course_blocks

function backup_course_blocks($bf, $preferences)
{
    global $CFG;
    $status = true;
    // Read all of the block table
    $blocks = blocks_get_record();
    $pages = array();
    $pages[] = page_create_object(PAGE_COURSE_VIEW, $preferences->backup_course);
    if (!empty($CFG->showblocksonmodpages)) {
        // get course structure
        $course = get_record('course', 'id', $preferences->backup_course);
        $modinfo =& get_fast_modinfo($course);
        foreach ($preferences->mods as $module) {
            if (!$module->backup) {
                continue;
            }
            if (empty($modinfo->instances[$module->name])) {
                continue;
            }
            $pagetypes = page_import_types('mod/' . $module->name . '/');
            if (empty($pagetypes)) {
                continue;
            }
            foreach ($pagetypes as $pagetype) {
                foreach ($modinfo->instances[$module->name] as $cm) {
                    if (!empty($module->instances[$cm->instance]->backup)) {
                        $pages[] = page_create_object($pagetype, $cm->instance);
                    }
                }
            }
        }
    }
    //Blocks open tag
    fwrite($bf, start_tag('BLOCKS', 2, true));
    foreach ($pages as $page) {
        if ($instances = blocks_get_by_page($page)) {
            //Iterate over every block
            foreach ($instances as $position) {
                foreach ($position as $instance) {
                    //If we somehow have a block with an invalid id, skip it
                    if (empty($blocks[$instance->blockid]->name)) {
                        continue;
                    }
                    $blockname = $blocks[$instance->blockid]->name;
                    if (!($blockobj = block_instance($blockname, $instance))) {
                        // Invalid block
                        continue;
                    }
                    // encode absolute links in block config
                    $instance->configdata = $blockobj->get_backup_encoded_config();
                    //Begin Block
                    fwrite($bf, start_tag('BLOCK', 3, true));
                    fwrite($bf, full_tag('ID', 4, false, $instance->id));
                    fwrite($bf, full_tag('NAME', 4, false, $blockname));
                    fwrite($bf, full_tag('PAGEID', 4, false, $instance->pageid));
                    fwrite($bf, full_tag('PAGETYPE', 4, false, $instance->pagetype));
                    fwrite($bf, full_tag('POSITION', 4, false, $instance->position));
                    fwrite($bf, full_tag('WEIGHT', 4, false, $instance->weight));
                    fwrite($bf, full_tag('VISIBLE', 4, false, $instance->visible));
                    fwrite($bf, full_tag('CONFIGDATA', 4, false, $instance->configdata));
                    // Write instance data if needed
                    if ($blockobj->backuprestore_instancedata_used()) {
                        fwrite($bf, start_tag('INSTANCEDATA', 4, true));
                        $status = $blockobj->instance_backup($bf, $preferences);
                        fwrite($bf, end_tag('INSTANCEDATA', 4, true));
                    }
                    $context = get_context_instance(CONTEXT_BLOCK, $instance->id);
                    write_role_overrides_xml($bf, $context, 4);
                    /// write role_assign code here
                    write_role_assignments_xml($bf, $preferences, $context, 4);
                    //End Block
                    fwrite($bf, end_tag('BLOCK', 3, true));
                }
            }
        }
    }
    //Blocks close tag
    $status = fwrite($bf, end_tag('BLOCKS', 2, true));
    return $status;
}
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:80,代码来源:backuplib.php


示例10: upgrade_blocks_plugins


//.........这里部分代码省略.........
                        notify('Upgrading block ' . $block->name . ' from ' . $currblock->version . ' to ' . $block->version . ' FAILED!');
                    }
                    echo '<hr />';
                } else {
                    upgrade_log_start();
                    error('Version mismatch: block ' . $block->name . ' can\'t downgrade ' . $currblock->version . ' -> ' . $block->version . '!');
                }
            }
        } else {
            // block not installed yet, so install it
            // If it allows multiples, start with it enabled
            if ($blockobj->instance_allow_multiple()) {
                $block->multiple = 1;
            }
            // Set the block cron on install
            $block->cron = !empty($blockobj->cron) ? $blockobj->cron : 0;
            // [pj] Normally this would be inline in the if, but we need to
            //      check for NULL (necessary for 4.0.5 <= PHP < 4.2.0)
            $conflictblock = array_search($blocktitle, $blocktitles);
            if ($conflictblock !== false && $conflictblock !== NULL) {
                // Duplicate block titles are not allowed, they confuse people
                // AND PHP's associative arrays ;)
                error('<strong>Naming conflict</strong>: block <strong>' . $block->name . '</strong> has the same title with an existing block, <strong>' . $conflictblock . '</strong>!');
            }
            if (empty($updated_blocks)) {
                $strblocksetup = get_string('blocksetup');
                print_header($strblocksetup, $strblocksetup, build_navigation(array(array('name' => $strblocksetup, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript(), false, '&nbsp;', '&nbsp;');
            }
            $updated_blocks = true;
            upgrade_log_start();
            print_heading($block->name);
            $db->debug = true;
            @set_time_limit(0);
            // To allow slow databases to complete the long SQL
            /// Both old .sql files and new install.xml are supported
            /// but we priorize install.xml (XMLDB) if present
            $status = false;
            if (file_exists($fullblock . '/db/install.xml')) {
                $status = install_from_xmldb_file($fullblock . '/db/install.xml');
                //New method
            } else {
                if (file_exists($fullblock . '/db/' . $CFG->dbtype . '.sql')) {
                    $status = modify_database($fullblock . '/db/' . $CFG->dbtype . '.sql');
                    //Old method
                } else {
                    $status = true;
                }
            }
            $db->debug = false;
            if ($status) {
                if ($block->id = insert_record('block', $block)) {
                    $blockobj->after_install();
                    $component = 'block/' . $block->name;
                    if (!update_capabilities($component)) {
                        notify('Could not set up ' . $block->name . ' capabilities!');
                    }
                    events_update_definition($component);
                    notify(get_string('blocksuccess', '', $blocktitle), 'notifysuccess');
                    echo '<hr />';
                } else {
                    error($block->name . ' block could not be added to the block list!');
                }
            } else {
                error('Block ' . $block->name . ' tables could NOT be set up successfully!');
            }
        }
        $blocktitles[$block->name] = $blocktitle;
    }
    if (!empty($notices)) {
        upgrade_log_start();
        foreach ($notices as $notice) {
            notify($notice);
        }
    }
    // Finally, if we are in the first_install of BLOCKS (this means that we are
    // upgrading from Moodle < 1.3), put blocks in all existing courses.
    if ($first_install) {
        upgrade_log_start();
        //Iterate over each course
        if ($courses = get_records('course')) {
            foreach ($courses as $course) {
                $page = page_create_object(PAGE_COURSE_VIEW, $course->id);
                blocks_repopulate_page($page);
            }
        }
    }
    if (!empty($CFG->siteblocksadded)) {
        /// This is a once-off hack to make a proper upgrade
        upgrade_log_start();
        $page = page_create_object(PAGE_COURSE_VIEW, SITEID);
        blocks_repopulate_page($page);
        delete_records('config', 'name', 'siteblocksadded');
    }
    upgrade_log_finish();
    if (!empty($updated_blocks)) {
        print_continue($continueto);
        print_footer('none');
        die;
    }
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:101,代码来源:blocklib.php


示例11: process_group_tag


//.........这里部分代码省略.........
         
                // Second, look in the course alias table to see if the code should be translated to something else
                 if($aliases = get_field('enrol_coursealias', 'toids', 'fromid', $group->coursecode)){
                     $this->log_line("Found alias of course code: Translated $group->coursecode to $aliases");
                     // Alias is allowed to be a comma-separated list, so let's split it
                     $group->coursecode = explode(',', $aliases);
                 }
                */
         // For compatibility with the (currently inactive) course aliasing, we need this to be an array
         $group->coursecode = array($group->coursecode);
         // Third, check if the course(s) exist
         foreach ($group->coursecode as $coursecode) {
             $coursecode = trim($coursecode);
             if (!get_field('course', 'id', 'idnumber', $coursecode)) {
                 if (!$CFG->enrol_createnewcourses) {
                     $this->log_line("Course {$coursecode} not found in Moodle's course idnumbers.");
                 } else {
                     // Create the (hidden) course(s) if not found
                     $course = new object();
                     $course->fullname = $group->description;
                     $course->shortname = $coursecode;
                     $course->idnumber = $coursecode;
                     $course->format = 'topics';
                     $course->visible = 0;
                     // Insert default names for teachers/students, from the current language
                     $site = get_site();
                     if (current_language() == $CFG->lang) {
                         $course->teacher = $site->teacher;
                         $course->teachers = $site->teachers;
                         $course->student = $site->student;
                         $course->students = $site->students;
                     } else {
                         $course->teacher = get_string("defaultcourseteacher");
                         $course->teachers = get_string("defaultcourseteachers");
                         $course->student = get_string("defaultcoursestudent");
                         $course->students = get_string("defaultcoursestudents");
                     }
                     // Handle course categorisation (taken from the group.org.orgunit field if present)
                     if (strlen($group->category) > 0) {
                         // If the category is defined and exists in Moodle, we want to store it in that one
                         if ($catid = get_field('course_categories', 'id', 'name', addslashes($group->category))) {
                             $course->category = $catid;
                         } elseif ($CFG->enrol_createnewcategories) {
                             // Else if we're allowed to create new categories, let's create this one
                             $newcat->name = $group->category;
                             $newcat->visible = 0;
                             if ($catid = insert_record('course_categories', $newcat)) {
                                 $course->category = $catid;
                                 $this->log_line("Created new (hidden) category, #{$catid}: {$newcat->name}");
                             } else {
                                 $this->log_line('Failed to create new category: ' . $newcat->name);
                             }
                         } else {
                             // If not found and not allowed to create, stick with default
                             $this->log_line('Category ' . $group->category . ' not found in Moodle database, so using default category instead.');
                             $course->category = 1;
                         }
                     } else {
                         $course->category = 1;
                     }
                     $course->timecreated = time();
                     $course->startdate = time();
                     $course->numsections = 1;
                     // Choose a sort order that puts us at the start of the list!
                     $sortinfo = get_record_sql('SELECT MIN(sortorder) AS min,
                        MAX(sortorder) AS max
                         FROM ' . $CFG->prefix . 'course WHERE category<>0');
                     if (is_object($sortinfo)) {
                         // no courses?
                         $max = $sortinfo->max;
                         $min = $sortinfo->min;
                         unset($sortinfo);
                         $course->sortorder = $min - 1;
                     } else {
                         $course->sortorder = 1000;
                     }
                     if ($course->id = insert_record('course', addslashes_object($course))) {
                         // Setup the blocks
                         $page = page_create_object(PAGE_COURSE_VIEW, $course->id);
                         blocks_repopulate_page($page);
                         // Return value not checked because you can always edit later
                         $section = new object();
                         $section->course = $course->id;
                         // Create a default section.
                         $section->section = 0;
                         $section->id = insert_record("course_sections", $section);
                         add_to_log(SITEID, "course", "new", "view.php?id={$course->id}", "{$course->fullname} (ID {$course->id})");
                         $this->log_line("Created course {$coursecode} in Moodle (Moodle ID is {$course->id})");
                     } else {
                         $this->log_line('Failed to create course ' . $coursecode . ' in Moodle');
                     }
                 }
             } elseif ($recstatus == 3 && ($courseid = get_field('course', 'id', 'idnumber', $coursecode))) {
                 // If course does exist, but recstatus==3 (delete), then set the course as hidden
                 set_field('course', 'visible', '0', 'id', $courseid);
             }
         }
         // End of foreach(coursecode)
     }
 }
开发者ID:r007,项目名称:PMoodle,代码行数:101,代码来源:enrol.php


示例12: create_course

 function create_course($course, $skip_fix_course_sortorder = 0)
 {
     global $CFG;
     // define a template
     if (!empty($CFG->enrol_db_template)) {
         $template = get_record("course", 'shortname', $CFG->enrol_db_template);
         $template = (array) $template;
     } else {
         $site = get_site();
         $template = array('startdate' => time() + 3600 * 24, 'summary' => get_string("defaultcoursesummary"), 'format' => "weeks", 'password' => "", 'guest' => 0, 'numsections' => 10, 'idnumber' => '', 'cost' => '', 'newsitems' => 5, 'showgrades' => 1, 'groupmode' => 0, 'groupmodeforce' => 0, 'student' => $site->student, 'students' => $site->students, 'teacher' => $site->teacher, 'teachers' => $site->teachers);
     }
     // overlay template
     foreach (array_keys($template) as $key) {
         if (empty($course->{$key})) {
             $course->{$key} = $template[$key];
         }
     }
     $course->category = 1;
     // the misc 'catch-all' category
     if (!empty($CFG->enrol_db_category)) {
         //category = 0 or undef will break moodle
         $course->category = $CFG->enrol_db_category;
     }
     // define the sortorder
     $sort = get_field_sql('SELECT COALESCE(MAX(sortorder)+1, 100) AS max ' . ' FROM ' . $CFG->prefix . 'course ' . ' WHERE category=' . $course->category);
     $course->sortorder = $sort;
     // override with local data
     $course->startdate = time() + 3600 * 24;
     $course->timecreated = time();
     $course->visible = 1;
     // clear out id just in case
     unset($course->id);
     // truncate a few key fields
     $course->idnumber = substr($course->idnumber, 0, 100);
     $course->shortname = substr($course->shortname, 0, 100);
     // store it and log
     if ($newcourseid = insert_record("course", addslashes_object($course))) {
         // Set up new course
         $section = NULL;
         $section->course = $newcourseid;
         // Create a default section.
         $section->section = 0;
         $section->id = insert_record("course_sections", $section);
         $page = page_create_object(PAGE_COURSE_VIEW, $newcourseid);
         blocks_repopulate_page($page);
         // Return value no
         if (!$skip_fix_course_sortorder) {
             fix_course_sortorder();
         }
         add_to_log($newcourseid, "course", "new", "view.php?id={$newcourseid}", "enrol/database auto-creation");
     } else {
         trigger_error("Could not create new course {$extcourse} from  from database");
         notify("Serious Error! Could not create the new course!");
         return false;
     }
     return $newcourseid;
 }
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:57,代码来源:enrol.php


示例13: page_create_instance

/**
 * Factory function page_create_object(). Called with a numeric ID for a page, it autodetects
 * the page type, constructs the correct object and returns it.
 */
function page_create_instance($instance)
{
    page_id_and_class($id, $class);
    return page_create_object($id, $instance);
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:9,代码来源:pagelib.php


示例14: backup_course_blocks

function backup_course_blocks($bf, $preferences)
{
    global $CFG;
    $status = true;
    // Read all of the block table
    $blocks = blocks_get_record();
    $pages = array();
    $pages[] = page_create_object(PAGE_COURSE_VIEW, $preferences->backup_course);
    // Let's see if we have to backup blocks from modules
    $modulerecords = get_records_sql('SELECT name, id FROM ' . $CFG->prefix . 'modules');
    foreach ($preferences->mods as $module) {
        if (!$module->backup) {
            continue;
        }
        $cmods = get_records_select('course_modules', 'course = ' . $preferences->backup_course . ' AND module = ' . $modulerecords[$module->name]->id);
        if (empty($cmods)) {
            continue;
        }
        $pagetypes = page_import_types('mod/' . $module->name . '/');
        if (empty($pagetypes)) {
            continue;
        }
        foreach ($pagetypes as $pagetype) {
            foreach ($cmods as $cmod) {
                $pages[] = page_create_object($pagetype, $cmod->instance);
            }
        }
    }
    //Blocks open tag
    fwrite($bf, start_tag('BLOCKS', 2, true));
    while ($page = array_pop($pages)) {
        if ($instances = blocks_get_by_page($page)) {
            //Iterate over every block
            foreach ($instances as $position) {
                foreach ($position as $instance) {
                    //If we somehow have a block with an invalid id, skip it
                    if (empty($blocks[$instance->blockid]->name)) {
                        continue;
                    }
                    //Begin Block
                    fwrite($bf, start_tag('BLOCK', 3, true));
                    fwrite($bf, full_tag('ID', 4, false, $instance->id));
                    fwrite($bf, full_tag('NAME', 4, false, $blocks[$instance->blockid]->name));
                    fwrite($bf, full_tag('PAGEID', 4, false, $instance->pageid));
                    fwrite($bf, full_tag('PAGETYPE', 4, false, $instance->pagetype));
                    fwrite($bf, full_tag('POSITION', 4, false, $instance->position));
                    fwrite($bf, full_tag('WEIGHT', 4, false, $instance->weight));
                    fwrite($bf, full_tag('VISIBLE', 4, false, $instance->visible));
                    fwrite($bf, full_tag('CONFIGDATA', 4, false, $instance->configdata));
                    $context = get_context_instance(CONTEXT_BLOCK, $instance->id);
                    write_role_overrides_xml($bf, $context, 4);
                    /// write role_assign code here
                    write_role_assignments_xml($bf, $preferences, $context, 4);
                    //End Block
                    fwrite($bf, end_tag('BLOCK', 3, true));
                }
            }
        }
    }
    //Blocks close tag
    $status = fwrite($bf, end_tag('BLOCKS', 2, true));
    return $status;
}
开发者ID:veritech,项目名称:pare-project,代码行数:63,代码来源:backuplib.php


示例15: get_content

 function get_content()
 {
     global $CFG, $editing, $COURSE, $USER;
     if (!empty($COURSE)) {
         $this->courseid = $COURSE->id;
     }
     /// When displaying feeds in block, we double $CFG->block_rss_client_timeout
     /// so those feeds retrieved and cached by the cron() process will have a
     /// better chance to be used
     if (!empty($CFG->block_rss_client_timeout)) {
         $CFG->block_rss_client_timeout *= 2;
     }
     require_once $CFG->libdir . '/rsslib.php';
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = '';
     $this->content->footer = '';
     if (empty($this->instance)) {
         // We're being asked for content without an associated instance
         return $this->content;
     }
     $output = '';
     $rssid = -1;
     $display_description = false;
     if (isset($CFG->block_rss_client_num_entries) && is_numeric($CFG->block_rss_client_num_entries)) {
         $shownumentries = intval($CFG->block_rss_client_num_entries);
     } else {
         $shownumentries = 5;
         //default to 5 entries is not specified in admin section or instance
     }
     if (!empty($this->config)) {
         if (!empty($this->config->rssid)) {
             if (is_array($this->config->rssid)) {
                 $rssidarray = $this->config->rssid;
             } else {
                 // Make an array of the single value
                 $rssidarray = array($this->config->rssid);
             }
         }
         if (!empty($this->config->display_description)) {
             $display_description = intval($this->config->display_description);
         }
         if (!empty($this->config->shownumentries)) {
             $shownumentries = intval($this->config->shownumentries);
         }
     }
     if (empty($this->instance->pinned)) {
         $context = get_context_instance(CONTEXT_BLOCK, $this->instance->id);
     } else {
         $context = get_context_instance(CONTEXT_SYSTEM);
         // pinned blocks do not have own context
     }
     if (has_capability('block/rss_client:createsharedfeeds', $context) || has_capability('block/rss_client:createprivatefeeds', $context)) {
         $page = page_create_object($this->instance->pagetype, $this->instance->pageid);
         //if ($page->user_allowed_editing()) { // for SUBMITTERS_ALL_ACCOUNT_HOLDERS we're going to run into trouble later if we show it and then they don't have write access to the page.
         if (isset($this->config)) {
             // This instance is configured - show Add/Edit feeds link.
             $script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'managefeeds', 'id' => $this->courseid, 'section' => 'rss'));
             $output .= '<div class="info"><a title="' . get_string('feedsaddedit', 'block_rss_client') . '" href="' . $script . '">' . get_string('feedsaddedit', 'block_rss_client') . '</a></div>';
         } else {
             // This instance has not been configured yet - show configure link?
             if (has_capability('block/rss_client:manageanyfeeds', $context)) {
                 $script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'configblock', 'id' => $this->courseid, 'section' => 'rss'));
                 $output .= '<div class="info"><a title="' . get_string('feedsconfigurenewinstance', 'block_rss_client') . '" href="' . $script . '">' . get_string('feedsconfigurenewinstance', 'block_rss_client') . '</a></div>';
             }
         }
         //}
     }
     // Daryl Hawes note: if count of rssidarray is greater than 1
     // we should possibly display a drop down menu of selected feed titles
     // so user can select a single feed to view (similar to RSSFeed)
     if (!empty($rssidarray)) {
         $numids = count($rssidarray);
         $count = 0;
         foreach ($rssidarray as $rssid) {
             $output .= $this->get_rss_by_id($rssid, $display_description, $shownumentries, $numids > 1 ? true : false);
             if ($numids > 1 && $count != $numids - 1 && !empty($rssfeedstring)) {
                 $output .= '<hr style="width=:80%" />';
             }
             $count++;
         }
     }
     $this->content->text = $output;
     return $this->content;
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:87,代码来源:block_rss_client.php


示例16: update_course

/**
 * Update a course and return true or false
 *
 * @param object $data  - all the data needed for an entry in the 'course' table
 */
function update_course($data)
{
    global $USER, $CFG;
    // Preprocess allowed mods
    $allowedmods = empty($data->allowedmods) ? array() : $data->allowedmods;
    unset($data->allowedmods);
    // Normal teachers can't change setting
    if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
        unset($data->restrictmodules);
    }
    $movecat = false;
    $oldcourse = get_record('course', 'id', $data->id);
    // should not fail, already tested above
    if (!has_capability('moodle/course:create', get_context_instance(CONTEXT_COURSECAT, $oldcourse->category)) or !has_capability('moodle/course:create', get_context_instance(CONTEXT_COURSECAT, $data->category))) {
        // can not move to new category, keep the old one
        unset($data->category);
    } elseif ($oldcourse->category != $data->category) {
        $movecat = true;
    }
    // Update with the new data
    if (update_record('course', $data)) {
        $course = get_record('course', 'id', $data->id);
        add_to_log($course->id, "course", "update", "edit.php?id={$course->id}", $course->id);
        // "Admins" can change allowed mods for a course
        if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
            update_restricted_mods($course, $allowedmods);
        }
        if ($movecat) {
            $context = get_context_instance(CONTEXT_COURSE, $course->id);
            $newparent = get_context_instance(CONTEXT_COURSECAT, $course->category);
            context_moved($context, $newparent);
        }
        fix_course_sortorder();
         

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP page_css函数代码示例发布时间:2022-05-15
下一篇:
PHP page_create_instance函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap