Пример #1
0
require_capability('moodle/course:update', $context);
// OK, now let's process the parameters and do stuff
switch ($_SERVER['REQUEST_METHOD']) {
    case 'POST':
        switch ($class) {
            case 'block':
                switch ($field) {
                    case 'visible':
                        blocks_execute_action($PAGE, $pageblocks, 'toggle', $blockinstance);
                        break;
                    case 'position':
                        // Misleading case. Should probably call it 'move'.
                        // We want to move the block around. This means changing
                        // the column (position field) and/or block sort order
                        // (weight field).
                        blocks_move_block($PAGE, $blockinstance, $column, $value);
                        break;
                }
                break;
            case 'section':
                if (!record_exists('course_sections', 'course', $course->id, 'section', $id)) {
                    error_log('AJAX commands.php: Bad Section ID ' . $id);
                    die;
                }
                switch ($field) {
                    case 'visible':
                        set_section_visible($course->id, $id, $value);
                        break;
                    case 'move':
                        move_section($course, $id, $value);
                        break;
Пример #2
0
                 $recordexists = record_exists('block_instance', 'position', $column, 'pageId', $courseid, 'id', $instanceid);
                 if ($isaddednewblock || $undifinedinsertedid) {
                     if (!empty($countrecords)) {
                         $destweight = $recordexists ? $instweight->weight : $instweight->weight + 1;
                     } else {
                         $destweight = 0;
                     }
                 } else {
                     if (!empty($countrecords)) {
                         $destweight = $recordexists ? $instweight->weight : $instweight->weight + 1;
                     } else {
                         $destweight = 0;
                     }
                 }
             }
             blocks_move_block($PAGE, $blockinstance, $column, $destweight);
             $current_blocks = blocks_get_by_page_pinned($PAGE);
             global $COURSE;
             foreach ($current_blocks as $pos => $blocks) {
                 if (count($current_blocks[$pos]) == 0) {
                     print_side_block('', '', NULL, NULL, '', array('id' => $pos . 'inst0', 'class' => 'tempblockhandle'), '');
                 }
             }
             break;
     }
     break;
 case 'section':
     if (!record_exists('course_sections', 'course', $course->id, 'section', $id)) {
         error_log('AJAX commands.php: Bad Section ID ' . $id);
         die;
     }