Skip to content

Commit

Permalink
new moodlepatch files tested with moodle 1.9x and 2.1x
Browse files Browse the repository at this point in the history
git-svn-id: https://xerteonlinetoolkits.googlecode.com/svn/trunk@214 912cdd6b-5c7d-d5a7-a2ba-d0f0cdb91641
  • Loading branch information
ronm123 committed Nov 1, 2011
1 parent dbee052 commit 785b7ad
Show file tree
Hide file tree
Showing 3 changed files with 407 additions and 0 deletions.
238 changes: 238 additions & 0 deletions moodle_config.txt
@@ -0,0 +1,238 @@
<?php

//moodle integration (please view moodle_integration_readme.txt before use)
//The require path below is the path to the moodle installation config file
//usually found in the root of the moodle installation
//this needs to be the path from root rather than something like ../../moodle/config.php
//e.g. this might be something like require("/home/yourdomain/public_html/config.php");
//for a xampp/maxos install this should be something like require("/xampp/htdocs/moodle/config.php");
//set this same path in moodle_integration.txt also
require("/xampp/htdocs/moodle/config.php");

/**
*
* Config page, sets up the site variable from the database
*
* @author Patrick Lockley
* @version 1.0
* @copyright Copyright (c) 2008,2009 University of Nottingham
* @package
*/

/**
* $xerte_toolkits_site variable
* Variable used to hold database settings
* @global object $xerte_toolkits_site
*/

// Same as error_reporting(E_ALL);
global $xerte_toolkits_site;

// Change this to FALSE for production sites.
global $development;
$development = false;
if(php_uname('n') == 'orange') {
$development = true;
}
ini_set('error_reporting', 0);
if($development) {
ini_set('error_reporting', E_ALL);
}

if(!function_exists('_debug')) {
function _debug($string, $up = 0) {
global $development;
if(isset($development) && $development) {
// yes, we really don't want to report file write errors if this doesn't work.
$backtrace = debug_backtrace();
if(isset($backtrace[$up]['file'])) {
$string = $backtrace[$up]['file'] . $backtrace[$up]['line'] . $string;
}
@file_put_contents('/tmp/debug.log', date('Y-m-d H:i:s ') . $string . "\n", FILE_APPEND);
}
}
}

