skala
Julio Montoya 16 years ago
commit c2413c3f89
  1. 48
      main/auth/course_description.php
  2. 6
      main/auth/courses.php
  3. 15
      main/auth/generate_api_key.inc.php
  4. 28
      main/auth/lostPassword.php
  5. 210
      main/auth/lost_password.lib.php
  6. 2
      main/auth/profile.php
  7. 3
      main/exercice/admin.php
  8. 8
      main/exercice/exercice.php
  9. 18
      main/exercice/exercise_admin.php
  10. 40
      main/exercice/hotpotatoes.php
  11. 82
      main/exercice/question_create.php
  12. 11
      main/glossary/index.php
  13. 29
      main/inc/ajax/course_home.ajax.php
  14. 27
      main/inc/ajax/user_manager.ajax.php
  15. 28
      main/inc/lib/glossary.lib.php
  16. 22
      main/inc/lib/group_portal_manager.lib.php
  17. 196
      main/inc/lib/login.lib.php
  18. 18
      tests/main/auth/lost_password.lib.test.php

@ -1,48 +0,0 @@
<?php // $Id: course_description.php 2009-08-26 14:12:48 darkvela $
/* For licensing terms, see /dokeos_license.txt */
/**
==============================================================================
* This script lists the course description in Ajax.
* This script is for all users in general.
*
* @author Ronny Velasquez
* @package dokeos.auth
==============================================================================
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
// Name of the language file that needs to be included.
$language_file = array ('course_description');
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(INCLUDE_PATH).'reduced_header.inc.php' ;
/*
==============================================================================
MAIN CODE
==============================================================================
*/
function show_course_description() {
// Get the name of the database course.
$database_course = CourseManager::get_name_database_course($_GET['code']);
$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION, $database_course);
$sql = "SELECT * FROM $tbl_course_description WHERE session_id=0 ORDER BY id";
$result = Database::query($sql);
while ($description = Database::fetch_object($result)) {
$descriptions[$description->id] = $description;
}
// Function that displays the details of the course description in html.
return CourseManager::get_details_course_description_html($descriptions, api_get_system_encoding(), false);
}
echo show_course_description();

@ -15,7 +15,7 @@
*/
// Names of the language file that needs to be included.
$language_file = array ('courses', 'registration');
$language_file = array ('courses', 'registration');
// Delete the globals['_cid'], we don't need it here.
$cidReset = true; // Flag forcing the 'current course' reset
@ -495,7 +495,7 @@ function display_subscribe_to_courses($courses) {
// block course description
echo "\t\t<td>";
$icon_title = get_lang('CourseDetails') . ' - ' . $course['title'];
echo "<a href='course_description.php?code=".$course['code']."' title='$icon_title' rel='gb_page_center[778]'>".Display::return_icon('synthese_view.gif', $icon_title)."</a>";
echo "<a href='".api_get_path(WEB_CODE_PATH)."inc/lib/ajax/course_home.ajax.php?a=show_course_information&code=".$course['code']."' title='$icon_title' rel='gb_page_center[778]'>".Display::return_icon('synthese_view.gif', $icon_title)."</a>";
echo "\t\t</td>";
}
@ -858,7 +858,7 @@ function display_courses_in_category($user_category_id, $showicons) {
// block course description
echo "\t\t<td>";
$icon_title = get_lang('CourseDetails') . ' - ' . $course['title'];
echo "<a href='course_description.php?code=".$course['code']."' title='$icon_title' rel='gb_page_center[778]'>".Display::return_icon('synthese_view.gif', $icon_title)."</a>";
echo "<a href='".api_get_path(WEB_CODE_PATH)."inc/ajax/course_home.ajax.php?a=show_course_information&code=".$course['code']."' title='$icon_title' rel='gb_page_center[778]'>".Display::return_icon('synthese_view.gif', $icon_title)."</a>";
echo "\t\t</td>";
}

@ -1,15 +0,0 @@
<?php
require '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
$array_list_key = array();
$user_id = api_get_user_id();
$api_service = 'dokeos';
$num = UserManager::update_api_key($user_id, $api_service);
$array_list_key = UserManager::get_api_keys($user_id, $api_service);
?>
<div class="row">
<div class="label"><?php echo get_lang('MyApiKey'); ?></div>
<div class="formw">
<input type="text" name="api_key_generate" id="id_api_key_generate" size="40" value="<?php echo $array_list_key[$num]; ?>"/>
</div>
</div>

@ -1,5 +1,5 @@
<?php
/* For licensing terms, see /dokeos_license.txt */
/* For licensing terms, see /license.txt */
/**
==============================================================================
* SCRIPT PURPOSE :
@ -13,22 +13,22 @@
*
* @todo refactor, move relevant functions to code libraries
*
* @package dokeos.auth
* @package chamilo.auth
==============================================================================
*/
// name of the language file that needs to be included
$language_file = 'registration';
require '../inc/global.inc.php';
require_once 'lost_password.lib.php';
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'login.lib.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
$tool_name = get_lang('LostPassword');
Display :: display_header($tool_name);
$this_section = SECTION_CAMPUS;
$tool_name = get_lang('LostPass');
$this_section = SECTION_CAMPUS;
$tool_name = get_lang('LostPass');
// Forbidden to retrieve the lost password
if (api_get_setting('allow_lostpassword') == 'false') {
@ -40,8 +40,7 @@ echo $tool_name;
echo '</div>';
if (isset ($_GET['reset']) && isset ($_GET['id'])) {
$msg = reset_password($_GET["reset"], $_GET["id"], true);
$msg = Login::reset_password($_GET["reset"], $_GET["id"], true);
$msg1= '<a href="'.api_get_path(WEB_CODE_PATH).'auth/lostPassword.php" class="fake_button_back" >'.get_lang('Back').'</a>';
echo '<br /><br /><div class="actions" >'.$msg1.'</div>';
@ -59,6 +58,7 @@ if (isset ($_GET['reset']) && isset ($_GET['id'])) {
if ($form->validate()) {
$values = $form->exportValues();
$user = $values['user'];
$email = $values['email'];
@ -74,8 +74,8 @@ if (isset ($_GET['reset']) && isset ($_GET['id'])) {
FROM ".$tbl_user."
WHERE ( username = '".Database::escape_string($user)."' $condition ) ";
$result = Database::query($query);
$num_rows = Database::num_rows($result);
$result = Database::query($query);
$num_rows = Database::num_rows($result);
if ($result && $num_rows > 0) {
if ($num_rows > 1) {
@ -88,9 +88,9 @@ if (isset ($_GET['reset']) && isset ($_GET['id'])) {
$user = Database::fetch_array($result);
}
if ($userPasswordCrypted != 'none') {
handle_encrypted_password($user, $by_username);
Login::handle_encrypted_password($user, $by_username);
} else {
send_password_to_user($user, $by_username);
Login::send_password_to_user($user, $by_username);
}
} else {
Display::display_error_message(get_lang('NoUserAccountWithThisEmailAddress'));
@ -100,12 +100,10 @@ if (isset ($_GET['reset']) && isset ($_GET['id'])) {
echo '<br /><br /><div class="actions" >'.$msg.'</div>';
} else {
echo '<p>';
echo get_lang('EnterEmailUserAndWellSendYouPassword');
echo '</p>';
$form->display();
}
}
Display :: display_footer();
Display :: display_footer();

@ -1,210 +0,0 @@
<?php
/* For licensing terms, see /dokeos_license.txt */
/**
* @deprecated by Ivan Tcholakov, 09-OCT-2009.
* Get email headers
*
* @return string
* @author Olivier Cauberghe <olivier.cauberghe@UGent.be>, Ghent University
*/
/*
function get_email_headers() {
$emailHeaders = "From: \"".addslashes(api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS))."\" <".api_get_setting('emailAdministrator').">\n";
$emailHeaders .= "Reply-To: ".api_get_setting('emailAdministrator')."\n";
$emailHeaders .= "Return-Path: ".api_get_setting('emailAdministrator')."\n";
$emailHeaders .= "X-Sender: ".api_get_setting('emailAdministrator')."\n";
$emailHeaders .= "X-Mailer: PHP / ".phpversion()."\n";
$emailHeaders .= "Content-Type: text/plain;\n\tcharset=\"".api_get_system_encoding()."\"\n";
$emailHeaders .= "Mime-Version: 1.0";
return $emailHeaders;
}
*/
/**
* Enter description here...
*
* @param unknown_type $user
* @param boolean $reset
* @param boolean $by_username
* @return unknown
* @author Olivier Cauberghe <olivier.cauberghe@UGent.be>, Ghent University
*/
function get_user_account_list($user, $reset = false, $by_username = false) {
global $_configuration;
$portal_url = $_configuration['root_web'];
if ($_configuration['multiple_access_urls']) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1 ) {
$url = api_get_access_url($access_url_id);
$portal_url = $url['url'];
}
}
if ($reset) {
if ($by_username) {
$secret_word = get_secret_word($user['email']);
if ($reset) {
$reset_link = $portal_url."main/auth/lostPassword.php?reset=".$secret_word."&id=".$user['uid'];
} else {
$reset_link = get_lang('Pass')." : $user[password]";
}
$user_account_list = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$user['loginName']."\n".get_lang('ResetLink').' : '.$reset_link.'';
if ($user_account_list) {
$user_account_list = "\n------------------------\n" . $user_account_list;
}
} else {
foreach ($user as $this_user) {
$secret_word = get_secret_word($this_user['email']);
if ($reset) {
$reset_link = $portal_url."main/auth/lostPassword.php?reset=".$secret_word."&id=".$this_user['uid'];
} else {
$reset_link = get_lang('Pass')." : $this_user[password]";
}
$user_account_list[] = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$this_user['loginName']."\n".get_lang('ResetLink').' : '.$reset_link.'';
}
if ($user_account_list) {
$user_account_list = implode("\n------------------------\n", $user_account_list);
}
}
} else {
if (!$by_username) {
$user = $user[0];
}
$reset_link = get_lang('Pass')." : $user[password]";
$user_account_list = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$user['loginName']."\n".$reset_link.'';
}
return $user_account_list;
}
/**
* This function sends the actual password to the user
*
* @param unknown_type $user
* @author Olivier Cauberghe <olivier.cauberghe@UGent.be>, Ghent University
*/
function send_password_to_user($user, $by_username = false) {
global $_configuration;
/*
$emailHeaders = get_email_headers(); // Email Headers
*/
$email_subject = "[".api_get_setting('siteName')."] ".get_lang('LoginRequest'); // SUBJECT
if ($by_username) { // Show only for lost password
$user_account_list = get_user_account_list($user, false, $by_username); // BODY
$email_to = $user['email'];
} else {
$user_account_list = get_user_account_list($user); // BODY
$email_to = $user[0]['email'];
}
$portal_url = $_configuration['root_web'];
if ($_configuration['multiple_access_urls']) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1 ) {
$url = api_get_access_url($access_url_id);
$portal_url = $url['url'];
}
}
$email_body = get_lang('YourAccountParam')." ".$portal_url."\n\n$user_account_list";
// SEND MESSAGE
$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
$email_admin = api_get_setting('emailAdministrator');
if (@api_mail('', $email_to, $email_subject, $email_body, $sender_name, $email_admin) == 1) {
Display::display_confirmation_message(get_lang('YourPasswordHasBeenEmailed'));
} else {
$message = get_lang('SystemUnableToSendEmailContact').' '.Display :: encrypted_mailto_link(api_get_setting('emailAdministrator'), get_lang('PlatformAdmin')).".</p>";
}
}
/**
* Enter description here...
*
* @param unknown_type $user
* @param bool $by_username
* @return unknown
*
* @author Olivier Cauberghe <olivier.cauberghe@UGent.be>, Ghent University
*/
function handle_encrypted_password($user, $by_username = false) {
global $_configuration;
/*
$emailHeaders = get_email_headers(); // Email Headers
*/
$email_subject = "[".api_get_setting('siteName')."] ".get_lang('LoginRequest'); // SUBJECT
if ($by_username) { // Show only for lost password
$user_account_list = get_user_account_list($user, true, $by_username); // BODY
$email_to = $user['email'];
} else {
$user_account_list = get_user_account_list($user, true); // BODY
$email_to = $user[0]['email'];
}
$secret_word = get_secret_word($email_to);
$email_body = get_lang('DearUser')." :\n".get_lang('password_request')."\n\n";
$email_body .= "-----------------------------------------------\n".$user_account_list."\n-----------------------------------------------\n\n";
$email_body .= get_lang('PasswordEncryptedForSecurity');
$email_body .= "\n\n".get_lang('Formula').",\n".get_lang('PlataformAdmin');
$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
$email_admin = api_get_setting('emailAdministrator');
if (@api_mail('', $email_to, $email_subject, $email_body, $sender_name, $email_admin) == 1) {
Display::display_confirmation_message(get_lang('YourPasswordHasBeenEmailed'));
} else {
$message = get_lang('SystemUnableToSendEmailContact').' '.Display :: encrypted_mailto_link(api_get_setting('emailAdministrator'), get_lang('PlatformAdmin')).".</p>";
Display::display_error_message($message, false);
}
}
/**
* Enter description here...
* @author Olivier Cauberghe <olivier.cauberghe@UGent.be>, Ghent University
*/
function get_secret_word($add) {
global $_configuration;
return $secret_word = md5($_configuration['security_key'].$add);
}
/**
* Enter description here...
* @author Olivier Cauberghe <olivier.cauberghe@UGent.be>, Ghent University
*/
function reset_password($secret, $id, $by_username = false) {
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$id = intval($id);
$sql = "SELECT user_id AS uid, lastname AS lastName, firstname AS firstName, username AS loginName, password, email FROM ".$tbl_user." WHERE user_id=$id";
$result = Database::query($sql);
$num_rows = Database::num_rows($result);
if ($result && $num_rows > 0) {
$user = Database::fetch_array($result);
} else {
return 'Could not reset password.'; // TODO: This message has to be translated.
}
if (get_secret_word($user['email']) == $secret) { // OK, secret word is good. Now change password and mail it.
$user['password'] = api_generate_password();
$crypted = $user['password'];
$crypted = api_get_encrypted_password($crypted);
$sql = "UPDATE ".$tbl_user." SET password='$crypted' WHERE user_id=$id";
$result = Database::query($sql);
return send_password_to_user($user, $by_username);
} else {
return 'Not allowed.'; // TODO: This message has to be translated.
}
}

@ -60,7 +60,7 @@ function generate_open_id_form() {
beforeSend: function(objeto) {
/*$("#div_api_key").html("Loading...");*/ },
type: "POST",
url: "../auth/generate_api_key.inc.php",
url: "'.api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=generate_api_key",
data: "num_key_id="+"",
success: function(datos) {
$("#div_api_key").html(datos);

@ -423,6 +423,7 @@ function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
Display::display_header($nameTools,'Exercise');
$show_quiz_edition = true;
if (isset($exerciseId) && !empty($exerciseId)) {
$TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM);
@ -438,8 +439,6 @@ if (isset($exerciseId) && !empty($exerciseId)) {
echo '<div class="actions">';
echo Display::return_icon('preview.gif', get_lang('Preview')).'<a href="exercice_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.get_lang('Preview').'</a>';
if ($show_quiz_edition) {
echo Display::return_icon('edit.gif', get_lang('ModifyExercise')).'<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.get_lang('ModifyExercise').'</a>';
} else {

@ -801,7 +801,7 @@ if (($is_allowedToEdit) and ($origin != 'learnpath')) {
echo '<a href="javascript: void(0);" onclick="javascript: document.form1a.submit();">'.Display::return_icon('csv.gif',get_lang('ExportAsCSV')).get_lang('ExportAsCSV').'</a>';
echo '<a href="javascript: void(0);" onclick="javascript: document.form1b.submit();">' . Display :: return_icon('excel.gif', get_lang('ExportAsXLS')) . get_lang('ExportAsXLS') . '</a>';
//echo '<a href="javascript: void(0);" onclick="javascript: document.form1c.submit();">'.Display::return_icon('synthese_view.gif',$alt).$alt.'</a>';
echo '<a href="' . api_add_url_param($_SERVER['REQUEST_URI'], 'show=test') . '">' . Display :: return_icon('quiz.gif', get_lang('BackToExercisesList')) . get_lang('BackToExercisesList') . '</a>';
echo '<a href="' . api_add_url_param($_SERVER['REQUEST_URI'], 'show=test') . '">' . Display :: return_icon('message_reply_forum.png', get_lang('GoBackToQuestionList')) . get_lang('GoBackToQuestionList') . '</a>';
echo '<form id="form1a" name="form1a" method="post" action="' . api_get_self() . '?show=' . Security :: remove_XSS($_GET['show']) . '">';
echo '<input type="hidden" name="export_report" value="export_report">';
echo '<input type="hidden" name="export_format" value="csv">';
@ -820,7 +820,7 @@ if (($is_allowedToEdit) and ($origin != 'learnpath')) {
} else {
//the student view
if ($show == 'result') {
echo '<a href="' . api_add_url_param($_SERVER['REQUEST_URI'], 'show=test') . '">' . Display :: return_icon('quiz.gif', get_lang('BackToExercisesList')) . get_lang('BackToExercisesList') . '</a>';
echo '<a href="' . api_add_url_param($_SERVER['REQUEST_URI'], 'show=test') . '">' . Display :: return_icon('message_reply_forum.png', get_lang('GoBackToQuestionList')) . get_lang('GoBackToQuestionList') . '</a>';
} else {
echo '<a href="' . api_add_url_param($_SERVER['REQUEST_URI'], 'show=result') . '">' . Display :: return_icon('show_test_results.gif', get_lang('Results')) . get_lang('Results') . '</a>';
}
@ -908,8 +908,8 @@ if ($show == 'test') {
<td>
<a href="admin.php?<?php echo api_get_cidreq()?>&amp;exerciseId=<?php echo $row['id']; ?>"><img src="../img/wizard_small.gif" border="0" title="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" /></a>
<a href="exercice.php?<?php echo api_get_cidreq()?>&amp;choice=copy_exercise&amp;exerciseId=<?php echo $row['id']; ?>"><img width="16" src="../img/cd.gif" border="0" title="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" /></a>
<a href="exercice.php?<?php echo api_get_cidreq()?>&amp;choice=clean_results&amp;exerciseId=<?php echo $row['id']; ?>"><img width="16" src="../img/clean_group.gif" border="0" title="<?php echo api_htmlentities(get_lang('CleanStudentResults'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('CleanStudentResults'),ENT_QUOTES,$charset); ?>" /></a>
<a href="exercice.php?<?php echo api_get_cidreq()?>&amp;choice=copy_exercise&amp;exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset)); echo " ".$row['title']; echo "?"; ?>')) return false;"><img width="16" src="../img/cd.gif" border="0" title="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" /></a>
<a href="exercice.php?<?php echo api_get_cidreq()?>&amp;choice=clean_results&amp;exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToDeleteResults'),ENT_QUOTES,$charset)); echo " ".$row['title']; echo "?"; ?>')) return false;" ><img width="16" src="../img/clean_group.gif" border="0" title="<?php echo api_htmlentities(get_lang('CleanStudentResults'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('CleanStudentResults'),ENT_QUOTES,$charset); ?>" /></a>
<?php

@ -9,7 +9,6 @@
* @version $Id$
*/
// name of the language file that needs to be included
$language_file='exercice';
@ -162,8 +161,10 @@ if ($form -> validate()) {
$objExercise -> processCreation($form);
if ($form -> getSubmitValue('edit') == 'true') {
header('Location:exercice.php?message=ExerciseEdited&'.api_get_cidreq());
exit;
} else {
header('Location:admin.php?message=ExerciseAdded&exerciseId='.$objExercise->id);
exit;
}
} else {
/*********************
@ -174,14 +175,17 @@ if ($form -> validate()) {
}
if (!empty($gradebook) && $gradebook=='view') {
$interbreadcrumb[]= array (
'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
'name' => get_lang('Gradebook')
);
$interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'],'name' => get_lang('Gradebook'));
}
$nameTools=get_lang('ExerciseManagement');
$interbreadcrumb[] = array ("url"=>"exercice.php", "name"=> get_lang('Exercices'));
Display::display_header($nameTools,"Exercise");
$interbreadcrumb[] = array ("url"=>'exercice.php', 'name'=> get_lang('Exercices'));
Display::display_header($nameTools,get_lang('Exercise'));
echo '<div class="actions">';
echo '<a href="exercice.php?show=test">' . Display :: return_icon('message_reply_forum.png', get_lang('GoBackToQuestionList')) . get_lang('GoBackToQuestionList') . '</a>';
echo '</div>';
if ($objExercise->feedbacktype==1)
Display::display_normal_message(get_lang("DirectFeedbackCantModifyTypeQuestion"));
if(api_get_setting('search_enabled')=='true' && !extension_loaded('xapian')) {

@ -1,26 +1,8 @@
<?php
/*
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See "documentation/licence.html" more details.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/* For licensing terms, see /license.txt */
/**
* Code for Hotpotatoes integration.
* @package dokeos.exercise
* @package chamilo.exercise
* @author Istvan Mandak
* @version $Id: hotpotatoes.php 20798 2009-05-18 18:13:25Z cvargas1 $
*/
@ -36,15 +18,14 @@ require_once '../inc/global.inc.php';
require_once (api_get_path(LIBRARY_PATH).'fileUpload.lib.php');
require_once (api_get_path(LIBRARY_PATH).'document.lib.php');
require_once (api_get_path(LIBRARY_PATH).'fileManage.lib.php');
require_once (api_get_path(LIBRARY_PATH)."pclzip/pclzip.lib.php");
require_once (api_get_path(LIBRARY_PATH).'pclzip/pclzip.lib.php');
require_once 'hotpotatoes.lib.php';
// section (for the tabs)
$this_section=SECTION_COURSES;
// access restriction: only teachers are allowed here
if(!api_is_allowed_to_edit(null,true))
{
if(!api_is_allowed_to_edit(null,true)) {
api_not_allowed();
}
@ -76,13 +57,12 @@ $imgcount = (!empty($_POST['imgcount'])?$_POST['imgcount']:null);
$fld = (!empty($_POST['fld'])?$_POST['fld']:null);
// if user is allowed to edit
if (api_is_allowed_to_edit(null,true))
{
if (api_is_allowed_to_edit(null,true)) {
//disable document parsing(?) - obviously deprecated
$enableDocumentParsing=false;
if(hotpotatoes_init($document_sys_path.$uploadPath))
{//if the directory doesn't exist
if(hotpotatoes_init($document_sys_path.$uploadPath)) {
//if the directory doesn't exist
//create the "HotPotatoes" directory
$doc_id = add_document($_course, '/HotPotatoes_files','folder',0,'HotPotatoes Files');
//update properties in dbase (in any case)
@ -223,7 +203,11 @@ if((api_is_allowed_to_edit(null,true)) && (($finish == 0) || ($finish == 2)))
exit;
}
Display::display_header($nameTools,"Exercise");
Display::display_header($nameTools,get_lang('Exercise'));
echo '<div class="actions">';
echo '<a href="exercice.php?show=test">' . Display :: return_icon('message_reply_forum.png', get_lang('GoBackToQuestionList')) . get_lang('GoBackToQuestionList') . '</a>';
echo '</div>';
if ($finish==2) //if we are in the img upload process
{

@ -1,40 +1,15 @@
<?php // $Id: question_create.php 20569 2009-05-12 21:34:00Z pcool $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2009 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) various contributors
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
<?php
/* For licensing terms, see /license.txt */
// name of the language file that needs to be included
$language_file='exercice';
// including global Dokeos file
include("../inc/global.inc.php");
require_once '../inc/global.inc.php';
// including additional libraries
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
require_once ('question.class.php');
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once 'question.class.php';
// the section (tabs)
$this_section=SECTION_COURSES;
@ -48,8 +23,6 @@ $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices')
// Tool name
$nameTools=get_lang('AddQuestionToExercise');
// The form
$form = new FormValidator('add_question','post',api_get_self().'?'.api_get_cidreq());
// form title
@ -76,8 +49,7 @@ $tbl_exercices = Database :: get_course_table(TABLE_QUIZ_TEST);
$sql = "SELECT id,title,type,description, results_disabled FROM $tbl_exercices WHERE active<>'-1' ORDER BY title ASC";
$result = Database::query($sql);
$exercises['-'] = '-'.get_lang('SelectExercice').'-';
while ($row = Database :: fetch_array($result))
{
while ($row = Database :: fetch_array($result)) {
$exercises[$row['id']] = $row['title'];
}
$form->addElement('select', 'exercice', get_lang('Exercice'), $exercises);
@ -92,28 +64,25 @@ $form->addRule('exercice', '<span class="required">'.get_lang('YouHaveToSelectAT
$form->registerRule('validquestiontype', 'callback', 'check_question_type');
$form->addRule('question_type_hidden', get_lang('InvalidQuestionType'), 'validquestiontype');
if ($form->validate())
{
if ($form->validate()) {
$values = $form->exportValues();
//echo 'form validates';
//print_r($values);
foreach (Question::$questionTypes as $question_type_id => $question_type_class_and_name)
{
if (get_lang($question_type_class_and_name[1]) == $values['question_type_hidden'])
{
foreach (Question::$questionTypes as $question_type_id => $question_type_class_and_name) {
if (get_lang($question_type_class_and_name[1]) == $values['question_type_hidden']) {
$answer_type = $question_type_id;
}
}
header('Location: admin.php?exerciseId='.$values['exercice'].'&newQuestion=yes&answerType='.$answer_type);
}
else
{
exit;
} else {
// header
Display::display_header($nameTools);
echo '<div class="actions">';
echo '<a href="exercice.php?show=test">' . Display :: return_icon('message_reply_forum.png', get_lang('GoBackToQuestionList')) . get_lang('GoBackToQuestionList') . '</a>';
echo '</div>';
// displaying the form
$form->display();
@ -121,20 +90,12 @@ else
// footer
Display::display_footer();
}
?>
<script>
var ddlObj1=$("#questiontypes").finalselect({id:"test",viewWidth:'260px', viewHeight:'150px', selectText:'<?php echo Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle; cursor:hand'))."&nbsp;&nbsp;".get_lang('SelectQuestionType');?>',selectImage:'<?php echo api_get_path(WEB_IMG_PATH); ?>select.png', viewMouseoverColor: '#EFEFEF'});
$("#test-select").bind('click',function(){
$("#question_type_hidden").val(ddlObj1.getText());
});
<?php
// defining the pictures of the question types
$pictures_question_types[1] = 'mcua.gif';
@ -156,19 +117,14 @@ foreach (Question::$questionTypes as $key=>$value) {
<?php
function check_question_type($parameter)
{
foreach (Question::$questionTypes as $key=>$value)
{
function check_question_type($parameter) {
foreach (Question::$questionTypes as $key=>$value) {
$valid_question_types[] = get_lang($value[1]);
//$valid_question_types[] = trim($value[1]);
}
if (in_array($parameter, $valid_question_types))
{
if (in_array($parameter, $valid_question_types)) {
return true;
}
else
{
} else {
return false;
}
}

@ -139,13 +139,4 @@ if (api_is_allowed_to_edit(null,true)) {
// footer
Display::display_footer();
/**
@todo lots of cleaning
1. All the functions below should be move to glossary.class.php
2. glossary.class.php should be renamed to glossary.lib.php and moved to inc/lib
3. glossary_ajax_request.php file should be deleted. The content of that file should be move to inc/ajax/glossary.ajax.php
4. We should call all functions like Glossary::display_something();
http://support.chamilo.org/issues/510
Julio Montoya
*/
Display::display_footer();

@ -1,13 +1,13 @@
<?php
/* For licensing terms, see /chamilo_license.txt */
/* For licensing terms, see /license.txt */
/**
* Responses to AJAX calls
*/
require_once '../global.inc.php';
$action = $_GET['a'];
*/
$action = $_GET['a'];
switch ($action) {
case 'set_visibility':
require_once '../global.inc.php';
if(api_is_allowed_to_edit(null,true)) {
$tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$tool_id = Security::remove_XSS($_GET["id"]);
@ -80,6 +80,27 @@ switch ($action) {
print(json_encode($response_data));
}
break;
case 'show_course_information' :
$language_file = array ('course_description');
require_once '../global.inc.php';
require_once api_get_path(INCLUDE_PATH).'reduced_header.inc.php' ;
// Get the name of the database course.
$database_course = CourseManager::get_name_database_course($_GET['code']);
$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION, $database_course);
$sql = "SELECT * FROM $tbl_course_description WHERE session_id=0 ORDER BY id";
$result = Database::query($sql);
while ($description = Database::fetch_object($result)) {
$descriptions[$description->id] = $description;
}
// Function that displays the details of the course description in html.
echo CourseManager::get_details_course_description_html($descriptions, api_get_system_encoding(), false);
break;
default:
echo '';
}

@ -10,14 +10,33 @@ $action = $_GET['a'];
switch ($action) {
case 'search_tags':
if (api_is_anonymous()) {
echo '';
break;
echo '';
} else {
$field_id = intval($_GET['field_id']);
$tag = $_GET['tag'];
echo UserManager::get_tags($tag, $field_id,'json','10');
break;
echo UserManager::get_tags($tag, $field_id,'json','10');
}
break;
case 'generate_api_key':
if (api_is_anonymous()) {
echo '';
} else {
$array_list_key = array();
$user_id = api_get_user_id();
$api_service = 'dokeos';
$num = UserManager::update_api_key($user_id, $api_service);
$array_list_key = UserManager::get_api_keys($user_id, $api_service);
?>
<div class="row">
<div class="label"><?php echo get_lang('MyApiKey'); ?></div>
<div class="formw">
<input type="text" name="api_key_generate" id="id_api_key_generate" size="40" value="<?php echo $array_list_key[$num]; ?>"/>
</div>
</div>
<?php
}
break;
default:
echo '';
}

@ -1,5 +1,13 @@
<?php
/* For licensing terms, see /license.txt */
/**
==============================================================================
* This library provides functions for the glossary tool.
* Include/require it in your code to use its functionality.
* @package chamilo.library
==============================================================================
*/
class GlossaryManager {
function __construct() {
@ -116,9 +124,7 @@ class GlossaryManager {
{
// display the feedback message
Display::display_error_message(get_lang('GlossaryTermAlreadyExistsYouShouldEditIt'));
}
else
{
} else {
$sql = "UPDATE $t_glossary SET
name = '".Database::escape_string(Security::remove_XSS($values['glossary_title']))."',
description = '".Database::escape_string(Security::remove_XSS(stripslashes(api_html_entity_decode($values['glossary_comment'])),COURSEMANAGERLOWSECURITY))."'
@ -142,7 +148,6 @@ class GlossaryManager {
{
// Database table definition
$t_glossary = Database :: get_course_table(TABLE_GLOSSARY);
$get_max = "SELECT MAX(display_order) FROM $t_glossary";
$res_max = Database::query($get_max);
$dsp=0;
@ -172,12 +177,9 @@ class GlossaryManager {
}
$result = Database::query($sql);
$count = Database::num_rows($result);
if ($count > 0)
{
if ($count > 0) {
return true;
}
else
{
} else {
return false;
}
}
@ -313,7 +315,7 @@ class GlossaryManager {
}
/**
* get all the data of the glossary
* Get all the data of a glossary
*
* @param unknown_type $from
* @param unknown_type $number_of_items
@ -458,7 +460,7 @@ class GlossaryManager {
}
/**
* Enter description here...
* Re-order glossary
*
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University, Belgium
* @version januari 2009, dokeos 1.8.6
@ -481,7 +483,7 @@ class GlossaryManager {
}
/**
* Enter description here...
* Move a glossary
*
* @param unknown_type $direction
* @param unknown_type $glossary_id

@ -1,11 +1,11 @@
<?php
/* For licensing terms, see /chamilo_license.txt */
/* For licensing terms, see /license.txt */
/**
==============================================================================
* This library provides functions for the group management.
* Include/require it in your code to use its functionality.
* @author Julio Montoya <gugli100@gmail.com>
* @package dokeos.library
* @package chamilo.library
==============================================================================
*/
// Group permissions
@ -163,7 +163,7 @@ class GroupPortalManager
$tags = array();
if (Database::num_rows($res)>0) {
while ($row = Database::fetch_array($res,'ASSOC')) {
$tags[] = $row;
$tags[] = $row;
}
}
@ -247,12 +247,12 @@ class GroupPortalManager
$result=Database::query($sql);
$array = array();
while ($row = Database::fetch_array($result, 'ASSOC')) {
if ($with_image == true) {
$picture = self::get_picture_group($row['id'], $row['picture_uri'],80);
$img = '<img src="'.$picture['file'].'" />';
$row['picture_uri'] = $img;
}
$array[$row['id']] = $row;
if ($with_image == true) {
$picture = self::get_picture_group($row['id'], $row['picture_uri'],80);
$img = '<img src="'.$picture['file'].'" />';
$row['picture_uri'] = $img;
}
$array[$row['id']] = $row;
}
return $array;
}
@ -434,8 +434,7 @@ class GroupPortalManager
$role = self::get_user_group_role($user_id,$group_id);
if ($role == 0) {
$sql = "INSERT INTO $table_url_rel_group
SET user_id = ".intval($user_id).", group_id = ".intval($group_id).", relation_type = ".intval($relation_type)."";
SET user_id = ".intval($user_id).", group_id = ".intval($group_id).", relation_type = ".intval($relation_type);
$result = Database::query($sql);
if ($result)
@ -461,6 +460,7 @@ class GroupPortalManager
$table_ = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
$condition_relation = "";
if (!empty($relation_type)) {
$relation_type = intval($relation_type);
$condition_relation = " AND relation_type = '$relation_type'";
}
$sql = "DELETE FROM $table_ WHERE group_id = ".intval($group_id).$condition_relation;

@ -1,11 +1,191 @@
<?php
/* For licensing terms, see /license.txt */
/**
*
* @todo Here I should move all functions located in dokeos/index.php, dokeos/user_portal.php
* and all functions that means login, logout, show courses after login (maybe)
*
* Julio Montoya
*
*
*/
==============================================================================
* Code library for login process
*
* @author Olivier Cauberghe <olivier.cauberghe@UGent.be>, Ghent University
* @author Julio Montoya <gugli100@gmail.com>
* @package chamilo.login
==============================================================================
*/
class Login
{
/**
* Get user account list
*
* @param unknown_type $user
* @param boolean $reset
* @param boolean $by_username
* @return unknown
*/
public static function get_user_account_list($user, $reset = false, $by_username = false) {
global $_configuration;
$portal_url = $_configuration['root_web'];
if ($_configuration['multiple_access_urls']) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1 ) {
$url = api_get_access_url($access_url_id);
$portal_url = $url['url'];
}
}
if ($reset) {
if ($by_username) {
$secret_word = self::get_secret_word($user['email']);
if ($reset) {
$reset_link = $portal_url."main/auth/lostPassword.php?reset=".$secret_word."&id=".$user['uid'];
} else {
$reset_link = get_lang('Pass')." : $user[password]";
}
$user_account_list = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$user['loginName']."\n".get_lang('ResetLink').' : '.$reset_link.'';
if ($user_account_list) {
$user_account_list = "\n------------------------\n" . $user_account_list;
}
} else {
foreach ($user as $this_user) {
$secret_word = self::get_secret_word($this_user['email']);
if ($reset) {
$reset_link = $portal_url."main/auth/lostPassword.php?reset=".$secret_word."&id=".$this_user['uid'];
} else {
$reset_link = get_lang('Pass')." : $this_user[password]";
}
$user_account_list[] = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$this_user['loginName']."\n".get_lang('ResetLink').' : '.$reset_link.'';
}
if ($user_account_list) {
$user_account_list = implode("\n------------------------\n", $user_account_list);
}
}
} else {
if (!$by_username) {
$user = $user[0];
}
$reset_link = get_lang('Pass')." : $user[password]";
$user_account_list = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$user['loginName']."\n".$reset_link.'';
}
return $user_account_list;
}
/**
* This function sends the actual password to the user
*
* @param unknown_type $user
* @author Olivier Cauberghe <olivier.cauberghe@UGent.be>, Ghent University
*/
public static function send_password_to_user($user, $by_username = false) {
global $_configuration;
/*
$emailHeaders = get_email_headers(); // Email Headers
*/
$email_subject = "[".api_get_setting('siteName')."] ".get_lang('LoginRequest'); // SUBJECT
if ($by_username) { // Show only for lost password
$user_account_list = self::get_user_account_list($user, false, $by_username); // BODY
$email_to = $user['email'];
} else {
$user_account_list = self::get_user_account_list($user); // BODY
$email_to = $user[0]['email'];
}
$portal_url = $_configuration['root_web'];
if ($_configuration['multiple_access_urls']) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1 ) {
$url = api_get_access_url($access_url_id);
$portal_url = $url['url'];
}
}
$email_body = get_lang('YourAccountParam')." ".$portal_url."\n\n$user_account_list";
// SEND MESSAGE
$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
$email_admin = api_get_setting('emailAdministrator');
if (@api_mail('', $email_to, $email_subject, $email_body, $sender_name, $email_admin) == 1) {
Display::display_confirmation_message(get_lang('YourPasswordHasBeenEmailed'));
} else {
$message = get_lang('SystemUnableToSendEmailContact').' '.Display :: encrypted_mailto_link(api_get_setting('emailAdministrator'), get_lang('PlatformAdmin')).".</p>";
}
}
/**
* Handle encrypted password, send an email to a user with his password
*
* @param int user id
* @param bool $by_username
*
* @author Olivier Cauberghe <olivier.cauberghe@UGent.be>, Ghent University
*/
public static function handle_encrypted_password($user, $by_username = false) {
global $_configuration;
$email_subject = "[".api_get_setting('siteName')."] ".get_lang('LoginRequest'); // SUBJECT
if ($by_username) { // Show only for lost password
$user_account_list = self::get_user_account_list($user, true, $by_username); // BODY
$email_to = $user['email'];
} else {
$user_account_list = self::get_user_account_list($user, true); // BODY
$email_to = $user[0]['email'];
}
$secret_word = self::get_secret_word($email_to);
$email_body = get_lang('DearUser')." :\n".get_lang('password_request')."\n\n";
$email_body .= "-----------------------------------------------\n".$user_account_list."\n-----------------------------------------------\n\n";
$email_body .= get_lang('PasswordEncryptedForSecurity');
$email_body .= "\n\n".get_lang('Formula').",\n".get_lang('PlataformAdmin');
$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
$email_admin = api_get_setting('emailAdministrator');
if (@api_mail('', $email_to, $email_subject, $email_body, $sender_name, $email_admin) == 1) {
Display::display_confirmation_message(get_lang('YourPasswordHasBeenEmailed'));
} else {
$message = get_lang('SystemUnableToSendEmailContact').' '.Display :: encrypted_mailto_link(api_get_setting('emailAdministrator'), get_lang('PlatformAdmin')).".</p>";
Display::display_error_message($message, false);
}
}
/**
* Gets the secret word
* @author Olivier Cauberghe <olivier.cauberghe@UGent.be>, Ghent University
*/
public static function get_secret_word($add) {
global $_configuration;
return $secret_word = md5($_configuration['security_key'].$add);
}
/**
* Resets a password
* @author Olivier Cauberghe <olivier.cauberghe@UGent.be>, Ghent University
*/
public static function reset_password($secret, $id, $by_username = false) {
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$id = intval($id);
$sql = "SELECT user_id AS uid, lastname AS lastName, firstname AS firstName, username AS loginName, password, email FROM ".$tbl_user." WHERE user_id=$id";
$result = Database::query($sql);
$num_rows = Database::num_rows($result);
if ($result && $num_rows > 0) {
$user = Database::fetch_array($result);
} else {
return get_lang('CouldNotResetPassword');
}
if (self::get_secret_word($user['email']) == $secret) { // OK, secret word is good. Now change password and mail it.
$user['password'] = api_generate_password();
$crypted = $user['password'];
$crypted = api_get_encrypted_password($crypted);
$sql = "UPDATE ".$tbl_user." SET password='$crypted' WHERE user_id=$id";
$result = Database::query($sql);
return self::send_password_to_user($user, $by_username);
} else {
return get_lang('NotAllowed');
}
}
}
?>

@ -1,5 +1,5 @@
<?php
require_once(api_get_path(SYS_CODE_PATH).'auth/lost_password.lib.php');
require_once(api_get_path(LIBRARY_PATH).'login.lib.php');
require_once(api_get_path(LIBRARY_PATH).'course.lib.php');
class TestLostPassword extends UnitTestCase {
@ -17,7 +17,7 @@ class TestLostPassword extends UnitTestCase {
function testget_secret_word(){
global $_configuration;
$add='';
$res = get_secret_word($add);
$res = Login::get_secret_word($add);
$this->assertTrue($res);
$this->assertTrue(is_string($res));
//var_dump($res);
@ -27,10 +27,10 @@ class TestLostPassword extends UnitTestCase {
global $_configuration;
$user='';
$thisUser=array();
$secretword = get_secret_word($thisUser["email"]);
$secretword = Login::get_secret_word($thisUser["email"]);
$reset_link = get_lang('Pass')." : $thisUser[password]";
$userAccountList[] = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$thisUser["loginName"]."\n".get_lang('ResetLink').' : '.$reset_link.'';
$res = get_user_account_list($user, $reset = false);
$res = Login::get_user_account_list($user, $reset = false);
$this->assertTrue($userAccountList);
$this->assertTrue(is_array($userAccountList));
//var_dump($userAccountList);
@ -43,16 +43,16 @@ class TestLostPassword extends UnitTestCase {
ob_start();
$user=array('abc');
$emailSubject = "[".api_get_setting('siteName')."] ".get_lang('LoginRequest'); // SUBJECT
$userAccountList = get_user_account_list($user, true); // BODY
$userAccountList = Login::get_user_account_list($user, true); // BODY
$emailTo = $user[0]["email"];
$secretword = get_secret_word($emailTo);
$secretword = Login::get_secret_word($emailTo);
$emailBody = get_lang('DearUser')." :\n".get_lang("password_request")."\n\n";
$emailBody .= "-----------------------------------------------\n".$userAccountList."\n-----------------------------------------------\n\n";
$emailBody .=get_lang('PasswordEncryptedForSecurity');
$emailBody .="\n\n".get_lang('Formula').",\n".get_lang('PlataformAdmin');
$sender_name = api_get_setting('administratorName').' '.api_get_setting('administratorSurname');
$email_admin = api_get_setting('emailAdministrator');
$res=handle_encrypted_password($user);
$res=Login::handle_encrypted_password($user);
if(!is_array($res))$this->assertTrue(is_null($res));
ob_end_clean();
//var_dump($res);
@ -61,7 +61,7 @@ class TestLostPassword extends UnitTestCase {
function testreset_password(){
$secret='1234567891011';
$id=5;
$res=reset_password($secret, $id);
$res=Login::reset_password($secret, $id);
$this->assertTrue($res);
$this->assertTrue(is_string($res));
//var_dump($res);
@ -70,7 +70,7 @@ class TestLostPassword extends UnitTestCase {
function testsend_password_to_user() {
$user=array();
ob_start();
$res=send_password_to_user($user);
$res=Login::send_password_to_user($user);
if(!is_null($res))$this->assertTrue(is_array($res));
ob_end_clean();
//var_dump($res);

Loading…
Cancel
Save