commit
a955b9e777
@ -0,0 +1,13 @@ |
||||
<?php |
||||
// HTTP404 page with neat styling |
||||
// 2011, Jean-Karim Bockstael <jeankarim@cblue.be> |
||||
// ErrorDocument 404 /404/ |
||||
|
||||
$language_file = array('document', 'index'); |
||||
require_once('../main/inc/global.inc.php'); |
||||
|
||||
$msg = get_lang('FileNotFound'); |
||||
Display::display_header($msg); |
||||
Display::display_error_message($msg); |
||||
Display::display_footer(); |
||||
?> |
@ -0,0 +1,13 @@ |
||||
CustomPages looks for alternatives in this directory, and displays them if present. The user-provided custom pages must exactly be named as such : |
||||
|
||||
- index-logged.php for the general landing page before login |
||||
- index-unlogged.php for the general landing page when already logged-in |
||||
- registration.php for the registration form |
||||
- registration-feedback.php for the registration success feedback |
||||
- lostpassword.php for the password recovery form |
||||
- lostpassword-feedback.php for the password recovery feedback page |
||||
|
||||
Important note : |
||||
If you pull this feature from a repo, not through an upgrade or install process, you have to exectute the following SQL statements in the main database or this option won't appear in the admin interface : |
||||
INSERT INTO settings_options (variable, value, display_text) VALUES ('use_custom_pages', 'true', 'Yes'), ('use_custom_pages', 'false', 'No'); |
||||
INSERT INTO settings_current (variable, type, category, selected_value, title, comment, scope) VALUES ('use_custom_pages','radio','Platform','false','UseCustomPages','UseCustomPagesComment', 'platform'); |
@ -0,0 +1,73 @@ |
||||
<?php |
||||
// CustomPages : Browser language detection |
||||
// Include this file in your custom page if you want to set the language variable of the Chamilo session to the best pick according to the visitor's browser's options. |
||||
// 2011, Jean-Karim Bockstael, CBlue <jeankarim@cblue.be> |
||||
|
||||
// This requires the Chamilo system to be initialized |
||||
// (note that it's easier to do the following include in the parent page) |
||||
// require_once('path/to/main/inc/global.inc.php'); |
||||
|
||||
// Returns the best match between available languages and visitor preferences |
||||
// return the best match as 2-chars code, null when none match |
||||
function get_preferred_language($available_langs) { |
||||
// Parsing the Accept-languages HTTP header |
||||
$langs = array(); |
||||
foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $httplang) { |
||||
$rawlang = explode(';q=', $httplang); |
||||
if (strpos($rawlang[0], '-') !== FALSE) { |
||||
// We ignore the locale part, as in en-GB vs en-US |
||||
$rawlang[0] = substr($rawlang[0], 0, strpos($rawlang[0], '-')); |
||||
} |
||||
if (count($rawlang) == 1) { |
||||
$rawlang[1] = 1.0; // The absence of weighting means a weight of 1 (max) |
||||
} |
||||
$langs[$rawlang[1]][] = $rawlang[0]; |
||||
} |
||||
krsort($langs, SORT_NUMERIC); |
||||
// Choosing the best match |
||||
foreach($langs as $weight => $codes) { |
||||
foreach ($codes as $code) { |
||||
if (in_array($code, $available_langs)) { |
||||
return $code; |
||||
} |
||||
} |
||||
} |
||||
// No match |
||||
return null; |
||||
} |
||||
|
||||
// Wrapper function for the get_lang function |
||||
// use this if you want to avoid translation caching issues |
||||
function cp_get_lang($variable) { |
||||
return get_lang($variable, null, $_SESSION['user_language_choice']); |
||||
} |
||||
|
||||
// Note that Chamilo languages are expressed as full english names, not 2-characters codes |
||||
// e.g. 'english' instead of 'en', 'french' instead of 'fr', ... |
||||
// We need a matching array. Note the value for the null key, which is the default language. |
||||
// Also note that this is an example matchin array, not all languages are present. |
||||
$chamilo_langs = array(null => 'english', 'en' => 'english', 'fr' => 'french', 'es' => 'spanish'); |
||||
|
||||
// Which of these can we actually pick from ? |
||||
$available_langs = array('en','fr'); |
||||
|
||||
// Which language files will we need ? |
||||
$language_file = array('courses', 'index', 'registration', 'admin','userInfo'); |
||||
|
||||
// Let's find out which language to serve to this particular browser |
||||
$lang_match = $chamilo_langs[get_preferred_language($available_langs)]; |
||||
|
||||
// Chamilo overrides this parameters at some places, e.g. in the logout link |
||||
if (isset($_REQUEST['language']) && !empty($_REQUEST['language']) && in_array($_REQUEST['language'], $chamilo_langs)) { |
||||
$lang_match = $_REQUEST['language']; |
||||
} |
||||
|
||||
// Maybe a language had already been selected, we should honor this |
||||
if (isset($_SESSION['user_language_choice']) && in_array($_SESSION['user_language_choice'], $chamilo_langs)) { |
||||
$lang_match = $_SESSION['user_language_choice']; |
||||
} |
||||
|
||||
// We need to set the relevant session variables to the best match, to use Chamilo's i18n lib. |
||||
$_user['language'] = $lang_match; |
||||
$_SESSION['user_language_choice'] = $lang_match; |
||||
?> |
@ -0,0 +1,246 @@ |
||||
<?php |
||||
|
||||
// name of the language file that needs to be included |
||||
$language_file = array('admin','events'); |
||||
$cidReset = true; |
||||
require_once '../inc/global.inc.php'; |
||||
$this_section = SECTION_PLATFORM_ADMIN; |
||||
api_protect_admin_script(); |
||||
|
||||
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
||||
$tool_name = get_lang('events_title'); |
||||
|
||||
$action = isset($_POST['action'])?$_POST['action']:null; |
||||
$eventId = isset($_POST['eventId'])?$_POST['eventId']:null; |
||||
$eventUsers = isset($_POST['eventUsers'])?$_POST['eventUsers']:null; |
||||
$eventMessage = isset($_POST['eventMessage'])?$_POST['eventMessage']:null; |
||||
$eventSubject = isset($_POST['eventSubject'])?$_POST['eventSubject']:null; |
||||
|
||||
if($action == 'modEventType') { |
||||
if($eventUsers) { |
||||
$users = explode(';',$eventUsers); |
||||
} |
||||
else { |
||||
$users = array(); |
||||
} |
||||
|
||||
eventType_mod($eventId,$users,$eventMessage,$eventSubject); |
||||
// echo mysql_error(); |
||||
header('location: event_type.php'); |
||||
exit; |
||||
} |
||||
|
||||
$ets = eventType_getAll(); |
||||
|
||||
|
||||
$ajaxPath = api_get_path(WEB_CODE_PATH).'inc/ajax/events.ajax.php'; |
||||
$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; |
||||
|
||||
Display::display_header($tool_name); |
||||
|
||||
?> |
||||
|
||||
<script language="javascript"> |
||||
var usersList; |
||||
var eventTypes = <?php print json_encode($ets) ?>;
|
||||
|
||||
$(document).ready(function(){ |
||||
ajax({action:"getUsers"},function(data) { |
||||
usersList = data; |
||||
} |
||||
); |
||||
|
||||
// ajax({action:"getEventTypes"},function(data) { |
||||
// eventTypes = data; |
||||
// showEventTypes(data); |
||||
// } |
||||
// ); |
||||
}); |
||||
|
||||
function ajax(params,func) { |
||||
$.ajax({ |
||||
url: "<?php echo $ajaxPath ?>",
|
||||
type: "POST", |
||||
data: params, |
||||
success: func |
||||
} |
||||
); |
||||
} |
||||
|
||||
function refreshUsersList() { |
||||
removeAllOption($('#usersList')); |
||||
$.each(usersList,function(ind,item) { |
||||
addOption($('#usersList'),item.user_id,item.firstname + ' '+item.lastname); |
||||
} |
||||
); |
||||
} |
||||
|
||||
// function showEventTypes(data) { |
||||
// $.each(data,function(ind,item) { |
||||
// addOption($('#eventList'),item.id,item.name); |
||||
// } |
||||
// ); |
||||
// } |
||||
|
||||
function getCurrentEventTypeInd() { |
||||
var ind=false; |
||||
$.each(eventTypes,function(i,item) |
||||
{ |
||||
if(item.id == $('#eventList option:selected').first().attr('value')) { |
||||
ind=i; |
||||
return false; |
||||
} |
||||
} |
||||
) |
||||
|
||||
return ind; |
||||
} |
||||
|
||||
function showEventType() { |
||||
eInd = getCurrentEventTypeInd(); |
||||
|
||||
$('#eventId').attr('value',eventTypes[eInd].id); |
||||
$('#eventName').attr('value',eventTypes[eInd].name); |
||||
$('#eventNameTitle').text(eventTypes[eInd].nameLangVar); |
||||
$('#eventMessage').text(eventTypes[eInd].message); |
||||
$('#eventSubject').attr('value',eventTypes[eInd].subject); |
||||
$('#descLangVar').text(eventTypes[eInd].descLangVar); |
||||
|
||||
ajax({action:"getEventTypeUsers","id":eventTypes[eInd].id},function(data) { |
||||
removeAllOption($('#usersSubList')); |
||||
|
||||
refreshUsersList(); |
||||
|
||||
usersIds = new Array(); |
||||
|
||||
$.each(data,function(ind,item) { |
||||
addOption($('#usersSubList'),item.user_id,item.firstname + ' '+item.lastname); |
||||
usersIds[ind] = item.value; |
||||
removeOption($('#usersList'),item.user_id); |
||||
}); |
||||
|
||||
$('#eventUsers').attr('value',usersIds.join(';')); |
||||
} |
||||
); |
||||
} |
||||
|
||||
function submitForm() { |
||||
if($('#eventId')) { |
||||
usersIds = new Array(); |
||||
|
||||
$('#usersSubList option').each(function(ind,item) |
||||
{ |
||||
usersIds[ind] = item.value; |
||||
} |
||||
); |
||||
|
||||
$('#eventUsers').attr('value',usersIds.join(';')); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
|
||||
function addOption(select,value,text) { |
||||
select.append('<option value="'+value+'">'+text+'</option>'); |
||||
} |
||||
|
||||
function removeOption(select,value) { |
||||
select.find('option[value='+value+']').remove(); |
||||
} |
||||
|
||||
function removeAllOption(select) { |
||||
select.find('option').remove(); |
||||
} |
||||
|
||||
function moveUsers(src,dest) { |
||||
src.find('option:selected').each(function(index,opt) { |
||||
text = opt.text; |
||||
val = opt.value; |
||||
|
||||
addOption(dest,val,text); |
||||
removeOption(src,val); |
||||
}); |
||||
} |
||||
</script> |
||||
|
||||
<h3><?php print get_lang('events_title') ?></h3>
|
||||
|
||||
<table id="" width="90%"> |
||||
<tr> |
||||
<td width="5%"> |
||||
<h4><?php print get_lang('events_listTitle'); ?></h4>
|
||||
</td> |
||||
<td width="5%"> |
||||
<h4><?php print get_lang('events_userListTile'); ?></h4>
|
||||
</td> |
||||
<td width="5%"> |
||||
|
||||
</td> |
||||
<td width="5%"> |
||||
<h4><?php print get_lang('events_userSubListTile'); ?></h4>
|
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td> |
||||
<select multiple="1" id="eventList" onChange="showEventType()"> |
||||
<?php |
||||
|
||||
foreach($ets as $et) { |
||||
print '<option value="'.$et['id'].'">'.$et['nameLangVar'].'</option>'; |
||||
} |
||||
|
||||
?> |
||||
</select> |
||||
</td> |
||||
<td> |
||||
<select multiple="1" id="usersList"></select> |
||||
</td> |
||||
<td valign="middle"> |
||||
<button class="arrowr" onclick='moveUsers($("#usersList"),$("#usersSubList")); return false;'></button> |
||||
<br /> |
||||
<button class="arrowl" onclick='moveUsers($("#usersSubList"),$("#usersList")); return false;'></button> |
||||
</td> |
||||
<td> |
||||
<select multiple="1" id="usersSubList"></select> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
|
||||
<br /> |
||||
|
||||
<h2 id="eventNameTitle"></h2> |
||||
|
||||
<form method="POST" onSubmit="return submitForm(); "> |
||||
<input type="hidden" name="action" value="modEventType" /> |
||||
<input type="hidden" name="eventId" id="eventId" /> |
||||
<input type="hidden" name="eventUsers" id="eventUsers" /> |
||||
<input type="hidden" id="eventName" /> |
||||
|
||||
<br /> |
||||
|
||||
<div id="descLangVar"> |
||||
</div> |
||||
<br /> |
||||
|
||||
<label for="eventSubject"><h4><?php print get_lang('events_labelSubject'); ?></h4></label>
|
||||
<input type="text" id="eventSubject" name="eventSubject" /> |
||||
<br /><br /> |
||||
<label for="eventMessage"><h4><?php print get_lang('events_labelMessage'); ?></h4></label>
|
||||
<textarea cols="100" rows="10" name="eventMessage" id="eventMessage"> |
||||
|
||||
</textarea> |
||||
|
||||
<br /><br /> |
||||
|
||||
<input type="submit" value="<?php print get_lang('events_btnMod'); ?>" />
|
||||
|
||||
</form> |
||||
|
||||
|
||||
<?php |
||||
|
||||
Display :: display_footer(); |
||||
|
||||
?> |
@ -0,0 +1,105 @@ |
||||
<?php |
||||
/*Written by Noel Dieschburg <noel@cblue.be> for the paris5 university |
||||
|
||||
* Checks if the user is already logged in via the cas system |
||||
* Gets all the info via the ldap module (ldap has to work) |
||||
|
||||
*/ |
||||
require_once(api_get_path(SYS_PATH).'main/auth/cas/cas_var.inc.php'); |
||||
require_once(api_get_path(SYS_PATH).'main/auth/ldap/authldap.php'); |
||||
|
||||
/** |
||||
* checks if the user already get a session |
||||
* @return the user login if the user already has a session ,false otherwise |
||||
**/ |
||||
|
||||
|
||||
function cas_is_authenticated() |
||||
{ |
||||
global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri; |
||||
global $PHPCAS_CLIENT; |
||||
global $logout; |
||||
|
||||
|
||||
if (!is_object($PHPCAS_CLIENT) ) |
||||
{ |
||||
phpCAS::client($cas_auth_ver,$cas_auth_server,$cas_auth_port,$cas_auth_uri); |
||||
// die("phpCAS::client($cas_auth_ver,$cas_auth_server,$cas_auth_port,$cas_auth_uri);"); |
||||
phpCAS::setNoCasServerValidation(); |
||||
} |
||||
$auth = phpCAS::checkAuthentication(); |
||||
|
||||
if ($auth) { |
||||
$login= trim(phpCAS::getUser()); |
||||
/* |
||||
Get user attributes. Here are the attributes for crdp platform |
||||
sn => name |
||||
ENTPersonMailInterne => mail |
||||
ENTPersonAlias => login |
||||
ENTPersonProfils => profil |
||||
givenName => first name |
||||
*/ |
||||
/*$user=phpCAS::getAttributes(); |
||||
$firstName = trim($user['givenName']); |
||||
$lastName = trim($user['sn']); |
||||
$login = trim($user['ENTPersonAlias']); |
||||
$profil = trim($user['ENTPersonProfils']); |
||||
$email = trim($user['ENTPersonMailInterne']); |
||||
$satus=5; |
||||
switch ($profil){ |
||||
case 'admin_etab': |
||||
$status=3; //Session admin |
||||
break; |
||||
case 'admin_sie': |
||||
$status=3; //Session admin |
||||
break; |
||||
case 'National_3': |
||||
$status=1; // Teacher |
||||
break; |
||||
case 'National_1': |
||||
$status=5; // Student |
||||
break; |
||||
default: |
||||
$status=5; // Student |
||||
}*/ |
||||
//If the user is in the dokeos database and we are ,not in a logout request, we upgrade his infomration by ldap |
||||
if (! $logout){ |
||||
$user_table = Database::get_main_table(TABLE_MAIN_USER); |
||||
$sql = "SELECT user_id, username, password, auth_source, active, expiration_date ". |
||||
"FROM $user_table ". |
||||
"WHERE username = '$login' "; |
||||
|
||||
$result = api_sql_query($sql,__FILE__,__LINE__); |
||||
if(mysql_num_rows($result) == 0) { |
||||
require_once(api_get_path(SYS_PATH).'main/inc/lib/usermanager.lib.php'); |
||||
$rnumber=rand(0,256000); |
||||
UserManager::create_user($firstName, $lastName, $status, $email, $login, md5('casplaceholder'.$rnumber), $official_code='',$language='',$phone='',$picture_uri='',$auth_source = PLATFORM_AUTH_SOURCE); |
||||
} |
||||
else { |
||||
$user = mysql_fetch_assoc($result); |
||||
$user_id = intval($user['user_id']); |
||||
//echo "deb : $status"; |
||||
UserManager::update_user ($user_id, $firstname, $lastname, $login, null, null, $email, $status, '', '', '', '', 1, null, 0, null,'') ; |
||||
|
||||
} |
||||
} |
||||
return($login); |
||||
} |
||||
else |
||||
{ |
||||
return(false); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Logs out the user of the cas |
||||
* The user MUST be logged in with cas to use this function |
||||
**/ |
||||
function cas_logout() |
||||
{ |
||||
|
||||
//phpCAS::logoutWithRedirectService("fmc.univ-paris5.fr"); |
||||
phpCAS::logoutWithRedirectService(api_get_path(WEB_PATH)); |
||||
} |
||||
|
||||
?> |
@ -0,0 +1,20 @@ |
||||
<? |
||||
/* This file contains all the configuration variable for the cas module |
||||
* In the future, these will be in the database |
||||
*/ |
||||
require_once('lib/CAS.php'); |
||||
define("CAS_VERSION_2_0",'2.0'); |
||||
define("SAML_VERSION_1_1", 'S1'); |
||||
|
||||
global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri; |
||||
|
||||
$cas_auth_server = api_get_setting('cas_server'); |
||||
$cas_auth_uri = api_get_setting('cas_server_uri'); |
||||
$cas_auth_port = intval(api_get_setting('cas_port')); |
||||
|
||||
$cas_auth_uri = api_get_setting('cas_server_uri'); |
||||
if ( ! is_string($cas_auth_uri)) $cas_auth_uri = ''; |
||||
|
||||
$cas_auth_ver = '2.0'; |
||||
//$cas_auth_ver = SAML_VERSION_1_1; |
||||
?> |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,218 @@ |
||||
<?php |
||||
/* |
||||
* Copyright © 2003-2010, The ESUP-Portail consortium & the JA-SIG Collaborative. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above copyright notice, |
||||
* this list of conditions and the following disclaimer in the documentation |
||||
* and/or other materials provided with the distribution. |
||||
* * Neither the name of the ESUP-Portail consortium & the JA-SIG |
||||
* Collaborative nor the names of its contributors may be used to endorse or |
||||
* promote products derived from this software without specific prior |
||||
* written permission. |
||||
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
*/ |
||||
|
||||
/** |
||||
* @file CAS/PGTStorage/pgt-db.php |
||||
* Basic class for PGT database storage |
||||
*/ |
||||
|
||||
/** |
||||
* @class PGTStorageDB |
||||
* The PGTStorageDB class is a class for PGT database storage. An instance of |
||||
* this class is returned by CASClient::SetPGTStorageDB(). |
||||
* |
||||
* @author Pascal Aubry <pascal.aubry at univ-rennes1.fr> |
||||
* |
||||
* @ingroup internalPGTStorageDB |
||||
*/ |
||||
|
||||
class PGTStorageDB extends PGTStorage |
||||
{ |
||||
/** |
||||
* @addtogroup internalPGTStorageDB |
||||
* @{ |
||||
*/ |
||||
|
||||
/** |
||||
* a string representing a PEAR DB URL to connect to the database. Written by |
||||
* PGTStorageDB::PGTStorageDB(), read by getURL(). |
||||
* |
||||
* @hideinitializer |
||||
* @private |
||||
*/ |
||||
var $_url=''; |
||||
|
||||
/** |
||||
* This method returns the PEAR DB URL to use to connect to the database. |
||||
* |
||||
* @return a PEAR DB URL |
||||
* |
||||
* @private |
||||
*/ |
||||
function getURL() |
||||
{ |
||||
return $this->_url; |
||||
} |
||||
|
||||
/** |
||||
* The handle of the connection to the database where PGT's are stored. Written by |
||||
* PGTStorageDB::init(), read by getLink(). |
||||
* |
||||
* @hideinitializer |
||||
* @private |
||||
*/ |
||||
var $_link = null; |
||||
|
||||
/** |
||||
* This method returns the handle of the connection to the database where PGT's are |
||||
* stored. |
||||
* |
||||
* @return a handle of connection. |
||||
* |
||||
* @private |
||||
*/ |
||||
function getLink() |
||||
{ |
||||
return $this->_link; |
||||
} |
||||
|
||||
/** |
||||
* The name of the table where PGT's are stored. Written by |
||||
* PGTStorageDB::PGTStorageDB(), read by getTable(). |
||||
* |
||||
* @hideinitializer |
||||
* @private |
||||
*/ |
||||
var $_table = ''; |
||||
|
||||
/** |
||||
* This method returns the name of the table where PGT's are stored. |
||||
* |
||||
* @return the name of a table. |
||||
* |
||||
* @private |
||||
*/ |
||||
function getTable() |
||||
{ |
||||
return $this->_table; |
||||
} |
||||
|
||||
// ######################################################################## |
||||
// DEBUGGING |
||||
// ######################################################################## |
||||
|
||||
/** |
||||
* This method returns an informational string giving the type of storage |
||||
* used by the object (used for debugging purposes). |
||||
* |
||||
* @return an informational string. |
||||
* @public |
||||
*/ |
||||
function getStorageType() |
||||
{ |
||||
return "database"; |
||||
} |
||||
|
||||
/** |
||||
* This method returns an informational string giving informations on the |
||||
* parameters of the storage.(used for debugging purposes). |
||||
* |
||||
* @public |
||||
*/ |
||||
function getStorageInfo() |
||||
{ |
||||
return 'url=`'.$this->getURL().'\', table=`'.$this->getTable().'\''; |
||||
} |
||||
|
||||
// ######################################################################## |
||||
// CONSTRUCTOR |
||||
// ######################################################################## |
||||
|
||||
/** |
||||
* The class constructor, called by CASClient::SetPGTStorageDB(). |
||||
* |
||||
* @param $cas_parent the CASClient instance that creates the object. |
||||
* @param $user the user to access the data with |
||||
* @param $password the user's password |
||||
* @param $database_type the type of the database hosting the data |
||||
* @param $hostname the server hosting the database |
||||
* @param $port the port the server is listening on |
||||
* @param $database the name of the database |
||||
* @param $table the name of the table storing the data |
||||
* |
||||
* @public |
||||
*/ |
||||
function PGTStorageDB($cas_parent,$user,$password,$database_type,$hostname,$port,$database,$table) |
||||
{ |
||||
phpCAS::traceBegin(); |
||||
|
||||
// call the ancestor's constructor |
||||
$this->PGTStorage($cas_parent); |
||||
|
||||
if ( empty($database_type) ) $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE; |
||||
if ( empty($hostname) ) $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME; |
||||
if ( $port==0 ) $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT; |
||||
if ( empty($database) ) $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE; |
||||
if ( empty($table) ) $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE; |
||||
|
||||
// build and store the PEAR DB URL |
||||
$this->_url = $database_type.':'.'//'.$user.':'.$password.'@'.$hostname.':'.$port.'/'.$database; |
||||
|
||||
// XXX should use setURL and setTable |
||||
phpCAS::traceEnd(); |
||||
} |
||||
|
||||
// ######################################################################## |
||||
// INITIALIZATION |
||||
// ######################################################################## |
||||
|
||||
/** |
||||
* This method is used to initialize the storage. Halts on error. |
||||
* |
||||
* @public |
||||
*/ |
||||
function init() |
||||
{ |
||||
phpCAS::traceBegin(); |
||||
// if the storage has already been initialized, return immediatly |
||||
if ( $this->isInitialized() ) |
||||
return; |
||||
// call the ancestor's method (mark as initialized) |
||||
parent::init(); |
||||
|
||||
//include phpDB library (the test was introduced in release 0.4.8 for |
||||
//the integration into Tikiwiki). |
||||
if (!class_exists('DB')) { |
||||
include_once('DB.php'); |
||||
} |
||||
|
||||
// try to connect to the database |
||||
$this->_link = DB::connect($this->getURL()); |
||||
if ( DB::isError($this->_link) ) { |
||||
phpCAS::error('could not connect to database ('.DB::errorMessage($this->_link).')'); |
||||
} |
||||
var_dump($this->_link); |
||||
phpCAS::traceBEnd(); |
||||
} |
||||
|
||||
/** @} */ |
||||
} |
||||
|
||||
?> |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue