+++ /dev/null
-//set DDM to intersect mode
-//YAHOO.util.DDM.mode = YAHOO.util.DDM.INTERSECT;
-
-//hide content body until done loading(manipulation looks ugly elsewise)
-document.getElementById('content').style.display='none';
-
-//onload object for handling scripts on page load, this insurses they run in my order
-function onload_class(){
- this.scripts = new Array();
- this.debug = false;
-}
-
-onload_class.prototype.add = function(script){
- if(this.debug)YAHOO.log("onload.add - adding "+script,"junk");
- this.scripts[this.scripts.length] = script;
- }
-
-onload_class.prototype.load = function(){
- var scriptcount = this.scripts.length;
- if(this.debug)YAHOO.log("onload.load - loading "+scriptcount+" scripts","info");
- for(i=0;i<scriptcount;i++)
- eval(this.scripts[i]);
- }
-
-var onload = new onload_class();
-
-
-
-//main page object
-function main_class(){
- this.portal = new php_portal_class();
-
- this.blocks = new Array();
- this.sections = new Array();
-
- this.leftcolumn = null;
- this.rightcolumn = null;
-
- //this.logview = new YAHOO.widget.LogReader(document.body.appendChild(document.createElement('div')));
- this.icons = [];
- this.marker = null;
- //things to process onload
- onload.add('main.process_document();');
- onload.add("document.getElementById('content').style.display='block';");
-
- this.connectQueue = [];
- this.connectQueueHead = 0;
- this.connectQueueConnection = null;
-
- this.debug = true;
-}
-
-
-main_class.prototype.process_blocks = function(){
- //remove unneeded icons (old school position icons and delete/hide although they will be readded)
- var rmIconClasses = ['icon up','icon down','icon right','icon left','icon delete','icon hide'];
- for(var c=0;c<rmIconClasses.length;c++){
- els = YAHOO.util.Dom.getElementsByClassName(rmIconClasses[c]);
-
- for(var x=0;x<els.length;x++)
- els[x].parentNode.removeChild(els[x]);
- }
-
- //process the block ids passed from php
- var blockcount = this.portal.blocks.length;
- YAHOO.log("main.processBlocks - processing "+blockcount+" blocks","info");
- for(i=0;i<blockcount;i++){
- this.blocks[i] = new block_class(this.portal.blocks[i][1],"blocks");
-
- //put in correct side array also
- if(this.portal.blocks[i][0] == 'l')
- main.leftcolumn.add_block(this.blocks[i]);
- else if(this.portal.blocks[i][0] == 'r')
- main.rightcolumn.add_block(this.blocks[i]);
-
- //hide if called for
- if(this.portal.blocks[i][2] == 1)
- this.blocks[i].toggle_hide(null,null,true);
- }
-
- }
-
-//process the document to get important containers
-main_class.prototype.process_document = function(){
- YAHOO.log("Processing Document","info");
- //process columns for blocks
- this.leftcolumn = new column_class('left-column',"blocks",null,'l');
- this.rightcolumn = new column_class('right-column',"blocks",null,'r');
-
- //process sections
- this.sections[0] = document.getElementById('section-0');
- var ct = 1;
- while(document.getElementById('section-'+ct) != null){
- this.sections[ct]=new section_class('section-'+ct,"sections");
- this.sections[ct].addToGroup('resources');
- ct++;
- }
- if(this.debug)YAHOO.log("Processed "+ct+" sections");
-
- }
-
-//return block by id
-main_class.prototype.get_block_index = function(el){
- var blockcount = this.blocks.length;
- for(i=0;i<blockcount;i++)
- if(this.blocks[i] == el)
- return i;
- }
-
-main_class.prototype.get_section_index = function(el){
- var sectioncount = this.sections.length;
- for(i=0;i<sectioncount;i++)
- if(this.sections[i] == el)
- return i;
- }
-
-main_class.prototype.mk_button = function(tag,imgSrc,attributes,imgAttributes){
- //create button and return object
- var container = document.createElement(tag);
- container.style.cursor = 'pointer';
- var image = document.createElement('img');
- image.setAttribute('src',main.portal.wwwroot+imgSrc);
- container.appendChild(image);
-
- if(attributes != null)
- for(var c=0;c<attributes.length;c++)
- container.setAttribute(attributes[c][0],attributes[c][1]);
-
- if(imgAttributes != null)
- for(var c=0;c<attributes.length;c++)
- image.setAttribute(imgAttributes[c][0],imgAttributes[c][1]);
-
- return container;
- }
-
-main_class.prototype.connect = function(method,urlStub,callback,body){
- if(this.debug)YAHOO.log("Making "+method+" connection to /course/format/topicsajax/commands.php?courseId="+main.portal.id+"&"+urlStub);
- if(callback == null){
- callback = {}
- }
- return YAHOO.util.Connect.asyncRequest(method,this.portal.wwwroot+"/course/format/topicsajax/commands.php?courseId="+main.portal.id+"&"+urlStub,callback,body);
-
-
- }
-
-main_class.prototype.connectQueue_add = function(method,urlStub,callback,body){
- var Qlength = main.connectQueue.length;
- main.connectQueue[Qlength] = [];
- main.connectQueue[Qlength]['method'] = method;
- main.connectQueue[Qlength]['urlStub'] = urlStub;
- main.connectQueue[Qlength]['body'] = body;
-
- if(main.connectQueueConnection == null || !YAHOO.util.Connect.isCallInProgress(main.connectQueueConnection))
- main.connectQueue_fireNext();
- }
-
-main_class.prototype.connectQueue_fireNext= function(){
- var head = main.connectQueueHead;
- if(head >= main.connectQueue.length)
- return;
-
- var callback = {
- success: function(){
- main.connectQueue_fireNext();
- }
- }
-
- main.connectQueueConnection = main.connect(main.connectQueue[head]['method'],main.connectQueue[head]['urlStub'],callback,main.connectQueue[head]['body'])
-
- main.connectQueueHead++;
- }
-
-main_class.prototype.update_marker = function(newMarker){
- if(this.marker != null)
- this.marker.toggle_highlight();
-
- this.marker = newMarker;
- this.marker.toggle_highlight();
-
- this.connect('post','class=course&field=marker',null,'value='+this.marker.sectionId);
- }
-
-
-
-
-var main = new main_class();
-
-
-
-
-//portal to php data
-function php_portal_class(){
- this.id = null;
-
- //array of id's of blocks set at end of page load by php
- this.blocks = new Array();
- this.imagePath = null;
-
- //flag for week fomat
- this.isWeek = false;
-
- YAHOO.log("instantiated php_portal_class","info");
-}
-
-
-
-
+++ /dev/null
-<?php
- /*
- * $Id$
- *handle the ajax commands of the topics format
- */
-
- require_once('../../../config.php');
- require_once('../../lib.php');
- require_once($CFG->libdir.'/blocklib.php');
-
- require_once($CFG->dirroot.'/mod/forum/lib.php');
- require_once($CFG->dirroot.'/lib/ajaxlib/ajaxlib.php');
-
- //verify user is authorized
- if(!isteacher($course->id)){
- echo("Not authorized to edit page!");
- die;
- }
-
- if(!$_GET[courseId]){
- echo("No ID presented!");
- die;
- }
-
-
- switch($_SERVER['REQUEST_METHOD']){
-
-
- case POST:
- switch($_GET['class']){
- case block: switch($_GET[field]){
-
- case visible:
- $dataobject->id = $_POST[instanceId];
- $dataobject->visible = $_POST[value];
- update_record('block_instance',$dataobject);
- break;
-
- case position:
- $dataobject->id = $_POST[instanceId];
- $dataobject->position = $_POST[value];
- $dataobject->weight = $_POST[weight];
- update_record('block_instance',$dataobject);
- //echo("Got ".$_GET['class'].",".$_GET[field]."Posted id=".$dataobject->id." position=".$dataobject->position." weight=".$dataobject->weight);
- break;
- }
- break;
-
-
- case section: switch($_GET[field]){
-
- case visible:
- $dataobject->id = get_field('course_sections','id','course',$_GET[courseId],'section',(int)$_POST[id]);
- $dataobject->visible = $_POST[value];
- update_record('course_sections',$dataobject);
- break;
-
-
- case sequence:
- $dataobject->id = get_field('course_sections','id','course',$_GET[courseId],'section',(int)$_POST[id]);
- $dataobject->sequence = $_POST[value];
- update_record('course_sections',$dataobject);
- break;
-
- case all:
- $dataobject->id = get_field('course_sections','id','course',$_GET[courseId],'section',(int)$_POST[id]);
- $dataobject->summary = $_POST[summary];
- $dataobject->sequence = $_POST[sequence];
- $dataobject->visible = $_POST[visible];
- update_record('course_sections',$dataobject);
- break;
-
-
-
- }
- break;
-
-
-
-
- case resource: switch($_GET[field]){
-
- case visible:
- $dataobject->id = $_POST[id];
- $dataobject->visible = $_POST[value];
- update_record('course_modules',$dataobject);
- break;
-
- case groupmode:
- $dataobject->id = $_POST[id];
- $dataobject->groupmode = $_POST[value];
- update_record('course_modules',$dataobject);
- break;
-
- case section:
- $dataobject->id = $_POST[id];
- //$dataobject->section = get_field('course_sections','id','course',$_GET[courseId],'section',(int)$_POST[value]);
- $dataobject->section = $_POST[value];
- update_record('course_modules',$dataobject);
- break;
-
- }
- break;
-
- case course: switch($_GET[field]){
-
- case marker:
- $dataobject->id = $_GET[courseId];
- $dataobject->marker = $_POST[value];
- update_record('course',$dataobject);
- break;
-
-
- }
- break;
-
- }
-
-
- break;
- case DELETE:
- switch($_GET['class']){
- case block:
- delete_records('block_instance','id',$_GET[instanceId]);
- break;
-
- case section:
- $dataobject->id = get_field('course_sections','id','course',$_GET[courseId],'section',(int)$_GET[id]);
- $dataobject->summary = '';
- $dataobject->sequence = '';
- $dataobject->visible = '1';
- update_record('course_sections',$dataobject);
- break;
-
- case resource:
- delete_records('course_modules','id',$_GET[id]);
- break;
-
- }
- break;
- }
-?>