Feature #5397 - Replacing again the deprecated function api_sql_query() with Database::query().

skala
Ivan Tcholakov 16 years ago
parent b597238212
commit 9b1f3ed934
  1. 72
      main/admin/add_many_session_to_category.php
  2. 30
      main/admin/resume_session.php
  3. 14
      main/admin/session_add.php
  4. 20
      main/admin/session_category_edit.php
  5. 94
      main/admin/session_category_list.php
  6. 92
      main/admin/session_course_user.php
  7. 16
      main/admin/session_edit.php
  8. 130
      main/admin/special_exports.php
  9. 2
      main/course_description/index.php
  10. 46
      main/course_home/activity.php
  11. 116
      main/coursecopy/classes/CourseBuilder.class.php
  12. 146
      main/coursecopy/classes/CourseRestorer.class.php
  13. 270
      main/coursecopy/copy_course_session.php
  14. 12
      main/exercice/exercice_submit.php
  15. 50
      main/glossary/index.php
  16. 18
      main/inc/lib/add_course.lib.inc.php
  17. 18
      main/inc/lib/course.lib.php
  18. 2
      main/inc/lib/fileUpload.lib.php
  19. 252
      main/inc/lib/main_api.lib.php
  20. 264
      main/inc/lib/sessionmanager.lib.php
  21. 98
      main/inc/lib/usermanager.lib.php
  22. 38
      main/inc/local.inc.php
  23. 26
      main/link/link.php
  24. 26
      main/survey/survey.lib.php
  25. 62
      main/tracking/courseLog.php
  26. 114
      user_portal.php

@ -52,7 +52,7 @@ if(isset($_GET['add_type']) && $_GET['add_type']!=''){
if (!api_is_platform_admin()) {
$sql = 'SELECT session_admin_id FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_session;
$rs = api_sql_query($sql,__FILE__,__LINE__);
$rs = Database::query($sql,__FILE__,__LINE__);
if (Database::result($rs,0,0)!=$_user['user_id']) {
api_not_allowed(true);
}
@ -60,29 +60,29 @@ if (!api_is_platform_admin()) {
function search_courses($needle,$type) {
global $tbl_course, $tbl_session, $id_session;
$xajax_response = new XajaxResponse();
$return = '';
$return = '';
if(!empty($needle) && !empty($type)) {
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_setting('platform_charset');
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id';
$rs = api_sql_query($sql, __FILE__, __LINE__);
$sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id';
$rs = Database::query($sql, __FILE__, __LINE__);
$course_list = array();
$return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">';
while($course = Database :: fetch_array($rs)) {
$course_list[] = $course['id'];
$return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>';
while($course = Database :: fetch_array($rs)) {
$course_list[] = $course['id'];
$return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>';
}
$return .= '</select>';
$xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return));
}
$_SESSION['course_list'] = $course_list;
return $xajax_response;
}
$_SESSION['course_list'] = $course_list;
return $xajax_response;
}
$xajax -> processRequests();
$htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
@ -95,18 +95,18 @@ function add_course_to_session (code, content) {
for (i=0;i<destination.length;i++) {
if(destination.options[i].text == content) {
return false;
}
}
}
destination.options[destination.length] = new Option(content,code);
destination.selectedIndex = -1;
sortOptions(destination.options);
sortOptions(destination.options);
}
function send() {
if (document.formulaire.CategorySessionId.value!=0) {
//alert(document.formulaire.CategorySessionId.value);
document.formulaire.formSent.value=0;
document.formulaire.submit();
}
}
}
function remove_item(origin)
{
@ -132,7 +132,7 @@ if ($_POST['formSent']) {
if($Categoryid != 0 && count($SessionCategoryList)>0 ){
$session_id = join(',', $SessionCategoryList);
$sql = "UPDATE $tbl_session SET session_category_id = $Categoryid WHERE id in ($session_id) ";
api_sql_query($sql,__FILE__,__LINE__);
Database::query($sql,__FILE__,__LINE__);
header('Location: session_list.php?id_category='.$Categoryid);
} else {
header('Location: add_many_session_to_category.php?msg=error');
@ -153,16 +153,16 @@ $rows_category_session = array();
if(isset($_POST['CategorySessionId']) && $_POST['formSent'] == 0 ){
$where = 'WHERE session_category_id !='.intval($_POST['CategorySessionId']);
$sql = 'SELECT id, name FROM '.$tbl_session .' WHERE session_category_id ='.intval($_POST['CategorySessionId']).' ORDER BY name';
$result=api_sql_query($sql,__FILE__,__LINE__);
$result=Database::query($sql,__FILE__,__LINE__);
$rows_category_session = api_store_result($result);
}
$sql = "SELECT id, name FROM $tbl_session_category ORDER BY name";
$result=api_sql_query($sql,__FILE__,__LINE__);
$result=Database::query($sql,__FILE__,__LINE__);
$rows_session_category = api_store_result($result);
$sql = "SELECT id, name FROM $tbl_session $where ORDER BY name";
$result=api_sql_query($sql,__FILE__,__LINE__);
$result=Database::query($sql,__FILE__,__LINE__);
$rows_session = api_store_result($result);
?>
<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?page=<?php echo $_GET['page']; if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
@ -180,11 +180,11 @@ if(!empty($errorMsg))
<td width="" align="center"> <b><?php echo get_lang('SessionCategoryName') ?> :</b><br />
<select name="CategorySessionId" style="width: 320px;" onchange="javascript:send();" >
<option value="0" selected> </option>
<?php
<?php
foreach($rows_session_category as $category) {
if($category['id'] == $_POST['CategorySessionId'])
echo '<option value="'.$category['id'].'" selected>'.$category['name'].'</option>';
else
else
echo '<option value="'.$category['id'].'">'.$category['name'].'</option>';
}
?>
@ -200,13 +200,13 @@ if(!empty($errorMsg))
<?php if($add_type == 'multiple') { ?>
<tr><td width="45%" align="center">
<?php echo get_lang('FirstLetterCourse'); ?> :
<?php echo get_lang('FirstLetterCourse'); ?> :
<select name="firstLetterCourse" onchange = "xajax_search_courses(this.value,'multiple')">
<option value="%">--</option>
<?php
echo Display :: get_alphabet_options();
echo Display :: get_numeric_options(0,9,'');
?>
?>
</select>
</td>
<td>&nbsp;</td></tr>
@ -214,8 +214,8 @@ if(!empty($errorMsg))
<tr>
<td width="45%" align="center">
<div id="ajax_list_courses_multiple">
<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:320px;">
<?php
<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:320px;">
<?php
foreach($rows_session as $enreg) {
?>
<option value="<?php echo $enreg['id']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['name'],ENT_QUOTES).'"'; if(in_array($enreg['id'],$CourseList)) echo 'selected="selected"'; ?>><?php echo $enreg['name']; ?></option>
@ -236,8 +236,8 @@ if(!empty($errorMsg))
<button class="arrowr" type="button" onclick="moveItem(document.getElementById('origin'), document.getElementById('destination'))" onclick="moveItem(document.getElementById('origin'), document.getElementById('destination'))"></button>
<br /><br />
<button class="arrowl" type="button" onclick="moveItem(document.getElementById('destination'), document.getElementById('origin'))" onclick="moveItem(document.getElementById('destination'), document.getElementById('origin'))"></button>
<?php
}
<?php
}
?>
<br /><br /><br /><br /><br /><br />
<?php
@ -246,7 +246,7 @@ if(!empty($errorMsg))
</td>
<td width="45%" align="center">
<select id='destination' name="SessionCategoryList[]" multiple="multiple" size="20" style="width:320px;">
<?php
<?php
foreach($rows_category_session as $enreg) {
?>
<option value="<?php echo $enreg['id']; ?>" <?php echo 'title="'.htmlspecialchars($enreg['name'],ENT_QUOTES).'"'; if(in_array($enreg['id'],$CourseList)) echo 'selected="selected"'; ?>><?php echo $enreg['name']; ?></option>
@ -269,25 +269,25 @@ function moveItem(origin , destination){
}
destination.selectedIndex = -1;
sortOptions(destination.options);
}
function sortOptions(options) {
newOptions = new Array();
for (i = 0 ; i<options.length ; i++) {
newOptions[i] = options[i];
newOptions[i] = options[i];
}
newOptions = newOptions.sort(mysort);
options.length = 0;
for(i = 0 ; i < newOptions.length ; i++){
options[i] = newOptions[i];
for(i = 0 ; i < newOptions.length ; i++){
options[i] = newOptions[i];
}
}
function mysort(a, b){

@ -54,8 +54,8 @@ if(!api_is_platform_admin() && $session['session_admin_id']!=$_user['user_id'])
api_not_allowed(true);
}
$sql = 'SELECT name FROM '.$tbl_session_category.' WHERE id = "'.intval($session['session_category_id']).'"';
$rs = api_sql_query($sql, __FILE__, __LINE__);
$sql = 'SELECT name FROM '.$tbl_session_category.' WHERE id = "'.intval($session['session_category_id']).'"';
$rs = Database::query($sql, __FILE__, __LINE__);
$session_category = '';
if(mysql_num_rows($rs)>0) {
$rows_session_category = api_store_result($rs);
@ -213,30 +213,30 @@ else {
$courses=Database::store_result($result);
foreach($courses as $course){
//select the number of users
$sql = " SELECT count(*) FROM $tbl_session_rel_user sru, $tbl_session_rel_course_rel_user srcru
$sql = " SELECT count(*) FROM $tbl_session_rel_user sru, $tbl_session_rel_course_rel_user srcru
WHERE srcru.id_user = sru.id_user AND srcru.course_code = '".Database::escape_string($course['code'])."'
AND srcru.id_session = '".intval($id_session)."'";
$rs = api_sql_query($sql, __FILE__, __LINE__);
AND srcru.id_session = '".intval($id_session)."'";
$rs = Database::query($sql, __FILE__, __LINE__);
$course['nbr_users'] = mysql_result($rs,0,0);
// Get coachs of the courses in session
$sql = "SELECT user.lastname,user.firstname,user.username FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user
$sql = "SELECT user.lastname,user.firstname,user.username FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user
WHERE session_rcru.id_user = user.user_id AND session_rcru.id_session = '".intval($id_session)."' AND session_rcru.course_code ='".Database::escape_string($course['code'])."' AND session_rcru.status=2";
$rs = Database::query($sql,__FILE__,__LINE__);
$coachs = array();
if (Database::num_rows($rs) > 0) {
if (Database::num_rows($rs) > 0) {
while($info_coach = Database::fetch_array($rs)) {
$coachs[] = $info_coach['lastname'].' '.$info_coach['firstname'].' ('.$info_coach['username'].')';
}
}
} else {
$coach = get_lang('None');
}
if (count($coachs) > 0) {
$coach = implode('<br />',$coachs);
} else {

@ -199,10 +199,10 @@ if (intval($count_users)<50) {
</td>
</tr>
<?php
$id_session_category = '';
$id_session_category = '';
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$sql = 'SELECT id, name FROM '.$tbl_session_category.' ORDER BY name ASC';
$result = api_sql_query($sql,__FILE__,__LINE__);
$result = Database::query($sql,__FILE__,__LINE__);
$Categories = api_store_result($result);
?>
<tr>
@ -369,8 +369,8 @@ for ($i=$thisYear-5;$i <= ($thisYear+5);$i++) {
<tr>
<td width="40%"><?php echo get_lang('SessionVisibility') ?></td>
<td width="60%">
<select name="session_visibility" style="width:250px;">
<?php
<select name="session_visibility" style="width:250px;">
<?php
$visibility_list = array(SESSION_VISIBLE_READ_ONLY=>get_lang('ReadOnly'), SESSION_VISIBLE=>get_lang('Visible'), SESSION_INVISIBLE=>api_ucfirst(get_lang('Invisible')));
foreach($visibility_list as $key=>$item): ?>
<option value="<?php echo $key; ?>" <?php if($item == $visibility_id) echo 'selected="selected"'; ?>><?php echo $item; ?></option>
@ -399,9 +399,9 @@ function setDisable(select){
document.form.day_end.disabled = (select.checked) ? true : false;
document.form.month_end.disabled = (select.checked) ? true : false;
document.form.year_end.disabled = (select.checked) ? true : false;
document.form.session_visibility.disabled = (select.checked) ? true : false;
document.form.session_visibility.selectedIndex = 0;
document.form.session_visibility.disabled = (select.checked) ? true : false;
document.form.session_visibility.selectedIndex = 0;
}
</script>
<?php

@ -4,7 +4,7 @@
Dokeos - elearning and course management software
Copyright (c) 2009 Dokeos SPRL
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
@ -37,7 +37,7 @@ $tool_name = get_lang('EditSessionCategory');
$interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin'));
$interbreadcrumb[]=array('url' => "session_category_list.php","name" => get_lang('ListSessionCategory'));
$sql = "SELECT * FROM $tbl_session_category WHERE id='".$id."' ORDER BY name";
$result=api_sql_query($sql,__FILE__,__LINE__);
$result=Database::query($sql,__FILE__,__LINE__);
if (!$infos=mysql_fetch_array($result)) {
header('Location: session_list.php');
exit();
@ -51,12 +51,12 @@ if (!api_is_platform_admin() && $infos['session_admin_id']!=$_user['user_id']) {
if ($_POST['formSent']) {
$formSent=1;
$name= $_POST['name'];
$year_start= $_POST['year_start'];
$month_start=$_POST['month_start'];
$day_start=$_POST['day_start'];
$year_end=$_POST['year_end'];
$month_end=$_POST['month_end'];
$day_end=$_POST['day_end'];
$year_start= $_POST['year_start'];
$month_start=$_POST['month_start'];
$day_start=$_POST['day_start'];
$year_end=$_POST['year_end'];
$month_end=$_POST['month_end'];
$day_end=$_POST['day_end'];
$return = SessionManager::edit_category_session($id, $name, $year_start, $month_start, $day_start, $year_end, $month_end, $day_end);
if ($return == strval(intval($return))) {
header('Location: session_category_list.php?action=show_message&message='.urlencode(get_lang('SessionCategoryUpdate')));
@ -209,13 +209,13 @@ for($i=$thisYear-5;$i <= ($thisYear+5);$i++)
<tr>
<td>
&nbsp;
</td>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<button class="save" type="submit" value="<?php echo get_lang('ModifyThisSession') ?>"><?php echo get_lang('ModifyThisSession') ?></button>
</td>
</tr>

@ -12,19 +12,19 @@ api_protect_admin_script(true);
// setting the section (for the tabs)
$this_section=SECTION_PLATFORM_ADMIN;
$htmlHeadXtra[] = '<script language="javascript">
function selectAll(idCheck,numRows,action) {
for(i=0;i<numRows;i++) {
idcheck = document.getElementById(idCheck+"_"+i);
if (action == "true"){
idcheck.checked = true;
} else {
idcheck.checked = false;
}
}
}
}
}
}
</script>';
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
@ -55,7 +55,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
$active_group[] = $form->createElement('checkbox','active','',get_lang('Active'));
$active_group[] = $form->createElement('checkbox','inactive','',get_lang('Inactive'));
$form->addGroup($active_group,'',get_lang('ActiveSession'),'<br/>',false);
$form->addElement('style_submit_button', 'submit',get_lang('SearchUsers'),'class="search"');
$defaults['active'] = 1;
$defaults['inactive'] = 1;
@ -65,46 +65,46 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
$limit = 20;
$from = $page * $limit;
//if user is crfp admin only list its sessions
if(!api_is_platform_admin()) {
if(!api_is_platform_admin()) {
$where .= (empty($_REQUEST['keyword']) ? " " : " WHERE name LIKE '%".addslashes($_REQUEST['keyword'])."%'");
}
else {
$where .= (empty($_REQUEST['keyword']) ? " " : " WHERE name LIKE '%".addslashes($_REQUEST['keyword'])."%'");
}
$query = "SELECT sc.*, (select count(id) FROM $tbl_session WHERE session_category_id = sc.id) as nbr_session
FROM $tbl_session_category sc
$where
ORDER BY $sort $order
$query = "SELECT sc.*, (select count(id) FROM $tbl_session WHERE session_category_id = sc.id) as nbr_session
FROM $tbl_session_category sc
$where
ORDER BY $sort $order
LIMIT $from,".($limit+1);
$query_rows = "SELECT count(*) as total_rows
$query_rows = "SELECT count(*) as total_rows
FROM $tbl_session_category sc $where ";
$order = ($order == 'ASC')? 'DESC': 'ASC';
$result_rows = api_sql_query($query_rows,__FILE__,__LINE__);
$result_rows = Database::query($query_rows,__FILE__,__LINE__);
$recorset = Database::fetch_array($result_rows);
$num = $recorset['total_rows'];
$result = api_sql_query($query,__FILE__,__LINE__);
$result = Database::query($query,__FILE__,__LINE__);
$Sessions = api_store_result($result);
$nbr_results = sizeof($Sessions);
$tool_name = get_lang('ListSessionCategory');
Display::display_header($tool_name);
$tool_name = get_lang('ListSessionCategory');
Display::display_header($tool_name);
api_display_tool_title($tool_name);
if (!empty($_GET['warn'])) {
Display::display_warning_message(urldecode($_GET['warn']),false);
}
if(isset($_GET['action'])) {
Display::display_normal_message(stripslashes($_GET['message']),false);
}
?>
<div class="actions">
?>
<div class="actions">
<?php
echo '<div style="float:right;">
<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_category_add.php">'.Display::return_icon('view_more_stats.gif',get_lang('AddSession')).get_lang('AddSessionCategory').'</a>
</div>';
<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_category_add.php">'.Display::return_icon('view_more_stats.gif',get_lang('AddSession')).get_lang('AddSessionCategory').'</a>
</div>';
?>
<form method="POST" action="session_category_list.php">
<input type="text" name="keyword" value="<?php echo Security::remove_XSS($_GET['keyword']); ?>"/>
@ -112,8 +112,8 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
<!-- <a href="session_list.php?search=advanced"><?php echo get_lang('AdvancedSearch'); ?></a> -->
</form>
<form method="post" action="<?php echo api_get_self(); ?>?action=delete&sort=<?php echo $sort; ?>" onsubmit="javascript:if(!confirm('<?php echo get_lang('ConfirmYourChoice'); ?>')) return false;">
</div><br />
<div align="left">
</div><br />
<div align="left">
<?php
if(count($Sessions)==0 && isset($_POST['keyword'])) {
echo get_lang('NoSearchResults');
@ -122,23 +122,23 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
if ($num > $limit) {
if ($page) {
?>
<a href="<?php echo api_get_self(); ?>?page=<?php echo $page-1; ?>&sort=<?php echo $sort; ?>&order=<?php echo Security::remove_XSS($_REQUEST['order']); ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Previous'); ?></a>
<a href="<?php echo api_get_self(); ?>?page=<?php echo $page-1; ?>&sort=<?php echo $sort; ?>&order=<?php echo Security::remove_XSS($_REQUEST['order']); ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Previous'); ?></a>
<?php
} else {
echo get_lang('Previous');
}
?>
?>
|
<?php
if($nbr_results > $limit) {
?>
<a href="<?php echo api_get_self(); ?>?page=<?php echo $page+1; ?>&sort=<?php echo $sort; ?>&order=<?php echo Security::remove_XSS($_REQUEST['order']); ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Next'); ?></a>
?>
<a href="<?php echo api_get_self(); ?>?page=<?php echo $page+1; ?>&sort=<?php echo $sort; ?>&order=<?php echo Security::remove_XSS($_REQUEST['order']); ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Next'); ?></a>
<?php
} else {
echo get_lang('Next');
}
}
?>
?>
</div>
<br />
<table class="data_table" width="100%">
@ -150,7 +150,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
<th><a href="<?php echo api_get_self(); ?>?sort=date_end&order=<?php echo ($sort=='date_end')? $order: 'ASC'; ?>"><?php echo get_lang('EndDate'); ?></a></th>
<th><?php echo get_lang('Actions'); ?></th>
</tr>
<?php
$i=0;
$x=0;
@ -159,15 +159,15 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
break;
}
$sql = 'SELECT COUNT(session_category_id) FROM '.$tbl_session.' WHERE session_category_id = '.intval($enreg['id']);
$rs = api_sql_query($sql, __FILE__, __LINE__);
$rs = Database::query($sql, __FILE__, __LINE__);
list($nb_courses) = Database::fetch_array($rs);
?>
<tr class="<?php echo $i?'row_odd':'row_even'; ?>">
<td><input type="checkbox" id="idChecked_<?php echo $x; ?>" name="idChecked[]" value="<?php echo $enreg['id']; ?>"></td>
<td><input type="checkbox" id="idChecked_<?php echo $x; ?>" name="idChecked[]" value="<?php echo $enreg['id']; ?>"></td>
<td><?php echo api_htmlentities($enreg['name'],ENT_QUOTES,$charset); ?></td>
<td><?php echo "<a href=\"session_list.php?id_category=".$enreg['id']."\">".$nb_courses." Sesion(es) </a>"; ?></td>
<td><?php echo api_htmlentities($enreg['date_start'],ENT_QUOTES,$charset); ?></td>
<td><?php echo api_htmlentities($enreg['date_end'],ENT_QUOTES,$charset); ?></td>
<td><?php echo api_htmlentities($enreg['date_end'],ENT_QUOTES,$charset); ?></td>
<td>
<a href="session_category_edit.php?&id=<?php echo $enreg['id']; ?>"><?php Display::display_icon('edit.gif', get_lang('Edit')); ?></a>
<a href="<?php echo api_get_self(); ?>?sort=<?php echo $sort; ?>&action=delete_off_session&idChecked=<?php echo $enreg['id']; ?>" onclick="javascript:if(!confirm('<?php echo get_lang('ConfirmYourChoice'); ?>')) return false;"><?php Display::display_icon('delete.gif', get_lang('Delete')); ?></a>
@ -176,23 +176,23 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
<?php
$i=$i ? 0 : 1;
$x++;
}
unset($Sessions);
}
unset($Sessions);
?>
</table>
<br />
<div align="left">
<?php
if ($num > $limit) {
if ($page)
{
?>
<a href="<?php echo api_get_self(); ?>?page=<?php echo $page-1; ?>&sort=<?php echo $sort; ?>&order=<?php echo Security::remove_XSS($_REQUEST['order']); ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Previous'); ?></a>
<?php
}
else
@ -200,16 +200,16 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
echo get_lang('Previous');
}
?>
|
<?php
if($nbr_results > $limit)
{
?>
<a href="<?php echo api_get_self(); ?>?page=<?php echo $page+1; ?>&sort=<?php echo $sort; ?>&order=<?php echo Security::remove_XSS($_REQUEST['order']); ?>&keyword=<?php echo $_REQUEST['keyword']; ?><?php echo @$cond_url; ?>"><?php echo get_lang('Next'); ?></a>
<?php
}
else

@ -46,7 +46,7 @@ if (empty($id_user) || empty($id_session)) {
if (!api_is_platform_admin()) {
$sql = 'SELECT session_admin_id FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_session;
$rs = api_sql_query($sql,__FILE__,__LINE__);
$rs = Database::query($sql, __FILE__, __LINE__);
if (Database::result($rs,0,0)!=$_user['user_id']) {
api_not_allowed(true);
}
@ -58,35 +58,35 @@ $CourseList=$SessionList=array();
$courses=$sessions=array();
$noPHP_SELF=true;
if ($_POST['formSent']) {
$formSent = $_POST['formSent'];
if ($_POST['formSent']) {
$formSent = $_POST['formSent'];
$CourseList = $_POST['SessionCoursesList'];
if (!is_array($CourseList)) {
$CourseList=array();
}
$sql="SELECT distinct code
FROM $tbl_course course LEFT JOIN $tbl_session_rel_course session_rel_course
ON course.code = session_rel_course.course_code inner join $tbl_session_rel_course_rel_user as srcru
ON (srcru.id_session = session_rel_course.id_session)
FROM $tbl_course course LEFT JOIN $tbl_session_rel_course session_rel_course
ON course.code = session_rel_course.course_code inner join $tbl_session_rel_course_rel_user as srcru
ON (srcru.id_session = session_rel_course.id_session)
WHERE id_user = $id_user and session_rel_course.id_session = $id_session";
$rs = api_sql_query($sql);
$existingCourses = api_store_result($rs);
if (count($CourseList) == count($existingCourses)) {
$rs = Database::query($sql, __FILE__, __LINE__);
$existingCourses = api_store_result($rs);
if (count($CourseList) == count($existingCourses)) {
header('Location: session_course_user.php?id_session='.$id_session.'&id_user='.$id_user.'&msg='.get_lang('MaybeYouWantToDeleteThisUserFromSession'));
exit;
}
foreach($CourseList as $enreg_course) {
foreach($CourseList as $enreg_course) {
$exists = false;
foreach($existingCourses as $existingCourse) {
if($enreg_course == $existingCourse['course_code']) {
$exists=true;
}
}
if(!$exists) {
$enreg_course = Database::escape_string($enreg_course);
if(!$exists) {
$enreg_course = Database::escape_string($enreg_course);
$sql_delete = "DELETE FROM $tbl_session_rel_course_rel_user
WHERE id_user='".$id_user."' AND course_code='".$enreg_course."' AND id_session=$id_session";
Database::query($sql_delete,__FILE__, __LINE__);
@ -94,21 +94,21 @@ if ($_POST['formSent']) {
//update session rel course table
$sql_update = "UPDATE $tbl_session_rel_course SET nbr_users= nbr_users - 1 WHERE id_session='$id_session' AND course_code='$enreg_course'";
Database::query($sql_update,__FILE__, __LINE__);
}
}
}
}
foreach($existingCourses as $existingCourse) {
foreach($existingCourses as $existingCourse) {
//$sql_insert_rel_course= "INSERT INTO $tbl_session_rel_course(id_session,course_code, id_coach) VALUES('$id_session','$enreg_course','$id_coach')";
if(!in_array($existingCourse['code'], $CourseList)){
$existingCourse = Database::escape_string($existingCourse['code']);
$sql_insert = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user) VALUES('$id_session','$existingCourse','$id_user')";
Database::query($sql_insert,__FILE__, __LINE__);
if(Database::affected_rows()) {
if(Database::affected_rows()) {
//update session rel course table
$sql_update = "UPDATE $tbl_session_rel_course SET nbr_users= nbr_users + 1 WHERE id_session='$id_session' AND course_code='$existingCourse'";
Database::query($sql_update,__FILE__, __LINE__);
}
}
}
//header('Location: session_course_user.php?id_user='.$id_user.'&id_session='.$id_session);
@ -120,7 +120,7 @@ if ($_POST['formSent']) {
Display::display_header($tool_name);
if (!empty($_GET['msg'])) {
Display::display_normal_message(urldecode($_GET['msg']));
Display::display_normal_message(urldecode($_GET['msg']));
}
// the form header
@ -128,22 +128,22 @@ $session_info = SessionManager::fetch($id_session);
echo '<div class="row"><div class="form_header">'.$tool_name.' ('.$session_info['name'].')</div></div><br />';
$nosessionCourses = $sessionCourses = array();
/*$sql="SELECT distinct code, title, visual_code, session_rel_course.id_session
FROM $tbl_course course LEFT JOIN $tbl_session_rel_course session_rel_course
ON course.code = session_rel_course.course_code inner join $tbl_session_rel_course_rel_user as srcru
ON (srcru.id_session = session_rel_course.id_session)
/*$sql="SELECT distinct code, title, visual_code, session_rel_course.id_session
FROM $tbl_course course LEFT JOIN $tbl_session_rel_course session_rel_course
ON course.code = session_rel_course.course_code inner join $tbl_session_rel_course_rel_user as srcru
ON (srcru.id_session = session_rel_course.id_session)
WHERE id_user = $id_user and session_rel_course.id_session = $id_session";
*/
// actual user
$sql="SELECT code, title, visual_code, srcru.id_session " .
"FROM $tbl_course course inner JOIN $tbl_session_rel_course_rel_user as srcru " .
"ON course.code = srcru.course_code where srcru.id_user = $id_user AND id_session = $id_session";
//all
$sql_all="SELECT code, title, visual_code, src.id_session " .
"FROM $tbl_course course inner JOIN $tbl_session_rel_course as src " .
"ON course.code = src.course_code AND id_session = $id_session";
/*
echo $sql="SELECT code, title, visual_code, id_session
@ -152,10 +152,10 @@ $sql_all="SELECT code, title, visual_code, src.id_session " .
ON course.code = session_rel_course.course_code
AND session_rel_course.id_session = ".intval($id_session)."
ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title";
*/
*/
/*global $_configuration;
if ($_configuration['multiple_access_urls']==true) {
$tbl_course_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
if ($_configuration['multiple_access_urls']==true) {
$tbl_course_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1){
$sql="SELECT code, title, visual_code, id_session
@ -164,28 +164,28 @@ if ($_configuration['multiple_access_urls']==true) {
ON course.code = session_rel_course.course_code
AND session_rel_course.id_session = ".intval($id_session)."
INNER JOIN $tbl_course_rel_access_url url_course ON (url_course.course_code=course.code)
WHERE access_url_id = $access_url_id
WHERE access_url_id = $access_url_id
ORDER BY ".(sizeof($courses)?"(code IN(".implode(',',$courses).")) DESC,":"")." title";
}
}
}*/
$result=api_sql_query($sql,__FILE__,__LINE__);
$Courses=api_store_result($result);
$result=Database::query($sql,__FILE__,__LINE__);
$Courses=api_store_result($result);
$result=api_sql_query($sql_all,__FILE__,__LINE__);
$CoursesAll=api_store_result($result);
$result=Database::query($sql_all,__FILE__,__LINE__);
$CoursesAll=api_store_result($result);
$course_temp = array();
foreach($Courses as $course) {
$course_temp[] = $course['code'];
}
}
foreach($CoursesAll as $course) {
if (in_array($course['code'], $course_temp)) {
$nosessionCourses[$course['code']] = $course ;
} else {
$sessionCourses[$course['code']] = $course ;
}
}
}
unset($Courses);
?>
@ -232,11 +232,11 @@ unset($nosessionCourses);
<td width="45%" align="center"><select id='destination' name="SessionCoursesList[]" multiple="multiple" size="20" style="width:320px;">
<?php
foreach($sessionCourses as $enreg)
{
?>
{
?>
<option value="<?php echo $enreg['code']; ?>" title="<?php echo htmlspecialchars($enreg['title'].' ('.$enreg['visual_code'].')',ENT_QUOTES); ?>"><?php echo $enreg['title'].' ('.$enreg['visual_code'].')'; ?></option>
<?php
<?php
}
unset($sessionCourses);
?>
@ -259,25 +259,25 @@ function moveItem(origin , destination){
}
destination.selectedIndex = -1;
sortOptions(destination.options);
}
function sortOptions(options) {
newOptions = new Array();
for (i = 0 ; i<options.length ; i++) {
newOptions[i] = options[i];
newOptions[i] = options[i];
}
newOptions = newOptions.sort(mysort);
options.length = 0;
for(i = 0 ; i < newOptions.length ; i++){
options[i] = newOptions[i];
for(i = 0 ; i < newOptions.length ; i++){
options[i] = newOptions[i];
}
}
function mysort(a, b){

@ -55,7 +55,7 @@ if ($_POST['formSent']) {
$id_coach=$_POST['id_coach'];
$id_session_category = $_POST['session_category'];
$id_visibility = $_POST['session_visibility'];
$return = SessionManager::edit_session($id,$name,$year_start,$month_start,$day_start,$year_end,$month_end,$day_end,$nb_days_acess_before,$nb_days_acess_after,$nolimit, $id_coach, $id_session_category,$id_visibility);
if ($return == strval(intval($return))) {
header('Location: resume_session.php?id_session='.$return);
@ -123,10 +123,10 @@ unset($Coaches);
</select></td>
</tr>
<?php
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
//$access_url_id = api_get_current_access_url_id();
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
//$access_url_id = api_get_current_access_url_id();
$sql = 'SELECT id, name FROM '.$tbl_session_category.' ORDER BY name ASC';
$result = api_sql_query($sql,__FILE__,__LINE__);
$result = Database::query($sql,__FILE__,__LINE__);
$Categories = api_store_result($result);
?>
<tr>
@ -315,8 +315,8 @@ for($i=$thisYear-5;$i <= ($thisYear+5);$i++)
<tr>
<td width="30%"><?php echo get_lang('SessionVisibility') ?></td>
<td width="70%">
<select name="session_visibility" style="width:250px;">
<?php
<select name="session_visibility" style="width:250px;">
<?php
$visibility_list = array(SESSION_VISIBLE_READ_ONLY=>get_lang('ReadOnly'), SESSION_VISIBLE=>get_lang('Visible'), SESSION_INVISIBLE=>api_ucfirst(get_lang('Invisible')));
foreach($visibility_list as $key=>$item): ?>
<option value="<?php echo $key; ?>" <?php if($key == $infos['visibility']) echo 'selected="selected"'; ?>><?php echo $item; ?></option>
@ -352,8 +352,8 @@ function setDisable(select){
document.form.year_end.disabled = (select.checked) ? true : false;
document.form.session_visibility.disabled = (select.checked) ? true : false;
document.form.session_visibility.selectedIndex = 0;
document.form.session_visibility.selectedIndex = 0;
}
</script>

@ -3,13 +3,13 @@
/**
* ==============================================================================
* Special exports
*
*
* @author Jhon Hinojosa <jhon.hinojosa@dokeos.com>
* @package special.export
* ==============================================================================
*/
// name of the language file that needs to be included
// name of the language file that needs to be included
$language_file = array ('admin');
// including the global file
include ('../inc/global.inc.php');
@ -48,7 +48,7 @@ $error =0;
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (isset ($_POST['backup_option']) && $_POST['backup_option'] == 'full_backup')) {
require_once api_get_path(LIBRARY_PATH).'document.lib.php';
require_once api_get_path(LIBRARY_PATH).'pclzip/pclzip.lib.php';
@ -58,14 +58,14 @@ if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (i
$to_group_id = 0;
$code_course = '';
$sql_session = "SELECT id, name FROM $tbl_session ";
$query_session = api_sql_query($sql_session, __FILE__, __LINE__);
$query_session = Database::query($sql_session, __FILE__, __LINE__);
$ListSession = array();
while($rows_session = mysql_fetch_assoc($query_session)) {
$ListSession[$rows_session['id']] = $rows_session['name'];
$ListSession[$rows_session['id']] = $rows_session['name'];
}
$zip_folder=new PclZip($FileZip['TEMP_FILE_ZIP']);
if(!isset($_POST['resource']) || count($_POST['resource']) == 0 ) {
Display::display_error_message(get_lang('ErrorMsgSpecialExport'));
Display::display_error_message(get_lang('ErrorMsgSpecialExport'));
} else {
$Resource = $_POST['resource'];
foreach($Resource as $Code_course => $Sessions) {
@ -73,36 +73,36 @@ if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (i
$tbl_document = Database::get_course_table(TABLE_DOCUMENT, $_course['db_name']);
$tbl_property = Database::get_course_table(TABLE_ITEM_PROPERTY, $_course['db_name']);
//Add tem to the zip file course
$sql = "SELECT path FROM $tbl_document AS docs, $tbl_property AS props
WHERE `props`.`tool`='".TOOL_DOCUMENT."'
AND `docs`.`id`=`props`.`ref`
AND `docs`.`path` LIKE '".$querypath."/%'
AND `docs`.`filetype`='file'
AND `docs`.`session_id` = '0'
AND `props`.`visibility`<>'2'
$sql = "SELECT path FROM $tbl_document AS docs, $tbl_property AS props
WHERE `props`.`tool`='".TOOL_DOCUMENT."'
AND `docs`.`id`=`props`.`ref`
AND `docs`.`path` LIKE '".$querypath."/%'
AND `docs`.`filetype`='file'
AND `docs`.`session_id` = '0'
AND `props`.`visibility`<>'2'
AND `props`.`to_group_id`=".$to_group_id."";
$query = api_sql_query($sql ,__FILE__,__LINE__);
$query = Database::query($sql ,__FILE__,__LINE__);
while($rows_course_file = mysql_fetch_assoc($query)) {
$zip_folder->add($FileZip['PATH_COURSE'].$_course['directory']."/document".$rows_course_file['path'],
$zip_folder->add($FileZip['PATH_COURSE'].$_course['directory']."/document".$rows_course_file['path'],
PCLZIP_OPT_ADD_PATH, $_course['directory'],
PCLZIP_OPT_REMOVE_PATH, $FileZip['PATH_COURSE'].$_course['directory']."/document".$FileZip['PATH_REMOVE']
);
}
foreach($Sessions as $IdSession => $value){
foreach($Sessions as $IdSession => $value){
$session_id = Security::remove_XSS($IdSession);
//Add tem to the zip file session course
$sql_session_doc = "SELECT path FROM $tbl_document AS docs,$tbl_property AS props
WHERE `props`.`tool`='".TOOL_DOCUMENT."'
AND `docs`.`id`=`props`.`ref`
AND `docs`.`path` LIKE '".$querypath."/%'
AND `docs`.`filetype`='file'
AND `docs`.`session_id` = '$session_id'
AND `props`.`visibility`<>'2'
$sql_session_doc = "SELECT path FROM $tbl_document AS docs,$tbl_property AS props
WHERE `props`.`tool`='".TOOL_DOCUMENT."'
AND `docs`.`id`=`props`.`ref`
AND `docs`.`path` LIKE '".$querypath."/%'
AND `docs`.`filetype`='file'
AND `docs`.`session_id` = '$session_id'
AND `props`.`visibility`<>'2'
AND `props`.`to_group_id`=".$to_group_id."";
$query_session_doc = api_sql_query($sql_session_doc, __FILE__, __LINE__);
$query_session_doc = Database::query($sql_session_doc, __FILE__, __LINE__);
while($rows_course_session_file = mysql_fetch_assoc($query_session_doc)) {
$zip_folder->add($FileZip['PATH_COURSE'].$_course['directory'].'/document'.$rows_course_session_file['path'],
PCLZIP_OPT_ADD_PATH, $_course['directory']."/".$ListSession[$session_id],
$zip_folder->add($FileZip['PATH_COURSE'].$_course['directory'].'/document'.$rows_course_session_file['path'],
PCLZIP_OPT_ADD_PATH, $_course['directory']."/".$ListSession[$session_id],
PCLZIP_OPT_REMOVE_PATH, $FileZip['PATH_COURSE'].$_course['directory'].'/document'.$FileZip['PATH_REMOVE']
);
}
@ -121,7 +121,7 @@ if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (i
{
window.location="../course_info/download.php?archive=<?php echo $name; ?>&session=true";
}
</script> //-->
</script> //-->
<?php
}
@ -133,7 +133,7 @@ function create_zip(){
$sys_archive_path = api_get_path(SYS_ARCHIVE_PATH);
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$temp_zip_dir = $sys_archive_path."temp";
if(!is_dir($temp_zip_dir)) {
if(!is_dir($temp_zip_dir)) {
mkdir($temp_zip_dir);
} else {
$handle=opendir($temp_zip_dir);
@ -146,12 +146,12 @@ function create_zip(){
closedir($handle);
}
$temp_zip_file = $temp_zip_dir."/".md5(time()).".zip"; //create zipfile of given directory
return array('PATH' => $path,
'PATH_TEMP_ARCHIVE' => $temp_zip_dir,
'PATH_COURSE' => $sys_course_path,
return array('PATH' => $path,
'PATH_TEMP_ARCHIVE' => $temp_zip_dir,
'PATH_COURSE' => $sys_course_path,
'TEMP_FILE_ZIP' => $temp_zip_file,
'PATH_REMOVE' => $remove_dir);
}
@ -159,12 +159,12 @@ function create_zip(){
function rename_zip($FileZip) {
event_download(($FileZip['PATH'] == '/')?'full_export_'.date('Ymd').'.zip (folder)': basename($FileZip['PATH']).'.zip (folder)');
$name = ($FileZip['PATH']=='/')? 'full_export_'.date('Ymd').'.zip':basename($FileZip['PATH']).'.zip';
if(file_exists($FileZip['PATH_TEMP_ARCHIVE'].'/'.$name)){ unlink($FileZip['PATH_TEMP_ARCHIVE'].'/'.$name); }
if(file_exists($FileZip['TEMP_FILE_ZIP'])) {
if(file_exists($FileZip['PATH_TEMP_ARCHIVE'].'/'.$name)){ unlink($FileZip['PATH_TEMP_ARCHIVE'].'/'.$name); }
if(file_exists($FileZip['TEMP_FILE_ZIP'])) {
rename($FileZip['TEMP_FILE_ZIP'], $FileZip['PATH_TEMP_ARCHIVE'].'/'.$name);
return $name;
} else { return false; }
}
function fullexportspecial(){
@ -185,42 +185,42 @@ function fullexportspecial(){
$tbl_document = Database::get_course_table(TABLE_DOCUMENT, $_course['db_name']);
$tbl_property = Database::get_course_table(TABLE_ITEM_PROPERTY, $_course['db_name']);
//Add tem to the zip file course
$sql = "SELECT path FROM $tbl_document AS docs, $tbl_property AS props
WHERE `props`.`tool`='".TOOL_DOCUMENT."'
AND `docs`.`id`=`props`.`ref`
AND `docs`.`path` LIKE '".$querypath."/%'
AND `docs`.`filetype`='file'
AND `docs`.`session_id` = '0'
AND `props`.`visibility`<>'2'
$sql = "SELECT path FROM $tbl_document AS docs, $tbl_property AS props
WHERE `props`.`tool`='".TOOL_DOCUMENT."'
AND `docs`.`id`=`props`.`ref`
AND `docs`.`path` LIKE '".$querypath."/%'
AND `docs`.`filetype`='file'
AND `docs`.`session_id` = '0'
AND `props`.`visibility`<>'2'
AND `props`.`to_group_id`=".$to_group_id."";
$query = api_sql_query($sql ,__FILE__,__LINE__);
$query = Database::query($sql ,__FILE__,__LINE__);
while($rows_course_file = mysql_fetch_assoc($query)) {
$rows_course_file['path'];
$zip_folder->add($FileZip['PATH_COURSE'].$_course['directory']."/document".$rows_course_file['path'],
$zip_folder->add($FileZip['PATH_COURSE'].$_course['directory']."/document".$rows_course_file['path'],
PCLZIP_OPT_ADD_PATH, $_course['directory'],
PCLZIP_OPT_REMOVE_PATH, $FileZip['PATH_COURSE'].$_course['directory']."/document".$FileZip['PATH_REMOVE']
);
}
//Add tem to the zip file session course
$code_course = $_course['code'];
$sql_session = "SELECT id, name, course_code FROM $tbl_session_course
INNER JOIN $tbl_session ON id_session = id
$sql_session = "SELECT id, name, course_code FROM $tbl_session_course
INNER JOIN $tbl_session ON id_session = id
WHERE course_code = '$code_course' ";
$query_session = api_sql_query($sql_session, __FILE__, __LINE__);
$query_session = Database::query($sql_session, __FILE__, __LINE__);
while($rows_session = mysql_fetch_assoc($query_session)) {
$session_id = $rows_session['id'];
$sql_session_doc = "SELECT path FROM $tbl_document AS docs,$tbl_property AS props
WHERE `props`.`tool`='".TOOL_DOCUMENT."'
AND `docs`.`id`=`props`.`ref`
AND `docs`.`path` LIKE '".$querypath."/%'
AND `docs`.`filetype`='file'
AND `docs`.`session_id` = '$session_id'
AND `props`.`visibility`<>'2'
$sql_session_doc = "SELECT path FROM $tbl_document AS docs,$tbl_property AS props
WHERE `props`.`tool`='".TOOL_DOCUMENT."'
AND `docs`.`id`=`props`.`ref`
AND `docs`.`path` LIKE '".$querypath."/%'
AND `docs`.`filetype`='file'
AND `docs`.`session_id` = '$session_id'
AND `props`.`visibility`<>'2'
AND `props`.`to_group_id`=".$to_group_id."";
$query_session_doc = api_sql_query($sql_session_doc, __FILE__, __LINE__);
$query_session_doc = Database::query($sql_session_doc, __FILE__, __LINE__);
while($rows_course_session_file = mysql_fetch_assoc($query_session_doc)) {
$zip_folder->add($FileZip['PATH_COURSE'].$_course['directory'].'/document'.$rows_course_session_file['path'],
PCLZIP_OPT_ADD_PATH, $_course['directory']."/".$rows_session['name'],
$zip_folder->add($FileZip['PATH_COURSE'].$_course['directory'].'/document'.$rows_course_session_file['path'],
PCLZIP_OPT_ADD_PATH, $_course['directory']."/".$rows_session['name'],
PCLZIP_OPT_REMOVE_PATH, $FileZip['PATH_COURSE'].$_course['directory'].'/document'.$FileZip['PATH_REMOVE']
);
}
@ -233,15 +233,15 @@ function fullexportspecial(){
}else{
$export = true;
return $name;
}
}
}else{
Display::display_error_message(get_lang('ErrorMsgSpecialExport')); //main API
$export = false;
return false;
}
}
}
if($export == true && $name != false) {
if($export == true && $name != false) {
Display::display_confirmation_message(get_lang('BackupCreated').'<br /><br /><a class="bottom-link" href="'.api_get_path(WEB_CODE_PATH).'course_info/download.php?archive='.urlencode($name).'&session=true">'.$name.'</a>', false);
echo '<p><a class="bottom-link" href="'.api_get_path(WEB_CODE_PATH).'admin/index.php">&nbsp;'.get_lang('MainMenu').'</a></p>';
} else{
@ -251,8 +251,8 @@ if($export == true && $name != false) {
$course = $cb->build_session_course();
if($course === false){
Display::display_error_message(get_lang('ErrorMsgSpecialExport'));
form_special_export();
} else {
form_special_export();
} else {
Display::display_normal_message(get_lang('ToExportSpecialSelect'));
CourseSelectForm :: display_form_session_export($course);
}
@ -278,7 +278,7 @@ function form_special_export(){
}
/*
==============================================================================
FOOTER
FOOTER
==============================================================================
*/
Display::display_footer();

@ -141,7 +141,7 @@ if (api_is_allowed_to_edit(null,true) && !is_null($description_id) || $action ==
// Delete a description block
if ($action == 'delete') {
$sql = "DELETE FROM $tbl_course_description WHERE id='".$description_id."'";
api_sql_query($sql, __FILE__, __LINE__);
Database::query($sql, __FILE__, __LINE__);
//update item_property (delete)
api_item_property_update(api_get_course_info(), TOOL_COURSE_DESCRIPTION, Database::escape_string($description_id), 'delete', api_get_user_id());
Display :: display_confirmation_message(get_lang('CourseDescriptionDeleted'));

@ -58,13 +58,13 @@ function show_tools_category($course_tool_category)
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$is_allowed_to_edit = api_is_allowed_to_edit();
$is_platform_admin = api_is_platform_admin();
//condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id,true,true);
switch ($course_tool_category) {
case TOOL_STUDENT_VIEW:
$result = Database::query("SELECT * FROM $course_tool_table WHERE visibility = '1' AND (category = 'authoring' OR category = 'interaction') $condition_session ORDER BY id",__FILE__,__LINE__);
$colLink ="##003399";
@ -219,11 +219,11 @@ function show_tools_category($course_tool_category)
$lnk = '';
foreach($all_tools_list as $toolsRow)
{
if (api_get_session_id()!=0 && in_array($toolsRow['name'],array('course_maintenance','course_setting'))) {
continue;
}
if(!($i%2))
{echo "<tr valign=\"top\">\n";}
@ -255,7 +255,7 @@ function show_tools_category($course_tool_category)
}
}
// Both checks are necessary as is_platform_admin doesn't take student view into account
if( $is_platform_admin && $is_allowed_to_edit)
{
@ -348,10 +348,10 @@ function show_tools_category($course_tool_category)
$tool_name = get_lang(ucfirst($toolsRow['name']));
}
Display::display_icon($toolsRow['image'], $tool_name, array('class'=>'tool-icon','id'=>'toolimage_'.$toolsRow["id"]));
//validacion when belongs to a session
$session_img = api_get_session_image($toolsRow['session_id'], $_user['status']);
echo '</a> ';
echo $my_tool_link;
@ -413,11 +413,11 @@ if (isset($_GET['sent_http_request']) && $_GET['sent_http_request']==1) {
if(isset($_GET['visibility']) && $_GET['visibility']==0) // visibility 1 -> 0
{
if ($_GET["id"]==strval(intval($_GET["id"]))) {
$sql="UPDATE $tool_table SET visibility=0 WHERE id='".$_GET["id"]."'";
Database::query($sql,__FILE__,__LINE__);
$sql="UPDATE $tool_table SET visibility=0 WHERE id='".$_GET["id"]."'";
Database::query($sql,__FILE__,__LINE__);
}
}
/*
-----------------------------------------------------------
REACTIVATE
@ -426,7 +426,7 @@ if (isset($_GET['sent_http_request']) && $_GET['sent_http_request']==1) {
elseif(isset($_GET['visibility'])&& $_GET['visibility']==1) // visibility 0,2 -> 1
{
if ($_GET["id"]==strval(intval($_GET["id"]))) {
Database::query("UPDATE $tool_table SET visibility=1 WHERE id='".$_GET["id"]."'",__FILE__,__LINE__);
Database::query("UPDATE $tool_table SET visibility=1 WHERE id='".$_GET["id"]."'",__FILE__,__LINE__);
}
}
@ -508,45 +508,45 @@ if(api_is_platform_admin())
*
* @param id session id
* @return string session data
*
*
*/
function show_session_data($id_session) {
$session_table = Database::get_main_table(TABLE_MAIN_SESSION);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$session_category_table = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$sql = 'SELECT name, nbr_courses, nbr_users, nbr_classes, DATE_FORMAT(date_start,"%d-%m-%Y") as date_start, DATE_FORMAT(date_end,"%d-%m-%Y") as date_end, lastname, firstname, username, session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end, session_category_id, visibility
FROM '.$session_table.'
LEFT JOIN '.$user_table.'
ON id_coach = user_id
WHERE '.$session_table.'.id='.$id_session;
$rs = api_sql_query($sql, __FILE__, __LINE__);
$rs = Database::query($sql, __FILE__, __LINE__);
$session = api_store_result($rs);
$session = $session[0];
$sql_category = 'SELECT name FROM '.$session_category_table.' WHERE id = "'.intval($session['session_category_id']).'"';
$rs_category = api_sql_query($sql_category, __FILE__, __LINE__);
$rs_category = Database::query($sql_category, __FILE__, __LINE__);
$session_category = '';
if (mysql_num_rows($rs_category) > 0) {
$rows_session_category = api_store_result($rs_category);
$rows_session_category = $rows_session_category[0];
$session_category = $rows_session_category['name'];
}
if ($session['date_start'] == '00-00-0000') {
$msg_date = get_lang('NoTimeLimits');
} else {
$msg_date = get_lang('From').' '.$session['date_start'].' '.get_lang('To').' '.$session['date_end'];
}
$output = '';
if (!empty($session_category)) {
$output .= '<tr><td>'. get_lang('SessionCategory') . ': ' . '<b>' . $session_category .'</b></td></tr>';
}
$output .= '<tr><td style="width:50%">'. get_lang('SessionName') . ': ' . '<b>' . $session['name'] .'</b></td><td>'. get_lang('GeneralCoach') . ': ' . '<b>' . $session['lastname'].' '.$session['firstname'].' ('.$session['username'].')' .'</b></td></tr>';
$output .= '<tr><td>'. get_lang('SessionIdentifier') . ': '. Display::return_icon('star.png', ' ', array('align' => 'absmiddle')) .'</td><td>'. get_lang('Date') . ': ' . '<b>' . $msg_date .'</b></td></tr>';
return $output;
}
@ -604,10 +604,10 @@ if(api_is_allowed_to_edit())
<?php show_tools_category(TOOL_ADMIN_PLATEFORM); ?>
</table>
</div>
<?php
} elseif (api_is_coach()) {
if (api_get_setting('show_session_data') === 'true' && $id_session > 0) {
?>
<div class="courseadminview">

@ -58,24 +58,24 @@ class CourseBuilder
*/
function build($session_id = 0,$course_code = '')
{
if (!empty($session_id) && !empty($course_code)) {
$course_info = api_get_course_info($course_code);
$table_link = Database :: get_course_table(TABLE_LINKED_RESOURCES,$course_info['dbName']);
$table_link = Database :: get_course_table(TABLE_LINKED_RESOURCES,$course_info['dbName']);
$table_properties = Database :: get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']);
$this->build_documents($session_id,$course_code);
$this->build_quizzes($session_id,$course_code);
$this->build_glossary($session_id,$course_code);
$this->build_learnpaths($session_id,$course_code);
$this->build_links($session_id,$course_code);
$this->build_course_descriptions($session_id,$course_code);
} else {
$table_link = Database :: get_course_table(TABLE_LINKED_RESOURCES);
$table_properties = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$this->build_events();
$this->build_announcements();
$this->build_links();
@ -89,7 +89,7 @@ class CourseBuilder
}
//TABLE_LINKED_RESOURCES is the "resource" course table, which is deprecated, apparently
foreach ($this->course->resources as $type => $resources) {
foreach ($resources as $id => $resource) {
$sql = "SELECT * FROM ".$table_link." WHERE source_type = '".$resource->get_type()."' AND source_id = '".$resource->get_id()."'";
@ -99,7 +99,7 @@ class CourseBuilder
}
}
}
foreach ($this->course->resources as $type => $resources)
{
foreach ($resources as $id => $resource)
@ -125,45 +125,45 @@ class CourseBuilder
*/
function build_documents($session_id = 0,$course_code = '')
{
if (!empty($course_code) && !empty($session_id)) {
$course_info = api_get_course_info($course_code);
$table_doc = Database :: get_course_table(TABLE_DOCUMENT,$course_info['dbName']);
$table_prop = Database :: get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']);
$session_id = intval($session_id);
if (!empty($this->course->type) && $this->course->type=='partial') {
if (!empty($this->course->type) && $this->course->type=='partial') {
$sql = 'SELECT * FROM '.$table_doc.' d, '.$table_prop.' p WHERE tool = \''.TOOL_DOCUMENT.'\' AND p.ref = d.id AND p.visibility != 2 AND path NOT LIKE \'/images/gallery%\' AND session_id = '.$session_id.' ORDER BY path';
} else {
$sql = 'SELECT * FROM '.$table_doc.' d, '.$table_prop.' p WHERE tool = \''.TOOL_DOCUMENT.'\' AND p.ref = d.id AND p.visibility != 2 AND session_id = '.$session_id.' ORDER BY path';
}
}
$db_result = Database::query($sql, __FILE__, __LINE__);
while ($obj = Database::fetch_object($db_result))
{
$doc = new Document($obj->id, $obj->path, $obj->comment, $obj->title, $obj->filetype, $obj->size);
$this->course->add_resource($doc);
}
}
} else {
$table_doc = Database :: get_course_table(TABLE_DOCUMENT);
$table_prop = Database :: get_course_table(TABLE_ITEM_PROPERTY);
if (!empty($this->course->type) && $this->course->type=='partial')
if (!empty($this->course->type) && $this->course->type=='partial')
$sql = 'SELECT * FROM '.$table_doc.' d, '.$table_prop.' p WHERE tool = \''.TOOL_DOCUMENT.'\' AND p.ref = d.id AND p.visibility != 2 AND path NOT LIKE \'/images/gallery%\' ORDER BY path';
else
$sql = 'SELECT * FROM '.$table_doc.' d, '.$table_prop.' p WHERE tool = \''.TOOL_DOCUMENT.'\' AND p.ref = d.id AND p.visibility != 2 ORDER BY path';
$db_result = Database::query($sql, __FILE__, __LINE__);
while ($obj = Database::fetch_object($db_result))
{
$doc = new Document($obj->id, $obj->path, $obj->comment, $obj->title, $obj->filetype, $obj->size);
$this->course->add_resource($doc);
}
}
}
}
/**
* Build the forums
@ -230,29 +230,29 @@ class CourseBuilder
*/
function build_links($session_id = 0,$course_code = '')
{
if (!empty($session_id) && !empty($course_code)) {
$course_info = api_get_course_info($course_code);
$table = Database :: get_course_table(TABLE_LINK,$course_info['dbName']);
$table_prop = Database :: get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']);
$session_id = intval($session_id);
$sql = "SELECT * FROM $table l, $table_prop p WHERE p.ref=l.id AND p.tool = '".TOOL_LINK."' AND p.visibility != 2 AND session_id = '$session_id' ORDER BY l.display_order";
$sql = "SELECT * FROM $table l, $table_prop p WHERE p.ref=l.id AND p.tool = '".TOOL_LINK."' AND p.visibility != 2 AND session_id = '$session_id' ORDER BY l.display_order";
} else {
$table = Database :: get_course_table(TABLE_LINK);
$table_prop = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$sql = "SELECT * FROM $table l, $table_prop p WHERE p.ref=l.id AND p.tool = '".TOOL_LINK."' AND p.visibility != 2 ORDER BY l.display_order";
$sql = "SELECT * FROM $table l, $table_prop p WHERE p.ref=l.id AND p.tool = '".TOOL_LINK."' AND p.visibility != 2 ORDER BY l.display_order";
}
$db_result = api_sql_query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql, __FILE__, __LINE__);
while ($obj = Database::fetch_object($db_result))
{
$link = new Link($obj->id, $obj->title, $obj->url, $obj->description, $obj->category_id, $obj->on_homepage);
$this->course->add_resource($link);
if (!empty($course_code)) {
$res = $this->build_link_category($obj->category_id,$course_code);
} else {
$res = $this->build_link_category($obj->category_id);
$res = $this->build_link_category($obj->category_id);
}
if($res > 0)
@ -284,7 +284,7 @@ class CourseBuilder
$course_info = api_get_course_info($course_code);
$link_cat_table = Database :: get_course_table(TABLE_LINK_CATEGORY, $course_info['dbName']);
} else {
$link_cat_table = Database :: get_course_table(TABLE_LINK_CATEGORY);
$link_cat_table = Database :: get_course_table(TABLE_LINK_CATEGORY);
}
$sql = 'SELECT * FROM '.$link_cat_table.' WHERE id = '.$id;
@ -306,17 +306,17 @@ class CourseBuilder
$course_info = api_get_course_info($course_code);
$table_qui = Database :: get_course_table(TABLE_QUIZ_TEST, $course_info['dbName']);
$table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION, $course_info['dbName']);
$table_doc = Database :: get_course_table(TABLE_DOCUMENT, $course_info['dbName']);
$table_doc = Database :: get_course_table(TABLE_DOCUMENT, $course_info['dbName']);
$session_id = intval($session_id);
$sql = 'SELECT * FROM '.$table_qui.' WHERE active >=0 AND session_id = '.$session_id; //select only quizzes with active = 0 or 1 (not -1 which is for deleted quizzes)
} else {
$table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
$table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
$table_doc = Database :: get_course_table(TABLE_DOCUMENT);
$sql = 'SELECT * FROM '.$table_qui.' WHERE active >=0'; //select only quizzes with active = 0 or 1 (not -1 which is for deleted quizzes)
$sql = 'SELECT * FROM '.$table_qui.' WHERE active >=0'; //select only quizzes with active = 0 or 1 (not -1 which is for deleted quizzes)
}
$db_result = api_sql_query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql, __FILE__, __LINE__);
while ($obj = Database::fetch_object($db_result))
{
if (strlen($obj->sound) > 0)
@ -333,21 +333,21 @@ class CourseBuilder
}
$this->course->add_resource($quiz);
}
if (!empty($course_code)) {
$this->build_quiz_questions($course_code);
} else {
$this->build_quiz_questions();
$this->build_quiz_questions();
}
}
/**
* Build the Quiz-Questions
*/
function build_quiz_questions($course_code = '')
{
if (!empty($course_code)) {
$course_info = api_get_course_info($course_code);
$table_qui = Database :: get_course_table(TABLE_QUIZ_TEST,$course_info['dbName']);
@ -358,7 +358,7 @@ class CourseBuilder
$table_qui = Database :: get_course_table(TABLE_QUIZ_TEST);
$table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION);
$table_que = Database :: get_course_table(TABLE_QUIZ_QUESTION);
$table_ans = Database :: get_course_table(TABLE_QUIZ_ANSWER);
$table_ans = Database :: get_course_table(TABLE_QUIZ_ANSWER);
}
// Building normal tests.
@ -521,7 +521,7 @@ class CourseBuilder
$course_info = api_get_course_info($course_code);
$table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION,$course_info['dbName']);
$session_id = intval($session_id);
$sql = 'SELECT * FROM '.$table. ' WHERE session_id ='.$session_id;
$sql = 'SELECT * FROM '.$table. ' WHERE session_id ='.$session_id;
} else {
$table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION);
$sql = 'SELECT * FROM '.$table;
@ -539,23 +539,23 @@ class CourseBuilder
*/
function build_learnpaths($session_id = 0,$course_code = '')
{
if (!empty($session_id) && !empty($course_code)) {
$course_info = api_get_course_info($course_code);
$table_main = Database :: get_course_table(TABLE_LP_MAIN,$course_info['dbName']);
$table_item = Database :: get_course_table(TABLE_LP_ITEM,$course_info['dbName']);
$table_tool = Database::get_course_table(TABLE_TOOL_LIST,$course_info['dbName']);
$sql = 'SELECT * FROM '.$table_main.' WHERE session_id = '.$session_id;
$sql = 'SELECT * FROM '.$table_main.' WHERE session_id = '.$session_id;
} else {
$table_main = Database :: get_course_table(TABLE_LP_MAIN);
$table_item = Database :: get_course_table(TABLE_LP_ITEM);
$table_tool = Database::get_course_table(TABLE_TOOL_LIST);
$sql = 'SELECT * FROM '.$table_main;
$sql = 'SELECT * FROM '.$table_main;
}
$db_result = api_sql_query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql, __FILE__, __LINE__);
while ($obj = Database::fetch_object($db_result))
{
@ -638,33 +638,33 @@ class CourseBuilder
* Build the glossarys
*/
function build_glossary($session_id = 0, $course_code = '') {
if (!empty($session_id) && !empty($course_code)) {
$course_info = api_get_course_info($course_code);
$table_glossary = Database :: get_course_table(TABLE_GLOSSARY,$course_info['dbName']);
$session_id = intval($session_id);
$session_id = intval($session_id);
if (!empty($this->course->type) && $this->course->type=='partial') {
$sql = 'SELECT * FROM '.$table_glossary.' g WHERE session_id = '.$session_id;
} else {
$sql = 'SELECT * FROM '.$table_glossary.' g WHERE session_id = '.$session_id;
}
}
} else {
$table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
$table_glossary = Database :: get_course_table(TABLE_GLOSSARY);
if (!empty($this->course->type) && $this->course->type=='partial') {
$sql = 'SELECT * FROM '.$table_glossary.' g ';
} else {
$sql = 'SELECT * FROM '.$table_glossary.' g ';
}
}
}
$db_result = api_sql_query($sql, __FILE__, __LINE__);
$db_result = Database::query($sql, __FILE__, __LINE__);
while ($obj = Database::fetch_object($db_result))
{
$doc = new Glossary($obj->glossary_id, $obj->name, $obj->description, $obj->display_order);
$this->course->add_resource($doc);
}
}
/*
* build session course by jhon
* */
@ -672,19 +672,19 @@ class CourseBuilder
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$list_course = Database::get_course_list();
$list = array();
$list = array();
foreach($list_course as $_course) {
$this->course = new Course();
$this->course->code = $_course['code'];
$this->course->type = 'partial';
$this->course->path = api_get_path(SYS_COURSE_PATH).$_course['directory'].'/';
$this->course->backup_path = api_get_path(SYS_COURSE_PATH).$_course['directory'];
$this->course->encoding = api_get_system_encoding(); //current platform encoding
$this->course->encoding = api_get_system_encoding(); //current platform encoding
$code_course = $_course['code'];
$sql_session = "SELECT id, name, course_code FROM $tbl_session_course
INNER JOIN $tbl_session ON id_session = id
$sql_session = "SELECT id, name, course_code FROM $tbl_session_course
INNER JOIN $tbl_session ON id_session = id
WHERE course_code = '$code_course' ";
$query_session = api_sql_query($sql_session, __FILE__, __LINE__);
$query_session = Database::query($sql_session, __FILE__, __LINE__);
while($rows_session = mysql_fetch_assoc($query_session)) {
$session = new CourseSession($rows_session['id'], $rows_session['name']);
$this->course->add_resource($session);

@ -83,7 +83,7 @@ class CourseRestorer
* which the resources should be stored. Default: Current Dokeos-course.
*/
function restore($destination_course_code = '',$session_id = 0)
{
{
if ($destination_course_code == '') {
$course_info = api_get_course_info();
$this->course->destination_db = $course_info['dbName'];
@ -94,7 +94,7 @@ class CourseRestorer
$this->course->destination_path = $course_info['directory'];
}
// platform encoding
$course_charset = $this->course->encoding;
$course_charset = $this->course->encoding;
if (!empty($session_id)) {
$this->restore_documents($session_id);
@ -102,7 +102,7 @@ class CourseRestorer
$this->restore_glossary($session_id);
$this->restore_learnpaths($session_id);
$this->restore_links($session_id);
$this->restore_course_descriptions($session_id);
$this->restore_course_descriptions($session_id);
} else {
$this->restore_links();
$this->restore_tool_intro();
@ -110,24 +110,24 @@ class CourseRestorer
$this->restore_announcements();
$this->restore_documents();
$this->restore_scorm_documents();
$this->restore_course_descriptions();
$this->restore_course_descriptions();
$this->restore_quizzes(); // after restore_documents! (for correct import of sound/video)
$this->restore_learnpaths();
$this->restore_surveys();
$this->restore_student_publication();
$this->restore_glossary();
$this->restore_glossary();
}
// Restore the item properties
$table = Database :: get_course_table(TABLE_ITEM_PROPERTY, $this->course->destination_db);
$condition_session = "";
if (!empty($session_id)) {
$condition_session = " , id_session='".intval($session_id)."'";
}
foreach ($this->course->resources as $type => $resources) {
if (is_array($resources)) {
foreach ($resources as $id => $resource) {
@ -183,8 +183,8 @@ class CourseRestorer
* Restore documents
*/
function restore_documents($session_id = 0)
{
if ($this->course->has_resources(RESOURCE_DOCUMENT)) {
{
if ($this->course->has_resources(RESOURCE_DOCUMENT)) {
$table = Database :: get_course_table(TABLE_DOCUMENT, $this->course->destination_db);
$resources = $this->course->resources;
$destination_course['dbName']= $this->course->destination_db;
@ -263,76 +263,76 @@ class CourseRestorer
$new_file_name = $file_name_no_ext.'_'.$i.$ext;
$file_exists = file_exists($path.$new_file_name);
}
if (!empty($session_id)) {
$document_path = explode('/',$document->path,3);
$course_path = $path; // "/var/www/wiener/courses/"
$orig_base_folder = $document_path[1];
$orig_base_path = $course_path.$document_path[0].'/'.$document_path[1];
if (is_dir($orig_base_path)) {
$new_base_foldername = $orig_base_folder; // e.g: "carpeta1"
$new_base_path = $orig_base_path; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1"
if ($_SESSION['orig_base_foldername'] != $new_base_foldername) {
unset($_SESSION['new_base_foldername']);
unset($_SESSION['orig_base_foldername']);
unset($_SESSION['new_base_path']);
}
unset($_SESSION['new_base_path']);
}
$folder_exists = file_exists($new_base_path);
if ($folder_exists) {
$_SESSION['orig_base_foldername'] = $new_base_foldername; // e.g: carpeta1 in session
$x = '';
while ($folder_exists) {
while ($folder_exists) {
$x = $x + 1;
$new_base_foldername = $document_path[1].'_'.$x;
$new_base_foldername = $document_path[1].'_'.$x;
$new_base_path = $orig_base_path.'_'.$x;
if ($_SESSION['new_base_foldername'] == $new_base_foldername) break;
$folder_exists = file_exists($new_base_path);
}
}
$_SESSION['new_base_foldername'] = $new_base_foldername;
$_SESSION['new_base_path'] = $new_base_path;
}
$_SESSION['new_base_path'] = $new_base_path;
}
if (isset($_SESSION['new_base_foldername']) && isset($_SESSION['new_base_path'])) {
if (isset($_SESSION['new_base_foldername']) && isset($_SESSION['new_base_path'])) {
$new_base_foldername = $_SESSION['new_base_foldername'];
$new_base_path = $_SESSION['new_base_path'];
$new_base_path = $_SESSION['new_base_path'];
}
$dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png"
$dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png"
$basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1"
$dest_filename = basename($dest_document_path); // e.g: "collaborative.png"
$base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document"
$dest_filename = basename($dest_document_path); // e.g: "collaborative.png"
$base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document"
$course_info = api_get_course_info($this->course->destination_path);
$path_title = '/'.$new_base_foldername.'/'.$document_path[2];
copy_folder_course_session($basedir_dest_path, $base_path_document,$session_id,$course_info, $document);
copy($course_path.$document->path, $dest_document_path);
$sql = "INSERT INTO $table SET path = '$path_title', comment = '".Database::escape_string($document->comment)."', title = '".Database::escape_string(basename($path_title))."' ,filetype='".$document->file_type."', size= '".$document->size."', session_id = '$session_id'";
Database::query($sql, __FILE__, __LINE__);
$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = Database::get_last_insert_id();
} else {
$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = Database::get_last_insert_id();
} else {
copy($path.$document->path, $path.$new_file_name);
$sql = "INSERT INTO ".$table." SET path = '/".Database::escape_string(substr($new_file_name, 9))."', comment = '".Database::escape_string($document->comment)."', title = '".Database::escape_string($document->title)."' ,filetype='".$document->file_type."', size= '".$document->size."', session_id = '$session_id'";
Database::query($sql, __FILE__, __LINE__);
$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = Database::get_last_insert_id();
}
} else {
}
} else {
copy($this->course->backup_path.'/'.$document->path, $path.$new_file_name);
$sql = "INSERT INTO ".$table." SET path = '/".Database::escape_string(substr($new_file_name, 9))."', comment = '".Database::escape_string($document->comment)."', title = '".Database::escape_string($document->title)."' ,filetype='".$document->file_type."', size= '".$document->size."'";
api_sql_query($sql, __FILE__, __LINE__);
Database::query($sql, __FILE__, __LINE__);
$this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = Database::get_last_insert_id();
}
}
break;
} // end switch
} // end if file exists
else
@ -383,7 +383,7 @@ class CourseRestorer
// Delete sessions for the copy the new folder in session
unset($_SESSION['new_base_foldername']);
unset($_SESSION['orig_base_foldername']);
unset($_SESSION['new_base_path']);
unset($_SESSION['new_base_path']);
}
}
@ -635,14 +635,14 @@ class CourseRestorer
$sql = "SELECT MAX(display_order) FROM $link_table WHERE category_id='" . Database::escape_string($cat_id). "'";
$result = Database::query($sql, __FILE__, __LINE__);
list($max_order) = Database::fetch_array($result);
$condition_session = "";
$condition_session = "";
if (!empty($session_id)) {
$condition_session = " , session_id = '$session_id' ";
$condition_session = " , session_id = '$session_id' ";
}
$sql = "INSERT INTO ".$link_table." SET url = '".Database::escape_string($link->url)."', title = '".Database::escape_string($link->title)."', description = '".Database::escape_string($link->description)."', category_id='".$cat_id."', on_homepage = '".$link->on_homepage."', display_order='".($max_order+1)."' $condition_session";
Database::query($sql, __FILE__, __LINE__);
$this->course->resources[RESOURCE_LINK][$id]->destination_id = Database::get_last_insert_id();
}
@ -674,12 +674,12 @@ class CourseRestorer
*/
function restore_link_category($id,$session_id = 0)
{
$condition_session = "";
$condition_session = "";
if (!empty($session_id)) {
$condition_session = " , session_id = '$session_id' ";
$condition_session = " , session_id = '$session_id' ";
}
if ($id == 0)
return 0;
$link_cat_table = Database :: get_course_table(TABLE_LINK_CATEGORY, $this->course->destination_db);
@ -800,13 +800,13 @@ class CourseRestorer
}
if ($id != -1)
{
$condition_session = "";
$condition_session = "";
if (!empty($session_id)) {
$session_id = intval($session_id);
$condition_session = " , session_id = '$session_id' ";
$condition_session = " , session_id = '$session_id' ";
}
// Normal tests are stored in the database.
$sql = "INSERT INTO ".$table_qui.
" SET title = '".Database::escape_string($quiz->title).
@ -1109,13 +1109,13 @@ class CourseRestorer
$resources = $this->course->resources;
foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) {
$condition_session = "";
if (!empty($session_id)) {
$session_id = intval($session_id);
$condition_session = " , session_id = '$session_id' ";
}
}
$sql = "INSERT INTO ".$table_main." " .
"SET lp_type = '".$lp->lp_type."', " .
"name = '".Database::escape_string($lp->name)."', " .
@ -1175,12 +1175,12 @@ class CourseRestorer
$path = Database::escape_string($item['path']);
if(strval(intval($path)) === $path) {
if (!empty($session_id)) {
$path = intval($path);
$path = intval($path);
} else {
$path = $this->get_new_id($item['item_type'],$path);
}
}
$path = $this->get_new_id($item['item_type'],$path);
}
}
$sql = "INSERT INTO ".$table_item." SET " .
"lp_id = '".Database::escape_string($new_lp_id)."', " .
"item_type='".Database::escape_string($item['item_type'])."', " .
@ -1408,19 +1408,19 @@ class CourseRestorer
$t_item_propery = Database :: get_course_table(TABLE_ITEM_PROPERTY, $this->course->destination_db);
$resources = $this->course->resources;
foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) {
$condition_session = "";
$condition_session = "";
if (!empty($session_id)) {
$session_id = intval($session_id);
$condition_session = " , session_id = '$session_id' ";
$condition_session = " , session_id = '$session_id' ";
}
$sql = "INSERT INTO ".$table_glossary." SET name = '".Database::escape_string($glossary->name)."', description = '".Database::escape_string($glossary->description)."', display_order='".Database::escape_string($glossary->display_order)."' $condition_session ";
Database::query($sql, __FILE__, __LINE__);
$this->course->resources[RESOURCE_GLOSSARY][$id]->destination_id = Database::get_last_insert_id();
}
}
}
}
}
}
}
?>

@ -4,15 +4,15 @@
/**
* ==============================================================================
* Copy resources from one course in a session to another one.
*
*
* @author Christian Fasanando <christian.fasanando@dokeos.com>
* @package dokeos.backup
* ==============================================================================
*/
/* INIT SECTION */
// name of the language file that needs to be included
// name of the language file that needs to be included
$language_file = array('coursebackup','admin');
$cidReset = true;
require_once '../inc/global.inc.php';
@ -56,201 +56,201 @@ $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
/* FUNCTIONS */
function make_select_session_list($name,$sessions,$attr = array()) {
$attrs = '';
if (count($attr) > 0) {
if (count($attr) > 0) {
foreach ($attr as $key => $value) {
$attrs .= ' '.$key.'='.$value. ' ';
}
$attrs .= ' '.$key.'='.$value. ' ';
}
}
$output = '<select name="'.$name.'" '.$attrs.'>';
if (count($sessions) == 0) {
$output .= '<option value = "0">'.get_lang('ThereIsNotStillASession').'</option>';
$output = '<select name="'.$name.'" '.$attrs.'>';
if (count($sessions) == 0) {
$output .= '<option value = "0">'.get_lang('ThereIsNotStillASession').'</option>';
} else {
$output .= '<option value = "0">'.get_lang('SelectASession').'</option>';
$output .= '<option value = "0">'.get_lang('SelectASession').'</option>';
}
if (is_array($sessions)) {
foreach ($sessions as $session) {
$output .= '<option value="'.$session['id'].'">'.$session['name'].' ('.$session['category_name'].')</option>';
$output .= '<option value="'.$session['id'].'">'.$session['name'].' ('.$session['category_name'].')</option>';
}
}
}
$output .= '</select>';
return $output;
}
function display_form() {
global $charset;
$html = '';
$sessions = SessionManager::get_sessions_list();
$sessions = SessionManager::get_sessions_list();
$html .= '<form name="formulaire" method="post" action="'.api_get_self().'" >';
$html .= '<table border="0" cellpadding="5" cellspacing="0" width="100%" align="center">';
$html .= '<tr><td width="30%" align="center"><b>'.get_lang('OriginCoursesFromSession').':</b></td>';
$html .= '<td >&nbsp;</td><td align="center" width="30%"><b>'.get_lang('DestinationCoursesFromSession').':</b></td></tr>';
$html .= '<tr><td width="30%" align="center">'.make_select_session_list('sessions_list_origin',$sessions,array('onchange'=>'xajax_search_courses(this.value,\'origin\')')).'</td>';
$html .= '<td>&nbsp;</td><td width="30%" align="center"><div id="ajax_sessions_list_destination">';
$html .= '<select name="sessions_list_destination" onchange = "xajax_search_courses(this.value,\'destination\')">';
$html .= '<option value = "0">'.get_lang('ThereIsNotStillASession').'</option></select ></div></td></tr>';
$html .= '<option value = "0">'.get_lang('ThereIsNotStillASession').'</option></select ></div></td></tr>';
$html .= '<tr><td width="30%" align="center"><div id="ajax_list_courses_origin">';
$html .= '<select id="origin" name="SessionCoursesListOrigin[]" multiple="multiple" size="20" style="width:320px;"></select></div></td>';
// Options configuration
$html .= '<td align="top"><div class="sectiontitle">'.get_lang('CopyCourse').'</div>';
// Options configuration
$html .= '<td align="top"><div class="sectiontitle">'.get_lang('CopyCourse').'</div>';
$introduction = get_lang('CopyCourseFromSessionToSessionExplanation',true);
$html .= '<div class="normal-message">'.$introduction.'</div>';
$html .= '<div class="normal-message">'.$introduction.'</div>';
$html .= '<div style="height:150px;padding-top:10px;padding-bottom:50px"><h3>'.get_lang('TypeOfCopy').'</h3>';
$html .= '<input type="radio" class="checkbox" id="copy_option_1" name="copy_option" value="full_copy" checked="checked"/>';
$html .= '<label for="copy_option_1">'.get_lang('FullCopy').'</label><br/>';
$html .= '<label for="copy_option_1">'.get_lang('FullCopy').'</label><br/>';
$html .= '<input type="radio" class="checkbox" id="copy_option_2" name="copy_option" value="select_items" disabled="disabled"/>';
$html .= '<label for="copy_option_2"><span id="title_option2" style="color:#aaa">'.get_lang('LetMeSelectItems').'</span></label><br/><br/>';
$html .= '<button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.get_lang('CopyCourse').'</button></div>';
// actions
$html .= '<div class="sectiontitle">';
// link back to the documents overview
$html .= '<a href="../admin/index.php">'.Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('PlatformAdmin'),array('style'=>'vertical-align:middle')).get_lang('Back').' '.get_lang('To').' '.get_lang('PlatformAdmin').'</a>';
$html .= '</div>';
$html .= '</td><td width="30%" align="center">';
$html .= '<div id="ajax_list_courses_destination">';
$html .= '<select id="destination" name="SessionCoursesListDestination[]" multiple="multiple" size="20" style="width:320px;" ></select></div></td>';
$html .= '</tr></table></form>';
$html .= '</tr></table></form>';
echo $html;
}
function search_courses($id_session,$type) {
global $tbl_course, $tbl_session_rel_course, $course_list;
$xajax_response = new XajaxResponse();
$return_origin = '';
$select_destination = '';
if (!empty($type)) {
$id_session = intval($id_session);
if ($type == 'origin') {
// search courses by id_session for origin list
$sql = "SELECT c.code, c.visual_code, c.title, src.id_session
FROM $tbl_course c, $tbl_session_rel_course src
WHERE src.course_code = c.code
AND src.id_session = '".intval($id_session)."'";
$rs = api_sql_query($sql, __FILE__, __LINE__);
AND src.id_session = '".intval($id_session)."'";
$rs = Database::query($sql, __FILE__, __LINE__);
$course_list = array();
$return .= '<select id="origin" name="SessionCoursesListOrigin[]" multiple="multiple" size="20" style="width:320px;" onclick="checkSelected(this.id,\'copy_option_2\',\'title_option2\',\'destination\')">';
while($course = Database :: fetch_array($rs)) {
while($course = Database :: fetch_array($rs)) {
$course_list[] = "'{$course['code']}'";
$course_title=str_replace("'","\'",$course_title);
$course_title=str_replace("'","\'",$course_title);
$return .= '<option value="'.$course['code'].'" title="'.htmlspecialchars($course['title'].' ('.$course['visual_code'].')',ENT_QUOTES).'">'.$course['title'].' ('.$course['visual_code'].')</option>';
}
$return .= '</select>';
$_SESSION['course_list'] = $course_list;
$_SESSION['session_origin'] = $id_session;
// Build select for destination sessions where is not included current session from select origin
if (!empty($id_session)) {
if (!empty($id_session)) {
$session_table =Database::get_main_table(TABLE_MAIN_SESSION);
$session_category_table = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$sql = " SELECT s.id, s.name, sc.name as category_name
FROM $session_table s , $session_category_table sc
WHERE s.session_category_id = sc.id AND s.id NOT IN('$id_session')";
$rs_select_destination = api_sql_query($sql, __FILE__, __LINE__);
$select_destination .= '<select name="sessions_list_destination" onchange = "xajax_search_courses(this.value,\'destination\')">';
$rs_select_destination = Database::query($sql, __FILE__, __LINE__);
$select_destination .= '<select name="sessions_list_destination" onchange = "xajax_search_courses(this.value,\'destination\')">';
$select_destination .= '<option value = "0">'.get_lang('SelectASession').'</option>';
while($session = Database :: fetch_array($rs_select_destination)) {
$select_destination .= '<option value="'.$session['id'].'">'.$session['name'].' ('.$session['category_name'].')</option>';
while($session = Database :: fetch_array($rs_select_destination)) {
$select_destination .= '<option value="'.$session['id'].'">'.$session['name'].' ('.$session['category_name'].')</option>';
}
$select_destination .= '</select>';
$xajax_response -> addAssign('ajax_sessions_list_destination','innerHTML',api_utf8_encode($select_destination));
} else{
$select_destination .= '<select name="sessions_list_destination" onchange = "xajax_search_courses(this.value,\'destination\')">';
$select_destination .= '<select name="sessions_list_destination" onchange = "xajax_search_courses(this.value,\'destination\')">';
$select_destination .= '<option value = "0">'.get_lang('ThereIsNotStillASession').'</option>';
$select_destination .= '</select>';
$xajax_response -> addAssign('ajax_sessions_list_destination','innerHTML',api_utf8_encode($select_destination));
}
// select multiple destination empty
$select_multiple_empty = '<select id="destination" name="SessionCoursesListDestination[]" multiple="multiple" size="20" style="width:320px;"></select>';
// send response by ajax
$xajax_response -> addAssign('ajax_list_courses_origin','innerHTML',api_utf8_encode($return));
$xajax_response -> addAssign('ajax_list_courses_origin','innerHTML',api_utf8_encode($return));
$xajax_response -> addAssign('ajax_list_courses_destination','innerHTML',api_utf8_encode($select_multiple_empty));
} else {
$list_courses_origin = implode(',',$_SESSION['course_list']);
$session_origin = $_SESSION['session_origin'];
// search courses by id_session where course codes is include en courses list destination
$sql = "SELECT c.code, c.visual_code, c.title, src.id_session
FROM $tbl_course c, $tbl_session_rel_course src
WHERE src.course_code = c.code
AND src.id_session = '".intval($id_session)."'
AND c.code IN ($list_courses_origin)";
$rs = api_sql_query($sql, __FILE__, __LINE__);
AND c.code IN ($list_courses_origin)";
$rs = Database::query($sql, __FILE__, __LINE__);
$course_list_destination = array();
$return .= '<select id="destination" name="SessionCoursesListDestination[]" multiple="multiple" size="20" style="width:320px;" onmouseover="this.disabled=true;" onmouseout="this.disabled=false;">';
while($course = Database :: fetch_array($rs)) {
while($course = Database :: fetch_array($rs)) {
$course_list_destination[] = $course['code'];
$course_title=str_replace("'","\'",$course_title);
$return .= '<option value="'.$course['code'].'" title="'.htmlspecialchars($course['title'].' ('.$course['visual_code'].')',ENT_QUOTES).'">'.$course['title'].' ('.$course['visual_code'].')</option>';
$course_title=str_replace("'","\'",$course_title);
$return .= '<option value="'.$course['code'].'" title="'.htmlspecialchars($course['title'].' ('.$course['visual_code'].')',ENT_QUOTES).'">'.$course['title'].' ('.$course['visual_code'].')</option>';
}
$return .= '</select>';
$_SESSION['course_list_destination'] = $course_list_destination;
// send response by ajax
$xajax_response -> addAssign('ajax_list_courses_destination','innerHTML',api_utf8_encode($return));
// disable option from session courses list origin where if no the same con the destination
// disable option from session courses list origin where if no the same con the destination
$sql = "SELECT c.code, c.visual_code, c.title, src.id_session
FROM $tbl_course c, $tbl_session_rel_course src
WHERE src.course_code = c.code
AND src.id_session = '".intval($session_origin)."'";
$result = api_sql_query($sql, __FILE__, __LINE__);
AND src.id_session = '".intval($session_origin)."'";
$result = Database::query($sql, __FILE__, __LINE__);
$return_option_disabled = '<select id="origin" name="SessionCoursesListOrigin[]" multiple="multiple" size="20" style="width:320px;" onclick="checkSelected(this.id,\'copy_option_2\',\'title_option2\',\'destination\')">';
while($cours = Database :: fetch_array($result)) {
$course_title=str_replace("'","\'",$course_title);
while($cours = Database :: fetch_array($result)) {
$course_title=str_replace("'","\'",$course_title);
if (count($course_list_destination) > 0) {
if (!in_array($cours['code'],$course_list_destination)) {
if (!in_array($cours['code'],$course_list_destination)) {
$return_option_disabled .= '<optgroup style="color:#ccc" label="'.$cours['title'].' ('.$cours['visual_code'].')" >'.$cours['title'].' ('.$cours['visual_code'].')</optgroup>';
} else {
$return_option_disabled .= '<option value="'.$cours['code'].'" title="'.htmlspecialchars($cours['title'].' ('.$cours['visual_code'].')',ENT_QUOTES).'">'.$cours['title'].' ('.$cours['visual_code'].')</option>';
}
}
} else {
if (empty($id_session)) {
if (empty($id_session)) {
$return_option_disabled .= '<option value="'.$cours['code'].'" title="'.htmlspecialchars($cours['title'].' ('.$cours['visual_code'].')',ENT_QUOTES).'">'.$cours['title'].' ('.$cours['visual_code'].')</option>';
} else {
} else {
$return_option_disabled .= '<optgroup style="color:#ccc" label="'.$cours['title'].'('.$cours['visual_code'].')" >'.$cours['title'].' ('.$cours['visual_code'].')</optgroup>';
}
}
}
}
}
$return_option_disabled .= '</select>';
// send response by ajax
$xajax_response -> addAssign('ajax_list_courses_origin','innerHTML',api_utf8_encode($return_option_disabled));
$xajax_response -> addAssign('ajax_list_courses_origin','innerHTML',api_utf8_encode($return_option_disabled));
}
}
}
return $xajax_response;
}
$xajax -> processRequests();
@ -258,34 +258,34 @@ $xajax -> processRequests();
/* HTML head extra */
$htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
$htmlHeadXtra[] = '<script language="javascript">
$htmlHeadXtra[] = '<script language="javascript">
function checkSelected(id_select,id_radio,id_title,id_destination) {
var num=0;
obj_origin = document.getElementById(id_select);
obj_destination = document.getElementById(id_destination);
obj_destination = document.getElementById(id_destination);
for (x=0;x<obj_origin.options.length;x++) {
if (obj_origin.options[x].selected) {
if (obj_destination.options.length > 0) {
for (y=0;y<obj_destination.options.length;y++) {
if (obj_origin.options[x].selected) {
if (obj_destination.options.length > 0) {
for (y=0;y<obj_destination.options.length;y++) {
if (obj_origin.options[x].value == obj_destination.options[y].value) {
obj_destination.options[y].selected = true;
}
}
obj_destination.options[y].selected = true;
}
}
}
num++;
} else {
if (obj_destination.options.length > 0) {
for (y=0;y<obj_destination.options.length;y++) {
if (obj_destination.options.length > 0) {
for (y=0;y<obj_destination.options.length;y++) {
if (obj_origin.options[x].value == obj_destination.options[y].value) {
obj_destination.options[y].selected = false;
}
}
}
}
obj_destination.options[y].selected = false;
}
}
}
}
}
if (num == 1) {
document.getElementById(id_radio).disabled = false;
document.getElementById(id_title).style.color = \'#000\';
@ -303,108 +303,108 @@ Display::display_header($nameTools);
/* MAIN CODE */
if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (isset ($_POST['copy_option']) && $_POST['copy_option'] == 'full_copy')) {
if ((isset ($_POST['action']) && $_POST['action'] == 'course_select_form') || (isset ($_POST['copy_option']) && $_POST['copy_option'] == 'full_copy')) {
$destination_course = $origin_course = $destination_session = $origin_session = '';
if (isset ($_POST['action']) && $_POST['action'] == 'course_select_form') {
$destination_course = $_POST['destination_course'];
$origin_course = $_POST['origin_course'];
$destination_session = $_POST['destination_session'];
$origin_session = $_POST['origin_session'];
$course = CourseSelectForm :: get_posted_course('copy_course',$origin_session,$origin_course);
$cr = new CourseRestorer($course);
//$cr->set_file_option($_POST['same_file_name_option']);
$cr->restore($destination_course,$destination_session);
Display::display_normal_message(get_lang('CopyFinished'));
display_form();
display_form();
} else {
$arr_course_origin = array();
$arr_course_destination = array();
$destination_session = '';
$origin_session = '';
if (isset($_POST['SessionCoursesListOrigin'])) {
if (isset($_POST['SessionCoursesListOrigin'])) {
$arr_course_origin = $_POST['SessionCoursesListOrigin'];
}
if (isset($_POST['SessionCoursesListDestination'])) {
if (isset($_POST['SessionCoursesListDestination'])) {
$arr_course_destination = $_POST['SessionCoursesListDestination'];
}
if (isset($_POST['sessions_list_destination'])) {
if (isset($_POST['sessions_list_destination'])) {
$destination_session = $_POST['sessions_list_destination'];
}
if (isset($_POST['sessions_list_origin'])) {
if (isset($_POST['sessions_list_origin'])) {
$origin_session = $_POST['sessions_list_origin'];
}
if ((is_array($arr_course_origin) && count($arr_course_origin) > 0) && !empty($destination_session)) {
foreach ($arr_course_origin as $course_origin) {
$cb = new CourseBuilder();
$course = $cb->build($origin_session,$course_origin);
$cr = new CourseRestorer($course);
//$cr->set_file_option($_POST['same_file_name_option']);
$cr->restore($course_origin,$destination_session);
}
Display::display_normal_message(get_lang('CopyFinished'));
display_form();
} else {
display_form();
} else {
Display::display_error_message(get_lang('YouMustSelectACourseFromOriginalSession'));
display_form();
display_form();
}
}
} elseif (isset ($_POST['copy_option']) && $_POST['copy_option'] == 'select_items') {
// Else, if a CourseSelectForm is requested, show it
if (api_get_setting('show_glossary_in_documents') != 'none') {
// Else, if a CourseSelectForm is requested, show it
if (api_get_setting('show_glossary_in_documents') != 'none') {
Display::display_normal_message(get_lang('ToExportDocumentsWithGlossaryYouHaveToSelectGlossary'));
}
$arr_course_origin = array();
$arr_course_destination = array();
$destination_session = '';
$origin_session = '';
if (isset($_POST['SessionCoursesListOrigin'])) {
if (isset($_POST['SessionCoursesListOrigin'])) {
$arr_course_origin = $_POST['SessionCoursesListOrigin'];
}
if (isset($_POST['SessionCoursesListDestination'])) {
if (isset($_POST['SessionCoursesListDestination'])) {
$arr_course_destination = $_POST['SessionCoursesListDestination'];
}
if (isset($_POST['sessions_list_destination'])) {
if (isset($_POST['sessions_list_destination'])) {
$destination_session = $_POST['sessions_list_destination'];
}
if (isset($_POST['sessions_list_origin'])) {
if (isset($_POST['sessions_list_origin'])) {
$origin_session = $_POST['sessions_list_origin'];
}
if ((is_array($arr_course_origin) && count($arr_course_origin) > 0) && !empty($destination_session)) {
Display::display_normal_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz'));
Display::display_normal_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz'));
$cb = new CourseBuilder();
$course = $cb->build($origin_session,$arr_course_origin[0]);
//$hidden_fields['same_file_name_option'] = $_POST['same_file_name_option'];
$hidden_fields['destination_course'] = $arr_course_origin[0];
$hidden_fields['origin_course'] = $arr_course_origin[0];
$hidden_fields['destination_session'] = $destination_session;
$hidden_fields['origin_session'] = $origin_session;
$hidden_fields['origin_session'] = $origin_session;
CourseSelectForm :: display_form($course,$hidden_fields, true);
echo '<div style="float:right"><a href="javascript:window.back();">'.Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('PlatformAdmin'),array('style'=>'vertical-align:middle')).get_lang('Back').'</a></div>';
} else {
Display::display_error_message(get_lang('You must select a course from original session and select a destination session'));
display_form();
}
} else {
} else {
display_form();
}
/* FOOTER */
/* FOOTER */
Display::display_footer();

@ -626,18 +626,18 @@ if ($formSent) {
// goes to the script that will show the result of the exercise
if ($exerciseType == ALL_ON_ONE_PAGE) {
header("Location: exercise_result.php?id=$exe_id&exerciseType=$exerciseType&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id");
} else {
} else {
if ($exe_id != '') {
//clean incomplete
$update_query = 'UPDATE ' . $stat_table . ' SET ' . "status = '', data_tracking='', exe_date = '" . date('Y-m-d H:i:s') . "'" . ' WHERE exe_id = ' . Database::escape_string($exe_id);
api_sql_query($update_query, __FILE__, __LINE__);
}
Database::query($update_query, __FILE__, __LINE__);
}
header("Location: exercise_show.php?id=$exe_id&exerciseType=$exerciseType&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id");
}
exit ();
} else {
header("Location: exercice_submit.php?exerciseId=$exerciseId");
exit;
exit;
}
}
if ($debug > 0) {
@ -1085,10 +1085,10 @@ if (!empty ($error)) {
$submit_btn .= "</button>";
echo $submit_btn;
}
}
echo "</table>
</td>
</tr>

@ -144,24 +144,24 @@ function save_glossary($values)
// get the maximum display order of all the glossary items
$max_glossary_item = get_max_glossary_item();
// session_id
$session_id = api_get_session_id();
// check if the glossary term already exists
if (glossary_exists($values['glossary_title']))
{
// display the feedback message
Display::display_error_message('GlossaryTermAlreadyExistsYouShouldEditIt');
} else {
$sql = "INSERT INTO $t_glossary (name, description, display_order, session_id)
$sql = "INSERT INTO $t_glossary (name, description, display_order, session_id)
VALUES(
'".Database::escape_string(Security::remove_XSS($values['glossary_title']))."',
'".Database::escape_string(Security::remove_XSS(stripslashes(api_html_entity_decode($values['glossary_comment'])),COURSEMANAGERLOWSECURITY))."',
'".(int)($max_glossary_item + 1)."',
'".Database::escape_string($session_id)."'
)";
$result = api_sql_query($sql, __FILE__, __LINE__);
$result = Database::query($sql, __FILE__, __LINE__);
$id = Database::get_last_insert_id();
if ($id>0) {
//insert into item_property
@ -300,10 +300,10 @@ function delete_glossary($glossary_id)
$sql = "DELETE FROM $t_glossary WHERE glossary_id='".Database::escape_string($glossary_id)."'";
$result = Database::query($sql, __FILE__, __LINE__);
//update item_property (delete)
api_item_property_update(api_get_course_info(), TOOL_GLOSSARY, Database::escape_string($glossary_id), 'delete', api_get_user_id());
// reorder the remaining terms
reorder_glossary();
$_SESSION['max_glossary_display'] = get_max_glossary_item();
@ -340,9 +340,9 @@ function display_glossary()
$table->set_header(3, get_lang('CreationDate'), false);
$table->set_header(4, get_lang('UpdateDate'), false);
if (api_is_allowed_to_edit(null,true)) {
$table->set_header(5, get_lang('Actions'), false);
$table->set_header(5, get_lang('Actions'), false);
$table->set_column_filter(5, 'actions_filter');
}
}
$table->display();
}
if ($_SESSION['glossary_view'] == 'list')
@ -406,17 +406,17 @@ function get_glossary_data($from, $number_of_items, $column, $direction)
// Database table definition
$t_glossary = Database :: get_course_table(TABLE_GLOSSARY);
$t_item_propery = Database :: get_course_table(TABLE_ITEM_PROPERTY);
if (api_is_allowed_to_edit(null,true)) {
$col5 = ", glossary.glossary_id as col5";
} else {
$col5 = " ";
}
//condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
$sql = "SELECT
glossary.display_order as col0,
glossary.name as col1,
@ -425,41 +425,41 @@ function get_glossary_data($from, $number_of_items, $column, $direction)
ip.lastedit_date as col4
$col5,
glossary.session_id as session_id
FROM $t_glossary glossary, $t_item_propery ip
FROM $t_glossary glossary, $t_item_propery ip
WHERE glossary.glossary_id = ip.ref
AND tool = '".TOOL_GLOSSARY."' $condition_session";
$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items";
$res = api_sql_query($sql, __FILE__, __LINE__);
$res = Database::query($sql, __FILE__, __LINE__);
$return = array();
$array = array();
while ($data = Database::fetch_array($res)) {
$array[0] = $data[0];
//validacion when belongs to a session
$session_img = api_get_session_image($data['session_id'], $_user['status']);
$array[1] = $data[1] . $session_img;
if (!$_SESSION['glossary_view'] || $_SESSION['glossary_view'] == 'table') {
$array[2] = str_replace(array('<p>','</p>'),array('','<br />'),$data[2]);
} else {
$array[2] = $data[2];
}
$array[3] = $data[3];
$array[4] = $data[4];
if (api_is_allowed_to_edit(null,true)) {
$array[5] = $data[5];
}
$return[] = $array;
}
return $return;
return $return;
}
/**
@ -501,10 +501,10 @@ function actions_filter($glossary_id,$url_params,$row)
}
}
$return .= '<a href="'.api_get_self().'?action=edit_glossary&amp;glossary_id='.$row[5].'&msg=edit">'.Display::return_icon('edit.gif',get_lang('Edit')).'</a>';
$glossary_data = get_glossary_information($row[5]);
$glossary_term = $glossary_data['glossary_title'];
$return .= '<a href="'.api_get_self().'?action=delete_glossary&amp;glossary_id='.$row[5].'" onclick="return confirmation(\''.$glossary_term.'\');">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
return $return;
}

@ -633,8 +633,8 @@ function update_Db_course($courseDbName)
)";
Database::query($sql, __FILE__, __LINE__);
$sql = "ALTER TABLE `".$TABLEQUIZ . "` ADD INDEX ( session_id ) ";
api_sql_query($sql, __FILE__, __LINE__);
Database::query($sql, __FILE__, __LINE__);
// Exercise tool - questions
$sql = "
CREATE TABLE `".$TABLEQUIZQUESTIONLIST . "` (
@ -851,7 +851,7 @@ function update_Db_course($courseDbName)
Database::query($sql, __FILE__, __LINE__);
$sql = "ALTER TABLE `".$TABLETOOLLINK . "` ADD INDEX ( session_id ) ";
Database::query($sql, __FILE__, __LINE__);
$sql = "
CREATE TABLE `".$TABLETOOLLINKCATEGORIES . "` (
id smallint unsigned NOT NULL auto_increment,
@ -906,7 +906,7 @@ function update_Db_course($courseDbName)
Database::query($sql, __FILE__, __LINE__);
$sql = "ALTER TABLE `".$TABLETOOLWIKI . "` ADD INDEX ( session_id ) ";
Database::query($sql, __FILE__, __LINE__);
//
$sql = "CREATE TABLE `".$TABLEWIKICONF . "` (
page_id int NOT NULL default 0,
@ -1055,7 +1055,7 @@ function update_Db_course($courseDbName)
visibility tinyint NOT NULL default '1',
start_visible datetime NOT NULL default '0000-00-00 00:00:00',
end_visible datetime NOT NULL default '0000-00-00 00:00:00',
id_session INT NOT NULL DEFAULT 0
id_session INT NOT NULL DEFAULT 0
) TYPE=MyISAM;", __FILE__, __LINE__);
Database::query("ALTER TABLE `$TABLEITEMPROPERTY` ADD INDEX idx_item_property_toolref (tool,ref)", __FILE__, __LINE__);
@ -1316,7 +1316,7 @@ function update_Db_course($courseDbName)
}
$sql = "ALTER TABLE `".$tbl_blogs . "` ADD INDEX ( session_id ) ";
Database::query($sql, __FILE__, __LINE__);
$sql = "
CREATE TABLE `" . $tbl_blogs_comments . "` (
comment_id int NOT NULL AUTO_INCREMENT ,
@ -1658,7 +1658,7 @@ function update_Db_course($courseDbName)
$result = Database::query($sql, __FILE__, __LINE__) or die(mysql_error($sql));
$sql = "ALTER TABLE `".$TBL_GLOSSARY . "` ADD INDEX ( session_id ) ";
Database::query($sql, __FILE__, __LINE__);
// table notebook
$sql = "CREATE TABLE `".$TBL_NOTEBOOK."` (
notebook_id int unsigned NOT NULL auto_increment,
@ -2002,7 +2002,7 @@ function fill_Db_course($courseDbName, $courseRepository, $language,$default_doc
Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_GROUP . "','group/group.php','group.gif','".string2binary(api_get_setting('course_create_active_tools', 'groups')) . "','0','squaregrey.gif','NO','_self','interaction','0')", __FILE__, __LINE__);
Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_CHAT . "','chat/chat.php','chat.gif','".string2binary(api_get_setting('course_create_active_tools', 'chat')) . "','0','squaregrey.gif','NO','_self','interaction','0')", __FILE__, __LINE__);
Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_STUDENTPUBLICATION . "','work/work.php','works.gif','".string2binary(api_get_setting('course_create_active_tools', 'student_publications')) . "','0','squaregrey.gif','NO','_self','interaction','0')", __FILE__, __LINE__);
Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_SURVEY."','survey/survey_list.php','survey.gif','".string2binary(api_get_setting('course_create_active_tools', 'survey')) . "','0','squaregrey.gif','NO','_self','interaction','0')", __FILE__, __LINE__);
Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_SURVEY."','survey/survey_list.php','survey.gif','".string2binary(api_get_setting('course_create_active_tools', 'survey')) . "','0','squaregrey.gif','NO','_self','interaction','0')", __FILE__, __LINE__);
Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_WIKI ."','wiki/index.php','wiki.gif','".string2binary(api_get_setting('course_create_active_tools', 'wiki')) . "','0','squaregrey.gif','NO','_self','interaction','0')", __FILE__, __LINE__);
Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_GRADEBOOK."','gradebook/index.php','gradebook.gif','".string2binary(api_get_setting('course_create_active_tools', 'gradebook')). "','0','squaregrey.gif','NO','_self','authoring','0')", __FILE__, __LINE__);
Database::query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_GLOSSARY."','glossary/index.php','glossary.gif','".string2binary(api_get_setting('course_create_active_tools', 'glossary')). "','0','squaregrey.gif','NO','_self','authoring','0')", __FILE__, __LINE__);
@ -2185,7 +2185,7 @@ function fill_Db_course($courseDbName, $courseRepository, $language,$default_doc
$add_wikipedia_link_sql = " INSERT INTO `".$TABLETOOLLINK . "` (url, title, description, category_id, display_order, on_homepage, target)
VALUES ('http://www.wikipedia.org','Wikipedia','".lang2db(get_lang('Wikipedia')) . "','0','1','0','_self')";
api_sql_query($add_wikipedia_link_sql, __FILE__, __LINE__);
Database::query($add_wikipedia_link_sql, __FILE__, __LINE__);
//we need to add the item properties too!
$insert_id = Database :: get_last_insert_id();
$sql = "INSERT INTO `".$TABLEITEMPROPERTY . "` (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('" . TOOL_LINK . "',1,NOW(),NOW(),$insert_id,'LinkAdded',1,0,NULL,1)";

@ -865,30 +865,30 @@ class CourseManager {
$sql_query = "SELECT * FROM $table WHERE user_id = $user_id AND course_code = '$course_code'";
$sql_result = Database::query($sql_query, __FILE__, __LINE__);
$result = Database::fetch_array($sql_result);
if (!isset ($result) || empty ($result)) {
if ($in_a_session) {
$sql = 'SELECT 1 FROM '.Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER).'
WHERE id_user = '.$user_id.' AND course_code="'.$course_code.'"';
$rs = api_sql_query($sql, __FILE__, __LINE__);
$rs = Database::query($sql, __FILE__, __LINE__);
if (Database::num_rows($rs)>0) {
return true;
} else {
$sql = 'SELECT 1 FROM '.Database :: get_main_table(TABLE_MAIN_SESSION_COURSE).'
WHERE id_coach = '.$user_id.' AND course_code="'.$course_code.'"';
$rs = api_sql_query($sql, __FILE__, __LINE__);
$rs = Database::query($sql, __FILE__, __LINE__);
if (Database::num_rows($rs)>0) {
return true;
} else {
$sql = 'SELECT 1 FROM '.Database::get_main_table(TABLE_MAIN_SESSION).' WHERE id='.intval($_SESSION['id_session']).' AND id_coach='.$user_id;
$rs = api_sql_query($sql, __FILE__, __LINE__);
$rs = Database::query($sql, __FILE__, __LINE__);
if (Database::num_rows($rs)>0) {
return true;
}
}
}
} else {
} else {
return false; //user is not registered in course
}
} else {
@ -2028,16 +2028,16 @@ class CourseManager {
$rs = Database::query($sql, __FILE__, __LINE__);
return Database::result($rs, 0, 'code');
}
public static function get_session_category_id_by_session_id($session_id) {
$t_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$t_session = Database::get_main_table(TABLE_MAIN_SESSION);
$t_session = Database::get_main_table(TABLE_MAIN_SESSION);
$sql='SELECT sc.id session_category FROM '.$t_session_category.' sc INNER JOIN '.$t_session.' s ON
sc.id=s.session_category_id WHERE s.id="'.Database::escape_string($session_id).'"';
$rs=Database::query($sql,__FILE__,__LINE__);
return Database::result($rs,0,'session_category');
}
/**
* Get the database name of a course by the code
* @param string The course code

@ -1163,7 +1163,7 @@ function add_document($_course,$path,$filetype,$filesize,$title,$comment=NULL, $
(`path`, `filetype`, `size`, `title`, `comment`, `readonly`, `session_id`)
VALUES ('$path','$filetype','$filesize','".
Database::escape_string(htmlspecialchars($title, ENT_QUOTES, $charset))."', '$comment', $readonly, $session_id)";
if(api_sql_query($sql,__FILE__,__LINE__))
if(Database::query($sql,__FILE__,__LINE__))
{
//display_message("Added to database (id ".mysql_insert_id().")!");
return Database::insert_id();

@ -1425,29 +1425,29 @@ function api_get_session_info($session_id) {
$sesion_id = intval(Database::escape_string($session_id));
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$sql = "SELECT * FROM $tbl_session WHERE id = $session_id";
$result = api_sql_query($sql,__FILE__,__LINE__);
if (Database::num_rows($result)>0) {
$result = Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($result)>0) {
$data = Database::fetch_array($result, 'ASSOC');
}
}
return $data;
return $data;
}
/**
* Gets the session visibility by session id
* @param int session id
* @return int 0 = session still available, SESSION_VISIBLE_READ_ONLY = 1, SESSION_VISIBLE = 2, SESSION_INVISIBLE = 3
*/
function api_get_session_visibility($session_id) {
*/
function api_get_session_visibility($session_id) {
$visibility = 0; //means that the session is still available
if (!empty($session_id)) {
$sesion_id = intval(Database::escape_string($session_id));
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$is_coach = api_is_course_coach();
$condition_date_end = "";
$condition_date_end = "";
if ($is_coach) {
$condition_date_end = " AND (CURDATE() > (SELECT adddate(date_end,nb_days_access_after_end) FROM $tbl_session WHERE id = $session_id) AND date_end != '0000-00-00') ";
} else {
@ -1455,9 +1455,9 @@ function api_get_session_visibility($session_id) {
}
$sql = "SELECT visibility FROM $tbl_session
WHERE id = $session_id $condition_date_end "; // session is old and is not unlimited
WHERE id = $session_id $condition_date_end "; // session is old and is not unlimited
$result = api_sql_query($sql,__FILE__,__LINE__);
$result = Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($result)>0) {
$row = Database::fetch_array($result, 'ASSOC');
@ -1466,32 +1466,32 @@ function api_get_session_visibility($session_id) {
$visibility = 0;
}
}
return $visibility;
return $visibility;
}
/**
* Gets the visibility of an session of a course that a student have
* @param int session id
* @param string Dokeos course code
* @param int user id
* @param string Dokeos course code
* @param int user id
* @return int 0= Session available (in date), SESSION_VISIBLE_READ_ONLY = 1, SESSION_VISIBLE = 2, SESSION_INVISIBLE = 3
*/
function api_get_session_visibility_by_user($session_id,$course_code, $user_id) {
*/
function api_get_session_visibility_by_user($session_id,$course_code, $user_id) {
$visibility = 0; //means that the session is still available
if (!empty($session_id) && !empty($user_id)){
$sesion_id = intval(Database::escape_string($session_id));
$user_id = intval(Database::escape_string($user_id));
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION_REL_COURSE_REL_USER);
$sql = "SELECT visibility FROM $tbl_session
WHERE id_session = $session_id AND id_user = $user_id AND course_code = '$course_code'"; // session old
$result = api_sql_query($sql,__FILE__,__LINE__);
if (Database::num_rows($result)>0) {
WHERE id_session = $session_id AND id_user = $user_id AND course_code = '$course_code'"; // session old
$result = Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($result)>0) {
$row = Database::fetch_array($result, 'ASSOC');
$visibility = $row['visibility'];
} else {
$visibility = 0;
}
}
return $visibility;
return $visibility;
}
/**
@ -1516,22 +1516,22 @@ function api_get_session_image($session_id, $status_id) {
* This function add an additional condition according to the session of the course
* @param int session id
* @param bool optional, true if more than one condition false if the only condition in the query
* @param bool optional, true if condition is only with session_id = current session id, false if condition is with 0 else
* @param bool optional, true if condition is only with session_id = current session id, false if condition is with 0 else
* @return string condition of the session
*/
function api_get_session_condition($session_id, $state = true, $both = false) {
$session_id = intval($session_id);
$session_id = intval($session_id);
//condition to show resources by session
$condition_session = '';
$condition_add = $state == false ? " WHERE " : " AND ";
if ($session_id > 0) {
if (api_is_session_in_category($session_id,'20091U') || $both) {
$condition_session = $condition_add . " ( session_id = ".(int)$session_id." OR session_id = 0 ) ";
if (api_is_session_in_category($session_id,'20091U') || $both) {
$condition_session = $condition_add . " ( session_id = ".(int)$session_id." OR session_id = 0 ) ";
} else {
$condition_session = $condition_add . " session_id = ".(int)$session_id." ";
}
}
} else {
$condition_session = $condition_add . " session_id = 0 ";
}
@ -1540,7 +1540,7 @@ function api_get_session_condition($session_id, $state = true, $both = false) {
}
/**
* This function returns information about coachs from a course in session
* This function returns information about coachs from a course in session
* @param int - optional, session id
* @param string - optional, course code
* @return array - array containing user_id, lastname, firstname, username.
@ -1550,29 +1550,29 @@ function api_get_coachs_from_course($session_id=0,$course_code='') {
if (!empty($session_id)) {
$session_id = intval($session_id);
} else {
$session_id = api_get_session_id();
$session_id = api_get_session_id();
}
if (!empty($course_code)) {
$course_code = Database::escape_string($course_code);
} else {
$course_code = api_get_course_id();
}
$course_code = api_get_course_id();
}
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$coachs = array();
$sql = "SELECT u.user_id,u.lastname,u.firstname,u.username FROM $tbl_user u,$tbl_session_course_user scu
WHERE u.user_id = scu.id_user AND scu.id_session = '$session_id' AND scu.course_code = '$course_code' AND scu.status = 2";
WHERE u.user_id = scu.id_user AND scu.id_session = '$session_id' AND scu.course_code = '$course_code' AND scu.status = 2";
$rs = Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($rs) > 0) {
while ($row = Database::fetch_array($rs)) {
$coachs[] = $row;
}
return $coachs;
return $coachs;
} else {
return false;
}
@ -1669,36 +1669,36 @@ function api_is_coach($session_id = 0, $course_code = '') {
if (!empty($session_id)) {
$session_id = intval($session_id);
} else {
$session_id = api_get_session_id();
$session_id = api_get_session_id();
}
if (!empty($course_code)) {
$course_code = Database::escape_string($course_code);
} else {
$course_code = api_get_course_id();
}
$course_code = api_get_course_id();
}
$sql = "SELECT DISTINCT id, name, date_start, date_end
FROM session
INNER JOIN session_rel_course_rel_user session_rc_ru
ON session_rc_ru.id_user = '".Database::escape_string($_user['user_id'])."'
WHERE session_rc_ru.course_code = '$course_code' AND session_rc_ru.status = 2 AND session_rc_ru.id_session = '$session_id'
ORDER BY date_start, date_end, name";
$result = api_sql_query($sql,__FILE__,__LINE__);
WHERE session_rc_ru.course_code = '$course_code' AND session_rc_ru.status = 2 AND session_rc_ru.id_session = '$session_id'
ORDER BY date_start, date_end, name";
$result = Database::query($sql,__FILE__,__LINE__);
$sessionIsCoach = api_store_result($result);
$sql = "SELECT DISTINCT id, name, date_start, date_end
FROM session
WHERE session.id_coach = '".Database::escape_string($_user['user_id'])."'
AND id = '$session_id'
ORDER BY date_start, date_end, name";
$result = api_sql_query($sql,__FILE__,__LINE__);
$sessionIsCoach = array_merge($sessionIsCoach , api_store_result($result));
AND id = '$session_id'
ORDER BY date_start, date_end, name";
$result = Database::query($sql,__FILE__,__LINE__);
$sessionIsCoach = array_merge($sessionIsCoach , api_store_result($result));
return (count($sessionIsCoach) > 0);
}
/**
@ -1711,22 +1711,22 @@ function api_is_session_admin() {
}
/**
* This function check is a session is assigned into a category
* This function check is a session is assigned into a category
* @param int - session id
* @param string - category name
* @param string - category name
* @return bool - true if is found, otherwise false
*/
function api_is_session_in_category($session_id,$category_name) {
$session_id = intval($session_id);
$category_name = Database::escape_string($category_name);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$sql = "select 1 FROM $tbl_session WHERE $session_id IN (SELECT s.id FROM $tbl_session s, $tbl_session_category sc WHERE s.session_category_id = sc.id AND sc.name LIKE '%$category_name' )";
$rs = Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($rs) > 0) {
return true;
} else {
@ -1912,9 +1912,9 @@ function api_display_debug_info($debug_info) {
*/
function api_is_allowed_to_edit($tutor=false,$coach=false,$session_coach = false) {
$is_courseAdmin = api_is_course_admin() || api_is_platform_admin();
if (!$is_courseAdmin && $tutor == true) { //if we also want to check if the user is a tutor...
if (!$is_courseAdmin && $tutor == true) { //if we also want to check if the user is a tutor...
$is_courseAdmin = $is_courseAdmin || api_is_course_tutor();
}
if (!$is_courseAdmin && $coach == true) { //if we also want to check if the user is a coach...';
@ -1922,22 +1922,22 @@ function api_is_allowed_to_edit($tutor=false,$coach=false,$session_coach = false
// check if session visibility is read only for coachs
$is_allowed_coach_to_edit = api_is_course_coach();
$my_session_id = api_get_session_id();
$session_visibility = api_get_session_visibility($my_session_id);
$session_visibility = api_get_session_visibility($my_session_id);
if ($session_visibility==SESSION_VISIBLE_READ_ONLY) {
$is_allowed_coach_to_edit = false;
}
}
if (api_get_setting('allow_coach_to_edit_course_session') == 'true') { // check if coach is allowed to edit a course
$is_courseAdmin = $is_courseAdmin || $is_allowed_coach_to_edit;
} else {
$is_courseAdmin = $is_courseAdmin;
}
}
}
if (!$is_courseAdmin && $session_coach == true) {
if (!$is_courseAdmin && $session_coach == true) {
$is_courseAdmin = $is_courseAdmin || api_is_coach();
}
if (api_get_setting('student_view_enabled') == 'true') { //check if the student_view is enabled, and if so, if it is activated
$is_allowed = $is_courseAdmin && $_SESSION['studentview'] != "studentview";
return $is_allowed;
@ -1947,31 +1947,31 @@ function api_is_allowed_to_edit($tutor=false,$coach=false,$session_coach = false
}
/**
* Checks if a student can edit contents in a session depending
* on the session visibility
* Checks if a student can edit contents in a session depending
* on the session visibility
* @param bool Whether to check if the user has the tutor role
* @param bool Whether to check if the user has the coach role
* @return boolean, true: the user has the rights to edit, false: he does not
*/
function api_is_allowed_to_session_edit($tutor=false,$coach=false) {
if (api_is_allowed_to_edit($tutor, $coach)) {
// if I'm a teacher, I will return true in order to not affect the normal behaviour of Dokeos tools
// if I'm a teacher, I will return true in order to not affect the normal behaviour of Dokeos tools
return true;
} else {
if (api_get_session_id()==0) {
// i'm not in a session so i will return true to not affect the normal behaviour of Dokeos tools
// i'm not in a session so i will return true to not affect the normal behaviour of Dokeos tools
return true;
} else {
//I'm in a session and I'm a student
//I'm in a session and I'm a student
$session_id= api_get_session_id();
// Get the session visibility
$session_visibility = api_get_session_visibility($session_id); //if 0 the session is still available
$session_visibility = api_get_session_visibility($session_id); //if 0 the session is still available
if ($session_visibility!=0) {
//@todo we could load the session_rel_course_rel_user permission to increase the level of detail
//echo api_get_user_id();
//echo api_get_course_id();
switch($session_visibility) {
switch($session_visibility) {
case SESSION_VISIBLE_READ_ONLY: //1
return false;
break;
@ -2248,7 +2248,7 @@ function api_get_item_visibility($_course, $tool, $id) {
* @desc update the item_properties table (if entry not exists, insert) of the course
*/
function api_item_property_update($_course, $tool, $item_id, $lastedit_type, $user_id, $to_group_id = 0, $to_user_id = NULL, $start_visible = 0, $end_visible = 0, $session_id = 0) {
// definition of variables
$tool = Database::escape_string($tool);
$item_id = Database::escape_string($item_id);
@ -2266,33 +2266,33 @@ function api_item_property_update($_course, $tool, $item_id, $lastedit_type, $us
if (!empty($session_id)) {
$session_id = intval($session_id);
}
// Definition of tables
$TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY,$_course['dbName']);
$TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY,$_course['dbName']);
if ($to_user_id <= 0) {
$to_user_id = NULL; //no to_user_id set
}
if (!is_null($to_user_id)) {
// $to_user_id has more priority than $to_group_id
$to_field = "to_user_id";
$to_value = $to_user_id;
} else {
// $to_user_id is not set
// $to_user_id is not set
$to_field = "to_group_id";
$to_value = $to_group_id;
}
}
// set filters for $to_user_id and $to_group_id, with priority for $to_user_id
$condition_session = "";
if (!empty($session_id)) {
$condition_session = " AND id_session = '$session_id' ";
if (!empty($session_id)) {
$condition_session = " AND id_session = '$session_id' ";
}
$filter = "tool='$tool' AND ref='$item_id' $condition_session ";
$filter = "tool='$tool' AND ref='$item_id' $condition_session ";
if ($item_id == "*") {
$filter = "tool='$tool' AND visibility<>'2' $condition_session"; // for all (not deleted) items of the tool
}
@ -2313,79 +2313,79 @@ function api_item_property_update($_course, $tool, $item_id, $lastedit_type, $us
switch ($lastedit_type) {
case "delete" : // delete = make item only visible for the platform admin
$visibility = '2';
if (!empty($session_id)) {
// check if session id already exist into itemp_properties for updating visibility or add it
// check if session id already exist into itemp_properties for updating visibility or add it
$sql = "select id_session FROM $TABLE_ITEMPROPERTY WHERE tool = '$tool' AND ref='$item_id' AND id_session = '$session_id'";
$rs = Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($rs) > 0) {
if (Database::num_rows($rs) > 0) {
$sql = "UPDATE $TABLE_ITEMPROPERTY
SET lastedit_type='".str_replace('_', '', ucwords($tool))."Deleted', lastedit_date='$time', lastedit_user_id='$user_id', visibility='$visibility', id_session = '$session_id' $set_type
WHERE $filter";
} else {
$sql = "INSERT INTO $TABLE_ITEMPROPERTY
(tool, ref, insert_date, insert_user_id, lastedit_date, lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, id_session)
VALUES ('$tool','$item_id','$time', '$user_id', '$time', '$lastedit_type','$user_id', '$to_value', '$visibility', '$start_visible','$end_visible', '$session_id')";
VALUES ('$tool','$item_id','$time', '$user_id', '$time', '$lastedit_type','$user_id', '$to_value', '$visibility', '$start_visible','$end_visible', '$session_id')";
}
} else {
} else {
$sql = "UPDATE $TABLE_ITEMPROPERTY
SET lastedit_type='".str_replace('_', '', ucwords($tool))."Deleted', lastedit_date='$time', lastedit_user_id='$user_id', visibility='$visibility' $set_type
WHERE $filter";
WHERE $filter";
}
break;
case "visible" : // change item to visible
case "visible" : // change item to visible
$visibility = '1';
if (!empty($session_id)) {
// check if session id already exist into itemp_properties for updating visibility or add it
// check if session id already exist into itemp_properties for updating visibility or add it
$sql = "select id_session FROM $TABLE_ITEMPROPERTY WHERE tool = '$tool' AND ref='$item_id' AND id_session = '$session_id'";
$rs = Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($rs) > 0) {
if (Database::num_rows($rs) > 0) {
$sql = "UPDATE $TABLE_ITEMPROPERTY
SET lastedit_type='".str_replace('_', '', ucwords($tool))."Visible', lastedit_date='$time', lastedit_user_id='$user_id', visibility='$visibility', id_session = '$session_id' $set_type
WHERE $filter";
} else {
$sql = "INSERT INTO $TABLE_ITEMPROPERTY
(tool, ref, insert_date, insert_user_id, lastedit_date, lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, id_session)
VALUES ('$tool','$item_id','$time', '$user_id', '$time', '$lastedit_type','$user_id', '$to_value', '$visibility', '$start_visible','$end_visible', '$session_id')";
VALUES ('$tool','$item_id','$time', '$user_id', '$time', '$lastedit_type','$user_id', '$to_value', '$visibility', '$start_visible','$end_visible', '$session_id')";
}
} else {
} else {
$sql = "UPDATE $TABLE_ITEMPROPERTY
SET lastedit_type='".str_replace('_', '', ucwords($tool))."Visible', lastedit_date='$time', lastedit_user_id='$user_id', visibility='$visibility' $set_type
WHERE $filter";
}
WHERE $filter";
}
break;
case "invisible" : // change item to invisible
$visibility = '0';
if (!empty($session_id)) {
// check if session id already exist into itemp_properties for updating visibility or add it
$visibility = '0';
if (!empty($session_id)) {
// check if session id already exist into itemp_properties for updating visibility or add it
$sql = "Select id_session FROM $TABLE_ITEMPROPERTY WHERE tool = '$tool' AND ref='$item_id' AND id_session = '$session_id'";
$rs = Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($rs) > 0) {
if (Database::num_rows($rs) > 0) {
$sql = "UPDATE $TABLE_ITEMPROPERTY
SET lastedit_type='".str_replace('_', '', ucwords($tool))."Invisible', lastedit_date='$time', lastedit_user_id='$user_id', visibility='$visibility', id_session = '$session_id' $set_type
WHERE $filter";
WHERE $filter";
} else {
$sql = "INSERT INTO $TABLE_ITEMPROPERTY
(tool, ref, insert_date, insert_user_id, lastedit_date, lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, id_session)
VALUES ('$tool','$item_id','$time', '$user_id', '$time', '$lastedit_type','$user_id', '$to_value', '$visibility', '$start_visible','$end_visible', '$session_id')";
VALUES ('$tool','$item_id','$time', '$user_id', '$time', '$lastedit_type','$user_id', '$to_value', '$visibility', '$start_visible','$end_visible', '$session_id')";
}
} else {
$sql = "UPDATE $TABLE_ITEMPROPERTY
SET lastedit_type='".str_replace('_', '', ucwords($tool))."Invisible', lastedit_date='$time', lastedit_user_id='$user_id', visibility='$visibility' $set_type
WHERE $filter";
WHERE $filter";
}
break;
default : // item will be added or updated
$set_type = ", lastedit_type='$lastedit_type' ";
@ -2399,7 +2399,7 @@ function api_item_property_update($_course, $tool, $item_id, $lastedit_type, $us
$res = mysql_query($sql);
// insert if no entries are found (can only happen in case of $lastedit_type switch is 'default')
if (mysql_affected_rows() == 0) {
$sql = "INSERT INTO $TABLE_ITEMPROPERTY
(tool,ref,insert_date,insert_user_id,lastedit_date,lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible, id_session)
VALUES ('$tool','$item_id','$time', '$user_id', '$time', '$lastedit_type','$user_id', '$to_value','$visibility','$start_visible','$end_visible', '$session_id')";
@ -2957,7 +2957,7 @@ function copy_folder_course_session($pathname, $base_path_document,$session_id,$
if (is_dir($pathname) || empty($pathname)) {
return true;
}
// Ensure a file does not already exist with the same name
if (is_file($pathname)) {
trigger_error('mkdirr() File exists', E_USER_WARNING);
@ -2967,31 +2967,31 @@ function copy_folder_course_session($pathname, $base_path_document,$session_id,$
$folders = explode(DIRECTORY_SEPARATOR,str_replace($base_path_document.DIRECTORY_SEPARATOR,'',$pathname));
$new_pathname = $base_path_document;
$path = '';
$path = '';
foreach ($folders as $folder) {
$new_pathname .= DIRECTORY_SEPARATOR.$folder;
$path .= DIRECTORY_SEPARATOR.$folder;
if (!file_exists($new_pathname)) {
$sql = "SELECT * FROM $table WHERE path = '$path' AND filetype = 'folder' AND session_id = '$session_id'";
$rs1 = Database::query($sql,__FILE__,__LINE__);
$num_rows = Database::num_rows($rs1);
if ($num_rows == 0) {
if ($num_rows == 0) {
if (mkdir($new_pathname)) {
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
chmod($new_pathname,$perm);
}
// Insert new folder with destination session_id
}
// Insert new folder with destination session_id
$sql = "INSERT INTO ".$table." SET path = '$path', comment = '".Database::escape_string($document->comment)."', title = '".Database::escape_string(basename($new_pathname))."' ,filetype='folder', size= '0', session_id = '$session_id'";
Database::query($sql, __FILE__, __LINE__);
$document_id = Database::insert_id();
$document_id = Database::insert_id();
api_item_property_update($course_info,TOOL_DOCUMENT,$document_id,'FolderCreated',api_get_user_id(),0,0);
}
}
}
} // en foreach

@ -46,15 +46,15 @@ class SessionManager {
public static function create_session ($sname,$syear_start,$smonth_start,$sday_start,$syear_end,$smonth_end,$sday_end,$snb_days_acess_before,$snb_days_acess_after,$nolimit,$coach_username, $id_session_category,$id_visibility) {
global $_user;
$name= trim($sname);
$year_start= intval($syear_start);
$month_start=intval($smonth_start);
$day_start=intval($sday_start);
$year_end=intval($syear_end);
$month_end=intval($smonth_end);
$day_end=intval($sday_end);
$nb_days_acess_before = intval($snb_days_acess_before);
$nb_days_acess_after = intval($snb_days_acess_after);
$id_session_category = intval($id_session_category);
$year_start= intval($syear_start);
$month_start=intval($smonth_start);
$day_start=intval($sday_start);
$year_end=intval($syear_end);
$month_end=intval($smonth_end);
$day_end=intval($sday_end);
$nb_days_acess_before = intval($snb_days_acess_before);
$nb_days_acess_after = intval($snb_days_acess_after);
$id_session_category = intval($id_session_category);
$id_visibility = intval($id_visibility);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
@ -92,12 +92,12 @@ class SessionManager {
$msg=get_lang('SessionNameAlreadyExists');
return $msg;
} else {
$sql_insert = "INSERT INTO $tbl_session(name,date_start,date_end,id_coach,session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end, session_category_id,visibility)
$sql_insert = "INSERT INTO $tbl_session(name,date_start,date_end,id_coach,session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end, session_category_id,visibility)
VALUES('".Database::escape_string($name)."','$date_start','$date_end','$id_coach',".intval($_user['user_id']).",".$nb_days_acess_before.", ".$nb_days_acess_after.", ".$id_session_category.", ".$id_visibility.")";
Database::query($sql_insert ,__FILE__,__LINE__);
$id_session=Database::get_last_insert_id();
// add event to system log
$id_session=Database::get_last_insert_id();
// add event to system log
$time = time();
$user_id = api_get_user_id();
event_system(LOG_SESSION_CREATE, LOG_SESSION_ID, $id_session, $time, $user_id);
@ -139,7 +139,7 @@ class SessionManager {
$nb_days_acess_after = intval($nb_days_acess_after);
$id_session_category = intval($id_session_category);
$id_visibility = intval($id_visibility);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
@ -184,9 +184,9 @@ class SessionManager {
date_start='".$date_start."',
date_end='".$date_end."',
id_coach='".$id_coach."',
nb_days_access_before_beginning = ".$nb_days_acess_before.",
nb_days_access_after_end = ".$nb_days_acess_after.",
session_category_id = ".$id_session_category." ,
nb_days_access_before_beginning = ".$nb_days_acess_before.",
nb_days_access_after_end = ".$nb_days_acess_after.",
session_category_id = ".$id_session_category." ,
visibility= ".$id_visibility."
WHERE id='$id'";
Database::query($sql,__FILE__,__LINE__);
@ -203,8 +203,8 @@ class SessionManager {
* @author Carlos Vargas <carlos.vargas@dokeos.com>, from existing code
* @param array id_checked
* @param boolean optional, true if the function is called by a webservice, false otherwise.
* @return void Nothing, or false on error
* The parameters is a array to delete sessions
* @return void Nothing, or false on error
* The parameters is a array to delete sessions
**/
public static function delete_session ($id_checked,$from_ws = false) {
$tbl_session= Database::get_main_table(TABLE_MAIN_SESSION);
@ -218,7 +218,7 @@ class SessionManager {
} else {
$id_checked=intval($id_checked);
}
if (!api_is_platform_admin() && !$from_ws) {
$sql = 'SELECT session_admin_id FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_checked;
$rs = Database::query($sql,__FILE__,__LINE__);
@ -234,32 +234,32 @@ class SessionManager {
// delete extra session fields
$t_sf = Database::get_main_table(TABLE_MAIN_SESSION_FIELD);
$t_sfv = Database::get_main_table(TABLE_MAIN_SESSION_FIELD_VALUES);
// Delete extra fields from session where field variable is "SECCION"
$sql = "SELECT t_sfv.field_id FROM $t_sfv t_sfv, $t_sf t_sf WHERE t_sfv.session_id = '$id_checked' AND t_sf.field_variable = 'SECCION' ";
$rs_field = Database::query($sql,__FILE__,__LINE__);
$field_id = 0;
if (Database::num_rows($rs_field) == 1) {
$row_field = Database::fetch_row($rs_field);
$field_id = $row_field[0];
$sql_delete_sfv = "DELETE FROM $t_sfv WHERE session_id = '$id_checked' AND field_id = '$field_id'";
$rs_delete_sfv = Database::query($sql_delete_sfv,__FILE__,__LINE__);
$rs_delete_sfv = Database::query($sql_delete_sfv,__FILE__,__LINE__);
}
$sql = "SELECT * FROM $t_sfv WHERE field_id = '$field_id' ";
$rs_field_id = Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($rs_field_id) == 0) {
$sql_delete_sf = "DELETE FROM $t_sf WHERE id = '$field_id'";
$rs_delete_sf = Database::query($sql_delete_sf,__FILE__,__LINE__);
$rs_delete_sf = Database::query($sql_delete_sf,__FILE__,__LINE__);
}
/*
$sql = "SELECT distinct field_id FROM $t_sfv WHERE session_id = '$id_checked'";
$res_field_ids = @api_sql_query($sql,__FILE__,__LINE__);
$res_field_ids = @Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($res_field_ids) > 0) {
while($row_field_id = Database::fetch_row($res_field_ids)){
$field_ids[] = $row_field_id[0];
@ -269,11 +269,11 @@ class SessionManager {
//delete from table_session_field_value from a given session id
$sql_session_field_value = "DELETE FROM $t_sfv WHERE session_id = '$id_checked'";
@api_sql_query($sql_session_field_value,__FILE__,__LINE__);
@Database::query($sql_session_field_value,__FILE__,__LINE__);
$sql = "SELECT distinct field_id FROM $t_sfv";
$res_field_all_ids = @api_sql_query($sql,__FILE__,__LINE__);
$res_field_all_ids = @Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($res_field_all_ids) > 0) {
while($row_field_all_id = Database::fetch_row($res_field_all_ids)){
$field_all_ids[] = $row_field_all_id[0];
@ -282,17 +282,17 @@ class SessionManager {
if (count($field_ids) > 0 && count($field_all_ids) > 0) {
foreach($field_ids as $field_id) {
// check if field id is used into table field value
// check if field id is used into table field value
if (in_array($field_id,$field_all_ids)) {
continue;
} else {
$sql_session_field = "DELETE FROM $t_sf WHERE id = '$field_id'";
api_sql_query($sql_session_field,__FILE__,__LINE__);
}
}
Database::query($sql_session_field,__FILE__,__LINE__);
}
}
}
*/
// add event to system log
// add event to system log
$time = time();
$user_id = api_get_user_id();
event_system(LOG_SESSION_DELETE, LOG_SESSION_ID, $id_checked, $time, $user_id);
@ -309,7 +309,7 @@ class SessionManager {
* @return void Nothing, or false on error
**/
public static function suscribe_users_to_session ($id_session,$user_list, $visibility=SESSION_VISIBLE_READ_ONLY, $empty_users=true) {
if ($id_session!= strval(intval($id_session))) return false;
foreach($user_list as $intUser){
if ($intUser!= strval(intval($intUser))) return false;
@ -318,17 +318,17 @@ class SessionManager {
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
if (empty($visibility)) {
if (empty($visibility)) {
$sql = "SELECT visibility FROM $tbl_session WHERE id_session='$id_session'";
$result = api_sql_query($sql,__FILE__,__LINE__);
$result = Database::query($sql,__FILE__,__LINE__);
$row = Database::fetch_array($result);
$visibility = $row['visibility'];
if (empty($visibility))
$visibility = SESSION_VISIBLE_READ_ONLY; // by default readonly 1
}
$sql = "SELECT id_user FROM $tbl_session_rel_user WHERE id_session='$id_session'";
$result = Database::query($sql,__FILE__,__LINE__);
$existingUsers = array();
@ -630,16 +630,16 @@ class SessionManager {
public static function get_session_by_name ($session_name) {
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$sql = 'SELECT id, id_coach, date_start, date_end FROM '.$tbl_session.' WHERE name="'.Database::escape_string($session_name).'"';
$result = api_sql_query($sql, __FILE__, __LINE__);
$result = Database::query($sql, __FILE__, __LINE__);
$num = Database::num_rows($result);
if ($num>0){
return Database::fetch_array($result);
return Database::fetch_array($result);
} else {
return false;
}
}
/**
/**
* Create a session category
* @author Jhon Hinojosa <jhon.hinojosa@dokeos.com>, from existing code
* @param string name
@ -654,16 +654,16 @@ class SessionManager {
public static function create_category_session($sname,$syear_start,$smonth_start,$sday_start,$syear_end,$smonth_end, $sday_end){
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$name= trim($sname);
$year_start= intval($syear_start);
$month_start=intval($smonth_start);
$day_start=intval($sday_start);
$year_end=intval($syear_end);
$month_end=intval($smonth_end);
$year_start= intval($syear_start);
$month_start=intval($smonth_start);
$day_start=intval($sday_start);
$year_end=intval($syear_end);
$month_end=intval($smonth_end);
$day_end=intval($sday_end);
$date_start = "$year_start-".(($month_start < 10)?"0$month_start":$month_start)."-".(($day_start < 10)?"0$day_start":$day_start);
$date_end = "$year_end-".(($month_end < 10)?"0$month_end":$month_end)."-".(($day_end < 10)?"0$day_end":$day_end);
if (empty($name)) {
$msg=get_lang('SessionCategoryNameIsRequired');
return $msg;
@ -672,24 +672,24 @@ class SessionManager {
return $msg;
} elseif (!$month_end || !$day_end || !$year_end || !checkdate($month_end,$day_end,$year_end)) {
$msg=get_lang('InvalidEndDate');
return $msg;
return $msg;
} elseif($date_start >= $date_end) {
$msg=get_lang('StartDateShouldBeBeforeEndDate');
return $msg;
} else {
$sql = "INSERT INTO $tbl_session_category(name, date_start, date_end) VALUES('".Database::escape_string($name)."','$date_start','$date_end')";
api_sql_query($sql ,__FILE__,__LINE__);
Database::query($sql ,__FILE__,__LINE__);
$id_session=Database::get_last_insert_id();
// add event to system log
$time = time();
$user_id = api_get_user_id();
event_system(LOG_SESSION_CATEGORY_CREATE, LOG_SESSION_CATEGORY_ID, $id_session, $time, $user_id);
return $id_session;
}
}
}
/**
* Edit a sessions categories
/**
* Edit a sessions categories
* @author Jhon Hinojosa <jhon.hinojosa@dokeos.com>,from existing code
* @param integer id
* @param string name
@ -705,16 +705,16 @@ class SessionManager {
public static function edit_category_session($id, $sname,$syear_start,$smonth_start,$sday_start,$syear_end,$smonth_end, $sday_end){
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$name= trim($sname);
$year_start= intval($syear_start);
$month_start=intval($smonth_start);
$day_start=intval($sday_start);
$year_end=intval($syear_end);
$month_end=intval($smonth_end);
$year_start= intval($syear_start);
$month_start=intval($smonth_start);
$day_start=intval($sday_start);
$year_end=intval($syear_end);
$month_end=intval($smonth_end);
$day_end=intval($sday_end);
$id=intval($id);
$date_start = "$year_start-".(($month_start < 10)?"0$month_start":$month_start)."-".(($day_start < 10)?"0$day_start":$day_start);
$date_end = "$year_end-".(($month_end < 10)?"0$month_end":$month_end)."-".(($day_end < 10)?"0$day_end":$day_end);
if (empty($name)) {
$msg=get_lang('SessionCategoryNameIsRequired');
return $msg;
@ -723,83 +723,83 @@ class SessionManager {
return $msg;
} elseif (!$month_end || !$day_end || !$year_end || !checkdate($month_end,$day_end,$year_end)) {
$msg=get_lang('InvalidEndDate');
return $msg;
return $msg;
} elseif($date_start >= $date_end) {
$msg=get_lang('StartDateShouldBeBeforeEndDate');
return $msg;
} else {
$sql = "UPDATE $tbl_session_category SET name = '".Database::escape_string($name)."', date_start = '$date_start', date_end = '$date_end'
$sql = "UPDATE $tbl_session_category SET name = '".Database::escape_string($name)."', date_start = '$date_start', date_end = '$date_end'
WHERE id= '".$id."' ";
$result = api_sql_query($sql, __FILE__,__LINE__);
$result = Database::query($sql, __FILE__,__LINE__);
return ($result? true:false);
}
}
/**
* Delete sessions categories
/**
* Delete sessions categories
* @author Jhon Hinojosa <jhon.hinojosa@dokeos.com>, from existing code
* @param array id_checked
* @param bool include delete session
* @param bool optional, true if the function is called by a webservice, false otherwise.
* @return void Nothing, or false on error
* The parameters is a array to delete sessions
* @return void Nothing, or false on error
* The parameters is a array to delete sessions
**/
public static function delete_session_category($id_checked, $delete_session = false,$from_ws = false){
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
if(is_array($id_checked)) {
if(is_array($id_checked)) {
$id_checked=Database::escape_string(implode(',',$id_checked));
} else {
$id_checked=intval($id_checked);
}
$sql = "SELECT id FROM $tbl_session WHERE session_category_id IN (".$id_checked.")";
$result = @api_sql_query($sql,__FILE__,__LINE__);
$result = @Database::query($sql,__FILE__,__LINE__);
while ($rows = Database::fetch_array($result)) {
$session_id = $rows['id'];
if($delete_session == true){
if ($from_ws) {
SessionManager::delete_session($session_id,true);
} else {
SessionManager::delete_session($session_id);
}
SessionManager::delete_session($session_id,true);
} else {
SessionManager::delete_session($session_id);
}
}
}
}
$sql = "DELETE FROM $tbl_session_category WHERE id IN (".$id_checked.")";
$rs = @api_sql_query($sql,__FILE__,__LINE__);
$rs = @Database::query($sql,__FILE__,__LINE__);
$result = Database::affected_rows();
// add event to system log
$time = time();
$user_id = api_get_user_id();
event_system(LOG_SESSION_CATEGORY_DELETE, LOG_SESSION_CATEGORY_ID, $id_checked, $time, $user_id);
// delete extra session fields where field variable is "PERIODO"
$t_sf = Database::get_main_table(TABLE_MAIN_SESSION_FIELD);
$t_sfv = Database::get_main_table(TABLE_MAIN_SESSION_FIELD_VALUES);
$sql = "SELECT t_sfv.field_id FROM $t_sfv t_sfv, $t_sf t_sf WHERE t_sfv.session_id = '$id_checked' AND t_sf.field_variable = 'PERIODO' ";
$rs_field = Database::query($sql,__FILE__,__LINE__);
$field_id = 0;
if (Database::num_rows($rs_field) > 0) {
$row_field = Database::fetch_row($rs_field);
$field_id = $row_field[0];
$field_id = $row_field[0];
$sql_delete_sfv = "DELETE FROM $t_sfv WHERE session_id = '$id_checked' AND field_id = '$field_id'";
$rs_delete_sfv = Database::query($sql_delete_sfv,__FILE__,__LINE__);
}
}
$sql = "SELECT * FROM $t_sfv WHERE field_id = '$field_id' ";
$rs_field_id = Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($rs_field_id) == 0) {
$sql_delete_sf = "DELETE FROM $t_sf WHERE id = '$field_id'";
$rs_delete_sf = Database::query($sql_delete_sf,__FILE__,__LINE__);
$rs_delete_sf = Database::query($sql_delete_sf,__FILE__,__LINE__);
}
return true;
}
/**
* Get a list of sessions of which the given conditions match with an = 'cond'
* @param array $conditions a list of condition (exemple : status=>STUDENT)
@ -816,8 +816,8 @@ class SessionManager {
$return_array = array();
$sql_query = " SELECT s.id, s.name, s.nbr_courses, s.date_start, s.date_end, u.firstname, u.lastname , sc.name as category_name
FROM $session_table s
INNER JOIN $user_table u ON s.id_coach = u.user_id
FROM $session_table s
INNER JOIN $user_table u ON s.id_coach = u.user_id
LEFT JOIN $session_category_table sc ON s.session_category_id = sc.id ";
if (count($conditions)>0) {
@ -838,10 +838,10 @@ class SessionManager {
return $return_array;
}
/**
* Get the session category information by id
* Get the session category information by id
* @param string session category ID
* @return mixed false if the session category does not exist, array if the session category exists
*/
* @return mixed false if the session category does not exist, array if the session category exists
*/
public static function get_session_category ($id) {
$id = intval($id);
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
@ -854,85 +854,85 @@ class SessionManager {
return false;
}
}
/**
* Assign a coach to course in session with status = 2
* Assign a coach to course in session with status = 2
* @param int - user id
* @param int - session id
* @param string - course code
* @param bool - optional, if is true the user don't be a coach now, otherwise it'll assign a coach
* @return bool true if there are affected rows, otherwise false
*/
* @return bool true if there are affected rows, otherwise false
*/
function set_coach_to_course_session($user_id, $session_id = 0, $course_code = '',$nocoach = false) {
// Definition of variables
$user_id = intval($user_id);
if (!empty($session_id)) {
$session_id = intval($session_id);
// Definition of variables
$user_id = intval($user_id);
if (!empty($session_id)) {
$session_id = intval($session_id);
} else {
$session_id = api_get_session_id();
}
if (!empty($course_code)) {
$course_code = Database::escape_string($course_code);
}
if (!empty($course_code)) {
$course_code = Database::escape_string($course_code);
} else {
$course_code = api_get_course_id();
}
// definitios of tables
// definitios of tables
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
// check if user is a teacher
$sql= "SELECT * FROM $tbl_user WHERE status='1' AND user_id = '$user_id'";
$rs_check_user = Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($rs_check_user) > 0) {
if (Database::num_rows($rs_check_user) > 0) {
if ($nocoach) {
// check if user_id exits int session_rel_user
$sql = "SELECT id_user FROM $tbl_session_rel_user WHERE id_session = '$session_id' AND id_user = '$user_id'";
$res = Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($res) > 0) {
// The user don't be a coach now
if (Database::num_rows($res) > 0) {
// The user don't be a coach now
$sql = "UPDATE $tbl_session_rel_course_rel_user SET status = 0 WHERE id_session = '$session_id' AND course_code = '$course_code' AND id_user = '$user_id' ";
$rs_update = Database::query($sql,__FILE__,__LINE__);
$rs_update = Database::query($sql,__FILE__,__LINE__);
if (Database::affected_rows() > 0) return true;
else return false;
} else {
// The user don't be a coach now
// The user don't be a coach now
$sql = "DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session = '$session_id' AND course_code = '$course_code' AND id_user = '$user_id' ";
$rs_delete = Database::query($sql,__FILE__,__LINE__);
if (Database::affected_rows() > 0) return true;
else return false;
}
} else {
// Assign user like a coach to course
// First check if the user is registered in the course
// Assign user like a coach to course
// First check if the user is registered in the course
$sql = "SELECT id_user FROM $tbl_session_rel_course_rel_user WHERE id_session = '$session_id' AND course_code = '$course_code' AND id_user = '$user_id'";
$rs_check = Database::query($sql,__FILE__,__LINE__);
//Then update or insert
if (Database::num_rows($rs_check) > 0) {
$sql = "UPDATE $tbl_session_rel_course_rel_user SET status = 2 WHERE id_session = '$session_id' AND course_code = '$course_code' AND id_user = '$user_id' ";
$rs_update = Database::query($sql,__FILE__,__LINE__);
if (Database::affected_rows() > 0) return true;
else return false;
else return false;
} else {
$sql = " INSERT INTO $tbl_session_rel_course_rel_user(id_session, course_code, id_user, status) VALUES('$session_id', '$course_code', '$user_id', 2)";
$rs_insert = Database::query($sql,__FILE__,__LINE__);
if (Database::affected_rows() > 0) return true;
else return false;
}
else return false;
}
}
} else {
return false;
}
}
}
}

@ -1489,8 +1489,8 @@ class UserManager {
}
return $result_data;
}
/**
* Gives a list of [session_category][session_id] for the current user.
* @param integer $user_id
@ -1513,22 +1513,22 @@ class UserManager {
}
/*
//we filter the courses from the URL
$join_access_url=$where_access_url='';
global $_configuration;
$join_access_url=$where_access_url='';
global $_configuration;
if ($_configuration['multiple_access_urls']==true) {
$access_url_id = api_get_current_access_url_id();
if($access_url_id!=-1) {
$tbl_url_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$tbl_url_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$join_access_url= "LEFT JOIN $tbl_url_course url_rel_course ON url_rel_course.course_code= course.code";
$where_access_url=" AND access_url_id = $access_url_id ";
}
}
*/
*/
// get the list of sessions where the user is subscribed as student
$condition_date_end = "";
if ($is_time_over) {
$condition_date_end = " AND date_end < CURDATE() AND date_end != '0000-00-00' ";
$condition_date_end = " AND date_end < CURDATE() AND date_end != '0000-00-00' ";
} else {
$condition_date_end = " AND (date_end >= CURDATE() OR date_end = '0000-00-00') ";
}
@ -1537,12 +1537,12 @@ class UserManager {
FROM $tbl_session_user, $tbl_session
WHERE id_session=id AND id_user=$user_id $condition_date_end
ORDER BY session_category_id, date_start, date_end";
$result = Database::query($sessions_sql,__FILE__,__LINE__);
$result = Database::query($sessions_sql,__FILE__,__LINE__);
while ($row = Database::fetch_array($result)) {
$categories[$row['session_category_id']][] = $row['id'];
$categories[$row['session_category_id']][] = $row['id'];
}
// get the list of sessions where the user is subscribed as coach in a course $tbl_session_course_user
/*$sessions_sql = "SELECT DISTINCT id, session_category_id
FROM $tbl_session as session
@ -1550,33 +1550,33 @@ class UserManager {
ON session_rel_course.id_session = session.id
AND session_rel_course.id_coach = $user_id
ORDER BY session_category_id, date_start, date_end";*/
$sessions_sql = "SELECT DISTINCT id, session_category_id
FROM $tbl_session as session
INNER JOIN $tbl_session_course_user as session_rel_course_user
ON session_rel_course_user.id_session = session.id
AND session_rel_course_user.id_user = $user_id
AND session_rel_course_user.status = 2 $condition_date_end
AND session_rel_course_user.status = 2 $condition_date_end
ORDER BY session_category_id, date_start, date_end";
$result = Database::query($sessions_sql,__FILE__,__LINE__);
while ($row = Database::fetch_array($result)) {
$categories[$row['session_category_id']][] = $row['id'];
$categories[$row['session_category_id']][] = $row['id'];
}
// get the list of sessions where the user is subscribed as coach
$sessions_sql = "SELECT DISTINCT id, session_category_id
FROM $tbl_session as session
WHERE session.id_coach = $user_id $condition_date_end
ORDER BY session_category_id, date_start, date_end";
ORDER BY session_category_id, date_start, date_end";
$result = Database::query($sessions_sql,__FILE__,__LINE__);
while ($row = Database::fetch_array($result)) {
$categories[$row['session_category_id']][] = $row['id'];
$categories[$row['session_category_id']][] = $row['id'];
}
return $categories;
}
}
/**
* Gives a list of [session_id-course_code] => [status] for the current user.
* @param integer $user_id
@ -1643,23 +1643,23 @@ class UserManager {
WHERE id_session=id AND id_user=$user_id
AND (date_start <= CURDATE() AND date_end >= CURDATE() OR date_start='0000-00-00')
ORDER BY date_start, date_end, name";
$result = api_sql_query($sessions_sql,__FILE__,__LINE__);
$sessions=api_store_result($result);
$result = Database::query($sessions_sql,__FILE__,__LINE__);
$sessions=api_store_result($result);
$sessions = array_merge($sessions , api_store_result($result));
// get the list of sessions where the user is subscribed as student where visibility = SESSION_VISIBLE_READ_ONLY = 1 SESSION_VISIBLE = 2
$sessions_out_date_sql = "SELECT DISTINCT id, name, date_start, date_end
FROM $tbl_session_user, $tbl_session
WHERE id_session=id AND id_user=$user_id
AND (date_end <= CURDATE() AND date_end<>'0000-00-00') AND (visibility = ".SESSION_VISIBLE_READ_ONLY." || visibility = ".SESSION_VISIBLE.")
ORDER BY date_start, date_end, name";
$result_out_date = api_sql_query($sessions_out_date_sql,__FILE__,__LINE__);
$sessions_out_date=api_store_result($result_out_date);
$result_out_date = Database::query($sessions_out_date_sql,__FILE__,__LINE__);
$sessions_out_date=api_store_result($result_out_date);
$sessions = array_merge($sessions , $sessions_out_date);
// get the list of sessions where the user is subscribed as coach in a course
$sessions_sql = "SELECT DISTINCT id, name, date_start, date_end, DATE_SUB(date_start, INTERVAL nb_days_access_before_beginning DAY), ADDDATE(date_end, INTERVAL nb_days_access_after_end DAY)
FROM $tbl_session as session
@ -1729,17 +1729,17 @@ class UserManager {
ON session_course.id_session = session.id
WHERE session_course.id_session = $id_session
ORDER BY i";
*/
// this query is very similar to the above query, but it will check the session_rel_course_user table if there are courses registered to our user or not
$personal_course_list_sql = "SELECT distinct course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i, CONCAT(user.lastname,' ',user.firstname) t, email, course.course_language l, 1 sort, category_code user_course_cat, date_start, date_end, session.id as id_session, session.name as session_name, IF(session_course.id_coach = 3,'2', '5')
FROM $tbl_session_course_user as session_course_user INNER JOIN $tbl_course AS course
*/
// this query is very similar to the above query, but it will check the session_rel_course_user table if there are courses registered to our user or not
$personal_course_list_sql = "SELECT distinct course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i, CONCAT(user.lastname,' ',user.firstname) t, email, course.course_language l, 1 sort, category_code user_course_cat, date_start, date_end, session.id as id_session, session.name as session_name, IF(session_course.id_coach = 3,'2', '5')
FROM $tbl_session_course_user as session_course_user INNER JOIN $tbl_course AS course
ON course.code = session_course_user.course_code AND session_course_user.id_session = $id_session INNER JOIN $tbl_session as session ON session_course_user.id_session = session.id
INNER JOIN $tbl_session_course as session_course
INNER JOIN $tbl_session_course as session_course
LEFT JOIN $tbl_user as user ON user.user_id = session_course.id_coach
WHERE session_course_user.id_user = $user_id ORDER BY i";
$course_list_sql_result = api_sql_query($personal_course_list_sql, __FILE__, __LINE__);
$course_list_sql_result = Database::query($personal_course_list_sql, __FILE__, __LINE__);
while ($result_row = Database::fetch_array($course_list_sql_result)) {
$key = $result_row['id_session'].' - '.$result_row['k'];
$result_row['s'] = $result_row['14'];
@ -1750,7 +1750,7 @@ class UserManager {
}
}
//print_r($personal_course_list);
return $personal_course_list;
}
/**
@ -1763,30 +1763,30 @@ class UserManager {
$tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
$tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$user_id = intval($user_id);
//we filter the courses from the URL
$join_access_url=$where_access_url='';
global $_configuration;
$join_access_url=$where_access_url='';
global $_configuration;
if ($_configuration['multiple_access_urls']==true) {
$access_url_id = api_get_current_access_url_id();
if($access_url_id!=-1) {
$tbl_url_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$tbl_url_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$join_access_url= "LEFT JOIN $tbl_url_course url_rel_course ON url_rel_course.course_code= course.code";
$where_access_url=" AND access_url_id = $access_url_id ";
}
}
// variable initialisation
$personal_course_list_sql = '';
$personal_course_list = array();
$courses = array();
// this query is very similar to the above query, but it will check the session_rel_course_user table if there are courses registered to our user or not
$personal_course_list_sql = "SELECT distinct scu.course_code as code
// this query is very similar to the above query, but it will check the session_rel_course_user table if there are courses registered to our user or not
$personal_course_list_sql = "SELECT distinct scu.course_code as code
FROM $tbl_session_course_user as scu
$join_access_url
WHERE scu.id_user = $user_id
WHERE scu.id_user = $user_id
AND scu.id_session = $session_id
$where_access_url
ORDER BY code";

@ -935,11 +935,11 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { // ses
$tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
$tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$sql = " SELECT session.id_coach, session_admin_id FROM $tbl_session session,$tbl_session_course_user session_rcru
$sql = " SELECT session.id_coach, session_admin_id FROM $tbl_session session,$tbl_session_course_user session_rcru
WHERE session_rcru.id_session = session.id AND session_rcru.course_code = '$_cid' AND session_rcru.id_user='{$_user['user_id']}' AND session_rcru.status = 2";
/*$sql = "SELECT session.id_coach, session_admin_id
FROM ".$tbl_session." as session
INNER JOIN ".$tbl_session_course_user."
@ -977,10 +977,10 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { // ses
FROM ".$tbl_session_course_user."
WHERE course_code='$_cid'
AND id_user = '".$_user['user_id']."'
AND id_session = '".api_get_session_id()."'
AND id_session = '".api_get_session_id()."'
AND status = 2";
$result = api_sql_query($sql,__FILE__,__LINE__);
$result = Database::query($sql,__FILE__,__LINE__);
if ($row = Database::fetch_array($result)) {
$_courseUser['role'] = 'Professor';
$is_courseMember = true;
@ -999,11 +999,11 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { // ses
// Check if the user is a student is this session
$sql = "SELECT * FROM ".$tbl_session_course_user."
WHERE id_user = '".$_user['user_id']."'
AND id_session = '".api_get_session_id()."'
AND id_session = '".api_get_session_id()."'
AND course_code = '$cidReq' AND status NOT IN(2)";
$result = Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($result) > 0) { // this user have a recorded state for this course
while($row = Database::fetch_array($result)){
$is_courseMember = true;
@ -1045,25 +1045,25 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) { // ses
$is_allowed_in_course = true;
else $is_allowed_in_course = false;
}
// requires testing!!!
// check the session visibility
if ($is_allowed_in_course) {
$my_session_id = api_get_session_id();
//if I'm in a session
//var_dump($is_platformAdmin, $is_courseTutor,api_is_coach());
if ($my_session_id!=0)
if (!$is_platformAdmin) {
// admin and session coach are *not* affected to the invisible session mode
//if I'm in a session
//var_dump($is_platformAdmin, $is_courseTutor,api_is_coach());
if ($my_session_id!=0)
if (!$is_platformAdmin) {
// admin and session coach are *not* affected to the invisible session mode
// the coach is not affected because he can log in some days after the end date of a session
$session_visibility = api_get_session_visibility($my_session_id);
if ($session_visibility==SESSION_INVISIBLE)
$is_allowed_in_course =false;
$is_allowed_in_course =false;
}
}
// save the states
api_session_register('is_courseMember');

@ -112,7 +112,7 @@ $nameTools = get_lang('Links');
//condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id, false);
if (isset($_GET['action']) && $_GET['action']=='addlink') {
$nameTools = '';
$interbreadcrumb[] = array ('url' => 'link.php', 'name' => get_lang('Links'));
@ -270,11 +270,11 @@ if(api_get_setting('search_enabled')=='true') {
</div>
</div>';
$sqlcategories = "SELECT * FROM ".$tbl_categories." $condition_session ORDER BY display_order DESC";
$resultcategories = api_sql_query($sqlcategories,__FILE__,__LINE__);
$resultcategories = Database::query($sqlcategories,__FILE__,__LINE__);
if (Database::num_rows($resultcategories)) {
echo ' <div class="row">
@ -473,7 +473,7 @@ if (empty($_GET['action']) || ($_GET['action']!='editlink' && $_GET['action']!='
//Starting the table which contains the categories
$sqlcategories = "SELECT * FROM ".$tbl_categories." $condition_session ORDER BY display_order DESC";
$resultcategories = Database::query($sqlcategories);
echo '<table class="data_table">';
// displaying the links which have no category (thus category = 0 or NULL), if none present this will not be displayed
$sqlLinks = "SELECT * FROM ".$tbl_link." WHERE category_id=0 or category_id IS NULL";
@ -492,7 +492,7 @@ if (empty($_GET['action']) || ($_GET['action']!='editlink' && $_GET['action']!='
while ($myrow = Database::fetch_array($resultcategories)) {
//validacion when belongs to a session
$session_img = api_get_session_image($myrow['session_id'], $_user['status']);
//if (!isset($urlview))
if ($urlview == '')
{
@ -519,10 +519,10 @@ if (empty($_GET['action']) || ($_GET['action']!='editlink' && $_GET['action']!='
echo '<th width="81%" style="font-weight: bold; text-align:left;padding-left: 5px;">';
echo '<a href="'.api_get_self()."?".api_get_cidreq()."&urlview=".Security::remove_XSS($newurlview)."\">";
echo "<img src=../img/remove.gif>&nbsp;&nbsp;".api_htmlentities($myrow["category_title"],ENT_QUOTES,$charset)."</a><br/>&nbsp;&nbsp;&nbsp;".$myrow["description"];
if (api_is_allowed_to_edit(null,true))
{
echo '<th>';
{
echo '<th>';
showcategoryadmintools($myrow["id"]);
echo '</th>';
}
@ -543,9 +543,9 @@ if (empty($_GET['action']) || ($_GET['action']!='editlink' && $_GET['action']!='
echo'</a><br />&nbsp;&nbsp;&nbsp;';
echo $myrow["description"];
if (api_is_allowed_to_edit(null, true))
{
echo '<th style="text-align:center;">';
showcategoryadmintools($myrow["id"]);
{
echo '<th style="text-align:center;">';
showcategoryadmintools($myrow["id"]);
echo '</th>';
}
echo '</th>';

@ -261,7 +261,7 @@ class survey_manager
//insert into item_property
api_item_property_update(api_get_course_info(), TOOL_SURVEY, $survey_id, 'SurveyAdded', api_get_user_id());
}
if($values['survey_type']==1 && !empty($values['parent_id'])){
survey_manager::copy_survey($values['parent_id'],$survey_id);
}
@ -339,10 +339,10 @@ class survey_manager
anonymous = '".Database::escape_string($values['anonymous'])."'".$additionalsets."
WHERE survey_id = '".Database::escape_string($values['survey_id'])."'";
$result = Database::query($sql, __FILE__, __LINE__);
//update into item_property (update)
api_item_property_update(api_get_course_info(), TOOL_SURVEY, Database::escape_string($values['survey_id']), 'SurveyUpdated', api_get_user_id());
//$return['message'] = get_lang('SurveyUpdatedSuccesfully').'<br />'.get_lang('YouCanNowAddQuestionToYourSurvey').': ';
//$return['message'] .= '<a href="survey.php?survey_id='.$values['survey_id'].'">'.get_lang('Here').'</a>';
//$return['message'] .= get_lang('OrReturnToSurveyOverview').'<a href="survey_list.php">'.get_lang('Here').'</a>';
@ -434,10 +434,10 @@ class survey_manager
// deleting the questions of the survey
survey_manager::delete_all_survey_questions($survey_id, $shared);
//update into item_property (delete)
api_item_property_update(api_get_course_info(), TOOL_SURVEY, Database::escape_string($survey_id), 'delete', api_get_user_id());
return void;
}
@ -4642,12 +4642,12 @@ class SurveyUtil {
if ($search_restriction)
{
$search_restriction = ' AND '.$search_restriction;
}
}
//condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
//IF(is_shared<>0,'V','-') AS col6,
$sql = "SELECT
survey.survey_id AS col0,
@ -4672,17 +4672,17 @@ class SurveyUtil {
$sql .= " GROUP BY survey.survey_id";
$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items";
$res = api_sql_query($sql, __FILE__, __LINE__);
$res = Database::query($sql, __FILE__, __LINE__);
$surveys = array();
$array = array();
while ($survey = Database::fetch_array($res)) {
$array[0] = $survey[0];
$array[1] = $survey[1];
//validacion when belongs to a session
$session_img = api_get_session_image($survey['session_id'], $_user['status']);
$array[2] = $survey[2] . $session_img;
$array[3] = $survey[3];
$array[4] = $survey[4];
$array[5] = $survey[5];
@ -4691,12 +4691,12 @@ class SurveyUtil {
$array[8] = $survey[8];
$array[9] = $survey[9];
$array[10] = $survey[10];
$surveys[] = $array;
}
return $surveys;
}
function get_survey_data_for_coach($from, $number_of_items, $column, $direction)
{
//echo '<pre>';

@ -144,14 +144,14 @@ function count_item_resources() {
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$sql = "SELECT count(tool) AS total_number_of_items FROM $table_item_property track_resource, $table_user user" .
" WHERE track_resource.insert_user_id = user.user_id";
if (isset($_GET['keyword'])) {
$keyword = Database::escape_string($_GET['keyword']);
$sql .= " AND (user.username LIKE '%".$keyword."%' OR lastedit_type LIKE '%".$keyword."%' OR tool LIKE '%".$keyword."%')";
}
$sql .= " AND tool IN ('document', 'learnpath', 'quiz', 'glossary', 'link', 'course_description')";
$res = api_sql_query($sql, __FILE__, __LINE__);
$res = Database::query($sql, __FILE__, __LINE__);
$obj = Database::fetch_object($res);
return $obj->total_number_of_items;
}
@ -170,14 +170,14 @@ function get_item_resources_data($from, $number_of_items, $column, $direction) {
visibility as col6
FROM $table_item_property track_resource, $table_user user
WHERE track_resource.insert_user_id = user.user_id ";
if (isset($_GET['keyword'])) {
$keyword = Database::escape_string($_GET['keyword']);
$sql .= " AND (user.username LIKE '%".$keyword."%' OR lastedit_type LIKE '%".$keyword."%' OR tool LIKE '%".$keyword."%') ";
}
$sql .= " AND tool IN ('document', 'learnpath', 'quiz', 'glossary', 'link', 'course_description')";
if ($column == 0) { $column = '0'; }
if ($column != '' && $direction != '') {
if ($column != 2 && $column != 4) {
@ -186,12 +186,12 @@ function get_item_resources_data($from, $number_of_items, $column, $direction) {
} else {
$sql .= " ORDER BY col5 DESC ";
}
$sql .= " LIMIT $from, $number_of_items ";
$res = api_sql_query($sql, __FILE__, __LINE__) or die(mysql_error());
$res = Database::query($sql, __FILE__, __LINE__) or die(mysql_error());
$resources = array ();
while ($row = Database::fetch_array($res)) {
$ref = $row['ref'];
$table_name = get_tool_name_table($row['col0']);
@ -199,53 +199,53 @@ function get_item_resources_data($from, $number_of_items, $column, $direction) {
$id = $table_name['id_tool'];
$query = "SELECT session.id, session.name, user.username FROM $table_tool tool, $table_session session, $table_user user" .
" WHERE tool.session_id = session.id AND session.id_coach = user.user_id AND tool.$id = $ref";
$recorset = api_sql_query($query, __FILE__, __LINE__);
$recorset = Database::query($query, __FILE__, __LINE__);
if (!empty($recorset)) {
$obj = Database::fetch_object($recorset);
$name_session = '';
$coach_name = '';
if (!empty($obj)) {
$name_session = $obj->name;
$coach_name = $obj->username;
}
$url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
$row[0] = '';
if ($row['col6'] != 2) {
$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&'.$obj->id.'">'.api_ucfirst($row['col0']).'</a>';
} else {
$row[0] = api_ucfirst($row['col0']);
}
$row[1] = get_lang($row[1]);
$row[5] = api_ucfirst(format_locale_date($dateTimeFormatLong, strtotime($row['col5'])));
$row[4] = '';
if ($table_name['table_name'] == 'document') {
$condition = 'tool.title as title';
$query_document = "SELECT $condition FROM $table_tool tool" .
" WHERE id = $ref";
$rs_document = api_sql_query($query_document, __FILE__, __LINE__) or die(mysql_error());
$rs_document = Database::query($query_document, __FILE__, __LINE__) or die(mysql_error());
$obj_document = Database::fetch_object($rs_document);
$row[4] = $obj_document->title;
}
$row2 = $name_session;
if (!empty($coach_name)) {
$row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
}
$row[2] = $row2;
$resources[] = $row;
}
}
return $resources;
}
@ -788,9 +788,9 @@ if ($_GET['studentlist'] == 'false') {
array_unshift($csv_content, $csv_headers); // adding headers before the content
Export :: export_table_csv($csv_content, 'reporting_student_list');
}
} elseif($_GET['studentlist'] == 'resources') {
// Create a search-box
$form = new FormValidator('search_simple','get',api_get_path(WEB_CODE_PATH).'tracking/courseLog.php?'.api_get_cidreq().'&studentlist=resources','','width=200px',false);
$renderer =& $form->defaultRenderer();
@ -801,16 +801,16 @@ if ($_GET['studentlist'] == 'false') {
echo '<div class="actions">';
$form->display();
echo '</div>';
$table = new SortableTable('resources', 'count_item_resources', 'get_item_resources_data', 5, 20, 'DESC');
$parameters = array();
if (isset($_GET['keyword'])) {
$parameters['keyword'] = Security::remove_XSS($_GET['keyword']);
}
$parameters['studentlist'] = 'resources';
$table->set_additional_parameters($parameters);
$table->set_header(0, get_lang('Tool'));
$table->set_header(1, get_lang('EventType'));
@ -819,7 +819,7 @@ if ($_GET['studentlist'] == 'false') {
$table->set_header(4, get_lang('Document'), false);
$table->set_header(5, get_lang('Date'));
$table->display();
}
?>
</table>

@ -289,9 +289,9 @@ function display_history_course_session() {
if (isset($_GET['history']) && intval($_GET['history']) == 1) {
echo "<li><a href=\"user_portal.php\">".get_lang('DisplayTrainingList')."</a></li>";
} else {
echo "<li><a href=\"user_portal.php?history=1\">".get_lang('HistoryTrainingSessions')."</a></li>";
echo "<li><a href=\"user_portal.php?history=1\">".get_lang('HistoryTrainingSessions')."</a></li>";
}
}
/**
@ -387,11 +387,11 @@ function display_digest($toolsList, $digest, $orderKey, $courses) {
function get_logged_user_course_html($course, $session_id = 0, $class='courses') {
global $charset;
global $nosession;
$current_uid = api_get_user_id();
$info = api_get_course_info($course['code']);
$status_course = CourseManager::get_user_in_course_status($current_uid, $course['code']);
$status_course = CourseManager::get_user_in_course_status($current_uid, $course['code']);
if (!is_array($course['code'])) {
$my_course = api_get_course_info($course['code']);
$my_course['k'] = $my_course['id'];
@ -403,7 +403,7 @@ function get_logged_user_course_html($course, $session_id = 0, $class='courses')
$my_course['id_session'] = $session_id;
$my_course['status'] = ((empty($session_id))?$status_course:5);
}
if (api_get_setting('use_session_mode')=='true' && !$nosession) {
global $now, $date_start, $date_end;
}
@ -437,7 +437,7 @@ function get_logged_user_course_html($course, $session_id = 0, $class='courses')
//function logic - act on the data
$is_virtual_course = CourseManager :: is_virtual_course_from_system_code($my_course['k']);
if ($is_virtual_course) {
if ($is_virtual_course) {
// If the current user is also subscribed in the real course to which this
// virtual course is linked, we don't need to display the virtual course entry in
// the course list - it is combined with the real course entry.
@ -456,16 +456,16 @@ function get_logged_user_course_html($course, $session_id = 0, $class='courses')
$course_display_title = $course_title;
$course_display_code = $course_visual_code;
}
$s_course_status = $my_course['status'];
$is_coach = api_is_coach($my_course['id_session'],$course['code']);
$s_htlm_status_icon = "";
if ($s_course_status == 1) {
$s_htlm_status_icon=Display::return_icon('teachers.gif', get_lang('Teacher'));
}
if ($s_course_status == 2 || ($is_coach && $s_course_status != 1)) {
if ($s_course_status == 2 || ($is_coach && $s_course_status != 1)) {
$s_htlm_status_icon=Display::return_icon('coachs.gif', get_lang('GeneralCoach'));
}
if ($s_course_status == 5 && !$is_coach) {
@ -476,12 +476,12 @@ function get_logged_user_course_html($course, $session_id = 0, $class='courses')
$result.="\n\t";
$result .= '<li class="'.$class.'"><div class="coursestatusicons">'.$s_htlm_status_icon.'</div>';
//show a hyperlink to the course, unless the course is closed and user is not course admin
if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) {
if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) {
if(api_get_setting('use_session_mode')=='true' && !$nosession) {
if(empty($my_course['id_session'])) {
$my_course['id_session'] = 0;
}
if($user_in_course_status == COURSEMANAGER || ($date_start <= $now && $date_end >= $now) || $date_start=='0000-00-00') {
if($user_in_course_status == COURSEMANAGER || ($date_start <= $now && $date_end >= $now) || $date_start=='0000-00-00') {
$result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$my_course['id_session'].'">'.$course_display_title.'</a>';
}
} else {
@ -500,30 +500,30 @@ function get_logged_user_course_html($course, $session_id = 0, $class='courses')
if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') {
$result .= ' &ndash; ';
}
if (api_get_setting('display_teacher_in_courselist') == 'true') {
if (api_get_setting('display_teacher_in_courselist') == 'true') {
if (api_get_setting('use_session_mode')=='true' && !$nosession) {
$coachs_course = api_get_coachs_from_course($my_course['id_session'],$course['code']);
$course_coachs = array();
if (is_array($coachs_course)) {
foreach ($coachs_course as $coach_course) {
$course_coachs[] = $coach_course['lastname'].' '.$coach_course['firstname'];
$course_coachs[] = $coach_course['lastname'].' '.$coach_course['firstname'];
}
}
if ($s_course_status == 1) {
$result .= $course_teacher;
}
if ($s_course_status == 2 || ($is_coach && $s_course_status != 1)) {
if ($s_course_status == 2 || ($is_coach && $s_course_status != 1)) {
$result .= get_lang('Coachs').': '.implode(', ',$course_coachs);
}
} else {
$result .= $course_teacher;
}
if(!empty($course_teacher_email)) {
$result .= ' ('.$course_teacher_email.')';
}
@ -535,7 +535,7 @@ function get_logged_user_course_html($course, $session_id = 0, $class='courses')
$result .= show_notification($my_course);
if ((CONFVAL_showExtractInfo == SCRIPTVAL_InCourseList || CONFVAL_showExtractInfo == SCRIPTVAL_Both) && $nbDigestEntries > 0) {
reset($digest);
$result .= '
<ul>';
@ -587,7 +587,7 @@ function get_logged_user_course_html($course, $session_id = 0, $class='courses')
LEFT JOIN '.$main_user_table .' tu
ON ts.id_coach = tu.user_id
INNER JOIN '.$tbl_session_category.' sc ON ts.session_category_id = sc.id
WHERE ts.id='.(int) $my_course['id_session']. ' LIMIT 1';
WHERE ts.id='.(int) $my_course['id_session']. ' LIMIT 1';
$rs = Database::query($sql, __FILE__, __LINE__);
$sessioncoach = api_store_result($rs);
@ -615,7 +615,7 @@ function get_logged_user_course_html($course, $session_id = 0, $class='courses')
} else {
$output = array ($my_course['user_course_cat'], $result);
}
return $output;
}
@ -633,13 +633,13 @@ function get_session_title_box($session_id) {
$tbl_session_category = Database :: get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$active = false;
// Request for the name of the general coach
$sql =
$sql =
'SELECT tu.lastname, tu.firstname, ts.name, ts.date_start, ts.date_end, ts.session_category_id
FROM '.$tbl_session.' ts
LEFT JOIN '.$main_user_table .' tu
ON ts.id_coach = tu.user_id
WHERE ts.id='.intval($session_id);
$rs = api_sql_query($sql, __FILE__, __LINE__);
$rs = Database::query($sql, __FILE__, __LINE__);
$session_info = api_store_result($rs);
$session_info = $session_info[0];
$session = array();
@ -691,7 +691,7 @@ function get_global_courses_list($user_id) {
if (api_get_setting('use_session_mode')=='true' && !$nosession) {
global $now, $date_start, $date_end;
}
$output = array();
return $output;
}
@ -837,8 +837,8 @@ if (!empty ($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/',$_GET['in
// compose a structured array of session categories, sessions and courses
// for the current user
require_once $libpath.'sessionmanager.lib.php';
if (isset($_GET['history']) && intval($_GET['history']) == 1) {
if (isset($_GET['history']) && intval($_GET['history']) == 1) {
$courses_tree = UserManager::get_sessions_by_category($_user['user_id'],true,true);
} else {
$courses_tree = UserManager::get_sessions_by_category($_user['user_id'],true);
@ -856,7 +856,7 @@ if (!empty ($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/',$_GET['in
}
}
}
$list = '';
// this is the main function to get the course list
$personal_course_list = UserManager::get_personal_session_course_list($_user['user_id']);
@ -962,13 +962,13 @@ if (isset($_GET['history']) && intval($_GET['history']) == 1) {
echo '<h3>'.get_lang('HistoryTrainingSession').'</h3>';
}
if ( is_array($courses_tree) ) {
if ( is_array($courses_tree) ) {
foreach ($courses_tree as $key => $category) {
if ($key == 0) {
// sessions and courses that are not in a session category
if (!isset($_GET['history'])) { // check if it's not history trainnign session list
@ -976,17 +976,17 @@ if ( is_array($courses_tree) ) {
if(count($category['courses']) > 0) {
echo '<ul class="courseslist" style="list-style-type:none;">';
}
foreach ($category['courses'] as $course) {
foreach ($category['courses'] as $course) {
$c = get_logged_user_course_html($course, 0, 'independent_course_item');
echo $c[1];
echo $c[1];
}
if(count($category['courses']) > 0) {
echo '</ul>';
}
}
//independent sessions
foreach ($category['sessions'] as $session) {
//don't show empty sessions
@ -1000,17 +1000,17 @@ if ( is_array($courses_tree) ) {
//courses inside the current session
foreach ($session['courses'] as $course) {
$c = get_logged_user_course_html($course, $session['details']['id'], 'session_course_item');
echo $c[1];
echo $c[1];
}
echo '</ul>';
}
} else {
} else {
// all sessions included in
if (!empty($category['details'])) {
echo '<div class="session_category" id="session_category_'.$category['details']['id'].'" style="background-color:#fbfbfb; border:1px solid #dddddd; padding:5px; margin-top: 10px;">';
echo '<div class="session_category_title_box" id="session_category_title_box_'.$category['details']['id'].'" style="font-size:larger; color: #555555;">'. Display::return_icon('div_show.gif', get_lang('Expand'), array('align' => 'absmiddle', 'id' => 'category_img_'.$category['details']['id'])) . ' ' . get_lang('SessionCategory') . ': ' . $category['details']['name'].' - '.get_lang('From').' '.$category['details']['date_start'].' '.get_lang('Until').' '.$category['details']['date_end'].'</div>';
foreach ($category['sessions'] as $session) {
//don't show empty sessions
if (count($session['courses'])<1) { continue; }
@ -1020,7 +1020,7 @@ if ( is_array($courses_tree) ) {
$s = get_session_title_box($session['details']['id']);
echo get_lang('SessionName') . ': ' . $s['title']. ' - '.(!empty($s['coach'])?$s['coach'].' - ':'').$s['dates'];
echo '</li>';
foreach ($session['courses'] as $course) {
//echo '<li class="session_course_item" id="session_course_item_'.$course['code'].'" style="padding:5px">';
$c = get_logged_user_course_html($course, $session['details']['id'], 'session_course_item');
@ -1035,7 +1035,7 @@ if ( is_array($courses_tree) ) {
}
}
}
}
}
/*
@ -1077,7 +1077,7 @@ if ( is_array($list) ) {
if (count($listActives) > 0 && $display_actives) {
echo "<ul class=\"courseslist\">\n";
$name_category = array();
$i = 0;
$j=0;
@ -1085,7 +1085,7 @@ if ( is_array($list) ) {
$session_category_id=$value['session_category_id'];
if (!empty($value[3]['category'])) {
if (!in_array($value[3]['category'], $name_category)) {
if ($key != 0) {
echo '</ul>';
}
@ -1095,9 +1095,9 @@ if ( is_array($list) ) {
'<li class="category_box_title" id="category_box_title_'.$session_category_id.'">'.$name_category['name'].'</li>';
echo "</ul>\n";
}
}
if (!empty($value[2])) {
if ((isset($old_session) && $old_session != $value[2]) or ((!isset($old_session)) && isset($value[2]))) {
$old_session = $value[2];
@ -1105,26 +1105,26 @@ if ( is_array($list) ) {
echo '</ul>';
}
//Session
echo '<ul style="display:none" class="session_box_'.$session_category_id.'" >' .
'<li class="session_box_title" >'.$value[3]['title'].' '.$value[3]['dates'].'</li>';
if ( !empty($value[3]['coach']) ) {
echo '<li class="session_box_coach">'.$value[3]['coach'].'</li>';
}
echo "</ul>\n";
echo '<ul class="session_course_item" id="session_course_item_'.$i.'">';
}
}
//Courses
echo $value[1];
$i++;
}
echo "\n</ul><br /><br />\n";
}
if (count($listInactives) > 0 && !$display_actives) {
@ -1197,14 +1197,14 @@ if ($show_menu) {
echo '<div class="menusection">';
echo '<span class="menusectioncaption">'.get_lang('MenuUser').'</span>';
echo '<ul class="menulist">';
if ($show_create_link) {
if ($show_create_link) {
display_create_course_link();
}
if ($show_course_link) {
if ($show_course_link) {
display_edit_course_list_links();
display_history_course_session();
}
if ($show_digest_link) {
if ($show_digest_link) {
display_digest($toolsList, $digest, $orderKey, $courses);
}
echo '</ul>';

Loading…
Cancel
Save