if(!isset($xerte_toolkits_site)) {
//check if using moodle integration and if not start session as usual
if($_SESSION['integrate_with_moodle']!=true){
session_start();
}
// create new generic object to hold all our config stuff in....
$xerte_toolkits_site = new StdClass();

/**
* Access the database to get the variables
*/
if(!is_file(dirname(__FILE__) . '/database.php')) {
die("please run /setup");
}

require_once("database.php");
require_once(dirname(__FILE__) . '/website_code/php/database_library.php');

$row = db_query_one("SELECT * FROM {$xerte_toolkits_site->database_table_prefix}sitedetails");

if(!$row) {
die("Error talking to database; perhaps it is offline?");
}
/**
* Access the database to get the variables
* @version 1.0
* @author Patrick Lockley
* @copyright 2008,2009 University of Nottingham
*/

/**
* Include any script that is used for configuration
*/

if($row['integration_config_path']!=""){

require_once($row['integration_config_path']);

}

/**
* Site variables
*/

$xerte_toolkits_site->site_url = $row['site_url'];
$xerte_toolkits_site->apache = $row['apache'];
$xerte_toolkits_site->integration_config_path = $row['integration_config_path'];
$xerte_toolkits_site->admin_username = $row['admin_username'];
$xerte_toolkits_site->admin_password = $row['admin_password'];
$xerte_toolkits_site->mimetypes = explode(",",$row['mimetypes']);

/**
* Site session variables
*/

$xerte_toolkits_site->site_session_name = $row['site_session_name'];

/**
* Configure the look and feel for index.php page
*/

$xerte_toolkits_site->site_title = $row['site_title'];
$xerte_toolkits_site->name = $row['site_name'];
$xerte_toolkits_site->site_logo = $row['site_logo'];
$xerte_toolkits_site->organisational_logo = $row['organisational_logo'];
$xerte_toolkits_site->welcome_message = $row['welcome_message'];
$xerte_toolkits_site->demonstration_page = $xerte_toolkits_site->site_url . $row['demonstration_page'];

$xerte_toolkits_site->site_text = $row['site_text'];
$xerte_toolkits_site->news_text = base64_decode($row['news_text']);
$xerte_toolkits_site->pod_one = base64_decode($row['pod_one']);
$xerte_toolkits_site->pod_two = base64_decode($row['pod_two']);
$xerte_toolkits_site->copyright = utf8_decode($row['copyright']);

/**
* Configure the RSS Feed title
*/

$xerte_toolkits_site->rss_title = $row['rss_title'];
$xerte_toolkits_site->synd_publisher = $row['synd_publisher'];
$xerte_toolkits_site->synd_rights = $row['synd_rights'];
$xerte_toolkits_site->synd_license = $row['synd_license'];

/**
* Set up the string for the password protected play page
*/

$xerte_toolkits_site->form_string = base64_decode($row['form_string']);

/**
* Set up the string for the peer review page
*/

$xerte_toolkits_site->peer_form_string = base64_decode($row['peer_form_string']);

/**
* Site paths
*/

$xerte_toolkits_site->module_path = $row['module_path'];
$xerte_toolkits_site->website_code_path = $row['website_code_path'];
$xerte_toolkits_site->users_file_area_short = $row['users_file_area_short'];
$xerte_toolkits_site->php_library_path = $row['php_library_path'];
$xerte_toolkits_site->root_file_path = $row['root_file_path'];
$xerte_toolkits_site->basic_template_path = $xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path;
$xerte_toolkits_site->users_file_area_full = $xerte_toolkits_site->root_file_path . $xerte_toolkits_site->users_file_area_short;
$xerte_toolkits_site->import_path = $row['import_path'];

/**
* SQL query string used by play,edit and preview pages
*/

$xerte_toolkits_site->play_edit_preview_query = base64_decode($row['play_edit_preview_query']);

/**
* Error handling settings
*/

$xerte_toolkits_site->error_log_path = $xerte_toolkits_site->root_file_path . $row['error_log_path'];
$xerte_toolkits_site->email_error_list = $row['email_error_list'];
$xerte_toolkits_site->error_log_message= $row['error_log_message'];
$xerte_toolkits_site->error_email_message= $row['error_email_message'];
$xerte_toolkits_site->max_error_size= $row['max_error_size'];

/**
* LDAP Settings
*/

$xerte_toolkits_site->ldap_host = $row['ldap_host'];
$xerte_toolkits_site->ldap_port = $row['ldap_port'];
$xerte_toolkits_site->bind_pwd = $row['bind_pwd'];
$xerte_toolkits_site->basedn = $row['basedn'];
$xerte_toolkits_site->bind_dn = $row['bind_dn'];
$xerte_toolkits_site->LDAP_preference = $row['LDAP_preference'];
$xerte_toolkits_site->LDAP_filter = $row['LDAP_filter'];

/**
* Xerte settings
*/

$xerte_toolkits_site->flash_save_path = $row['flash_save_path'];
$xerte_toolkits_site->flash_upload_path = $row['flash_upload_path'];
$xerte_toolkits_site->flash_preview_check_path = $row['flash_preview_check_path'];
$xerte_toolkits_site->flash_flv_skin = $xerte_toolkits_site->site_url . $row['flash_flv_skin'];

/**
* Email settings
*/

$xerte_toolkits_site->site_email_account = $row['site_email_account'];
$xerte_toolkits_site->headers = $row['headers'];
$xerte_toolkits_site->email_to_add_to_username = $row['email_to_add_to_username'];

/**
* RSS Proxy settings
*/

$xerte_toolkits_site->proxy1 = $row['proxy1'];
$xerte_toolkits_site->port1 = $row['port1'];

/**
* Set up the feedback list from the feedback page
*/

$xerte_toolkits_site->feedback_list = $row['feedback_list'];

/* Optional :
require_once("session_handler.php");

$session_handle = new toolkits_session_handler();

session_set_save_handler(
array($session_handle,'xerte_session_open'),
array($session_handle,'xerte_session_close'),
array($session_handle,'xerte_session_read'),
array($session_handle,'xerte_session_write'),
array($session_handle,'xerte_session_destroy'),
array($session_handle,'xerte_session_clean'));
*/

$_SESSION['toolkits_sessionid'] = session_id();
}

112 changes: 112 additions & 0 deletions moodle_integration.txt
@@ -0,0 +1,112 @@
<?php
////moodle integration (please view moodle_integration_readme.txt before use)
//the following line sets a session variable so that the separate config file doesn't restart session_start and kill the moodle session
//if demo.php or switch.php is used then this session isn't set so the installation works fine without moodle integration
$_SESSION['integrate_with_moodle'] = true;

//The require path below is the path to the moodle installation config file
//usually found in the root of the moodle installation
//this needs to be the path from root rather than something like ../../moodle/config.php
//e.g. this might be something like require("/home/yourdomain/public_html/config.php");
//for a xampp/maxos install this should be something like require("/xampp/htdocs/moodle/config.php");
//set this same path in moodleintegration.php also
require("/xampp/htdocs/moodle/config.php");

//This ensures anyone visiting thie toolkits installation and this page direct is redirected to the moodle login first
//if not already logged in to moodle
require_login();

require_once("config.php");

/**
*
* Integration page, generic framework for integrating this service into other systems.
*
* Please look below at the INSERT strings and make sure you have these sorted
* If your system is providing it's own sessions then you also need to empty the code from session.php so it is just the PHP tags and possibly session_start().
*
* @author Patrick Lockley
* @version 1.0
* @copyright Copyright (c) 2008,2009 University of Nottingham
* @package
*/

/**
* Create the basic session
*/

include $xerte_toolkits_site->php_library_path . "login_library.php";

include $xerte_toolkits_site->php_library_path . "display_library.php";

$_SESSION['toolkits_firstname'] = $USER->firstname;//moodle session firstname

$_SESSION['toolkits_surname'] = $USER->lastname;//moodle session lastname

include $xerte_toolkits_site->php_library_path . "user_library.php";

$mysql_id=database_connect("index.php database connect success","index.php database connect fail");

$_SESSION['toolkits_logon_username'] = $USER->username;//moodle session username

/*
* Check to see if this is a users' first time on the site
*/

if(check_if_first_time($_SESSION['toolkits_logon_username'])){

/*
* create the user a new id
*/

$_SESSION['toolkits_logon_id'] = create_user_id($_SESSION['toolkits_logon_username'], $_SESSION['toolkits_firstname'], $_SESSION['toolkits_surname']);

/*
* create a virtual root folder for this user
*/

create_a_virtual_root_folder();

}else{

/*
* User exists so update the user settings
*/

$_SESSION['toolkits_logon_id'] = get_user_id();

update_user_logon_time();

}

recycle_bin();

/*
* Output the main page, including the user's and blank templates
*/

echo file_get_contents($xerte_toolkits_site->website_code_path . "management_headers");

echo "<script type=\"text/javascript\"> // JAVASCRIPT library for fixed variables\n // management of javascript is set up here\n // SITE SETTINGS\n";

echo "var site_url = \"" . $xerte_toolkits_site->site_url . "\";\n";

echo "var site_apache = \"" . $xerte_toolkits_site->apache . "\";\n";

echo "var properties_ajax_php_path = \"website_code/php/properties/\";\n var management_ajax_php_path = \"website_code/php/management/\";\n var ajax_php_path = \"website_code/php/\";\n";

echo logged_in_page_format_top(file_get_contents($xerte_toolkits_site->website_code_path . "management_top"));

list_users_projects("data_down");

echo logged_in_page_format_middle(file_get_contents($xerte_toolkits_site->website_code_path . "management_middle"));

list_blank_templates();

echo "&nbsp;&nbsp;&nbsp;Logged in as " .$_SESSION['toolkits_firstname'] ." " .$_SESSION['toolkits_surname'];

echo file_get_contents($xerte_toolkits_site->website_code_path . "management_bottom");

?>
</body>
</html>

0 comments on commit 785b7ad

Please sign in to comment.