diff --git a/main/admin/add_many_session_to_category.php b/main/admin/add_many_session_to_category.php index 2469378bdb..3e59c65b6d 100644 --- a/main/admin/add_many_session_to_category.php +++ b/main/admin/add_many_session_to_category.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 .= ''; - while($course = Database :: fetch_array($rs)) { - $course_list[] = $course['id']; - $return .= ''.$course['name'].''; + while($course = Database :: fetch_array($rs)) { + $course_list[] = $course['id']; + $return .= ''.$course['name'].''; } $return .= ''; $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;i0 ){ $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); ?> > @@ -180,11 +180,11 @@ if(!empty($errorMsg)) : - '.$category['name'].''; - else + else echo ''.$category['name'].''; } ?> @@ -200,13 +200,13 @@ if(!empty($errorMsg)) - : + : -- + ?> @@ -214,8 +214,8 @@ if(!empty($errorMsg)) - - + > @@ -236,8 +236,8 @@ if(!empty($errorMsg)) - - > @@ -269,25 +269,25 @@ function moveItem(origin , destination){ } destination.selectedIndex = -1; sortOptions(destination.options); - + } function sortOptions(options) { newOptions = new Array(); - + for (i = 0 ; i0) { $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('',$coachs); } else { diff --git a/main/admin/session_add.php b/main/admin/session_add.php index c5e905725d..0e4474e5c4 100755 --- a/main/admin/session_add.php +++ b/main/admin/session_add.php @@ -199,10 +199,10 @@ if (intval($count_users)<50) { @@ -369,8 +369,8 @@ for ($i=$thisYear-5;$i <= ($thisYear+5);$i++) { - - + get_lang('ReadOnly'), SESSION_VISIBLE=>get_lang('Visible'), SESSION_INVISIBLE=>api_ucfirst(get_lang('Invisible'))); foreach($visibility_list as $key=>$item): ?> > @@ -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; } '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++) - + - + diff --git a/main/admin/session_category_list.php b/main/admin/session_category_list.php index b1cc2e096f..fa9fff7107 100644 --- a/main/admin/session_category_list.php +++ b/main/admin/session_category_list.php @@ -12,19 +12,19 @@ api_protect_admin_script(true); // setting the section (for the tabs) $this_section=SECTION_PLATFORM_ADMIN; $htmlHeadXtra[] = ''; $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'),'',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); } - ?> - - + ?> + + - '.Display::return_icon('view_more_stats.gif',get_lang('AddSession')).get_lang('AddSessionCategory').' - '; + '.Display::return_icon('view_more_stats.gif',get_lang('AddSession')).get_lang('AddSessionCategory').' + '; ?> @@ -112,8 +112,8 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') { - - + + $limit) { if ($page) { ?> - + + ?> | $limit) { - ?> - + ?> + + ?> @@ -150,7 +150,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') { - + - + ".$nb_courses." Sesion(es) "; ?> - + @@ -176,23 +176,23 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') { - + - + $limit) { if ($page) { ?> - + - + - + | - + $limit) { ?> - + - + '.$tool_name.' ('.$session_info['name'].')'; $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); +{ +?> - @@ -259,25 +259,25 @@ function moveItem(origin , destination){ } destination.selectedIndex = -1; sortOptions(destination.options); - + } function sortOptions(options) { newOptions = new Array(); - + for (i = 0 ; i @@ -315,8 +315,8 @@ for($i=$thisYear-5;$i <= ($thisYear+5);$i++) - - + get_lang('ReadOnly'), SESSION_VISIBLE=>get_lang('Visible'), SESSION_INVISIBLE=>api_ucfirst(get_lang('Invisible'))); foreach($visibility_list as $key=>$item): ?> > @@ -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; } diff --git a/main/admin/special_exports.php b/main/admin/special_exports.php index 0eae32a491..60b193dc42 100644 --- a/main/admin/special_exports.php +++ b/main/admin/special_exports.php @@ -3,13 +3,13 @@ /** * ============================================================================== * Special exports - * + * * @author Jhon Hinojosa * @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=&session=true"; } - //--> + //--> $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').''.$name.'', false); echo ' '.get_lang('MainMenu').''; } 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(); diff --git a/main/course_description/index.php b/main/course_description/index.php index 3e8abffd0c..fbcef23959 100755 --- a/main/course_description/index.php +++ b/main/course_description/index.php @@ -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')); diff --git a/main/course_home/activity.php b/main/course_home/activity.php index 86d9583768..e4d142cfce 100755 --- a/main/course_home/activity.php +++ b/main/course_home/activity.php @@ -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 "\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 ' '; 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 .= ''. get_lang('SessionCategory') . ': ' . '' . $session_category .''; } $output .= ''. get_lang('SessionName') . ': ' . '' . $session['name'] .''. get_lang('GeneralCoach') . ': ' . '' . $session['lastname'].' '.$session['firstname'].' ('.$session['username'].')' .''; $output .= ''. get_lang('SessionIdentifier') . ': '. Display::return_icon('star.png', ' ', array('align' => 'absmiddle')) .''. get_lang('Date') . ': ' . '' . $msg_date .''; - + return $output; } @@ -604,10 +604,10 @@ if(api_is_allowed_to_edit()) - + 0) { ?> diff --git a/main/coursecopy/classes/CourseBuilder.class.php b/main/coursecopy/classes/CourseBuilder.class.php index 95fba7bdcb..c1d6310819 100755 --- a/main/coursecopy/classes/CourseBuilder.class.php +++ b/main/coursecopy/classes/CourseBuilder.class.php @@ -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); diff --git a/main/coursecopy/classes/CourseRestorer.class.php b/main/coursecopy/classes/CourseRestorer.class.php index d41cb677fd..a72ad5967c 100755 --- a/main/coursecopy/classes/CourseRestorer.class.php +++ b/main/coursecopy/classes/CourseRestorer.class.php @@ -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(); - - } - } - } + + } + } + } } ?> diff --git a/main/coursecopy/copy_course_session.php b/main/coursecopy/copy_course_session.php index 671cd85506..3223937aac 100644 --- a/main/coursecopy/copy_course_session.php +++ b/main/coursecopy/copy_course_session.php @@ -4,15 +4,15 @@ /** * ============================================================================== * Copy resources from one course in a session to another one. - * + * * @author Christian Fasanando * @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 = ''; - if (count($sessions) == 0) { - $output .= ''.get_lang('ThereIsNotStillASession').''; + + $output = ''; + if (count($sessions) == 0) { + $output .= ''.get_lang('ThereIsNotStillASession').''; } else { - $output .= ''.get_lang('SelectASession').''; + $output .= ''.get_lang('SelectASession').''; } - + if (is_array($sessions)) { foreach ($sessions as $session) { - $output .= ''.$session['name'].' ('.$session['category_name'].')'; + $output .= ''.$session['name'].' ('.$session['category_name'].')'; } - } + } $output .= ''; return $output; } function display_form() { - + global $charset; - + $html = ''; - $sessions = SessionManager::get_sessions_list(); - + $sessions = SessionManager::get_sessions_list(); + $html .= ''; - + $html .= ''; - + $html .= ''.get_lang('OriginCoursesFromSession').':'; $html .= ' '.get_lang('DestinationCoursesFromSession').':'; $html .= ''.make_select_session_list('sessions_list_origin',$sessions,array('onchange'=>'xajax_search_courses(this.value,\'origin\')')).''; $html .= ' '; $html .= ''; - $html .= ''.get_lang('ThereIsNotStillASession').''; - + $html .= ''.get_lang('ThereIsNotStillASession').''; + $html .= ''; $html .= ''; - - // Options configuration - $html .= ''.get_lang('CopyCourse').''; + + // Options configuration + $html .= ''.get_lang('CopyCourse').''; $introduction = get_lang('CopyCourseFromSessionToSessionExplanation',true); - $html .= ''.$introduction.''; + $html .= ''.$introduction.''; $html .= ''.get_lang('TypeOfCopy').''; $html .= ''; - $html .= ''.get_lang('FullCopy').''; + $html .= ''.get_lang('FullCopy').''; $html .= ''; $html .= ''.get_lang('LetMeSelectItems').''; $html .= ''.get_lang('CopyCourse').''; - + // actions $html .= ''; // link back to the documents overview $html .= ''.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').''; $html .= ''; - - + + $html .= ''; $html .= ''; $html .= ''; - $html .= ''; - + $html .= ''; + 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 .= ''; - 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 .= ''.$course['title'].' ('.$course['visual_code'].')'; - + } - + $return .= ''; $_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 .= ''; + + $rs_select_destination = Database::query($sql, __FILE__, __LINE__); + + $select_destination .= ''; $select_destination .= ''.get_lang('SelectASession').''; - while($session = Database :: fetch_array($rs_select_destination)) { - - $select_destination .= ''.$session['name'].' ('.$session['category_name'].')'; + while($session = Database :: fetch_array($rs_select_destination)) { + + $select_destination .= ''.$session['name'].' ('.$session['category_name'].')'; } $select_destination .= ''; $xajax_response -> addAssign('ajax_sessions_list_destination','innerHTML',api_utf8_encode($select_destination)); } else{ - $select_destination .= ''; + $select_destination .= ''; $select_destination .= ''.get_lang('ThereIsNotStillASession').''; $select_destination .= ''; $xajax_response -> addAssign('ajax_sessions_list_destination','innerHTML',api_utf8_encode($select_destination)); } - + // select multiple destination empty $select_multiple_empty = ''; - + // 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 .= ''; - while($course = Database :: fetch_array($rs)) { + while($course = Database :: fetch_array($rs)) { $course_list_destination[] = $course['code']; - $course_title=str_replace("'","\'",$course_title); - $return .= ''.$course['title'].' ('.$course['visual_code'].')'; + $course_title=str_replace("'","\'",$course_title); + $return .= ''.$course['title'].' ('.$course['visual_code'].')'; } $return .= ''; $_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 = ''; - 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 .= ''.$cours['title'].' ('.$cours['visual_code'].')'; } else { $return_option_disabled .= ''.$cours['title'].' ('.$cours['visual_code'].')'; - } + } } else { - if (empty($id_session)) { + if (empty($id_session)) { $return_option_disabled .= ''.$cours['title'].' ('.$cours['visual_code'].')'; - } else { + } else { $return_option_disabled .= ''.$cours['title'].' ('.$cours['visual_code'].')'; } - - } - } + + } + } $return_option_disabled .= ''; // 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[] = '
'.get_lang('MainMenu').'